# File lib/bundler/gem_helper.rb, line 9 9: def self.install_tasks(opts = {}) 10: dir = opts[:dir] || Dir.pwd 11: self.new(dir, opts[:name]).install 12: end
# File lib/bundler/gem_helper.rb, line 16 16: def initialize(base, name = nil) 17: Bundler.ui = UI::Shell.new(Thor::Base.shell.new) 18: @base = base 19: gemspecs = name ? [File.join(base, "#{name}.gemspec")] : Dir[File.join(base, "{,*}.gemspec")] 20: raise "Unable to determine name from existing gemspec. Use :name => 'gemname' in #install_tasks to manually set it." unless gemspecs.size == 1 21: @spec_path = gemspecs.first 22: @gemspec = Bundler.load_gemspec(@spec_path) 23: end
# File lib/bundler/gem_helper.rb, line 42 42: def build_gem 43: file_name = nil 44: sh("gem build -V '#{spec_path}'") { |out, code| 45: file_name = File.basename(built_gem_path) 46: FileUtils.mkdir_p(File.join(base, 'pkg')) 47: FileUtils.mv(built_gem_path, 'pkg') 48: Bundler.ui.confirm "#{name} #{version} built to pkg/#{file_name}" 49: } 50: File.join(base, 'pkg', file_name) 51: end
# File lib/bundler/gem_helper.rb, line 25 25: def install 26: desc "Build #{name}-#{version}.gem into the pkg directory" 27: task 'build' do 28: build_gem 29: end 30: 31: desc "Build and install #{name}-#{version}.gem into system gems" 32: task 'install' do 33: install_gem 34: end 35: 36: desc "Create tag #{version_tag} and build and push #{name}-#{version}.gem to Rubygems" 37: task 'release' do 38: release_gem 39: end 40: end
# File lib/bundler/gem_helper.rb, line 53 53: def install_gem 54: built_gem_path = build_gem 55: out, _ = sh_with_code("gem install '#{built_gem_path}'") 56: raise "Couldn't install gem, run `gem install #{built_gem_path}' for more detailed output" unless out[/Successfully installed/] 57: Bundler.ui.confirm "#{name} (#{version}) installed" 58: end
# File lib/bundler/gem_helper.rb, line 80 80: def built_gem_path 81: Dir[File.join(base, "#{name}-*.gem")].sort_by{|f| File.mtime(f)}.last 82: end
# File lib/bundler/gem_helper.rb, line 106 106: def clean? 107: sh_with_code("git diff --exit-code")[1] == 0 108: end
# File lib/bundler/gem_helper.rb, line 84 84: def git_push 85: perform_git_push 86: perform_git_push ' --tags' 87: Bundler.ui.confirm "Pushed git commits and tags" 88: end
# File lib/bundler/gem_helper.rb, line 96 96: def guard_already_tagged 97: if sh('git tag').split(/\n/).include?(version_tag) 98: raise("This tag has already been committed to the repo.") 99: end 100: end
# File lib/bundler/gem_helper.rb, line 102 102: def guard_clean 103: clean? or raise("There are files that need to be committed first.") 104: end
# File lib/bundler/gem_helper.rb, line 128 128: def name 129: gemspec.name 130: end
# File lib/bundler/gem_helper.rb, line 90 90: def perform_git_push(options = '') 91: cmd = "git push #{options}" 92: out, code = sh_with_code(cmd) 93: raise "Couldn't git push. `#{cmd}' failed with the following output:\n\n#{out}\n" unless code == 0 94: end
# File lib/bundler/gem_helper.rb, line 71 71: def rubygem_push(path) 72: if Pathname.new("~/.gem/credentials").expand_path.exist? 73: sh("gem push '#{path}'") 74: Bundler.ui.confirm "Pushed #{name} #{version} to rubygems.org" 75: else 76: raise "Your rubygems.org credentials aren't set. Run `gem push` to set them." 77: end 78: end
# File lib/bundler/gem_helper.rb, line 132 132: def sh(cmd, &block) 133: out, code = sh_with_code(cmd, &block) 134: code == 0 ? out : raise(out.empty? ? "Running `#{cmd}' failed. Run this command directly for more detailed output." : out) 135: end
# File lib/bundler/gem_helper.rb, line 137 137: def sh_with_code(cmd, &block) 138: cmd << " 2>&1" 139: outbuf = '' 140: Bundler.ui.debug(cmd) 141: Dir.chdir(base) { 142: outbuf = `#{cmd}` 143: if $? == 0 144: block.call(outbuf) if block 145: end 146: } 147: [outbuf, $?] 148: end
# File lib/bundler/gem_helper.rb, line 110 110: def tag_version 111: sh "git tag -a -m \"Version #{version}\" #{version_tag}" 112: Bundler.ui.confirm "Tagged #{version_tag}" 113: yield if block_given? 114: rescue 115: Bundler.ui.error "Untagged #{version_tag} due to error" 116: sh_with_code "git tag -d #{version_tag}" 117: raise 118: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.