Module: RunGemDev
- Defined in:
- lib/run-gem-dev/tasks.rb,
lib/run-gem-dev/version.rb
Overview
This module provides Runfile tasks for gem developers. The tasks are divided to three categories:
-
Rubygems tasks (publish, build etc)
-
Tests tasks (using minitest)
-
Rdoc tasks
Constant Summary collapse
- VERSION =
Version constant, used by gemspec
"0.2.0"
- @@default_rdoc_options =
[ "--main README.md", "--all", ]
Class Method Summary collapse
-
.gem_tasks(gemname, gemdir = "gems") ⇒ Object
Add rubygems tasks: build, install, publish and yank.
-
.minitest_tasks(pattern = "./test/test_*.rb") ⇒ Object
Add minitest task.
-
.rdoc_tasks(files = nil, options = @@default_rdoc_options) ⇒ Object
Add rdoc task.
Class Method Details
.gem_tasks(gemname, gemdir = "gems") ⇒ Object
Add rubygems tasks: build, install, publish and yank
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/run-gem-dev/tasks.rb', line 17 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"] 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") ⇒ Object
Add minitest task
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/run-gem-dev/tasks.rb', line 72 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) ⇒ Object
Add rdoc task
90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/run-gem-dev/tasks.rb', line 90 def self.rdoc_tasks(files=nil, =@@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>'] = inopts unless inopts.empty? = .join(' ') cmd = "rdoc #{} #{files}" say "!txtgrn!Running: !txtpur!#{cmd}" system cmd end end |