Class: Bundler::GemHelper
- Inherits:
-
Object
- Object
- Bundler::GemHelper
- Defined in:
- lib/bundler/gem_helper.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#gemspec ⇒ Object
readonly
Returns the value of attribute gemspec.
-
#spec_path ⇒ Object
readonly
Returns the value of attribute spec_path.
Class Method Summary collapse
Instance Method Summary collapse
- #build_gem ⇒ Object
-
#initialize(base, name = nil) ⇒ GemHelper
constructor
A new instance of GemHelper.
- #install ⇒ Object
- #install_gem ⇒ Object
- #release_gem ⇒ Object
Constructor Details
#initialize(base, name = nil) ⇒ GemHelper
Returns a new instance of GemHelper.
14 15 16 17 18 19 20 21 |
# File 'lib/bundler/gem_helper.rb', line 14 def initialize(base, name = nil) Bundler.ui = UI::Shell.new(Thor::Base.shell.new) @base = base gemspecs = name ? [File.join(base, "#{name}.gemspec")] : Dir[File.join(base, "*.gemspec")] raise "Unable to determine name from existing gemspec. Use :name => 'gemname' in #install_tasks to manually set it." unless gemspecs.size == 1 @spec_path = gemspecs.first @gemspec = Bundler.load_gemspec(@spec_path) end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
12 13 14 |
# File 'lib/bundler/gem_helper.rb', line 12 def base @base end |
#gemspec ⇒ Object (readonly)
Returns the value of attribute gemspec.
12 13 14 |
# File 'lib/bundler/gem_helper.rb', line 12 def gemspec @gemspec end |
#spec_path ⇒ Object (readonly)
Returns the value of attribute spec_path.
12 13 14 |
# File 'lib/bundler/gem_helper.rb', line 12 def spec_path @spec_path end |
Class Method Details
.install_tasks(opts = {}) ⇒ Object
7 8 9 10 |
# File 'lib/bundler/gem_helper.rb', line 7 def self.install_tasks(opts = {}) dir = opts[:dir] || Dir.pwd self.new(dir, opts[:name]).install end |
Instance Method Details
#build_gem ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/bundler/gem_helper.rb', line 40 def build_gem file_name = nil sh("gem build #{spec_path}") { |out, code| raise out unless out[/Successfully/] file_name = File.basename(built_gem_path) FileUtils.mkdir_p(File.join(base, 'pkg')) FileUtils.mv(built_gem_path, 'pkg') Bundler.ui.confirm "#{name} #{version} built to pkg/#{file_name}" } File.join(base, 'pkg', file_name) end |
#install ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/bundler/gem_helper.rb', line 23 def install desc "Build #{name}-#{version}.gem into the pkg directory" task 'build' do build_gem end desc "Build and install #{name}-#{version}.gem into system gems" task 'install' do install_gem end desc "Create tag #{version_tag} and build and push #{name}-#{version}.gem to Rubygems" task 'release' do release_gem end end |
#install_gem ⇒ Object
52 53 54 55 56 57 |
# File 'lib/bundler/gem_helper.rb', line 52 def install_gem built_gem_path = build_gem out, _ = sh_with_code("gem install #{built_gem_path}") raise "Couldn't install gem, run `gem install #{built_gem_path}' for more detailed output" unless out[/Successfully installed/] Bundler.ui.confirm "#{name} (#{version}) installed" end |
#release_gem ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/bundler/gem_helper.rb', line 59 def release_gem guard_clean guard_already_tagged built_gem_path = build_gem tag_version { git_push rubygem_push(built_gem_path) } end |