module RunGemDev
Constants
- VERSION
Public Class Methods
gem_tasks(gemname, gemdir="gems")
click to toggle source
# File lib/run-gem-dev/gem_tasks.rb, line 5 def self.gem_tasks(gemname, gemdir="gems") command "gem" spec = Gem::Specification::load "#{gemname}.gemspec" spec or abort "Error loading #{gemname}.gemspec" gemver = spec.version.to_s usage "build [--install]" help "Build gem from gemspec and move it to '#{gemdir}' folder.\nUse --install to also install it." action :build do |args| say "!txtgrn!Building gem" cmd = "gem build #{gemname}.gemspec" say "!txtgrn!Running: !txtpur!#{cmd}" system cmd say "!txtgrn!Moving gem file to #{gemdir}" files = Dir["*.gem"] Dir.exist? gemdir or FileUtils.mkdir gemdir files.each {|f| FileUtils.mv f, gemdir } args['--install'] and call "gem install" end usage "install [--remote]" help "Install gem from local gem file or from rubygems (--remote)." action :install do |args| if args['--remote'] cmd = "gem install #{gemname}" else gemfile = "gems/#{gemname}-#{gemver}.gem" cmd = "gem install #{gemfile}" end say "!txtgrn!Running: !txtpur!#{cmd}" system cmd end help "Publish gem to rubygems. Make sure to 'run gem build' before you publish." action :publish do gemfile = "gems/#{gemname}-#{gemver}.gem" File.exist? gemfile or abort "File not found #{gemfile}" cmd = "gem push #{gemfile}" say "!txtgrn!Running: !txtpur!#{cmd}" system cmd end usage "yank [<version>]" help "Yank gem from rubygems." action :yank do |args| ver = args['<version>'] || gemver cmd = "gem yank #{gemname} -v #{ver}" say "!txtgrn!Running: !txtpur!#{cmd}" system cmd end endcommand end
minitest_tasks(pattern="./test/*_test.rb")
click to toggle source
# File lib/run-gem-dev/minitest_tasks.rb, line 3 def self.minitest_tasks(pattern="./test/*_test.rb") usage "test [<name>]" help "Run all tests or a single test file." action :test do |args| if args['<name>'] file = pattern.sub "*", args['<name>'] say "!txtgrn!Using: !txtpur!#{file}" require file else Dir[pattern].each do |file| say "!txtgrn!Using: !txtpur!#{file}" require file end end end end
rdoc_tasks(files=nil, options=@@default_rdoc_options)
click to toggle source
# File lib/run-gem-dev/rdoc_tasks.rb, line 8 def self.rdoc_tasks(files=nil, options=@@default_rdoc_options) files or files = Dir['**/*.{rb,md}'] files = "'" + files.join("' '") + "'" usage "rdoc [-- <options>...]" help "Generate documentation using the rdoc command line tool. To pass arguments to rdoc, place them after '--'." action :rdoc do |args| inopts = args['<options>'] options = inopts unless inopts.empty? options = options.join(' ') cmd = "rdoc #{options} #{files}" say "!txtgrn!Running: !txtpur!#{cmd}" system cmd end end
rspec_tasks(opts={})
click to toggle source
# File lib/run-gem-dev/rspec_tasks.rb, line 3 def self.rspec_tasks(opts={}) opts = { action: opts } if opts.is_a? String opts = { action: 'spec', pattern: './spec/**/*_spec.rb', command: 'rspec' }.merge opts usage "#{opts[:action]} [<name>]" help "Run all specs or a single spec file matching a regex." action opts[:action].to_sym do |args| if args['<name>'] files = Dir[opts[:pattern]] files.select! { |file| file =~ /#{args['<name>']}/i } abort "Cannot find a matching spec file with #{opts[:pattern]}" if files.empty? file = files.first cmd = "#{opts[:command]} \"#{file}\"" else cmd = "#{opts[:command]}" end say "!txtgrn!Running: !txtpur!#{cmd}" system cmd end end