Class: Gem::Commands::ExportCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::ExportCommand
- Defined in:
- lib/rubygems/commands/export_command.rb
Overview
An alternate to Gem::Commands::QueryCommand that searches for gems starting with the the supplied argument.
Instance Method Summary collapse
-
#arguments ⇒ Object
:nodoc:.
-
#defaults_str ⇒ Object
:nodoc:.
- #execute ⇒ Object
-
#initialize ⇒ ExportCommand
constructor
A new instance of ExportCommand.
-
#usage ⇒ Object
:nodoc:.
Constructor Details
#initialize ⇒ ExportCommand
Returns a new instance of ExportCommand.
9 10 11 |
# File 'lib/rubygems/commands/export_command.rb', line 9 def initialize super 'export', 'Dumps your currently installed gems into yaml' end |
Instance Method Details
#arguments ⇒ Object
:nodoc:
13 14 15 |
# File 'lib/rubygems/commands/export_command.rb', line 13 def arguments # :nodoc: "GEMFILE location to save the export to" end |
#defaults_str ⇒ Object
:nodoc:
17 18 19 |
# File 'lib/rubygems/commands/export_command.rb', line 17 def defaults_str # :nodoc: "" end |
#execute ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rubygems/commands/export_command.rb', line 25 def execute export_file = get_one_optional_argument unless export_file then raise Gem::CommandLineError, "Please specify a file to save the export to" end dep = Gem::Dependency.new //, Gem::Requirement.default specs = Gem.source_index.search dep gems = [] specs.map do |spec| gems << { :name => spec.name, :version => spec.version.to_s, :install_options => '' } end output = {'sources' => Gem.sources, 'gems' => gems} File.open(export_file, 'w') do |f| f.write output.to_yaml end end |
#usage ⇒ Object
:nodoc:
21 22 23 |
# File 'lib/rubygems/commands/export_command.rb', line 21 def usage # :nodoc: "#{program_name} GEMFILE" end |