Class: Gem::Commands::CheckoutCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::CheckoutCommand
- Defined in:
- lib/rubygems/commands/checkout_command.rb
Instance Method Summary collapse
-
#arguments ⇒ Object
:nodoc:.
-
#defaults_str ⇒ Object
:nodoc:.
-
#description ⇒ Object
:nodoc:.
- #execute ⇒ Object
-
#initialize ⇒ CheckoutCommand
constructor
A new instance of CheckoutCommand.
-
#usage ⇒ Object
:nodoc:.
Constructor Details
#initialize ⇒ CheckoutCommand
Returns a new instance of CheckoutCommand.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rubygems/commands/checkout_command.rb', line 7 def initialize super 'checkout', description add_option('-v', '--version VERSION', 'version to checkout') do |version, | [:version] = version end add_option('-d', '--debug LEVEL', 'set debug mode (0=debug)') do |level, | [:debug_level] = Integer(level) end add_option('-s', '--[no-]verify', 'verify sources match gem exactly') do |verify, | [:verify] = verify end end |
Instance Method Details
#arguments ⇒ Object
:nodoc:
22 23 24 |
# File 'lib/rubygems/commands/checkout_command.rb', line 22 def arguments # :nodoc: "checkout checkout the original repository at the same version" end |
#defaults_str ⇒ Object
:nodoc:
30 31 32 |
# File 'lib/rubygems/commands/checkout_command.rb', line 30 def defaults_str # :nodoc: "" end |
#description ⇒ Object
:nodoc:
34 35 36 |
# File 'lib/rubygems/commands/checkout_command.rb', line 34 def description # :nodoc: "Checkout a gem's repository or sources at the same version" end |
#execute ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rubygems/commands/checkout_command.rb', line 38 def execute logger = Logger.new(STDERR) logger.level = [:debug_level] || Logger::WARN Gem::Checkout.logger = logger name = get_one_gem_name source = Gem::Checkout::Source.new(name, [:version]) version = source.version repository = source.repository repository.clone(directory: name) Dir.chdir(name) do repository.checkout(source.source_reference) if [:verify] verifier = Gem::Checkout::Verifier.new(name, version) verifier.verify! end end rescue Gem::Checkout::Repository::Error => ex alert_error ex. terminate_interaction 1 rescue Gem::Checkout::Verifier::Error => ex alert_error ex. terminate_interaction 1 end |
#usage ⇒ Object
:nodoc:
26 27 28 |
# File 'lib/rubygems/commands/checkout_command.rb', line 26 def usage # :nodoc: "#{program_name}" end |