Skip to content

Commit

Permalink
Merge pull request #60 from badges/limit-style-choice
Browse files Browse the repository at this point in the history
Limit style choice
  • Loading branch information
Sam Pikesley committed Jan 2, 2015
2 parents b9bada9 + e9ddb1d commit 5025695
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 18 deletions.
2 changes: 0 additions & 2 deletions DESC.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,3 @@ And if a license file is found, a License Badge will be generated. Currently sup
* GPL-3

The supported license details are in `https://github.com/badges/badgerbadgerbadger/blob/master/config/licenses.yaml`, if you're using a different license, send a PR! And if your gemspec license conflicts with your LICENSE file, you should probably fix that.

Use the `--pulls` flag to add badges for open Github issues and pull-requests.
5 changes: 4 additions & 1 deletion config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ badge_service: img.shields.io
license_colour: blue
bonus_badge_colour: ff6799
bonus_badge_link: https://github.com/badges/badgerbadgerbadger
badge_type: svg
badge_type: svg
valid_styles:
- flat
- flat-square
26 changes: 13 additions & 13 deletions config/services.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
travis:
alt_text: Build Status
scheme: https
url_path: travis-ci.org
badge_slug: travis
alt_text: Build Status
scheme: https
url_path: travis-ci.org
badge_slug: travis

coveralls:
alt_text: Coverage Status
url_path: coveralls.io/r
badge_slug: coveralls
alt_text: Coverage Status
url_path: coveralls.io/r
badge_slug: coveralls

gemnasium:
alt_text: Dependency Status
url_path: gemnasium.com
badge_slug: gemnasium
alt_text: Dependency Status
url_path: gemnasium.com
badge_slug: gemnasium

codeclimate:
alt_text: Code Climate
url_path: codeclimate.com/github
badge_slug: codeclimate/github
alt_text: Code Climate
url_path: codeclimate.com/github
badge_slug: codeclimate/github

pulls:
alt_text: Pending Pull-Requests
Expand Down
7 changes: 7 additions & 0 deletions features/alternative-styles.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ Feature: Alternative styles
[![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](http://doge.mit-license.org)
[![Badges](http://img.shields.io/:badges-7/7-ff6799.svg?style=flat-square)](https://github.com/badges/badgerbadgerbadger)
"""
Scenario: Invalid style choice
When I run `badger badge --style fluffy /tmp/wow_repo`
Then the output should contain:
"""
Invalid style choice 'fluffy'
"""
And the exit status should be 3
5 changes: 5 additions & 0 deletions lib/badger/badger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ def badge_type type
end

def style style
unless Config.instance.config['valid_styles'].include? style
puts "Invalid style choice '#{style}'"
exit 3
end

Config.instance.config['badge_style'] = style
end

Expand Down
3 changes: 2 additions & 1 deletion lib/badger/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ def version
long_desc File.read File.join File.dirname( __FILE__), '..', '..', 'DESC.md'
method_option :png, :type => :boolean, :default => false, :desc => 'Generate PNG badges instead of the default SVG (because sometimes Github does caching things)'
method_option :pulls, :type => :boolean, :default => false, :desc => 'Generate Github pull-request and issue-count badges'
method_option :style, :type => :string, :default => nil, :desc => "Choose a different badge style (currently supported: 'flat' or 'flat-square')"
method_option :style, :type => :string, :default => nil, :desc => "Choose a different badge style (currently supported: #{Config.instance.config['valid_styles'].join ', '})"

def badge dir = '.'
@badger = Badger.new Badger.git_remote dir

@badger.badge_type 'png' if options[:png]

@badger.style options[:style] if options[:style]

@badger.add 'travis' if Badger.has_travis? dir
Expand Down
2 changes: 1 addition & 1 deletion lib/badger/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Badger
VERSION = "0.11.1"
VERSION = "0.11.2"
end

0 comments on commit 5025695

Please sign in to comment.