badgerbadgerbadger 0.1.0 → 0.2.0

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: 29233402e5ecd4bd5842af639ae5bf21dfb43740
4
- data.tar.gz: 5fd4679480dc6716486afa84365dc7311685bcc1
3
+ metadata.gz: 65a87ea77e70e97c202ea2196a2d5345b7746d56
4
+ data.tar.gz: 6280794d0a4b77741f82a38638092eb9b4e5bebd
5
5
  SHA512:
6
- metadata.gz: d512a3d6ca441072c80865c2ddf342373cd2df458f777308e48b9eacee329a2a39d3ff1515196461734588713ed9eef623d5e87ac2ff87369cea1e3be3f41ccc
7
- data.tar.gz: 1883cc433abf9ec7850371ad155c096dee65db62e3bbd0fb907cc700da2587fe6a2f2417c126158ddafb158a4f6ce4331ef7fe6ed931f07306b8f8cb5745f487
6
+ metadata.gz: 5a398072936efa98fa4178b124fc6724e59483e2567c210970c370c9a025726bbb2e858ef4fc5c926b0d3640425387e5fbb6b4b495dadd759baced3d69b55b99
7
+ data.tar.gz: 7505edaea08d66fb098984a8ccc719cbec234587556fdd3c8df7f6327f04898665d3ece421d6f8602c820bd2d8c4db8d04bbf04176628bc58ed39b8fb7eef9a9
data/Guardfile CHANGED
@@ -1,8 +1,30 @@
1
1
  # A sample Guardfile
2
2
  # More info at https://github.com/guard/guard#readme
3
3
 
4
- guard 'cucumber' do
4
+ guard :cucumber do #, :cli => '--format pretty' do
5
5
  watch(%r{^features/.+\.feature$})
6
6
  watch(%r{^features/support/.+$}) { 'features' }
7
7
  watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
8
8
  end
9
+
10
+ guard :rspec do
11
+ watch(%r{^spec/.+_spec\.rb$})
12
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
13
+ watch('spec/spec_helper.rb') { "spec" }
14
+
15
+ # Rails example
16
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
17
+ watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
18
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
19
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
20
+ watch('config/routes.rb') { "spec/routing" }
21
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
22
+
23
+ # Capybara features specs
24
+ watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
25
+
26
+ # Turnip features and steps
27
+ watch(%r{^spec/acceptance/(.+)\.feature$})
28
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
29
+ end
30
+
data/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
  [![Coverage Status](http://b.adge.me/coveralls/pikesley/badger.svg)](https://coveralls.io/r/pikesley/badger)
3
3
  [![Dependency Status](http://b.adge.me/gemnasium/pikesley/badger.svg)](https://gemnasium.com/pikesley/badger)
4
4
  [![Code Climate](http://b.adge.me/codeclimate/github/pikesley/badger.svg)](https://codeclimate.com/github/pikesley/badger)
5
+ [![Gem Version](http://b.adge.me/gem/v/badgerbadgerbadger.svg)](https://rubygems.org/gems/badgerbadgerbadger)
5
6
  [![License](http://b.adge.me/:license-mit-blue.svg)](http://pikesley.mit-license.org)
6
7
 
7
-
8
8
  #Badger
9
9
 
10
10
  Because I grow weary of copy-n-pasting the badge URLs into the README of every project, and the [b.adge.me](http://b.adge.me) API now supports all of the services I use
@@ -13,7 +13,7 @@ Because I grow weary of copy-n-pasting the badge URLs into the README of every p
13
13
 
14
14
  Add it to your Gemfile
15
15
 
16
- gem 'badgerbadgerbadger', :github => 'pikesley/badger'
16
+ gem 'badgerbadgerbadger'
17
17
  bundle
18
18
 
19
19
  Then
@@ -0,0 +1 @@
1
+ http://b.adge.me/gem/v/badgerbadgerbadger.svg
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ['pikesley']
10
10
  spec.email = ['sam@pikesley.org']
11
11
  spec.description = %q{Generate Github project badges}
12
- spec.summary = %q{Generate Github project badges}
12
+ spec.summary = %q{Badge-Driven Development made easy. Generate a set of Github badges for your project without cutting-n-pasting every time}
13
13
  spec.homepage = 'https://github.com/pikesley/badger'
14
14
  spec.license = 'MIT'
15
15
  spec.files = `git ls-files`.split($/)
@@ -24,4 +24,6 @@ services:
24
24
  mit:
25
25
  alt_text: License
26
26
  badge_path: ":license-mit-blue.svg"
27
- url: http://%s.mit-license.org
27
+ url: http://%s.mit-license.org
28
+
29
+ badge_service: b.adge.me
@@ -12,6 +12,14 @@ Feature: Badge Robot
12
12
  [![Dependency Status](http://b.adge.me/gemnasium/doge/wow.svg)](https://gemnasium.com/doge/wow)
13
13
  [![Code Climate](http://b.adge.me/codeclimate/github/doge/wow.svg)](https://codeclimate.com/github/doge/wow)
14
14
  """
15
+ And the output should not contain:
16
+ """
17
+ ![License](http://b.adge.me/:license-mit-blue.svg)](http://doge.mit-license.org)
18
+ """
19
+ And the output should not contain:
20
+ """
21
+ [![Gem Version](http://b.adge.me/gem/v/suchgem.svg)](https://rubygems.org/gems/suchgem)
22
+ """
15
23
 
16
24
  Scenario: Generate only a subset of badges
17
25
  When I successfully run `badger badge --not travis /tmp/wow_repo`
@@ -50,7 +58,6 @@ Feature: Badge Robot
50
58
  [![Code Climate](http://b.adge.me/codeclimate/github/doge/wow.svg)](https://codeclimate.com/github/doge/wow)
51
59
  """
52
60
 
53
- @wip
54
61
  Scenario: Generate additional badges
55
62
  When I successfully run `badger badge --also mit /tmp/wow_repo`
56
63
  Then the output should contain:
@@ -59,5 +66,27 @@ Feature: Badge Robot
59
66
  [![Coverage Status](http://b.adge.me/coveralls/doge/wow.svg)](https://coveralls.io/r/doge/wow)
60
67
  [![Dependency Status](http://b.adge.me/gemnasium/doge/wow.svg)](https://gemnasium.com/doge/wow)
61
68
  [![Code Climate](http://b.adge.me/codeclimate/github/doge/wow.svg)](https://codeclimate.com/github/doge/wow)
69
+ [![License](http://b.adge.me/:license-mit-blue.svg)](http://doge.mit-license.org)
70
+ """
71
+
72
+ @gemspec
73
+ Scenario: Generate badges based on gemspec
74
+ When I successfully run `badger badge /tmp/wow_repo`
75
+ Then the output should contain:
76
+ """
77
+ [![Build Status](http://b.adge.me/travis/doge/wow.svg)](https://travis-ci.org/doge/wow)
78
+ [![Coverage Status](http://b.adge.me/coveralls/doge/wow.svg)](https://coveralls.io/r/doge/wow)
79
+ [![Dependency Status](http://b.adge.me/gemnasium/doge/wow.svg)](https://gemnasium.com/doge/wow)
80
+ [![Code Climate](http://b.adge.me/codeclimate/github/doge/wow.svg)](https://codeclimate.com/github/doge/wow)
81
+ [![Gem Version](http://b.adge.me/gem/v/suchgem.svg)](https://rubygems.org/gems/suchgem)
82
+ [![License](http://b.adge.me/:license-mit-blue.svg)](http://doge.mit-license.org)
83
+ """
84
+
85
+ @gemspec
86
+ Scenario: gemspec and --also mit
87
+ Given I successfully run `badger badge --also mit /tmp/wow_repo`
88
+ Then the output should not contain:
89
+ """
90
+ [![License](http://b.adge.me/:license-mit-blue.svg)](http://doge.mit-license.org)
62
91
  [![License](http://b.adge.me/:license-mit-blue.svg)](http://doge.mit-license.org)
63
92
  """
@@ -4,4 +4,17 @@ end
4
4
 
5
5
  After do
6
6
  FileUtils.remove_dir '/tmp/wow_repo', :force => true
7
- end
7
+ end
8
+
9
+ Before '@gemspec' do
10
+ f = File.open('/tmp/wow_repo/suchgem.gemspec', 'w')
11
+ [
12
+ "spec.name 'suchgem'",
13
+ "spec.license 'MIT'"
14
+ ].each do |line|
15
+ f.write line
16
+ f.write "\n"
17
+ end
18
+ f.close
19
+ end
20
+
@@ -15,11 +15,13 @@ module Badger
15
15
  'config/services.yaml'
16
16
  )
17
17
  )
18
- )['services']
18
+ )
19
+
20
+ @services = yaml['services']['defaults']
21
+ @extras = yaml['services']['extras']
22
+ @badge_service = yaml['badge_service']
23
+ @extra_badges = []
19
24
 
20
- @services = yaml['defaults']
21
- @extras = yaml['extras']
22
- @extra_badges = []
23
25
  end
24
26
 
25
27
  def github_slug url
@@ -30,8 +32,9 @@ module Badger
30
32
  s = []
31
33
  @services.each_pair do |k, h|
32
34
  unless @blacklist.include? k.to_s
33
- s << "[![%s](http://b.adge.me/%s/%s.svg)](https://%s/%s)" % [
35
+ s << "[![%s](http://%s/%s/%s.svg)](https://%s/%s)" % [
34
36
  h['alt_text'],
37
+ @badge_service,
35
38
  h['badge_slug'],
36
39
  @github_slug,
37
40
  h['url'],
@@ -41,7 +44,7 @@ module Badger
41
44
  end
42
45
  s += @extra_badges
43
46
 
44
- s
47
+ s.uniq
45
48
  end
46
49
 
47
50
  def remove items
@@ -71,8 +74,9 @@ module Badger
71
74
 
72
75
  owner = @github_slug.split('/')[0]
73
76
  t = e['url'] % owner
74
- s = "[![%s](http://b.adge.me/%s)](%s)" % [
77
+ s = "[![%s](http://%s/%s)](%s)" % [
75
78
  e['alt_text'],
79
+ @badge_service,
76
80
  e['badge_path'],
77
81
  t
78
82
  ]
@@ -82,6 +86,30 @@ module Badger
82
86
  end
83
87
  end
84
88
 
89
+ def gemspec lines
90
+ rg = ''
91
+ rubygem = (lines.select { |l| /\.name\s/.match l })[0].split(/\s/)[-1][1..-2]
92
+ rg << "[![Gem Version](http://%s/gem/v/%s.svg)](https://rubygems.org/gems/%s)" % [
93
+ @badge_service,
94
+ rubygem,
95
+ rubygem
96
+ ]
97
+
98
+ @extra_badges << rg
99
+
100
+ lc = ''
101
+ owner = @github_slug.split('/')[0]
102
+ license = (lines.select { |l| /license/.match l })[0].split(/\s/)[-1]
103
+ if /MIT/i.match license
104
+ lc << "[![License](http://%s/:license-mit-blue.svg)](http://%s.mit-license.org)" % [
105
+ @badge_service,
106
+ owner
107
+ ]
108
+
109
+ @extra_badges << lc
110
+ end
111
+ end
112
+
85
113
  def to_s
86
114
  badge.each do |b|
87
115
  b
@@ -5,7 +5,7 @@ module Badger
5
5
  class CLI < Thor
6
6
  desc 'badge', 'Generate badge markdown'
7
7
  long_desc <<-LONGDESC
8
- Generates badges for Github READMEs. The default services are
8
+ Generates badges for Github READMEs. The default services are:
9
9
 
10
10
  * Travis-ci
11
11
 
@@ -20,20 +20,30 @@ Extra badges: currently only one extra badge is supported, a link to the MIT lic
20
20
  [![License](http://b.adge.me/:license-mit-blue.svg)](http://doge.mit-license.org)
21
21
 
22
22
 
23
+ If a gemspec is found, the following badges will also be generated:
24
+
25
+ * [License: MIT] badge (presuming an MIT license is specified, linked as above)
26
+
27
+ * [Gem version] badge, linking to rubygems.org
28
+
23
29
  LONGDESC
24
30
  option :not, desc: 'Exclude these services (comma-separated list)'
25
31
  option :only, desc: 'Generate for *only* these services (comma-separated list)'
26
32
  option :also, desc: 'Include this extra service (currently only \'mit\')'
27
33
 
28
34
  def badge dir = '.'
29
- f = File.open '/tmp/wtf', 'w'
30
- f.write options
31
-
32
35
  @badger = Badger.new Git.open(dir).remote.url
33
36
  @badger.remove options[:not].split(',') if options[:not]
34
37
  @badger.only options[:only].split(',') if options[:only]
35
38
  @badger.also options[:also].split(',') if options[:also]
36
39
 
40
+ spec_file = (Dir.entries dir).select { |i| /gemspec/.match i }[0]
41
+
42
+ if spec_file
43
+ lines = File.open(File.join(dir, spec_file), 'r').readlines
44
+ @badger.gemspec lines
45
+ end
46
+
37
47
  puts @badger.to_s
38
48
  end
39
49
 
@@ -1,3 +1,3 @@
1
1
  module Badger
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -59,5 +59,16 @@ module Badger
59
59
  @badger.badge[4].should == "[![License](http://b.adge.me/:license-mit-blue.svg)](http://doge.mit-license.org)"
60
60
  end
61
61
  end
62
+
63
+ context 'gemspec' do
64
+ it 'should generate badges based on gemspec' do
65
+ @badger.gemspec [
66
+ "spec.name 'suchgem'",
67
+ "spec.license 'MIT'"
68
+ ]
69
+ @badger.badge[4].should == "[![Gem Version](http://b.adge.me/gem/v/suchgem.svg)](https://rubygems.org/gems/suchgem)"
70
+ @badger.badge[5].should == "[![License](http://b.adge.me/:license-mit-blue.svg)](http://doge.mit-license.org)"
71
+ end
72
+ end
62
73
  end
63
- end
74
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: badgerbadgerbadger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pikesley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-27 00:00:00.000000000 Z
11
+ date: 2014-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -221,6 +221,7 @@ files:
221
221
  - Guardfile
222
222
  - LICENSE.md
223
223
  - README.md
224
+ - RUBYGEMBADGE
224
225
  - Rakefile
225
226
  - badger.gemspec
226
227
  - bin/badger
@@ -259,7 +260,8 @@ rubyforge_project:
259
260
  rubygems_version: 2.2.0.rc.1
260
261
  signing_key:
261
262
  specification_version: 4
262
- summary: Generate Github project badges
263
+ summary: Badge-Driven Development made easy. Generate a set of Github badges for your
264
+ project without cutting-n-pasting every time
263
265
  test_files:
264
266
  - features/badger.feature
265
267
  - features/step_definitions/badger_steps.rb