Class: Gem::Commands::SnapshotCommand

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

Instance Method Summary collapse

Constructor Details

#initializeSnapshotCommand

Returns a new instance of SnapshotCommand.



5
6
7
8
9
10
11
12
# File 'lib/commands/snapshot_command.rb', line 5

def initialize
  super 'snapshot', 'Export/Import your gems.', :format => "tar"

  add_option('-f', '--format FORMAT', 'Snapshot format. Default is "tar". Can be "yml" too.') do |value, options|
    options[:format] = value
  end

end

Instance Method Details

#argumentsObject

:nodoc:



18
19
20
21
22
23
24
# File 'lib/commands/snapshot_command.rb', line 18

def arguments # :nodoc:
  args = <<-EOF
        ACTION    'export' or 'import' as action arguments
        FILENAME  file used to export/import actions
  EOF
  return args.gsub(/^\s+/, '')
end

#defaults_strObject

:nodoc:



14
15
16
# File 'lib/commands/snapshot_command.rb', line 14

def defaults_str # :nodoc:
  '--format "tar"'
end

#descriptionObject

:nodoc:



26
27
28
29
30
31
# File 'lib/commands/snapshot_command.rb', line 26

def description # :nodoc:
  <<-EOF
Describe here what snapshot does.
Updated description at: http://github.com/rogerleite/rubygems_snapshot
  EOF
end

#executeObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/commands/snapshot_command.rb', line 37

def execute
  action, filename = extract_action(options[:args])
  validate_options(options_without_args)

  if action == "export"
    export(filename)
  else
    import(filename)
  end
end

#usageObject

:nodoc:



33
34
35
# File 'lib/commands/snapshot_command.rb', line 33

def usage # :nodoc:
  "#{program_name} ACTION(export|import) FILENAME"
end