method
execute
v2_6_3 -
Show latest stable
- Class:
Gem::Commands::UnpackCommand
execute()public
No documentation available.
# File lib/rubygems/commands/unpack_command.rb, line 75
def execute
security_policy = options[:security_policy]
get_all_gem_names.each do |name|
dependency = Gem::Dependency.new name, options[:version]
path = get_path dependency
unless path
alert_error "Gem '#{name}' not installed nor fetchable."
next
end
if @options[:spec]
spec, metadata = get_metadata path, security_policy
if metadata.nil?
alert_error "--spec is unsupported on '#{name}' (old format gem)"
next
end
spec_file = File.basename spec.spec_file
FileUtils.mkdir_p @options[:target] if @options[:target]
destination = begin
if @options[:target]
File.join @options[:target], spec_file
else
spec_file
end
end
File.open destination, 'w' do |io|
io.write metadata
end
else
basename = File.basename path, '.gem'
target_dir = File.expand_path basename, options[:target]
package = Gem::Package.new path, security_policy
package.extract_files target_dir
say "Unpacked gem: '#{target_dir}'"
end
end
end