Class: Gem::Commands::CanCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::CanCommand
- Includes:
- VersionOption
- Defined in:
- lib/rubygems/commands/can_command.rb
Instance Method Summary collapse
-
#arguments ⇒ Object
:nodoc:.
-
#defaults_str ⇒ Object
:nodoc:.
- #execute ⇒ Object
-
#initialize ⇒ CanCommand
constructor
A new instance of CanCommand.
-
#usage ⇒ Object
:nodoc:.
Constructor Details
#initialize ⇒ CanCommand
Returns a new instance of CanCommand.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rubygems/commands/can_command.rb', line 10 def initialize super 'can', 'Can an installed gem into a .jar file', :version => Gem::Requirement.default, :target => Dir.pwd add_option('--target DIR', 'target directory for the .jar') do |value, | [:target] = value end add_version_option end |
Instance Method Details
#arguments ⇒ Object
:nodoc:
22 23 24 |
# File 'lib/rubygems/commands/can_command.rb', line 22 def arguments # :nodoc: "GEMNAME name of gem to unpack" end |
#defaults_str ⇒ Object
:nodoc:
26 27 28 |
# File 'lib/rubygems/commands/can_command.rb', line 26 def defaults_str # :nodoc: "--version '#{Gem::Requirement.default}'" end |
#execute ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rubygems/commands/can_command.rb', line 34 def execute get_all_gem_names.each do |name| path = get_path name, [:version] if path then basename = File.basename(path).sub(/\.gem$/, '') tmpgem_dir = File. File.join(Dir.tmpdir, 'cannery', basename) target_dir = File. File.join([:target]) FileUtils.mkdir_p tmpgem_dir FileUtils.mkdir_p target_dir Gem::Installer.new(path, :unpack => true).unpack tmpgem_dir sh "jar -cf #{target_dir}/#{basename}.jar -C #{tmpgem_dir}/lib ." FileUtils.rm_rf tmpgem_dir say "Gem has been canned: '#{target_dir}/#{basename}.jar'" else alert_error "Gem '#{name}' not installed." end end end |
#usage ⇒ Object
:nodoc:
30 31 32 |
# File 'lib/rubygems/commands/can_command.rb', line 30 def usage # :nodoc: "#{program_name} GEMNAME" end |