Class: Gem::Commands::PublishCommand

Inherits:
Gem::Command
  • Object
show all
Defined in:
lib/rubygems_plugin.rb

Instance Method Summary collapse

Constructor Details

#initializePublishCommand

Returns a new instance of PublishCommand.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rubygems_plugin.rb', line 6

def initialize
  super "publish", "Automatically publish a gem if the version has been updated"

  defaults.merge! :gem_repository => "rubygems"

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

Instance Method Details

#executeObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rubygems_plugin.rb', line 23

def execute
  options[:args].each do |gemspec|
    Dir.chdir(File.dirname(gemspec)) do
      gem = GemPublisher.publish_if_updated(File.basename(gemspec), options[:gem_repository])

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

#usageObject

:nodoc:



19
20
21
# File 'lib/rubygems_plugin.rb', line 19

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