Sha256: 99b80b0e461f6e3bc9360eafabe31dce63550d9cfd2dbacef984e6e45ee5df18

Contents?: true

Size: 1.2 KB

Versions: 1

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
    filename = build
    push(filename)
    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.filename
  end
  
  def push(filename)
    command = Gem::Commands::PushCommand.new
    command.handle_options([filename])
    command.execute
  end
  
  def remove(filename)
    `rm #{filename}`
    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

1 entries across 1 versions & 1 rubygems

Version Path
gem-release-0.0.4 lib/rubygems_plugin.rb