badgerbadgerbadger 0.10.2 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 509707f111ff5c90e4317418a93f928a28a464b8
4
- data.tar.gz: 6963b484b48b76ff0451d4d1cc2fe7b04160597b
3
+ metadata.gz: 9c9af23f129d7fc0d0ff6c2da27abae3da5bc596
4
+ data.tar.gz: e08ce50e33fc38845c8131ca2ebbf4d7e3c003a3
5
5
  SHA512:
6
- metadata.gz: 8a2d485d66c3b92b3629343b9d21ce68971a1b1f46dfc53cef9772c1cf07ed027680871ae6b66f35104b37603b438478cae046b4a88fdf0fdaca75bedc1a0289
7
- data.tar.gz: 050765279c4785e697846a9a59e896f290d283853936cb14b6b165fb7b390c6d1f13c37de71e275ccd898fd9ab29973e0d1bce40c6ef2c2c29b3902f5cbdb24f
6
+ metadata.gz: ec577ef671de98f9030e4127077af545e9c36f5df6cc301bcec5bf2c437b3d1fe37c7d6ed715106655e33002993ba11d0db749926ee173c448c856c5e4ae0c97
7
+ data.tar.gz: 9490e09bed7a3a9c27c9b3568026bf9a0e44b3a0e8eb97112638344d64164968bd40a48e5b5b24bcc7b51b85d627c32b2aaa652219291c31e647418bc2c3c936
@@ -0,0 +1,18 @@
1
+ Feature: Alternative styles
2
+
3
+ Background:
4
+ Given git remote is "https://github.com/doge/wow"
5
+
6
+ @travis @gemnasium @coveralls @gemspec @mit
7
+ Scenario: One with everything
8
+ When I successfully run `badger badge --style flat-square /tmp/wow_repo`
9
+ Then the output should contain:
10
+ """
11
+ [![Build Status](http://img.shields.io/travis/doge/wow.svg?style=flat-square)](https://travis-ci.org/doge/wow)
12
+ [![Dependency Status](http://img.shields.io/gemnasium/doge/wow.svg?style=flat-square)](https://gemnasium.com/doge/wow)
13
+ [![Coverage Status](http://img.shields.io/coveralls/doge/wow.svg?style=flat-square)](https://coveralls.io/r/doge/wow)
14
+ [![Code Climate](http://img.shields.io/codeclimate/github/doge/wow.svg?style=flat-square)](https://codeclimate.com/github/doge/wow)
15
+ [![Gem Version](http://img.shields.io/gem/v/suchgem.svg?style=flat-square)](https://rubygems.org/gems/suchgem)
16
+ [![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](http://doge.mit-license.org)
17
+ [![Badges](http://img.shields.io/:badges-7/7-ff6799.svg?style=flat-square)](https://github.com/badges/badgerbadgerbadger)
18
+ """
data/lib/badger/badge.rb CHANGED
@@ -1,10 +1,20 @@
1
1
  module Badger
2
2
  def Badger.badge text, badge_url, target_url
3
- "[![%s](%s.%s)](%s)" % [
3
+ badge_url = "%s.%s" % [
4
+ badge_url,
5
+ Config.instance.config['badge_type']
6
+ ]
7
+
8
+ badge_style = Config.instance.config['badge_style']
9
+ badge_url = "%s?style=%s" % [
10
+ badge_url,
11
+ badge_style
12
+ ] if badge_style
13
+
14
+ "[![%s](%s)](%s)" % [
4
15
  text,
5
16
  badge_url,
6
- Config.instance.config['badge_type'],
7
17
  target_url
8
18
  ]
9
19
  end
10
- end
20
+ end
data/lib/badger/badger.rb CHANGED
@@ -37,6 +37,10 @@ module Badger
37
37
  Config.instance.config['badge_type'] = type
38
38
  end
39
39
 
40
+ def style style
41
+ Config.instance.config['badge_style'] = style
42
+ end
43
+
40
44
  def to_s
41
45
  self.uniq!
42
46
 
data/lib/badger/cli.rb CHANGED
@@ -14,11 +14,13 @@ module Badger
14
14
  long_desc File.read File.join File.dirname( __FILE__), '..', '..', 'DESC.md'
15
15
  method_option :png, :type => :boolean, :default => false, :desc => 'Generate PNG badges instead of the default SVG (because sometimes Github does caching things)'
16
16
  method_option :pulls, :type => :boolean, :default => false, :desc => 'Generate Github pull-request and issue-count badges'
17
+ method_option :style, :type => :string, :default => nil, :desc => "Choose a different badge style (currently supported: 'flat' or 'flat-square')"
17
18
 
18
19
  def badge dir = '.'
19
20
  @badger = Badger.new Badger.git_remote dir
20
21
 
21
22
  @badger.badge_type 'png' if options[:png]
23
+ @badger.style options[:style] if options[:style]
22
24
 
23
25
  @badger.add 'travis' if Badger.has_travis? dir
24
26
  @badger.add 'gemnasium' if Badger.has_gemfile? dir
@@ -1,3 +1,3 @@
1
1
  module Badger
2
- VERSION = "0.10.2"
2
+ VERSION = "0.11.1"
3
3
  end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ module Badger
4
+ describe Badger do
5
+ before :each do
6
+ @badger = Badger.new "https://github.com/doge/wow"
7
+ end
8
+
9
+ after :each do
10
+ Config.instance.reset!
11
+ end
12
+
13
+ context 'alternative badge types' do
14
+ it 'appends a style parameter' do
15
+ @badger.style 'flat-square'
16
+ @badger.add 'issues'
17
+ expect(@badger[0]).to eq "[![Github Issues](http://githubbadges.herokuapp.com/doge/wow/issues.svg?style=flat-square)](https://github.com/doge/wow/issues)"
18
+ end
19
+
20
+ it 'lets me choose a different badge type' do
21
+ @badger.badge_type 'png'
22
+ @badger.add 'travis'
23
+ expect(@badger[0]).to eq '[![Build Status](http://img.shields.io/travis/doge/wow.png)](https://travis-ci.org/doge/wow)'
24
+ end
25
+ end
26
+ end
27
+ end
data/spec/badger_spec.rb CHANGED
@@ -11,89 +11,20 @@ module Badger
11
11
  end
12
12
 
13
13
  context 'initialisation' do
14
- it 'should have no badges by default' do
15
- expect(@badger.length).to eq 0
16
- end
17
- end
18
-
19
- context 'get the user and repo' do
20
- it 'extracts from an https url' do
21
- expect(@badger.github_slug).to eq ('doge/wow')
22
- end
23
-
24
- it 'extracts the owner' do
25
- expect(@badger.owner).to eq 'doge'
26
- end
27
-
28
- it 'extracts from an ssh url' do
29
- @badger = Badger.new "git@github.com:doge/wow.git"
30
- expect(@badger.github_slug).to eq ('doge/wow')
31
- end
32
-
33
- it 'knows that sometimes an https url has a .git suffix because REASONS' do
34
- @badger = Badger.new "https://github.com/doge/wow.git"
35
- expect(@badger.github_slug).to eq ('doge/wow')
36
- end
37
- end
38
-
39
- context 'service badges' do
40
- it 'should have a travis badge' do
41
- @badger.add 'travis'
42
- expect(@badger[0]).to eq "[![Build Status](http://img.shields.io/travis/doge/wow.svg)](https://travis-ci.org/doge/wow)"
43
- end
44
-
45
- it 'should have a travis badge and a gemnasium badge' do
46
- @badger.add 'travis'
47
- @badger.add 'gemnasium'
48
- expect(@badger[0]).to eq "[![Build Status](http://img.shields.io/travis/doge/wow.svg)](https://travis-ci.org/doge/wow)"
49
- expect(@badger[1]).to eq "[![Dependency Status](http://img.shields.io/gemnasium/doge/wow.svg)](https://gemnasium.com/doge/wow)"
50
- expect(@badger.length).to eq 2
51
- end
52
-
53
- it 'should handle an unknown service gracefully' do
54
- @badger.add 'doge-service'
55
- expect(@badger.length).to eq 0
56
- end
57
- end
58
-
59
- context 'licenses' do
60
- it 'should generate an MIT badge' do
61
- @badger.license 'mit'
62
- expect(@badger[0]).to eq "[![License](http://img.shields.io/:license-mit-blue.svg)](http://doge.mit-license.org)"
63
- end
64
-
65
- it 'should generate an Apache badge' do
66
- @badger.license 'apache'
67
- expect(@badger[0]).to eq "[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)"
68
- end
69
-
70
- it 'should generate a GPL3 badge' do
71
- @badger.license 'gpl-3.0'
72
- expect(@badger[0]).to eq "[![License](http://img.shields.io/:license-gpl3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0.html)"
73
- end
74
-
75
- it 'should be fine with multiple licenses' do
76
- @badger.license 'mit'
77
- @badger.license 'apache'
78
- expect(@badger[0]).to eq "[![License](http://img.shields.io/:license-mit-blue.svg)](http://doge.mit-license.org)"
79
- expect(@badger[1]).to eq "[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)"
80
- end
81
-
82
- it 'should generate nothing for an unknown license' do
83
- @badger.license 'doge-license'
14
+ it 'has no badges by default' do
84
15
  expect(@badger.length).to eq 0
85
16
  end
86
17
  end
87
18
 
88
19
  context 'rubygems' do
89
- it 'should have a rubygems badge' do
20
+ it 'has a rubygems badge' do
90
21
  @badger.rubygem 'suchgem'
91
22
  expect(@badger[0]).to eq "[![Gem Version](http://img.shields.io/gem/v/suchgem.svg)](https://rubygems.org/gems/suchgem)"
92
23
  end
93
24
  end
94
25
 
95
26
  context 'bonus badge' do
96
- it 'should have a badges badge' do
27
+ it 'has a badges badge' do
97
28
  @badger.add 'travis'
98
29
  @badger.add 'coveralls'
99
30
  @badger.bonus
@@ -102,14 +33,14 @@ module Badger
102
33
  end
103
34
 
104
35
  context 'github pulls' do
105
- it 'should have a pull-requests badge' do
36
+ it 'has a pull-requests badge' do
106
37
  @badger.add 'pulls'
107
38
  expect(@badger[0]).to eq "[![Pending Pull-Requests](http://githubbadges.herokuapp.com/doge/wow/pulls.svg)](https://github.com/doge/wow/pulls)"
108
39
  end
109
40
  end
110
41
 
111
42
  context 'output' do
112
- it 'should produce some lines of text' do
43
+ it 'produces some lines of text' do
113
44
  @badger.add 'travis'
114
45
  @badger.add 'codeclimate'
115
46
  @badger.license 'mit'
@@ -122,16 +53,10 @@ module Badger
122
53
  end
123
54
  end
124
55
 
125
- it 'should work with a "-" in the remote name' do
56
+ it 'works with a "-" in the remote name' do
126
57
  @badger = Badger.new 'https://github.com/pikesley/diabetes-dashboard.git'
127
58
  @badger.add 'travis'
128
59
  expect(@badger[0]).to eq '[![Build Status](http://img.shields.io/travis/pikesley/diabetes-dashboard.svg)](https://travis-ci.org/pikesley/diabetes-dashboard)'
129
60
  end
130
-
131
- it 'should let me choose a different badge type' do
132
- @badger.badge_type 'png'
133
- @badger.add 'travis'
134
- expect(@badger[0]).to eq '[![Build Status](http://img.shields.io/travis/doge/wow.png)](https://travis-ci.org/doge/wow)'
135
- end
136
61
  end
137
62
  end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ module Badger
4
+ describe Badger do
5
+ before :each do
6
+ @badger = Badger.new "https://github.com/doge/wow"
7
+ end
8
+
9
+ after :each do
10
+ Config.instance.reset!
11
+ end
12
+
13
+ context 'licenses' do
14
+ it 'generates an MIT badge' do
15
+ @badger.license 'mit'
16
+ expect(@badger[0]).to eq "[![License](http://img.shields.io/:license-mit-blue.svg)](http://doge.mit-license.org)"
17
+ end
18
+
19
+ it 'generates an Apache badge' do
20
+ @badger.license 'apache'
21
+ expect(@badger[0]).to eq "[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)"
22
+ end
23
+
24
+ it 'generates a GPL3 badge' do
25
+ @badger.license 'gpl-3.0'
26
+ expect(@badger[0]).to eq "[![License](http://img.shields.io/:license-gpl3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0.html)"
27
+ end
28
+
29
+ it 'is fine with multiple licenses' do
30
+ @badger.license 'mit'
31
+ @badger.license 'apache'
32
+ expect(@badger[0]).to eq "[![License](http://img.shields.io/:license-mit-blue.svg)](http://doge.mit-license.org)"
33
+ expect(@badger[1]).to eq "[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)"
34
+ end
35
+
36
+ it 'generates nothing for an unknown license' do
37
+ @badger.license 'doge-license'
38
+ expect(@badger.length).to eq 0
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ module Badger
4
+ describe Badger do
5
+ before :each do
6
+ @badger = Badger.new "https://github.com/doge/wow"
7
+ end
8
+
9
+ after :each do
10
+ Config.instance.reset!
11
+ end
12
+
13
+ context 'service badges' do
14
+ it 'has a travis badge' do
15
+ @badger.add 'travis'
16
+ expect(@badger[0]).to eq "[![Build Status](http://img.shields.io/travis/doge/wow.svg)](https://travis-ci.org/doge/wow)"
17
+ end
18
+
19
+ it 'has a travis badge and a gemnasium badge' do
20
+ @badger.add 'travis'
21
+ @badger.add 'gemnasium'
22
+ expect(@badger[0]).to eq "[![Build Status](http://img.shields.io/travis/doge/wow.svg)](https://travis-ci.org/doge/wow)"
23
+ expect(@badger[1]).to eq "[![Dependency Status](http://img.shields.io/gemnasium/doge/wow.svg)](https://gemnasium.com/doge/wow)"
24
+ expect(@badger.length).to eq 2
25
+ end
26
+
27
+ it 'handles an unknown service gracefully' do
28
+ @badger.add 'doge-service'
29
+ expect(@badger.length).to eq 0
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ module Badger
4
+ describe Badger do
5
+ before :each do
6
+ @badger = Badger.new "https://github.com/doge/wow"
7
+ end
8
+
9
+ after :each do
10
+ Config.instance.reset!
11
+ end
12
+
13
+ context 'get the user and repo' do
14
+ it 'extracts from an https url' do
15
+ expect(@badger.github_slug).to eq ('doge/wow')
16
+ end
17
+
18
+ it 'extracts the owner' do
19
+ expect(@badger.owner).to eq 'doge'
20
+ end
21
+
22
+ it 'extracts from an ssh url' do
23
+ @badger = Badger.new "git@github.com:doge/wow.git"
24
+ expect(@badger.github_slug).to eq ('doge/wow')
25
+ end
26
+
27
+ it 'knows that sometimes an https url has a .git suffix because REASONS' do
28
+ @badger = Badger.new "https://github.com/doge/wow.git"
29
+ expect(@badger.github_slug).to eq ('doge/wow')
30
+ end
31
+ end
32
+ end
33
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: badgerbadgerbadger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - pikesley
@@ -214,6 +214,7 @@ files:
214
214
  - config/config.yaml
215
215
  - config/licenses.yaml
216
216
  - config/services.yaml
217
+ - features/alternative-styles.feature
217
218
  - features/badger.feature
218
219
  - features/licenses.feature
219
220
  - features/png.feature
@@ -244,8 +245,12 @@ files:
244
245
  - lib/badger/rubygem.rb
245
246
  - lib/badger/service.rb
246
247
  - lib/badger/version.rb
248
+ - spec/badge_types_spec.rb
247
249
  - spec/badger_spec.rb
250
+ - spec/licenses_spec.rb
251
+ - spec/services_spec.rb
248
252
  - spec/spec_helper.rb
253
+ - spec/user_and_repo_spec.rb
249
254
  homepage: http://badges.github.io/badgerbadgerbadger/
250
255
  licenses:
251
256
  - MIT
@@ -272,6 +277,7 @@ specification_version: 4
272
277
  summary: Badge-Driven Development made easy. Generate a set of Github badges for your
273
278
  project without cutting-n-pasting every time
274
279
  test_files:
280
+ - features/alternative-styles.feature
275
281
  - features/badger.feature
276
282
  - features/licenses.feature
277
283
  - features/png.feature
@@ -291,5 +297,9 @@ test_files:
291
297
  - features/support/hooks/licenses.rb
292
298
  - features/support/hooks/rubygems.rb
293
299
  - features/support/hooks/services.rb
300
+ - spec/badge_types_spec.rb
294
301
  - spec/badger_spec.rb
302
+ - spec/licenses_spec.rb
303
+ - spec/services_spec.rb
295
304
  - spec/spec_helper.rb
305
+ - spec/user_and_repo_spec.rb