Class: Detroit::Gem
- Inherits:
-
Tool
- Object
- Tool
- Detroit::Gem
- Includes:
- RubyUtils, Standard
- Defined in:
- lib/detroit-gem.rb
Overview
-
purge
Constant Summary collapse
- MANPAGE =
Location of man_page for tool.
File.dirname(__FILE__) + '/../man/detroit-gem.5'
Instance Attribute Summary collapse
-
#autospec ⇒ Object
True or false whether to write gemspec from project metadata (default is ‘false`).
-
#gemspec ⇒ Object
The .gemspec filename (default looks-up ‘.gemspec` or `name.gemspec` file).
- #install ⇒ Object
-
#pkgdir ⇒ Object
Package directory (defaults to ‘pkg`).
-
#version ⇒ Object
readonly
Version to release.
Instance Method Summary collapse
- #assemble?(station, options = {}) ⇒ Boolean
-
#build ⇒ Object
Create a gem package.
-
#install? ⇒ Boolean
Whether to install the gem (default ‘false`).
-
#package ⇒ Object
Write gemspec if
autospec
istrue
and then build the gem. - #prerequisite ⇒ Object
-
#purge ⇒ Object
Remove package file(s).
-
#push ⇒ Object
Push gem package to RubyGems.org (a la Gemcutter).
-
#release ⇒ Object
Same as #push.
-
#reset ⇒ Object
Mark package files as outdated.
-
#spec(file = nil) ⇒ String
Convert metadata to a gemspec and write to
file
.
Instance Attribute Details
#autospec ⇒ Object
True or false whether to write gemspec from project metadata (default is ‘false`).
42 43 44 |
# File 'lib/detroit-gem.rb', line 42 def autospec @autospec end |
#gemspec ⇒ Object
The .gemspec filename (default looks-up ‘.gemspec` or `name.gemspec` file).
39 40 41 |
# File 'lib/detroit-gem.rb', line 39 def gemspec @gemspec end |
#install ⇒ Object
91 92 93 94 95 96 |
# File 'lib/detroit-gem.rb', line 91 def install return unless install? package_files.each do |file| sh "gem install --no-rdoc --no-ri #{file}" end end |
#pkgdir ⇒ Object
Package directory (defaults to ‘pkg`). Location of packages. This defaults to Project#pkg.
46 47 48 |
# File 'lib/detroit-gem.rb', line 46 def pkgdir @pkgdir end |
#version ⇒ Object (readonly)
Version to release. Defaults to current version.
60 61 62 |
# File 'lib/detroit-gem.rb', line 60 def version @version end |
Instance Method Details
#assemble?(station, options = {}) ⇒ Boolean
137 138 139 140 141 142 143 144 |
# File 'lib/detroit-gem.rb', line 137 def assemble?(station, ={}) return true if station == :package return true if station == :install return true if station == :release return true if station == :reset return true if station == :purge return false end |
#build ⇒ Object
Create a gem package.
72 73 74 75 76 77 78 |
# File 'lib/detroit-gem.rb', line 72 def build trace "gem build #{gemspec}" spec = load_gemspec package = ::Gem::Package.build(spec) mkdir_p(pkgdir) unless File.directory?(pkgdir) mv(package, pkgdir) end |
#install? ⇒ Boolean
Whether to install the gem (default ‘false`).
52 53 54 |
# File 'lib/detroit-gem.rb', line 52 def install? @install end |
#package ⇒ Object
Write gemspec if autospec
is true
and then build the gem.
66 67 68 69 |
# File 'lib/detroit-gem.rb', line 66 def package create_gemspec if autospec # TODO: should autospec be a generate phase? build end |
#prerequisite ⇒ Object
33 34 35 36 |
# File 'lib/detroit-gem.rb', line 33 def prerequisite require 'rubygems' require 'rubygems/package' end |
#purge ⇒ Object
This code is a little loose. Can it be more specific about which gem file(s) to remove?
Remove package file(s).
129 130 131 132 133 134 |
# File 'lib/detroit-gem.rb', line 129 def purge package_files.each do |f| rm(f) report "Removed #{f}" end end |
#push ⇒ Object
Push gem package to RubyGems.org (a la Gemcutter).
101 102 103 104 105 106 107 108 109 |
# File 'lib/detroit-gem.rb', line 101 def push if package_files.empty? report "No .gem packages found for version {version} at #{pkgdir}." else package_files.each do |file| sh "gem push #{file}" end end end |
#release ⇒ Object
Same as #push.
112 113 114 |
# File 'lib/detroit-gem.rb', line 112 def release push end |
#reset ⇒ Object
Mark package files as outdated.
117 118 119 120 121 122 |
# File 'lib/detroit-gem.rb', line 117 def reset package_files.each do |f| utime(0 ,0, f) report "Reset #{f}" end end |
#spec(file = nil) ⇒ String
Convert metadata to a gemspec and write to file
.
86 87 88 |
# File 'lib/detroit-gem.rb', line 86 def spec(file=nil) create_gemspec(file) end |