Sha256: 4f9679e77347385499b1379dd6976b0ea969a8634d6e396f5f7b6c814e6318bb

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

require 'rubygems/command_manager'
require 'rubygems/commands/build_command'
require 'rubygems/commands/push_command'

class Gem::Commands::ReleaseCommand < Gem::Command
  def initialize
    super 'release', 'Build a gem from a gemspec and push to rubygems.org'
  end

  def arguments # :nodoc:
    "GEMSPEC_FILE optional (will use the first *.gemspec if not specified)"
  end

  def usage # :nodoc:
    "#{program_name} [GEMSPEC_FILE]"
  end
  
  def execute
    file_name = build
    push(file_name)
    remove(filename)
    say "All done, thanks buddy."
  end
  
  def build
    command = Gem::Commands::BuildCommand.new
    command.handle_options([gemspec])
    command.execute
    command.load_gemspecs(gemspec).first.file_name
  end
  
  def push(filename)
    command = Gem::Commands::PushCommand.new
    command.handle_options([filename])
    command.execute
  end
  
  def remove(filename)
    `rm #{file_name}`
    say "Deleting left over gem file #{filename}"
  end
  
  def gemspec
    @gemspec ||= begin
      gemspec = Array(options[:args]).first
      gemspec ||= Dir['*.gemspec'].first
      gemspec || raise("No gemspec found or given.")
    end
  end
end

Gem::CommandManager.instance.register_command :release

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gem-release-0.0.3 lib/rubygems_plugin.rb
gem-release-0.0.2 lib/rubygems_plugin.rb