lib/badger/cli.rb in badgerbadgerbadger-0.1.0 vs lib/badger/cli.rb in badgerbadgerbadger-0.2.0
- old
+ new
@@ -3,11 +3,11 @@
module Badger
class CLI < Thor
desc 'badge', 'Generate badge markdown'
long_desc <<-LONGDESC
-Generates badges for Github READMEs. The default services are
+Generates badges for Github READMEs. The default services are:
* Travis-ci
* Code Climate
@@ -18,22 +18,32 @@
Extra badges: currently only one extra badge is supported, a link to the MIT license from here: https://github.com/remy/mit-license, e.g.
[![License](http://b.adge.me/:license-mit-blue.svg)](http://doge.mit-license.org)
+If a gemspec is found, the following badges will also be generated:
+
+ * [License: MIT] badge (presuming an MIT license is specified, linked as above)
+
+ * [Gem version] badge, linking to rubygems.org
+
LONGDESC
option :not, desc: 'Exclude these services (comma-separated list)'
option :only, desc: 'Generate for *only* these services (comma-separated list)'
option :also, desc: 'Include this extra service (currently only \'mit\')'
def badge dir = '.'
- f = File.open '/tmp/wtf', 'w'
- f.write options
-
@badger = Badger.new Git.open(dir).remote.url
@badger.remove options[:not].split(',') if options[:not]
@badger.only options[:only].split(',') if options[:only]
@badger.also options[:also].split(',') if options[:also]
+
+ spec_file = (Dir.entries dir).select { |i| /gemspec/.match i }[0]
+
+ if spec_file
+ lines = File.open(File.join(dir, spec_file), 'r').readlines
+ @badger.gemspec lines
+ end
puts @badger.to_s
end
default_task :badge
\ No newline at end of file