From 66bca2e99fee56d9715a0b8ed7f63f103460753d Mon Sep 17 00:00:00 2001 From: pikesley Date: Fri, 2 Jan 2015 14:17:38 +0000 Subject: [PATCH 1/5] Line things up --- config/services.yaml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/config/services.yaml b/config/services.yaml index 521988a..f28e4b0 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -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 From 2e54acc32f768208676ff3e24489874faec4fca1 Mon Sep 17 00:00:00 2001 From: pikesley Date: Fri, 2 Jan 2015 14:17:46 +0000 Subject: [PATCH 2/5] Irrelevant here --- DESC.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/DESC.md b/DESC.md index 32cc960..6742a7b 100644 --- a/DESC.md +++ b/DESC.md @@ -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. From 7e532a92f7b29afebddef55c70f60d39a561ccf1 Mon Sep 17 00:00:00 2001 From: pikesley Date: Fri, 2 Jan 2015 14:17:59 +0000 Subject: [PATCH 3/5] Limit style choices --- config/config.yaml | 5 ++++- features/alternative-styles.feature | 7 +++++++ lib/badger/cli.rb | 11 +++++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index db8ff3a..2e2b93f 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -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 \ No newline at end of file +badge_type: svg +valid_styles: + - flat + - flat-square diff --git a/features/alternative-styles.feature b/features/alternative-styles.feature index 9d5229e..f360993 100644 --- a/features/alternative-styles.feature +++ b/features/alternative-styles.feature @@ -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 diff --git a/lib/badger/cli.rb b/lib/badger/cli.rb index 0d33abd..5c3b64b 100644 --- a/lib/badger/cli.rb +++ b/lib/badger/cli.rb @@ -14,13 +14,20 @@ 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] + + if options[:style] + unless Config.instance.config['valid_styles'].include? options[:style] + puts "Invalid style choice '#{options[:style]}'" + exit 3 + end + @badger.style options[:style] + end @badger.add 'travis' if Badger.has_travis? dir @badger.add 'gemnasium' if Badger.has_gemfile? dir From 15097065e547a8ee8828b167e1f15b775f0574af Mon Sep 17 00:00:00 2001 From: pikesley Date: Fri, 2 Jan 2015 14:23:29 +0000 Subject: [PATCH 4/5] This is better here --- lib/badger/badger.rb | 5 +++++ lib/badger/cli.rb | 8 +------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/badger/badger.rb b/lib/badger/badger.rb index 8e24dcc..bb81d35 100644 --- a/lib/badger/badger.rb +++ b/lib/badger/badger.rb @@ -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 diff --git a/lib/badger/cli.rb b/lib/badger/cli.rb index 5c3b64b..48d9276 100644 --- a/lib/badger/cli.rb +++ b/lib/badger/cli.rb @@ -21,13 +21,7 @@ def badge dir = '.' @badger.badge_type 'png' if options[:png] - if options[:style] - unless Config.instance.config['valid_styles'].include? options[:style] - puts "Invalid style choice '#{options[:style]}'" - exit 3 - end - @badger.style options[:style] - end + @badger.style options[:style] if options[:style] @badger.add 'travis' if Badger.has_travis? dir @badger.add 'gemnasium' if Badger.has_gemfile? dir From e9ddb1daf138643341291de18809e0ca0bc7b9cc Mon Sep 17 00:00:00 2001 From: pikesley Date: Fri, 2 Jan 2015 14:23:45 +0000 Subject: [PATCH 5/5] Bump --- lib/badger/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/badger/version.rb b/lib/badger/version.rb index db6e925..5690b56 100644 --- a/lib/badger/version.rb +++ b/lib/badger/version.rb @@ -1,3 +1,3 @@ module Badger - VERSION = "0.11.1" + VERSION = "0.11.2" end