Sha256: 9e9695c2634962d483647ab5134ba7c3369616dedc905dac9f6903182c1b2a3a

Contents?: true

Size: 1.24 KB

Versions: 67

Compression:

Stored size: 1.24 KB

Contents

require "rubygems/command_manager"
require "rubygems/command"
require "gem_publisher"

class Gem::Commands::PublishCommand < Gem::Command
  def initialize
    super "publish", "Automatically publish a gem if the version has been updated"

    defaults.merge! :gem_repository => "rubygems"

    add_option(
      "-rREPOSITORY", "--repository=REPOSITORY",
      "Set the gem repository (rubygems or gemfury)",
      "Default: #{defaults[:gem_repository]}") do |value, options|
      options[:gem_repository] = value
    end

    add_option(
      "-aAS", "--as=AS",
      "Specify a shared account to publish the gem (gemfury only)"
    ) do |value, options|
      options[:as] = value
    end
  end

  def usage # :nodoc:
    "#{program_name} GEMFILE [GEMFILE ...]"
  end

  def execute
    options[:args].each do |gemspec|
      Dir.chdir(File.dirname(gemspec)) do
        new_opts = {}
        new_opts[:as] = options[:as] if options[:as]

        gem = GemPublisher.publish_if_updated(File.basename(gemspec), options[:gem_repository], new_opts)

        if gem
          $stderr.puts "Published #{gem}"
        else
          $stderr.puts "Nothing to do for #{gemspec}"
        end
      end
    end
  end
end

Gem::CommandManager.instance.register_command :publish

Version data entries

67 entries across 63 versions & 18 rubygems

Version Path
able-neo4j-1.0.0 vendor/bundle/jruby/1.9/gems/gem_publisher-1.5.0/lib/rubygems_plugin.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/logstash-codec-json-2.0.3/vendor/gems/gem_publisher-1.5.0/lib/rubygems_plugin.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/gem_publisher-1.5.0/lib/rubygems_plugin.rb
logstash-codec-json-2.0.3 vendor/gems/gem_publisher-1.5.0/lib/rubygems_plugin.rb
logstash-input-beats-0.9.2 vendor/jruby/1.9/gems/gem_publisher-1.5.0/lib/rubygems_plugin.rb
logstash-input-beats-0.9.1 vendor/jruby/1.9/gems/gem_publisher-1.5.0/lib/rubygems_plugin.rb
gem_publisher-1.5.0 lib/rubygems_plugin.rb