diff options
Diffstat (limited to 'ruby_1_9_3/lib/rubygems/commands')
29 files changed, 0 insertions, 3348 deletions
diff --git a/ruby_1_9_3/lib/rubygems/commands/build_command.rb b/ruby_1_9_3/lib/rubygems/commands/build_command.rb deleted file mode 100644 index 36a6fe48f2..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/build_command.rb +++ /dev/null @@ -1,59 +0,0 @@ -require 'rubygems/command' -require 'rubygems/builder' - -class Gem::Commands::BuildCommand < Gem::Command - - def initialize - super 'build', 'Build a gem from a gemspec' - - add_option '--force', 'skip validation of the spec' do |value, options| - options[:force] = true - end - end - - def arguments # :nodoc: - "GEMSPEC_FILE gemspec file name to build a gem for" - end - - def usage # :nodoc: - "#{program_name} GEMSPEC_FILE" - end - - def execute - gemspec = get_one_gem_name - - if File.exist? gemspec - spec = load_gemspec gemspec - - if spec then - Gem::Builder.new(spec).build options[:force] - else - alert_error "Error loading gemspec. Aborting." - terminate_interaction 1 - end - else - alert_error "Gemspec file not found: #{gemspec}" - terminate_interaction 1 - end - end - - def load_gemspec filename - if yaml?(filename) - open(filename) do |f| - begin - Gem::Specification.from_yaml(f) - rescue Gem::EndOfYAMLException - nil - end - end - else - Gem::Specification.load(filename) # can return nil - end - end - - def yaml?(filename) - line = open(filename) { |f| line = f.gets } - result = line =~ %r{!ruby/object:Gem::Specification} - result - end -end diff --git a/ruby_1_9_3/lib/rubygems/commands/cert_command.rb b/ruby_1_9_3/lib/rubygems/commands/cert_command.rb deleted file mode 100644 index b416b3863d..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/cert_command.rb +++ /dev/null @@ -1,86 +0,0 @@ -require 'rubygems/command' -require 'rubygems/security' - -class Gem::Commands::CertCommand < Gem::Command - - def initialize - super 'cert', 'Manage RubyGems certificates and signing settings' - - add_option('-a', '--add CERT', - 'Add a trusted certificate.') do |value, options| - cert = OpenSSL::X509::Certificate.new(File.read(value)) - Gem::Security.add_trusted_cert(cert) - say "Added '#{cert.subject.to_s}'" - end - - add_option('-l', '--list', - 'List trusted certificates.') do |value, options| - glob_str = File::join(Gem::Security::OPT[:trust_dir], '*.pem') - Dir::glob(glob_str) do |path| - begin - cert = OpenSSL::X509::Certificate.new(File.read(path)) - # this could probably be formatted more gracefully - say cert.subject.to_s - rescue OpenSSL::X509::CertificateError - next - end - end - end - - add_option('-r', '--remove STRING', - 'Remove trusted certificates containing', - 'STRING.') do |value, options| - trust_dir = Gem::Security::OPT[:trust_dir] - glob_str = File::join(trust_dir, '*.pem') - - Dir::glob(glob_str) do |path| - begin - cert = OpenSSL::X509::Certificate.new(File.read(path)) - if cert.subject.to_s.downcase.index(value) - say "Removed '#{cert.subject.to_s}'" - File.unlink(path) - end - rescue OpenSSL::X509::CertificateError - next - end - end - end - - add_option('-b', '--build EMAIL_ADDR', - 'Build private key and self-signed', - 'certificate for EMAIL_ADDR.') do |value, options| - vals = Gem::Security.build_self_signed_cert(value) - FileUtils.chmod 0600, vals[:key_path] - say "Public Cert: #{vals[:cert_path]}" - say "Private Key: #{vals[:key_path]}" - say "Don't forget to move the key file to somewhere private..." - end - - add_option('-C', '--certificate CERT', - 'Certificate for --sign command.') do |value, options| - cert = OpenSSL::X509::Certificate.new(File.read(value)) - options[:issuer_cert] = cert - end - - add_option('-K', '--private-key KEY', - 'Private key for --sign command.') do |value, options| - key = OpenSSL::PKey::RSA.new(File.read(value)) - options[:issuer_key] = key - end - - add_option('-s', '--sign NEWCERT', - 'Sign a certificate with my key and', - 'certificate.') do |value, options| - cert = OpenSSL::X509::Certificate.new(File.read(value)) - my_cert = options[:issuer_cert] - my_key = options[:issuer_key] - cert = Gem::Security.sign_cert(cert, my_key, my_cert) - File.open(value, 'wb') { |file| file.write(cert.to_pem) } - end - end - - def execute - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/check_command.rb b/ruby_1_9_3/lib/rubygems/commands/check_command.rb deleted file mode 100644 index 5a1bfd4f12..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/check_command.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'rubygems/command' -require 'rubygems/version_option' -require 'rubygems/validator' - -class Gem::Commands::CheckCommand < Gem::Command - - include Gem::VersionOption - - def initialize - super 'check', 'Check installed gems', - :verify => false, :alien => false - - add_option( '--verify FILE', - 'Verify gem file against its internal', - 'checksum') do |value, options| - options[:verify] = value - end - - add_option('-a', '--alien', "Report 'unmanaged' or rogue files in the", - "gem repository") do |value, options| - options[:alien] = true - end - - add_version_option 'check' - end - - def execute - if options[:alien] - say "Performing the 'alien' operation" - say - gems = get_all_gem_names rescue [] - Gem::Validator.new.alien(gems).sort.each do |key, val| - unless val.empty? then - say "#{key} has #{val.size} problems" - val.each do |error_entry| - say " #{error_entry.path}:" - say " #{error_entry.problem}" - end - else - say "#{key} is error-free" if Gem.configuration.verbose - end - say - end - end - - if options[:verify] - gem_name = options[:verify] - unless gem_name - alert_error "Must specify a .gem file with --verify NAME" - return - end - unless File.exist?(gem_name) - alert_error "Unknown file: #{gem_name}." - return - end - say "Verifying gem: '#{gem_name}'" - begin - Gem::Validator.new.verify_gem_file(gem_name) - rescue Exception - alert_error "#{gem_name} is invalid." - end - end - end - -end diff --git a/ruby_1_9_3/lib/rubygems/commands/cleanup_command.rb b/ruby_1_9_3/lib/rubygems/commands/cleanup_command.rb deleted file mode 100644 index 124c4c203a..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/cleanup_command.rb +++ /dev/null @@ -1,100 +0,0 @@ -require 'rubygems/command' -require 'rubygems/dependency_list' -require 'rubygems/uninstaller' - -class Gem::Commands::CleanupCommand < Gem::Command - - def initialize - super 'cleanup', - 'Clean up old versions of installed gems in the local repository', - :force => false, :install_dir => Gem.dir - - add_option('-d', '--dryrun', "") do |value, options| - options[:dryrun] = true - end - end - - def arguments # :nodoc: - "GEMNAME name of gem to cleanup" - end - - def defaults_str # :nodoc: - "--no-dryrun" - end - - def description # :nodoc: - <<-EOF -The cleanup command removes old gems from GEM_HOME. If an older version is -installed elsewhere in GEM_PATH the cleanup command won't touch it. - EOF - end - - def usage # :nodoc: - "#{program_name} [GEMNAME ...]" - end - - def execute - say "Cleaning up installed gems..." - primary_gems = {} - - Gem::Specification.each do |spec| - if primary_gems[spec.name].nil? or - primary_gems[spec.name].version < spec.version then - primary_gems[spec.name] = spec - end - end - - gems_to_cleanup = unless options[:args].empty? then - options[:args].map do |gem_name| - Gem::Specification.find_all_by_name gem_name - end.flatten - else - Gem::Specification.to_a - end - - gems_to_cleanup = gems_to_cleanup.select { |spec| - primary_gems[spec.name].version != spec.version - } - - deplist = Gem::DependencyList.new - gems_to_cleanup.uniq.each do |spec| deplist.add spec end - - deps = deplist.strongly_connected_components.flatten.reverse - - original_path = Gem.path - - deps.each do |spec| - if options[:dryrun] then - say "Dry Run Mode: Would uninstall #{spec.full_name}" - else - say "Attempting to uninstall #{spec.full_name}" - - options[:args] = [spec.name] - - uninstall_options = { - :executables => false, - :version => "= #{spec.version}", - } - - uninstall_options[:user_install] = Gem.user_dir == spec.base_dir - - uninstaller = Gem::Uninstaller.new spec.name, uninstall_options - - begin - uninstaller.uninstall - rescue Gem::DependencyRemovalException, Gem::InstallError, - Gem::GemNotInHomeException, Gem::FilePermissionError => e - say "Unable to uninstall #{spec.full_name}:" - say "\t#{e.class}: #{e.message}" - end - end - - # Restore path Gem::Uninstaller may have change - Gem.use_paths(*original_path) - end - - say "Clean Up Complete" - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/contents_command.rb b/ruby_1_9_3/lib/rubygems/commands/contents_command.rb deleted file mode 100644 index e483484615..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/contents_command.rb +++ /dev/null @@ -1,101 +0,0 @@ -require 'rubygems/command' -require 'rubygems/version_option' - -class Gem::Commands::ContentsCommand < Gem::Command - - include Gem::VersionOption - - def initialize - super 'contents', 'Display the contents of the installed gems', - :specdirs => [], :lib_only => false, :prefix => true - - add_version_option - - add_option( '--all', - "Contents for all gems") do |all, options| - options[:all] = all - end - - add_option('-s', '--spec-dir a,b,c', Array, - "Search for gems under specific paths") do |spec_dirs, options| - options[:specdirs] = spec_dirs - end - - add_option('-l', '--[no-]lib-only', - "Only return files in the Gem's lib_dirs") do |lib_only, options| - options[:lib_only] = lib_only - end - - add_option( '--[no-]prefix', - "Don't include installed path prefix") do |prefix, options| - options[:prefix] = prefix - end - end - - def arguments # :nodoc: - "GEMNAME name of gem to list contents for" - end - - def defaults_str # :nodoc: - "--no-lib-only --prefix" - end - - def usage # :nodoc: - "#{program_name} GEMNAME [GEMNAME ...]" - end - - def execute - version = options[:version] || Gem::Requirement.default - - spec_dirs = options[:specdirs].map do |i| - [i, File.join(i, "specifications")] - end.flatten - - path_kind = if spec_dirs.empty? then - spec_dirs = Gem::Specification.dirs - "default gem paths" - else - "specified path" - end - - gem_names = if options[:all] then - Gem::Specification.map(&:name) - else - get_all_gem_names - end - - gem_names.each do |name| - # HACK: find_by_name fails for some reason... ARGH - # How many places must we embed our resolve logic? - spec = Gem::Specification.find_all_by_name(name, version).last - - unless spec then - say "Unable to find gem '#{name}' in #{path_kind}" - - if Gem.configuration.verbose then - say "\nDirectories searched:" - spec_dirs.each { |dir| say dir } - end - - terminate_interaction 1 if gem_names.length == 1 - end - - gem_path = spec.full_gem_path - extra = "/{#{spec.require_paths.join ','}}" if options[:lib_only] - glob = "#{gem_path}#{extra}/**/*" - files = Dir[glob] - - gem_path = File.join gem_path, '' # add trailing / if missing - - files.sort.each do |file| - next if File.directory? file - - file = file.sub gem_path, '' unless options[:prefix] - - say file - end - end - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/dependency_command.rb b/ruby_1_9_3/lib/rubygems/commands/dependency_command.rb deleted file mode 100644 index 67cbbc1d5e..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/dependency_command.rb +++ /dev/null @@ -1,160 +0,0 @@ -require 'rubygems/command' -require 'rubygems/local_remote_options' -require 'rubygems/version_option' - -class Gem::Commands::DependencyCommand < Gem::Command - - include Gem::LocalRemoteOptions - include Gem::VersionOption - - def initialize - super 'dependency', - 'Show the dependencies of an installed gem', - :version => Gem::Requirement.default, :domain => :local - - add_version_option - add_platform_option - add_prerelease_option - - add_option('-R', '--[no-]reverse-dependencies', - 'Include reverse dependencies in the output') do - |value, options| - options[:reverse_dependencies] = value - end - - add_option('-p', '--pipe', - "Pipe Format (name --version ver)") do |value, options| - options[:pipe_format] = value - end - - add_local_remote_options - end - - def arguments # :nodoc: - "GEMNAME name of gem to show dependencies for" - end - - def defaults_str # :nodoc: - "--local --version '#{Gem::Requirement.default}' --no-reverse-dependencies" - end - - def usage # :nodoc: - "#{program_name} GEMNAME" - end - - def execute - if options[:reverse_dependencies] and remote? and not local? then - alert_error 'Only reverse dependencies for local gems are supported.' - terminate_interaction 1 - end - - options[:args] << '' if options[:args].empty? - - pattern = if options[:args].length == 1 and - options[:args].first =~ /\A\/(.*)\/(i)?\z/m then - flags = $2 ? Regexp::IGNORECASE : nil - Regexp.new $1, flags - else - /\A#{Regexp.union(*options[:args])}/ - end - - # TODO: deprecate for real damnit - dependency = Gem::Deprecate.skip_during { - Gem::Dependency.new pattern, options[:version] - } - dependency.prerelease = options[:prerelease] - - specs = [] - - specs.concat dependency.matching_specs if local? - - if remote? and not options[:reverse_dependencies] then - fetcher = Gem::SpecFetcher.fetcher - - # REFACTOR: fetcher.find_specs_matching => specs - specs_and_sources = fetcher.find_matching(dependency, - dependency.specific?, true, - dependency.prerelease?) - - specs.concat specs_and_sources.map { |spec_tuple, source_uri| - fetcher.fetch_spec spec_tuple, URI.parse(source_uri) - } - end - - if specs.empty? then - patterns = options[:args].join ',' - say "No gems found matching #{patterns} (#{options[:version]})" if - Gem.configuration.verbose - - terminate_interaction 1 - end - - specs = specs.uniq.sort - - reverse = Hash.new { |h, k| h[k] = [] } - - if options[:reverse_dependencies] then - specs.each do |spec| - reverse[spec.full_name] = find_reverse_dependencies spec - end - end - - if options[:pipe_format] then - specs.each do |spec| - unless spec.dependencies.empty? - spec.dependencies.sort_by { |dep| dep.name }.each do |dep| - say "#{dep.name} --version '#{dep.requirement}'" - end - end - end - else - response = '' - - specs.each do |spec| - response << print_dependencies(spec) - unless reverse[spec.full_name].empty? then - response << " Used by\n" - reverse[spec.full_name].each do |sp, dep| - response << " #{sp} (#{dep})\n" - end - end - response << "\n" - end - - say response - end - end - - def print_dependencies(spec, level = 0) - response = '' - response << ' ' * level + "Gem #{spec.full_name}\n" - unless spec.dependencies.empty? then - spec.dependencies.sort_by { |dep| dep.name }.each do |dep| - response << ' ' * level + " #{dep}\n" - end - end - response - end - - ## - # Returns an Array of [specification, dep] that are satisfied by +spec+. - - def find_reverse_dependencies(spec) - result = [] - - Gem::Specification.each do |sp| - sp.dependencies.each do |dep| - dep = Gem::Dependency.new(*dep) unless Gem::Dependency === dep - - if spec.name == dep.name and - dep.requirement.satisfied_by?(spec.version) then - result << [sp.full_name, dep] - end - end - end - - result - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/environment_command.rb b/ruby_1_9_3/lib/rubygems/commands/environment_command.rb deleted file mode 100644 index 9585c71250..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/environment_command.rb +++ /dev/null @@ -1,130 +0,0 @@ -require 'rubygems/command' - -class Gem::Commands::EnvironmentCommand < Gem::Command - - def initialize - super 'environment', 'Display information about the RubyGems environment' - end - - def arguments # :nodoc: - args = <<-EOF - packageversion display the package version - gemdir display the path where gems are installed - gempath display path used to search for gems - version display the gem format version - remotesources display the remote gem servers - platform display the supported gem platforms - <omitted> display everything - EOF - return args.gsub(/^\s+/, '') - end - - def description # :nodoc: - <<-EOF -The RubyGems environment can be controlled through command line arguments, -gemrc files, environment variables and built-in defaults. - -Command line argument defaults and some RubyGems defaults can be set in -~/.gemrc file for individual users and a /etc/gemrc for all users. A gemrc -is a YAML file with the following YAML keys: - - :sources: A YAML array of remote gem repositories to install gems from - :verbose: Verbosity of the gem command. false, true, and :really are the - levels - :update_sources: Enable/disable automatic updating of repository metadata - :backtrace: Print backtrace when RubyGems encounters an error - :gempath: The paths in which to look for gems - gem_command: A string containing arguments for the specified gem command - -Example: - - :verbose: false - install: --no-wrappers - update: --no-wrappers - -RubyGems' default local repository can be overridden with the GEM_PATH and -GEM_HOME environment variables. GEM_HOME sets the default repository to -install into. GEM_PATH allows multiple local repositories to be searched for -gems. - -If you are behind a proxy server, RubyGems uses the HTTP_PROXY, -HTTP_PROXY_USER and HTTP_PROXY_PASS environment variables to discover the -proxy server. - -If you are packaging RubyGems all of RubyGems' defaults are in -lib/rubygems/defaults.rb. You may override these in -lib/rubygems/defaults/operating_system.rb - EOF - end - - def usage # :nodoc: - "#{program_name} [arg]" - end - - def execute - out = '' - arg = options[:args][0] - case arg - when /^packageversion/ then - out << Gem::RubyGemsPackageVersion - when /^version/ then - out << Gem::VERSION - when /^gemdir/, /^gemhome/, /^home/, /^GEM_HOME/ then - out << Gem.dir - when /^gempath/, /^path/, /^GEM_PATH/ then - out << Gem.path.join(File::PATH_SEPARATOR) - when /^remotesources/ then - out << Gem.sources.join("\n") - when /^platform/ then - out << Gem.platforms.join(File::PATH_SEPARATOR) - when nil then - out = "RubyGems Environment:\n" - - out << " - RUBYGEMS VERSION: #{Gem::VERSION}\n" - - out << " - RUBY VERSION: #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}" - out << " patchlevel #{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL - out << ") [#{RUBY_PLATFORM}]\n" - - out << " - INSTALLATION DIRECTORY: #{Gem.dir}\n" - - out << " - RUBYGEMS PREFIX: #{Gem.prefix}\n" unless Gem.prefix.nil? - - out << " - RUBY EXECUTABLE: #{Gem.ruby}\n" - - out << " - EXECUTABLE DIRECTORY: #{Gem.bindir}\n" - - out << " - RUBYGEMS PLATFORMS:\n" - Gem.platforms.each do |platform| - out << " - #{platform}\n" - end - - out << " - GEM PATHS:\n" - out << " - #{Gem.dir}\n" - - path = Gem.path.dup - path.delete Gem.dir - path.each do |p| - out << " - #{p}\n" - end - - out << " - GEM CONFIGURATION:\n" - Gem.configuration.each do |name, value| - value = value.gsub(/./, '*') if name == 'gemcutter_key' - out << " - #{name.inspect} => #{value.inspect}\n" - end - - out << " - REMOTE SOURCES:\n" - Gem.sources.each do |s| - out << " - #{s}\n" - end - - else - raise Gem::CommandLineError, "Unknown environment option [#{arg}]" - end - say out - true - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/fetch_command.rb b/ruby_1_9_3/lib/rubygems/commands/fetch_command.rb deleted file mode 100644 index e7c9cc9525..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/fetch_command.rb +++ /dev/null @@ -1,78 +0,0 @@ -require 'rubygems/command' -require 'rubygems/local_remote_options' -require 'rubygems/version_option' - -class Gem::Commands::FetchCommand < Gem::Command - - include Gem::LocalRemoteOptions - include Gem::VersionOption - - def initialize - super 'fetch', 'Download a gem and place it in the current directory' - - add_bulk_threshold_option - add_proxy_option - add_source_option - add_clear_sources_option - - add_version_option - add_platform_option - add_prerelease_option - end - - def arguments # :nodoc: - 'GEMNAME name of gem to download' - end - - def defaults_str # :nodoc: - "--version '#{Gem::Requirement.default}'" - end - - def usage # :nodoc: - "#{program_name} GEMNAME [GEMNAME ...]" - end - - def execute - version = options[:version] || Gem::Requirement.default - all = Gem::Requirement.default != version - - platform = Gem.platforms.last - gem_names = get_all_gem_names - - gem_names.each do |gem_name| - dep = Gem::Dependency.new gem_name, version - dep.prerelease = options[:prerelease] - - specs_and_sources, errors = - Gem::SpecFetcher.fetcher.fetch_with_errors(dep, all, true, - dep.prerelease?) - - if platform then - filtered = specs_and_sources.select { |s,| s.platform == platform } - specs_and_sources = filtered unless filtered.empty? - end - - spec, source_uri = specs_and_sources.sort_by { |s,| s.version }.last - - if spec.nil? then - show_lookup_failure gem_name, version, errors, options[:domain] - next - end - - file = "#{spec.full_name}.gem" - remote_path = URI.parse(source_uri) + "gems/#{file}" - - fetch = Gem::RemoteFetcher.fetcher - - gem = fetch.fetch_path remote_path.to_s - - File.open file, "wb" do |f| - f.write gem - end - - say "Downloaded #{spec.full_name}" - end - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/generate_index_command.rb b/ruby_1_9_3/lib/rubygems/commands/generate_index_command.rb deleted file mode 100644 index d4b4790649..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/generate_index_command.rb +++ /dev/null @@ -1,124 +0,0 @@ -require 'rubygems/command' -require 'rubygems/indexer' - -## -# Generates a index files for use as a gem server. -# -# See `gem help generate_index` - -class Gem::Commands::GenerateIndexCommand < Gem::Command - - def initialize - super 'generate_index', - 'Generates the index files for a gem server directory', - :directory => '.', :build_legacy => true, :build_modern => true - - add_option '-d', '--directory=DIRNAME', - 'repository base dir containing gems subdir' do |dir, options| - options[:directory] = File.expand_path dir - end - - add_option '--[no-]legacy', - 'Generate Marshal.4.8' do |value, options| - unless options[:build_modern] or value then - raise OptionParser::InvalidOption, 'no indicies will be built' - end - - options[:build_legacy] = value - end - - add_option '--[no-]modern', - 'Generate indexes for RubyGems newer', - 'than 1.2.0' do |value, options| - unless options[:build_legacy] or value then - raise OptionParser::InvalidOption, 'no indicies will be built' - end - - options[:build_modern] = value - end - - add_option '--update', - 'Update modern indexes with gems added', - 'since the last update' do |value, options| - options[:update] = value - end - - add_option :RSS, '--rss-gems-host=GEM_HOST', - 'Host name where gems are served from,', - 'used for GUID and enclosure values' do |value, options| - options[:rss_gems_host] = value - end - - add_option :RSS, '--rss-host=HOST', - 'Host name for more gems information,', - 'used for RSS feed link' do |value, options| - options[:rss_host] = value - end - - add_option :RSS, '--rss-title=TITLE', - 'Set title for RSS feed' do |value, options| - options[:rss_title] = value - end - end - - def defaults_str # :nodoc: - "--directory . --legacy --modern" - end - - def description # :nodoc: - <<-EOF -The generate_index command creates a set of indexes for serving gems -statically. The command expects a 'gems' directory under the path given to -the --directory option. The given directory will be the directory you serve -as the gem repository. - -For `gem generate_index --directory /path/to/repo`, expose /path/to/repo via -your HTTP server configuration (not /path/to/repo/gems). - -When done, it will generate a set of files like this: - - gems/*.gem # .gem files you want to - # index - - specs.<version>.gz # specs index - latest_specs.<version>.gz # latest specs index - prerelease_specs.<version>.gz # prerelease specs index - quick/Marshal.<version>/<gemname>.gemspec.rz # Marshal quick index file - - # these files support legacy RubyGems - Marshal.<version> - Marshal.<version>.Z # Marshal full index - -The .Z and .rz extension files are compressed with the inflate algorithm. -The Marshal version number comes from ruby's Marshal::MAJOR_VERSION and -Marshal::MINOR_VERSION constants. It is used to ensure compatibility. - -If --rss-host and --rss-gem-host are given an RSS feed will be generated at -index.rss containing gems released in the last two days. - EOF - end - - def execute - if options[:update] and - (options[:rss_host] or options[:rss_gems_host]) then - alert_error '--update not compatible with RSS generation' - terminate_interaction 1 - end - - if not File.exist?(options[:directory]) or - not File.directory?(options[:directory]) then - alert_error "unknown directory name #{directory}." - terminate_interaction 1 - else - indexer = Gem::Indexer.new options.delete(:directory), options - - if options[:update] then - indexer.update_index - else - indexer.generate_index - end - end - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/help_command.rb b/ruby_1_9_3/lib/rubygems/commands/help_command.rb deleted file mode 100644 index 20b52429b2..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/help_command.rb +++ /dev/null @@ -1,167 +0,0 @@ -require 'rubygems/command' - -class Gem::Commands::HelpCommand < Gem::Command - - # :stopdoc: - EXAMPLES = <<-EOF -Some examples of 'gem' usage. - -* Install 'rake', either from local directory or remote server: - - gem install rake - -* Install 'rake', only from remote server: - - gem install rake --remote - -* Install 'rake', but only version 0.3.1, even if dependencies - are not met, and into a user-specific directory: - - gem install rake --version 0.3.1 --force --user-install - -* List local gems whose name begins with 'D': - - gem list D - -* List local and remote gems whose name contains 'log': - - gem search log --both - -* List only remote gems whose name contains 'log': - - gem search log --remote - -* Uninstall 'rake': - - gem uninstall rake - -* Create a gem: - - See http://rubygems.rubyforge.org/wiki/wiki.pl?CreateAGemInTenMinutes - -* See information about RubyGems: - - gem environment - -* Update all gems on your system: - - gem update - EOF - - PLATFORMS = <<-'EOF' -RubyGems platforms are composed of three parts, a CPU, an OS, and a -version. These values are taken from values in rbconfig.rb. You can view -your current platform by running `gem environment`. - -RubyGems matches platforms as follows: - - * The CPU must match exactly, unless one of the platforms has - "universal" as the CPU. - * The OS must match exactly. - * The versions must match exactly unless one of the versions is nil. - -For commands that install, uninstall and list gems, you can override what -RubyGems thinks your platform is with the --platform option. The platform -you pass must match "#{cpu}-#{os}" or "#{cpu}-#{os}-#{version}". On mswin -platforms, the version is the compiler version, not the OS version. (Ruby -compiled with VC6 uses "60" as the compiler version, VC8 uses "80".) - -Example platforms: - - x86-freebsd # Any FreeBSD version on an x86 CPU - universal-darwin-8 # Darwin 8 only gems that run on any CPU - x86-mswin32-80 # Windows gems compiled with VC8 - -When building platform gems, set the platform in the gem specification to -Gem::Platform::CURRENT. This will correctly mark the gem with your ruby's -platform. - EOF - # :startdoc: - - def initialize - super 'help', "Provide help on the 'gem' command" - end - - def arguments # :nodoc: - args = <<-EOF - commands List all 'gem' commands - examples Show examples of 'gem' usage - <command> Show specific help for <command> - EOF - return args.gsub(/^\s+/, '') - end - - def usage # :nodoc: - "#{program_name} ARGUMENT" - end - - def execute - command_manager = Gem::CommandManager.instance - arg = options[:args][0] - - if begins? "commands", arg then - out = [] - out << "GEM commands are:" - out << nil - - margin_width = 4 - - desc_width = command_manager.command_names.map { |n| n.size }.max + 4 - - summary_width = 80 - margin_width - desc_width - wrap_indent = ' ' * (margin_width + desc_width) - format = "#{' ' * margin_width}%-#{desc_width}s%s" - - command_manager.command_names.each do |cmd_name| - summary = command_manager[cmd_name].summary - summary = wrap(summary, summary_width).split "\n" - out << sprintf(format, cmd_name, summary.shift) - until summary.empty? do - out << "#{wrap_indent}#{summary.shift}" - end - end - - out << nil - out << "For help on a particular command, use 'gem help COMMAND'." - out << nil - out << "Commands may be abbreviated, so long as they are unambiguous." - out << "e.g. 'gem i rake' is short for 'gem install rake'." - - say out.join("\n") - - elsif begins? "options", arg then - say Gem::Command::HELP - - elsif begins? "examples", arg then - say EXAMPLES - - elsif begins? "platforms", arg then - say PLATFORMS - - elsif options[:help] then - command = command_manager[options[:help]] - if command - # help with provided command - command.invoke("--help") - else - alert_error "Unknown command #{options[:help]}. Try 'gem help commands'" - end - - elsif arg then - possibilities = command_manager.find_command_possibilities(arg.downcase) - if possibilities.size == 1 - command = command_manager[possibilities.first] - command.invoke("--help") - elsif possibilities.size > 1 - alert_warning "Ambiguous command #{arg} (#{possibilities.join(', ')})" - else - alert_warning "Unknown command #{arg}. Try gem help commands" - end - - else - say Gem::Command::HELP - end - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/install_command.rb b/ruby_1_9_3/lib/rubygems/commands/install_command.rb deleted file mode 100644 index 003ba8601c..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/install_command.rb +++ /dev/null @@ -1,165 +0,0 @@ -require 'rubygems/command' -require 'rubygems/doc_manager' -require 'rubygems/install_update_options' -require 'rubygems/dependency_installer' -require 'rubygems/local_remote_options' -require 'rubygems/validator' -require 'rubygems/version_option' - -## -# Gem installer command line tool -# -# See `gem help install` - -class Gem::Commands::InstallCommand < Gem::Command - - include Gem::VersionOption - include Gem::LocalRemoteOptions - include Gem::InstallUpdateOptions - - def initialize - defaults = Gem::DependencyInstaller::DEFAULT_OPTIONS.merge({ - :generate_rdoc => true, - :generate_ri => true, - :format_executable => false, - :version => Gem::Requirement.default, - }) - - super 'install', 'Install a gem into the local repository', defaults - - add_install_update_options - add_local_remote_options - add_platform_option - add_version_option - add_prerelease_option "to be installed. (Only for listed gems)" - end - - def arguments # :nodoc: - "GEMNAME name of gem to install" - end - - def defaults_str # :nodoc: - "--both --version '#{Gem::Requirement.default}' --rdoc --ri --no-force\n" \ - "--install-dir #{Gem.dir}" - end - - def description # :nodoc: - <<-EOF -The install command installs local or remote gem into a gem repository. - -For gems with executables ruby installs a wrapper file into the executable -directory by default. This can be overridden with the --no-wrappers option. -The wrapper allows you to choose among alternate gem versions using _version_. - -For example `rake _0.7.3_ --version` will run rake version 0.7.3 if a newer -version is also installed. - -If an extension fails to compile during gem installation the gem -specification is not written out, but the gem remains unpacked in the -repository. You may need to specify the path to the library's headers and -libraries to continue. You can do this by adding a -- between RubyGems' -options and the extension's build options: - - $ gem install some_extension_gem - [build fails] - Gem files will remain installed in \\ - /path/to/gems/some_extension_gem-1.0 for inspection. - Results logged to /path/to/gems/some_extension_gem-1.0/gem_make.out - $ gem install some_extension_gem -- --with-extension-lib=/path/to/lib - [build succeeds] - $ gem list some_extension_gem - - *** LOCAL GEMS *** - - some_extension_gem (1.0) - $ - -If you correct the compilation errors by editing the gem files you will need -to write the specification by hand. For example: - - $ gem install some_extension_gem - [build fails] - Gem files will remain installed in \\ - /path/to/gems/some_extension_gem-1.0 for inspection. - Results logged to /path/to/gems/some_extension_gem-1.0/gem_make.out - $ [cd /path/to/gems/some_extension_gem-1.0] - $ [edit files or what-have-you and run make] - $ gem spec ../../cache/some_extension_gem-1.0.gem --ruby > \\ - ../../specifications/some_extension_gem-1.0.gemspec - $ gem list some_extension_gem - - *** LOCAL GEMS *** - - some_extension_gem (1.0) - $ - - EOF - end - - def usage # :nodoc: - "#{program_name} GEMNAME [GEMNAME ...] [options] -- --build-flags" - end - - def execute - if options[:include_dependencies] then - alert "`gem install -y` is now default and will be removed" - alert "use --ignore-dependencies to install only the gems you list" - end - - installed_gems = [] - - ENV.delete 'GEM_PATH' if options[:install_dir].nil? and RUBY_VERSION > '1.9' - - exit_code = 0 - - get_all_gem_names.each do |gem_name| - begin - next if options[:conservative] and - not Gem::Dependency.new(gem_name, options[:version]).matching_specs.empty? - - inst = Gem::DependencyInstaller.new options - inst.install gem_name, options[:version] - - inst.installed_gems.each do |spec| - say "Successfully installed #{spec.full_name}" - end - - installed_gems.push(*inst.installed_gems) - rescue Gem::InstallError => e - alert_error "Error installing #{gem_name}:\n\t#{e.message}" - exit_code |= 1 - rescue Gem::GemNotFoundException => e - show_lookup_failure e.name, e.version, e.errors, options[:domain] - - exit_code |= 2 - end - end - - unless installed_gems.empty? then - gems = installed_gems.length == 1 ? 'gem' : 'gems' - say "#{installed_gems.length} #{gems} installed" - - # NOTE: *All* of the RI documents must be generated first. For some - # reason, RI docs cannot be generated after any RDoc documents are - # generated. - - if options[:generate_ri] then - installed_gems.each do |gem| - Gem::DocManager.new(gem, options[:rdoc_args]).generate_ri - end - - Gem::DocManager.update_ri_cache - end - - if options[:generate_rdoc] then - installed_gems.each do |gem| - Gem::DocManager.new(gem, options[:rdoc_args]).generate_rdoc - end - end - end - - raise Gem::SystemExitException, exit_code - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/list_command.rb b/ruby_1_9_3/lib/rubygems/commands/list_command.rb deleted file mode 100644 index f3e5da9551..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/list_command.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'rubygems/command' -require 'rubygems/commands/query_command' - -## -# An alternate to Gem::Commands::QueryCommand that searches for gems starting -# with the the supplied argument. - -class Gem::Commands::ListCommand < Gem::Commands::QueryCommand - - def initialize - super 'list', 'Display gems whose name starts with STRING' - - remove_option('--name-matches') - end - - def arguments # :nodoc: - "STRING start of gem name to look for" - end - - def defaults_str # :nodoc: - "--local --no-details" - end - - def usage # :nodoc: - "#{program_name} [STRING]" - end - - def execute - string = get_one_optional_argument || '' - options[:name] = /^#{string}/i - super - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/lock_command.rb b/ruby_1_9_3/lib/rubygems/commands/lock_command.rb deleted file mode 100644 index a6dca320ef..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/lock_command.rb +++ /dev/null @@ -1,110 +0,0 @@ -require 'rubygems/command' - -class Gem::Commands::LockCommand < Gem::Command - - def initialize - super 'lock', 'Generate a lockdown list of gems', - :strict => false - - add_option '-s', '--[no-]strict', - 'fail if unable to satisfy a dependency' do |strict, options| - options[:strict] = strict - end - end - - def arguments # :nodoc: - "GEMNAME name of gem to lock\nVERSION version of gem to lock" - end - - def defaults_str # :nodoc: - "--no-strict" - end - - def description # :nodoc: - <<-EOF -The lock command will generate a list of +gem+ statements that will lock down -the versions for the gem given in the command line. It will specify exact -versions in the requirements list to ensure that the gems loaded will always -be consistent. A full recursive search of all effected gems will be -generated. - -Example: - - gemlock rails-1.0.0 > lockdown.rb - -will produce in lockdown.rb: - - require "rubygems" - gem 'rails', '= 1.0.0' - gem 'rake', '= 0.7.0.1' - gem 'activesupport', '= 1.2.5' - gem 'activerecord', '= 1.13.2' - gem 'actionpack', '= 1.11.2' - gem 'actionmailer', '= 1.1.5' - gem 'actionwebservice', '= 1.0.0' - -Just load lockdown.rb from your application to ensure that the current -versions are loaded. Make sure that lockdown.rb is loaded *before* any -other require statements. - -Notice that rails 1.0.0 only requires that rake 0.6.2 or better be used. -Rake-0.7.0.1 is the most recent version installed that satisfies that, so we -lock it down to the exact version. - EOF - end - - def usage # :nodoc: - "#{program_name} GEMNAME-VERSION [GEMNAME-VERSION ...]" - end - - def complain(message) - if options[:strict] then - raise Gem::Exception, message - else - say "# #{message}" - end - end - - def execute - say "require 'rubygems'" - - locked = {} - - pending = options[:args] - - until pending.empty? do - full_name = pending.shift - - spec = Gem::Specification.load spec_path(full_name) - - if spec.nil? then - complain "Could not find gem #{full_name}, try using the full name" - next - end - - say "gem '#{spec.name}', '= #{spec.version}'" unless locked[spec.name] - locked[spec.name] = true - - spec.runtime_dependencies.each do |dep| - next if locked[dep.name] - candidates = dep.matching_specs - - if candidates.empty? then - complain "Unable to satisfy '#{dep}' from currently installed gems" - else - pending << candidates.last.full_name - end - end - end - end - - def spec_path(gem_full_name) - gemspecs = Gem.path.map { |path| - File.join path, "specifications", "#{gem_full_name}.gemspec" - } - - gemspecs.find { |path| File.exist? path } - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/outdated_command.rb b/ruby_1_9_3/lib/rubygems/commands/outdated_command.rb deleted file mode 100644 index ea6b9f0abf..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/outdated_command.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'rubygems/command' -require 'rubygems/local_remote_options' -require 'rubygems/spec_fetcher' -require 'rubygems/version_option' - -class Gem::Commands::OutdatedCommand < Gem::Command - - include Gem::LocalRemoteOptions - include Gem::VersionOption - - def initialize - super 'outdated', 'Display all gems that need updates' - - add_local_remote_options - add_platform_option - end - - def execute - Gem::Specification.outdated.sort.each do |name| - local = Gem::Specification.find_all_by_name(name).max - dep = Gem::Dependency.new local.name, ">= #{local.version}" - remotes = Gem::SpecFetcher.fetcher.fetch dep - - next if remotes.empty? - - remote = remotes.last.first - say "#{local.name} (#{local.version} < #{remote.version})" - end - end -end diff --git a/ruby_1_9_3/lib/rubygems/commands/owner_command.rb b/ruby_1_9_3/lib/rubygems/commands/owner_command.rb deleted file mode 100644 index 6ebf9aa1aa..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/owner_command.rb +++ /dev/null @@ -1,76 +0,0 @@ -require 'rubygems/command' -require 'rubygems/local_remote_options' -require 'rubygems/gemcutter_utilities' - -class Gem::Commands::OwnerCommand < Gem::Command - include Gem::LocalRemoteOptions - include Gem::GemcutterUtilities - - def description # :nodoc: - 'Manage gem owners on RubyGems.org.' - end - - def arguments # :nodoc: - "GEM gem to manage owners for" - end - - def initialize - super 'owner', description - add_proxy_option - add_key_option - defaults.merge! :add => [], :remove => [] - - add_option '-a', '--add EMAIL', 'Add an owner' do |value, options| - options[:add] << value - end - - add_option '-r', '--remove EMAIL', 'Remove an owner' do |value, options| - options[:remove] << value - end - end - - def execute - sign_in - name = get_one_gem_name - - add_owners name, options[:add] - remove_owners name, options[:remove] - show_owners name - end - - def show_owners name - response = rubygems_api_request :get, "api/v1/gems/#{name}/owners.yaml" do |request| - request.add_field "Authorization", api_key - end - - with_response response do |resp| - owners = YAML.load resp.body - - say "Owners for gem: #{name}" - owners.each do |owner| - say "- #{owner['email']}" - end - end - end - - def add_owners name, owners - manage_owners :post, name, owners - end - - def remove_owners name, owners - manage_owners :delete, name, owners - end - - def manage_owners method, name, owners - owners.each do |owner| - response = rubygems_api_request method, "api/v1/gems/#{name}/owners" do |request| - request.set_form_data 'email' => owner - request.add_field "Authorization", api_key - end - - with_response response - end - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/pristine_command.rb b/ruby_1_9_3/lib/rubygems/commands/pristine_command.rb deleted file mode 100644 index 83e6cc7a67..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/pristine_command.rb +++ /dev/null @@ -1,110 +0,0 @@ -require 'rubygems/command' -require 'rubygems/format' -require 'rubygems/installer' -require 'rubygems/version_option' - -class Gem::Commands::PristineCommand < Gem::Command - - include Gem::VersionOption - - def initialize - super 'pristine', - 'Restores installed gems to pristine condition from files located in the gem cache', - :version => Gem::Requirement.default, :extensions => true, - :all => false - - add_option('--all', - 'Restore all installed gems to pristine', - 'condition') do |value, options| - options[:all] = value - end - - add_option('--[no-]extensions', - 'Restore gems with extensions') do |value, options| - options[:extensions] = value - end - - add_version_option('restore to', 'pristine condition') - end - - def arguments # :nodoc: - "GEMNAME gem to restore to pristine condition (unless --all)" - end - - def defaults_str # :nodoc: - "--all --extensions" - end - - def description # :nodoc: - <<-EOF -The pristine command compares the installed gems with the contents of the -cached gem and restores any files that don't match the cached gem's copy. - -If you have made modifications to your installed gems, the pristine command -will revert them. After all the gem's files have been checked all bin stubs -for the gem are regenerated. - -If the cached gem cannot be found, you will need to use `gem install` to -revert the gem. - -If --no-extensions is provided pristine will not attempt to restore gems with -extensions. - EOF - end - - def usage # :nodoc: - "#{program_name} [args]" - end - - def execute - specs = if options[:all] then - Gem::Specification.map - else - get_all_gem_names.map do |gem_name| - Gem::Specification.find_all_by_name gem_name, options[:version] - end.flatten - end - - if specs.to_a.empty? then - raise Gem::Exception, - "Failed to find gems #{options[:args]} #{options[:version]}" - end - - install_dir = Gem.dir # TODO use installer option - - raise Gem::FilePermissionError.new(install_dir) unless - File.writable?(install_dir) - - say "Restoring gems to pristine condition..." - - specs.each do |spec| - unless spec.extensions.empty? or options[:extensions] then - say "Skipped #{spec.full_name}, it needs to compile an extension" - next - end - - gem = spec.cache_file - - unless File.exist? gem then - require 'rubygems/remote_fetcher' - - say "Cached gem for #{spec.full_name} not found, attempting to fetch..." - dep = Gem::Dependency.new spec.name, spec.version - Gem::RemoteFetcher.fetcher.download_to_cache dep - end - - # TODO use installer options - install_defaults = Gem::ConfigFile::PLATFORM_DEFAULTS['install'] - installer_env_shebang = install_defaults.to_s['--env-shebang'] - - installer = Gem::Installer.new(gem, - :wrappers => true, - :force => true, - :install_dir => spec.base_dir, - :env_shebang => installer_env_shebang) - installer.install - - say "Restored #{spec.full_name}" - end - end -end diff --git a/ruby_1_9_3/lib/rubygems/commands/push_command.rb b/ruby_1_9_3/lib/rubygems/commands/push_command.rb deleted file mode 100644 index a7663edf4a..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/push_command.rb +++ /dev/null @@ -1,60 +0,0 @@ -require 'rubygems/command' -require 'rubygems/local_remote_options' -require 'rubygems/gemcutter_utilities' - -class Gem::Commands::PushCommand < Gem::Command - include Gem::LocalRemoteOptions - include Gem::GemcutterUtilities - - def description # :nodoc: - 'Push a gem up to RubyGems.org' - end - - def arguments # :nodoc: - "GEM built gem to push up" - end - - def usage # :nodoc: - "#{program_name} GEM" - end - - def initialize - super 'push', description - add_proxy_option - add_key_option - - add_option( - '--host HOST', - 'Push to another gemcutter-compatible host' - ) do |value, options| - options[:host] = value - end - end - - def execute - sign_in - send_gem get_one_gem_name - end - - def send_gem name - args = [:post, "api/v1/gems"] - - args << options[:host] if options[:host] - - if Gem.latest_rubygems_version < Gem::Version.new(Gem::VERSION) then - alert_error "Using beta/unreleased version of rubygems. Not pushing." - terminate_interaction 1 - end - - response = rubygems_api_request(*args) do |request| - request.body = Gem.read_binary name - request.add_field "Content-Length", request.body.size - request.add_field "Content-Type", "application/octet-stream" - request.add_field "Authorization", api_key - end - - with_response response - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/query_command.rb b/ruby_1_9_3/lib/rubygems/commands/query_command.rb deleted file mode 100644 index 725da8787b..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/query_command.rb +++ /dev/null @@ -1,263 +0,0 @@ -require 'rubygems/command' -require 'rubygems/local_remote_options' -require 'rubygems/spec_fetcher' -require 'rubygems/version_option' -require 'rubygems/text' - -class Gem::Commands::QueryCommand < Gem::Command - - include Gem::Text - include Gem::LocalRemoteOptions - include Gem::VersionOption - - def initialize(name = 'query', - summary = 'Query gem information in local or remote repositories') - super name, summary, - :name => //, :domain => :local, :details => false, :versions => true, - :installed => false, :version => Gem::Requirement.default - - add_option('-i', '--[no-]installed', - 'Check for installed gem') do |value, options| - options[:installed] = value - end - - add_version_option command, "for use with --installed" - - add_option('-n', '--name-matches REGEXP', - 'Name of gem(s) to query on matches the', - 'provided REGEXP') do |value, options| - options[:name] = /#{value}/i - end - - add_option('-d', '--[no-]details', - 'Display detailed information of gem(s)') do |value, options| - options[:details] = value - end - - add_option( '--[no-]versions', - 'Display only gem names') do |value, options| - options[:versions] = value - options[:details] = false unless value - end - - add_option('-a', '--all', - 'Display all gem versions') do |value, options| - options[:all] = value - end - - add_option( '--[no-]prerelease', - 'Display prerelease versions') do |value, options| - options[:prerelease] = value - end - - add_local_remote_options - end - - def defaults_str # :nodoc: - "--local --name-matches // --no-details --versions --no-installed" - end - - def execute - exit_code = 0 - - name = options[:name] - prerelease = options[:prerelease] - - if options[:installed] then - if name.source.empty? then - alert_error "You must specify a gem name" - exit_code |= 4 - elsif installed? name, options[:version] then - say "true" - else - say "false" - exit_code |= 1 - end - - terminate_interaction exit_code - end - - req = Gem::Requirement.default - # TODO: deprecate for real - dep = Gem::Deprecate.skip_during { Gem::Dependency.new name, req } - - if local? then - if prerelease and not both? then - alert_warning "prereleases are always shown locally" - end - - if ui.outs.tty? or both? then - say - say "*** LOCAL GEMS ***" - say - end - - specs = Gem::Specification.find_all { |s| - s.name =~ name and req =~ s.version - } - - spec_tuples = specs.map do |spec| - [[spec.name, spec.version, spec.original_platform, spec], :local] - end - - output_query_results spec_tuples - end - - if remote? then - if ui.outs.tty? or both? then - say - say "*** REMOTE GEMS ***" - say - end - - all = options[:all] - - fetcher = Gem::SpecFetcher.fetcher - spec_tuples = fetcher.find_matching dep, all, false, prerelease - - spec_tuples += fetcher.find_matching dep, false, false, true if - prerelease and all - - output_query_results spec_tuples - end - end - - private - - ## - # Check if gem +name+ version +version+ is installed. - - def installed?(name, req = Gem::Requirement.default) - Gem::Specification.any? { |s| s.name =~ name and req =~ s.version } - end - - def output_query_results(spec_tuples) - output = [] - versions = Hash.new { |h,name| h[name] = [] } - - spec_tuples.each do |spec_tuple, source_uri| - versions[spec_tuple.first] << [spec_tuple, source_uri] - end - - versions = versions.sort_by do |(name,_),_| - name.downcase - end - - versions.each do |gem_name, matching_tuples| - matching_tuples = matching_tuples.sort_by do |(_, version,_),_| - version - end.reverse - - platforms = Hash.new { |h,version| h[version] = [] } - - matching_tuples.map do |(_, version, platform,_),_| - platforms[version] << platform if platform - end - - seen = {} - - matching_tuples.delete_if do |(_, version,_),_| - if seen[version] then - true - else - seen[version] = true - false - end - end - - entry = gem_name.dup - - if options[:versions] then - list = if platforms.empty? or options[:details] then - matching_tuples.map { |(_, version,_),_| version }.uniq - else - platforms.sort.reverse.map do |version, pls| - if pls == [Gem::Platform::RUBY] then - version - else - ruby = pls.delete Gem::Platform::RUBY - platform_list = [ruby, *pls.sort].compact - "#{version} #{platform_list.join ' '}" - end - end - end.join ', ' - - entry << " (#{list})" - end - - if options[:details] then - detail_tuple = matching_tuples.first - - spec = if detail_tuple.first.length == 4 then - detail_tuple.first.last - else - uri = URI.parse detail_tuple.last - Gem::SpecFetcher.fetcher.fetch_spec detail_tuple.first, uri - end - - entry << "\n" - - non_ruby = platforms.any? do |_, pls| - pls.any? { |pl| pl != Gem::Platform::RUBY } - end - - if non_ruby then - if platforms.length == 1 then - title = platforms.values.length == 1 ? 'Platform' : 'Platforms' - entry << " #{title}: #{platforms.values.sort.join ', '}\n" - else - entry << " Platforms:\n" - platforms.sort_by do |version,| - version - end.each do |version, pls| - label = " #{version}: " - data = format_text pls.sort.join(', '), 68, label.length - data[0, label.length] = label - entry << data << "\n" - end - end - end - - authors = "Author#{spec.authors.length > 1 ? 's' : ''}: " - authors << spec.authors.join(', ') - entry << format_text(authors, 68, 4) - - if spec.rubyforge_project and not spec.rubyforge_project.empty? then - rubyforge = "Rubyforge: http://rubyforge.org/projects/#{spec.rubyforge_project}" - entry << "\n" << format_text(rubyforge, 68, 4) - end - - if spec.homepage and not spec.homepage.empty? then - entry << "\n" << format_text("Homepage: #{spec.homepage}", 68, 4) - end - - if spec.license and not spec.license.empty? then - licenses = "License#{spec.licenses.length > 1 ? 's' : ''}: " - licenses << spec.licenses.join(', ') - entry << "\n" << format_text(licenses, 68, 4) - end - - if spec.loaded_from then - if matching_tuples.length == 1 then - loaded_from = File.dirname File.dirname(spec.loaded_from) - entry << "\n" << " Installed at: #{loaded_from}" - else - label = 'Installed at' - matching_tuples.each do |(_,version,_,s),| - loaded_from = File.dirname File.dirname(s.loaded_from) - entry << "\n" << " #{label} (#{version}): #{loaded_from}" - label = ' ' * label.length - end - end - end - - entry << "\n\n" << format_text(spec.summary, 68, 4) - end - output << entry - end - - say output.join(options[:details] ? "\n\n" : "\n") - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/rdoc_command.rb b/ruby_1_9_3/lib/rubygems/commands/rdoc_command.rb deleted file mode 100644 index ea0f3ad592..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/rdoc_command.rb +++ /dev/null @@ -1,91 +0,0 @@ -require 'rubygems/command' -require 'rubygems/version_option' -require 'rubygems/doc_manager' - -class Gem::Commands::RdocCommand < Gem::Command - include Gem::VersionOption - - def initialize - super 'rdoc', 'Generates RDoc for pre-installed gems', - :version => Gem::Requirement.default, - :include_rdoc => true, :include_ri => true, :overwrite => false - - add_option('--all', - 'Generate RDoc/RI documentation for all', - 'installed gems') do |value, options| - options[:all] = value - end - - add_option('--[no-]rdoc', - 'Generate RDoc HTML') do |value, options| - options[:include_rdoc] = value - end - - add_option('--[no-]ri', - 'Generate RI data') do |value, options| - options[:include_ri] = value - end - - add_option('--[no-]overwrite', - 'Overwrite installed documents') do |value, options| - options[:overwrite] = value - end - - add_version_option - end - - def arguments # :nodoc: - "GEMNAME gem to generate documentation for (unless --all)" - end - - def defaults_str # :nodoc: - "--version '#{Gem::Requirement.default}' --rdoc --ri --no-overwrite" - end - - def description # :nodoc: - <<-DESC -The rdoc command builds RDoc and RI documentation for installed gems. Use ---overwrite to force rebuilding of documentation. - DESC - end - - def usage # :nodoc: - "#{program_name} [args]" - end - - def execute - if options[:all] then - specs = Gem::SourceIndex.from_installed_gems.collect { |name, spec| - spec - } - else - gem_name = get_one_gem_name - dep = Gem::Dependency.new gem_name, options[:version] - specs = Gem::SourceIndex.from_installed_gems.search dep - end - - if specs.empty? - raise "Failed to find gem #{gem_name} to generate RDoc for #{options[:version]}" - end - - if options[:include_ri] - specs.sort.each do |spec| - doc = Gem::DocManager.new(spec) - doc.generate_ri if options[:overwrite] || !doc.ri_installed? - end - - Gem::DocManager.update_ri_cache - end - - if options[:include_rdoc] - specs.sort.each do |spec| - doc = Gem::DocManager.new(spec) - doc.generate_rdoc if options[:overwrite] || !doc.rdoc_installed? - end - end - - true - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/search_command.rb b/ruby_1_9_3/lib/rubygems/commands/search_command.rb deleted file mode 100644 index 52e96fd1ef..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/search_command.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'rubygems/command' -require 'rubygems/commands/query_command' - -class Gem::Commands::SearchCommand < Gem::Commands::QueryCommand - - def initialize - super 'search', 'Display all gems whose name contains STRING' - - remove_option '--name-matches' - end - - def arguments # :nodoc: - "STRING fragment of gem name to search for" - end - - def defaults_str # :nodoc: - "--local --no-details" - end - - def usage # :nodoc: - "#{program_name} [STRING]" - end - - def execute - string = get_one_optional_argument - options[:name] = /#{string}/i - super - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/server_command.rb b/ruby_1_9_3/lib/rubygems/commands/server_command.rb deleted file mode 100644 index b65d48c4fc..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/server_command.rb +++ /dev/null @@ -1,86 +0,0 @@ -require 'rubygems/command' -require 'rubygems/server' - -class Gem::Commands::ServerCommand < Gem::Command - - def initialize - super 'server', 'Documentation and gem repository HTTP server', - :port => 8808, :gemdir => [], :daemon => false - - OptionParser.accept :Port do |port| - if port =~ /\A\d+\z/ then - port = Integer port - raise OptionParser::InvalidArgument, "#{port}: not a port number" if - port > 65535 - - port - else - begin - Socket.getservbyname port - rescue SocketError - raise OptionParser::InvalidArgument, "#{port}: no such named service" - end - end - end - - add_option '-p', '--port=PORT', :Port, - 'port to listen on' do |port, options| - options[:port] = port - end - - add_option '-d', '--dir=GEMDIR', - 'directories from which to serve gems', - 'multiple directories may be provided' do |gemdir, options| - options[:gemdir] << File.expand_path(gemdir) - end - - add_option '--[no-]daemon', 'run as a daemon' do |daemon, options| - options[:daemon] = daemon - end - - add_option '-b', '--bind=HOST,HOST', - 'addresses to bind', Array do |address, options| - options[:addresses] ||= [] - options[:addresses].push(*address) - end - - add_option '-l', '--launch[=COMMAND]', - 'launches a browser window', - "COMMAND defaults to 'start' on Windows", - "and 'open' on all other platforms" do |launch, options| - launch ||= Gem.win_platform? ? 'start' : 'open' - options[:launch] = launch - end - end - - def defaults_str # :nodoc: - "--port 8808 --dir #{Gem.dir} --no-daemon" - end - - def description # :nodoc: - <<-EOF -The server command starts up a web server that hosts the RDoc for your -installed gems and can operate as a server for installation of gems on other -machines. - -The cache files for installed gems must exist to use the server as a source -for gem installation. - -To install gems from a running server, use `gem install GEMNAME --source -http://gem_server_host:8808` - -You can set up a shortcut to gem server documentation using the URL: - - http://localhost:8808/rdoc?q=%s - Firefox - http://localhost:8808/rdoc?q=* - LaunchBar - - EOF - end - - def execute - options[:gemdir] << Gem.dir if options[:gemdir].empty? - Gem::Server.run options - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/setup_command.rb b/ruby_1_9_3/lib/rubygems/commands/setup_command.rb deleted file mode 100644 index 0c957393d9..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/setup_command.rb +++ /dev/null @@ -1,358 +0,0 @@ -require 'rubygems/command' - -## -# Installs RubyGems itself. This command is ordinarily only available from a -# RubyGems checkout or tarball. - -class Gem::Commands::SetupCommand < Gem::Command - - def initialize - require 'tmpdir' - - super 'setup', 'Install RubyGems', - :format_executable => true, :rdoc => true, :ri => true, - :site_or_vendor => :sitelibdir, - :destdir => '', :prefix => '' - - add_option '--prefix=PREFIX', - 'Prefix path for installing RubyGems', - 'Will not affect gem repository location' do |prefix, options| - options[:prefix] = File.expand_path prefix - end - - add_option '--destdir=DESTDIR', - 'Root directory to install RubyGems into', - 'Mainly used for packaging RubyGems' do |destdir, options| - options[:destdir] = File.expand_path destdir - end - - add_option '--[no-]vendor', - 'Install into vendorlibdir not sitelibdir' do |vendor, options| - options[:site_or_vendor] = vendor ? :vendorlibdir : :sitelibdir - end - - add_option '--[no-]format-executable', - 'Makes `gem` match ruby', - 'If ruby is ruby18, gem will be gem18' do |value, options| - options[:format_executable] = value - end - - add_option '--[no-]rdoc', - 'Generate RDoc documentation for RubyGems' do |value, options| - options[:rdoc] = value - end - - add_option '--[no-]ri', - 'Generate RI documentation for RubyGems' do |value, options| - options[:ri] = value - end - end - - def check_ruby_version - required_version = Gem::Requirement.new '>= 1.8.7' - - unless required_version.satisfied_by? Gem.ruby_version then - alert_error "Expected Ruby version #{required_version}, is #{Gem.ruby_version}" - terminate_interaction 1 - end - end - - def defaults_str # :nodoc: - "--format-executable --rdoc --ri" - end - - def description # :nodoc: - <<-EOF -Installs RubyGems itself. - -RubyGems installs RDoc for itself in GEM_HOME. By default this is: - #{Gem.dir} - -If you prefer a different directory, set the GEM_HOME environment variable. - -RubyGems will install the gem command with a name matching ruby's -prefix and suffix. If ruby was installed as `ruby18`, gem will be -installed as `gem18`. - -By default, this RubyGems will install gem as: - #{Gem.default_exec_format % 'gem'} - EOF - end - - def execute - @verbose = Gem.configuration.really_verbose - - install_destdir = options[:destdir] - - unless install_destdir.empty? then - ENV['GEM_HOME'] ||= File.join(install_destdir, - Gem.default_dir.gsub(/^[a-zA-Z]:/, '')) - end - - check_ruby_version - - require 'fileutils' - if Gem.configuration.really_verbose then - extend FileUtils::Verbose - else - extend FileUtils - end - - lib_dir, bin_dir = make_destination_dirs install_destdir - - install_lib lib_dir - - install_executables bin_dir - - remove_old_bin_files bin_dir - - say "RubyGems #{Gem::VERSION} installed" - - uninstall_old_gemcutter - - install_rdoc - - say - if @verbose then - say "-" * 78 - say - end - - release_notes = File.join Dir.pwd, 'History.txt' - - release_notes = if File.exist? release_notes then - open release_notes do |io| - text = io.gets '===' - text << io.gets('===') - text[0...-3].sub(/^# coding:.*?^=/m, '') - end - else - "Oh-no! Unable to find release notes!" - end - - say release_notes - - say - say "-" * 78 - say - - say "RubyGems installed the following executables:" - say @bin_file_names.map { |name| "\t#{name}\n" } - say - - unless @bin_file_names.grep(/#{File::SEPARATOR}gem$/) then - say "If `gem` was installed by a previous RubyGems installation, you may need" - say "to remove it by hand." - say - end - end - - def install_executables(bin_dir) - say "Installing gem executable" if @verbose - - @bin_file_names = [] - - Dir.chdir 'bin' do - bin_files = Dir['*'] - - bin_files.delete 'update_rubygems' - - bin_files.each do |bin_file| - bin_file_formatted = if options[:format_executable] then - Gem.default_exec_format % bin_file - else - bin_file - end - - dest_file = File.join bin_dir, bin_file_formatted - bin_tmp_file = File.join Dir.tmpdir, bin_file - - begin - bin = File.readlines bin_file - bin[0] = "#!#{Gem.ruby}\n" - - File.open bin_tmp_file, 'w' do |fp| - fp.puts bin.join - end - - install bin_tmp_file, dest_file, :mode => 0755 - @bin_file_names << dest_file - ensure - rm bin_tmp_file - end - - next unless Gem.win_platform? - - begin - bin_cmd_file = File.join Dir.tmpdir, "#{bin_file}.bat" - - File.open bin_cmd_file, 'w' do |file| - file.puts <<-TEXT -@ECHO OFF -IF NOT "%~f0" == "~f0" GOTO :WinNT -@"#{File.basename(Gem.ruby).chomp('"')}" "#{dest_file}" %1 %2 %3 %4 %5 %6 %7 %8 %9 -GOTO :EOF -:WinNT -@"#{File.basename(Gem.ruby).chomp('"')}" "%~dpn0" %* -TEXT - end - - install bin_cmd_file, "#{dest_file}.bat", :mode => 0755 - ensure - rm bin_cmd_file - end - end - end - end - - def install_lib(lib_dir) - say "Installing RubyGems" if @verbose - - Dir.chdir 'lib' do - lib_files = Dir[File.join('**', '*rb')] - - lib_files.each do |lib_file| - dest_file = File.join lib_dir, lib_file - dest_dir = File.dirname dest_file - mkdir_p dest_dir unless File.directory? dest_dir - - install lib_file, dest_file, :mode => 0644 - end - end - end - - def install_rdoc - gem_doc_dir = File.join Gem.dir, 'doc' - rubygems_name = "rubygems-#{Gem::VERSION}" - rubygems_doc_dir = File.join gem_doc_dir, rubygems_name - - if File.writable? gem_doc_dir and - (not File.exist? rubygems_doc_dir or - File.writable? rubygems_doc_dir) then - say "Removing old RubyGems RDoc and ri" if @verbose - Dir[File.join(Gem.dir, 'doc', 'rubygems-[0-9]*')].each do |dir| - rm_rf dir - end - - if options[:ri] then - ri_dir = File.join rubygems_doc_dir, 'ri' - say "Installing #{rubygems_name} ri into #{ri_dir}" if @verbose - run_rdoc '--ri', '--op', ri_dir - end - - if options[:rdoc] then - rdoc_dir = File.join rubygems_doc_dir, 'rdoc' - say "Installing #{rubygems_name} rdoc into #{rdoc_dir}" if @verbose - run_rdoc '--op', rdoc_dir - end - elsif @verbose then - say "Skipping RDoc generation, #{gem_doc_dir} not writable" - say "Set the GEM_HOME environment variable if you want RDoc generated" - end - end - - def make_destination_dirs(install_destdir) - lib_dir, bin_dir = Gem.default_rubygems_dirs - - unless lib_dir - lib_dir, bin_dir = generate_default_dirs(install_destdir) - end - - mkdir_p lib_dir - mkdir_p bin_dir - - return lib_dir, bin_dir - end - - def generate_default_dirs(install_destdir) - prefix = options[:prefix] - site_or_vendor = options[:site_or_vendor] - - if prefix.empty? then - lib_dir = Gem::ConfigMap[site_or_vendor] - bin_dir = Gem::ConfigMap[:bindir] - else - # Apple installed RubyGems into libdir, and RubyGems <= 1.1.0 gets - # confused about installation location, so switch back to - # sitelibdir/vendorlibdir. - if defined?(APPLE_GEM_HOME) and - # just in case Apple and RubyGems don't get this patched up proper. - (prefix == Gem::ConfigMap[:libdir] or - # this one is important - prefix == File.join(Gem::ConfigMap[:libdir], 'ruby')) then - lib_dir = Gem::ConfigMap[site_or_vendor] - bin_dir = Gem::ConfigMap[:bindir] - else - lib_dir = File.join prefix, 'lib' - bin_dir = File.join prefix, 'bin' - end - end - - unless install_destdir.empty? then - lib_dir = File.join install_destdir, lib_dir.gsub(/^[a-zA-Z]:/, '') - bin_dir = File.join install_destdir, bin_dir.gsub(/^[a-zA-Z]:/, '') - end - - [lib_dir, bin_dir] - end - - def remove_old_bin_files(bin_dir) - old_bin_files = { - 'gem_mirror' => 'gem mirror', - 'gem_server' => 'gem server', - 'gemlock' => 'gem lock', - 'gemri' => 'ri', - 'gemwhich' => 'gem which', - 'index_gem_repository.rb' => 'gem generate_index', - } - - old_bin_files.each do |old_bin_file, new_name| - old_bin_path = File.join bin_dir, old_bin_file - next unless File.exist? old_bin_path - - deprecation_message = "`#{old_bin_file}` has been deprecated. Use `#{new_name}` instead." - - File.open old_bin_path, 'w' do |fp| - fp.write <<-EOF -#!#{Gem.ruby} - -abort "#{deprecation_message}" - EOF - end - - next unless Gem.win_platform? - - File.open "#{old_bin_path}.bat", 'w' do |fp| - fp.puts %{@ECHO.#{deprecation_message}} - end - end - end - - def run_rdoc(*args) - begin - gem 'rdoc' - rescue Gem::LoadError - end - - require 'rdoc/rdoc' - - args << '--main' << 'README.rdoc' << '--quiet' - args << '.' - args << 'README.rdoc' << 'UPGRADING.rdoc' - args << 'LICENSE.txt' << 'MIT.txt' << 'History.txt' - - r = RDoc::RDoc.new - r.document args - end - - def uninstall_old_gemcutter - require 'rubygems/uninstaller' - - ui = Gem::Uninstaller.new('gemcutter', :all => true, :ignore => true, - :version => '< 0.4') - ui.uninstall - rescue Gem::InstallError - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/sources_command.rb b/ruby_1_9_3/lib/rubygems/commands/sources_command.rb deleted file mode 100644 index ac14313e9d..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/sources_command.rb +++ /dev/null @@ -1,136 +0,0 @@ -require 'rubygems/command' -require 'rubygems/remote_fetcher' -require 'rubygems/spec_fetcher' -require 'rubygems/local_remote_options' - -class Gem::Commands::SourcesCommand < Gem::Command - - include Gem::LocalRemoteOptions - - def initialize - require 'fileutils' - - super 'sources', - 'Manage the sources and cache file RubyGems uses to search for gems' - - add_option '-a', '--add SOURCE_URI', 'Add source' do |value, options| - options[:add] = value - end - - add_option '-l', '--list', 'List sources' do |value, options| - options[:list] = value - end - - add_option '-r', '--remove SOURCE_URI', 'Remove source' do |value, options| - options[:remove] = value - end - - add_option '-c', '--clear-all', - 'Remove all sources (clear the cache)' do |value, options| - options[:clear_all] = value - end - - add_option '-u', '--update', 'Update source cache' do |value, options| - options[:update] = value - end - - add_proxy_option - end - - def defaults_str - '--list' - end - - def execute - options[:list] = !(options[:add] || - options[:clear_all] || - options[:remove] || - options[:update]) - - if options[:clear_all] then - path = Gem::SpecFetcher.fetcher.dir - FileUtils.rm_rf path - - unless File.exist? path then - say "*** Removed specs cache ***" - else - unless File.writable? path then - say "*** Unable to remove source cache (write protected) ***" - else - say "*** Unable to remove source cache ***" - end - - terminate_interaction 1 - end - end - - if options[:add] then - source_uri = options[:add] - uri = URI.parse source_uri - - begin - Gem::SpecFetcher.fetcher.load_specs uri, 'specs' - Gem.sources << source_uri - Gem.configuration.write - - say "#{source_uri} added to sources" - rescue URI::Error, ArgumentError - say "#{source_uri} is not a URI" - terminate_interaction 1 - rescue Gem::RemoteFetcher::FetchError => e - say "Error fetching #{source_uri}:\n\t#{e.message}" - terminate_interaction 1 - end - end - - if options[:remove] then - source_uri = options[:remove] - - unless Gem.sources.include? source_uri then - say "source #{source_uri} not present in cache" - else - Gem.sources.delete source_uri - Gem.configuration.write - - say "#{source_uri} removed from sources" - end - end - - if options[:update] then - fetcher = Gem::SpecFetcher.fetcher - - Gem.sources.each do |update_uri| - update_uri = URI.parse update_uri - fetcher.load_specs update_uri, 'specs' - fetcher.load_specs update_uri, 'latest_specs' - end - - say "source cache successfully updated" - end - - if options[:list] then - say "*** CURRENT SOURCES ***" - say - - Gem.sources.each do |source| - say source - end - end - end - - private - - def remove_cache_file(desc, path) - FileUtils.rm_rf path - - if not File.exist?(path) then - say "*** Removed #{desc} source cache ***" - elsif not File.writable?(path) then - say "*** Unable to remove #{desc} source cache (write protected) ***" - else - say "*** Unable to remove #{desc} source cache ***" - end - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/specification_command.rb b/ruby_1_9_3/lib/rubygems/commands/specification_command.rb deleted file mode 100644 index 566a9cc66e..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/specification_command.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'rubygems/command' -require 'rubygems/local_remote_options' -require 'rubygems/version_option' -require 'rubygems/format' - -class Gem::Commands::SpecificationCommand < Gem::Command - - include Gem::LocalRemoteOptions - include Gem::VersionOption - - def initialize - Gem.load_yaml - - super 'specification', 'Display gem specification (in yaml)', - :domain => :local, :version => Gem::Requirement.default, - :format => :yaml - - add_version_option('examine') - add_platform_option - - add_option('--all', 'Output specifications for all versions of', - 'the gem') do |value, options| - options[:all] = true - end - - add_option('--ruby', 'Output ruby format') do |value, options| - options[:format] = :ruby - end - - add_option('--yaml', 'Output RUBY format') do |value, options| - options[:format] = :yaml - end - - add_option('--marshal', 'Output Marshal format') do |value, options| - options[:format] = :marshal - end - - add_local_remote_options - end - - def arguments # :nodoc: - <<-ARGS -GEMFILE name of gem to show the gemspec for -FIELD name of gemspec field to show - ARGS - end - - def defaults_str # :nodoc: - "--local --version '#{Gem::Requirement.default}' --yaml" - end - - def usage # :nodoc: - "#{program_name} [GEMFILE] [FIELD]" - end - - def execute - specs = [] - gem = options[:args].shift - - unless gem then - raise Gem::CommandLineError, - "Please specify a gem name or file on the command line" - end - - case options[:version] - when String - req = Gem::Requirement.parse options[:version] - when Gem::Requirement - req = options[:version] - else - raise Gem::CommandLineError, "Unsupported version type: #{options[:version]}" - end - - if !req.none? and options[:all] - alert_error "Specify --all or -v, not both" - terminate_interaction 1 - end - - if options[:all] - dep = Gem::Dependency.new gem - else - dep = Gem::Dependency.new gem, options[:version] - end - - field = get_one_optional_argument - - raise Gem::CommandLineError, "--ruby and FIELD are mutually exclusive" if - field and options[:format] == :ruby - - if local? then - if File.exist? gem then - specs << Gem::Format.from_file_by_path(gem).spec rescue nil - end - - if specs.empty? then - specs.push(*dep.matching_specs) - end - end - - if remote? then - found = Gem::SpecFetcher.fetcher.fetch dep, true - - if dep.prerelease? or options[:prerelease] - found += Gem::SpecFetcher.fetcher.fetch dep, false, true, true - end - - specs.push(*found.map { |spec,| spec }) - end - - if specs.empty? then - alert_error "Unknown gem '#{gem}'" - terminate_interaction 1 - end - - unless options[:all] then - specs = [specs.sort_by { |s| s.version }.last] - end - - specs.each do |s| - s = s.send field if field - - say case options[:format] - when :ruby then s.to_ruby - when :marshal then Marshal.dump s - else s.to_yaml - end - - say "\n" - end - end -end diff --git a/ruby_1_9_3/lib/rubygems/commands/stale_command.rb b/ruby_1_9_3/lib/rubygems/commands/stale_command.rb deleted file mode 100644 index 36c517e27c..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/stale_command.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'rubygems/command' - -class Gem::Commands::StaleCommand < Gem::Command - def initialize - super('stale', 'List gems along with access times') - end - - def usage # :nodoc: - "#{program_name}" - end - - def execute - gem_to_atime = {} - Gem::Specification.each do |spec| - name = spec.full_name - Dir["#{spec.full_gem_path}/**/*.*"].each do |file| - next if File.directory?(file) - stat = File.stat(file) - gem_to_atime[name] ||= stat.atime - gem_to_atime[name] = stat.atime if gem_to_atime[name] < stat.atime - end - end - - gem_to_atime.sort_by { |_, atime| atime }.each do |name, atime| - say "#{name} at #{atime.strftime '%c'}" - end - end -end diff --git a/ruby_1_9_3/lib/rubygems/commands/uninstall_command.rb b/ruby_1_9_3/lib/rubygems/commands/uninstall_command.rb deleted file mode 100644 index aaadb762b5..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/uninstall_command.rb +++ /dev/null @@ -1,94 +0,0 @@ -require 'rubygems/command' -require 'rubygems/version_option' -require 'rubygems/uninstaller' - -## -# Gem uninstaller command line tool -# -# See `gem help uninstall` - -class Gem::Commands::UninstallCommand < Gem::Command - - include Gem::VersionOption - - def initialize - super 'uninstall', 'Uninstall gems from the local repository', - :version => Gem::Requirement.default, :user_install => true - - add_option('-a', '--[no-]all', - 'Uninstall all matching versions' - ) do |value, options| - options[:all] = value - end - - add_option('-I', '--[no-]ignore-dependencies', - 'Ignore dependency requirements while', - 'uninstalling') do |value, options| - options[:ignore] = value - end - - add_option('-x', '--[no-]executables', - 'Uninstall applicable executables without', - 'confirmation') do |value, options| - options[:executables] = value - end - - add_option('-i', '--install-dir DIR', - 'Directory to uninstall gem from') do |value, options| - options[:install_dir] = File.expand_path(value) - end - - add_option('-n', '--bindir DIR', - 'Directory to remove binaries from') do |value, options| - options[:bin_dir] = File.expand_path(value) - end - - add_option('--[no-]user-install', - 'Uninstall from user\'s home directory', - 'in addition to GEM_HOME.') do |value, options| - options[:user_install] = value - end - - add_option('--[no-]format-executable', - 'Assume executable names match Ruby\'s prefix and suffix.') do |value, options| - options[:format_executable] = value - end - - add_version_option - add_platform_option - end - - def arguments # :nodoc: - "GEMNAME name of gem to uninstall" - end - - def defaults_str # :nodoc: - "--version '#{Gem::Requirement.default}' --no-force " \ - "--install-dir #{Gem.dir}\n" \ - "--user-install" - end - - def usage # :nodoc: - "#{program_name} GEMNAME [GEMNAME ...]" - end - - def execute - original_path = Gem.path - - get_all_gem_names.each do |gem_name| - begin - Gem::Uninstaller.new(gem_name, options).uninstall - rescue Gem::InstallError => e - alert e.message - rescue Gem::GemNotInHomeException => e - spec = e.spec - alert("In order to remove #{spec.name}, please execute:\n" \ - "\tgem uninstall #{spec.name} --install-dir=#{spec.installation_path}") - ensure - Gem.use_paths(*original_path) - end - end - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/unpack_command.rb b/ruby_1_9_3/lib/rubygems/commands/unpack_command.rb deleted file mode 100644 index 64b8ad64f8..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/unpack_command.rb +++ /dev/null @@ -1,160 +0,0 @@ -require 'rubygems/command' -require 'rubygems/installer' -require 'rubygems/version_option' -require 'rubygems/remote_fetcher' - -class Gem::Commands::UnpackCommand < Gem::Command - - include Gem::VersionOption - - def initialize - require 'fileutils' - - super 'unpack', 'Unpack an installed gem to the current directory', - :version => Gem::Requirement.default, - :target => Dir.pwd - - add_option('--target=DIR', - 'target directory for unpacking') do |value, options| - options[:target] = value - end - - add_option('--spec', 'unpack the gem specification') do |value, options| - options[:spec] = true - end - - add_version_option - end - - def arguments # :nodoc: - "GEMNAME name of gem to unpack" - end - - def defaults_str # :nodoc: - "--version '#{Gem::Requirement.default}'" - end - - def usage # :nodoc: - "#{program_name} GEMNAME" - end - - #-- - # TODO: allow, e.g., 'gem unpack rake-0.3.1'. Find a general solution for - # this, so that it works for uninstall as well. (And check other commands - # at the same time.) - - def execute - get_all_gem_names.each do |name| - dependency = Gem::Dependency.new name, options[:version] - path = get_path dependency - - unless path then - alert_error "Gem '#{name}' not installed nor fetchable." - next - end - - if @options[:spec] then - spec, metadata = get_metadata path - - if metadata.nil? then - alert_error "--spec is unsupported on '#{name}' (old format gem)" - next - end - - spec_file = File.basename spec.spec_file - - open spec_file, 'w' do |io| - io.write metadata - end - else - basename = File.basename path, '.gem' - target_dir = File.expand_path basename, options[:target] - FileUtils.mkdir_p target_dir - Gem::Installer.new(path, :unpack => true).unpack target_dir - say "Unpacked gem: '#{target_dir}'" - end - end - end - - ## - # - # Find cached filename in Gem.path. Returns nil if the file cannot be found. - # - #-- - # TODO: see comments in get_path() about general service. - - def find_in_cache(filename) - Gem.path.each do |path| - this_path = File.join(path, "cache", filename) - return this_path if File.exist? this_path - end - - return nil - end - - ## - # Return the full path to the cached gem file matching the given - # name and version requirement. Returns 'nil' if no match. - # - # Example: - # - # get_path 'rake', '> 0.4' # "/usr/lib/ruby/gems/1.8/cache/rake-0.4.2.gem" - # get_path 'rake', '< 0.1' # nil - # get_path 'rak' # nil (exact name required) - #-- - # TODO: This should be refactored so that it's a general service. I don't - # think any of our existing classes are the right place though. Just maybe - # 'Cache'? - # - # TODO: It just uses Gem.dir for now. What's an easy way to get the list of - # source directories? - - def get_path dependency - return dependency.name if dependency.name =~ /\.gem$/i - - specs = dependency.matching_specs - - selected = specs.sort_by { |s| s.version }.last # HACK: hunt last down - - return Gem::RemoteFetcher.fetcher.download_to_cache(dependency) unless - selected - - return unless dependency.name =~ /^#{selected.name}$/i - - # We expect to find (basename).gem in the 'cache' directory. Furthermore, - # the name match must be exact (ignoring case). - - path = find_in_cache File.basename selected.cache_file - - return Gem::RemoteFetcher.fetcher.download_to_cache(dependency) unless path - - path - end - - ## - # Extracts the Gem::Specification and raw metadata from the .gem file at - # +path+. - - def get_metadata path - format = Gem::Format.from_file_by_path path - spec = format.spec - - metadata = nil - - open path, Gem.binary_mode do |io| - tar = Gem::Package::TarReader.new io - tar.each_entry do |entry| - case entry.full_name - when 'metadata' then - metadata = entry.read - when 'metadata.gz' then - metadata = Gem.gunzip entry.read - end - end - end - - return spec, metadata - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/update_command.rb b/ruby_1_9_3/lib/rubygems/commands/update_command.rb deleted file mode 100644 index d63b943c56..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/update_command.rb +++ /dev/null @@ -1,232 +0,0 @@ -require 'rubygems/command' -require 'rubygems/command_manager' -require 'rubygems/install_update_options' -require 'rubygems/local_remote_options' -require 'rubygems/spec_fetcher' -require 'rubygems/version_option' -require 'rubygems/commands/install_command' - -class Gem::Commands::UpdateCommand < Gem::Command - - include Gem::InstallUpdateOptions - include Gem::LocalRemoteOptions - include Gem::VersionOption - - def initialize - super 'update', - 'Update the named gems (or all installed gems) in the local repository', - :generate_rdoc => true, - :generate_ri => true, - :force => false - - add_install_update_options - - OptionParser.accept Gem::Version do |value| - Gem::Version.new value - - value - end - - add_option('--system [VERSION]', Gem::Version, - 'Update the RubyGems system software') do |value, options| - value = true unless value - - options[:system] = value - end - - add_local_remote_options - add_platform_option - add_prerelease_option "as update targets" - end - - def arguments # :nodoc: - "GEMNAME name of gem to update" - end - - def defaults_str # :nodoc: - "--rdoc --ri --no-force --install-dir #{Gem.dir}" - end - - def usage # :nodoc: - "#{program_name} GEMNAME [GEMNAME ...]" - end - - def execute - @installer = Gem::DependencyInstaller.new options - @updated = [] - - hig = {} - - if options[:system] then - update_rubygems - return - else - say "Updating installed gems" - - hig = {} # highest installed gems - - Gem::Specification.each do |spec| - if hig[spec.name].nil? or hig[spec.name].version < spec.version then - hig[spec.name] = spec - end - end - end - - gems_to_update = which_to_update hig, options[:args].uniq - - updated = update_gems gems_to_update - - if updated.empty? then - say "Nothing to update" - else - say "Gems updated: #{updated.map { |spec| spec.name }.join ', '}" - - if options[:generate_ri] then - updated.each do |gem| - Gem::DocManager.new(gem, options[:rdoc_args]).generate_ri - end - - Gem::DocManager.update_ri_cache - end - - if options[:generate_rdoc] then - updated.each do |gem| - Gem::DocManager.new(gem, options[:rdoc_args]).generate_rdoc - end - end - end - end - - def update_gem name, version = Gem::Requirement.default - return if @updated.any? { |spec| spec.name == name } - success = false - - say "Updating #{name}" - begin - @installer.install name, version - success = true - rescue Gem::InstallError => e - alert_error "Error installing #{name}:\n\t#{e.message}" - success = false - end - - @installer.installed_gems.each do |spec| - @updated << spec - say "Successfully installed #{spec.full_name}" if success - end - end - - def update_gems gems_to_update - gems_to_update.uniq.sort.each do |(name, version)| - update_gem name, version - end - - @updated - end - - ## - # Update RubyGems software to the latest version. - - def update_rubygems - unless options[:args].empty? then - alert_error "Gem names are not allowed with the --system option" - terminate_interaction 1 - end - - options[:user_install] = false - - # TODO: rename version and other variable name conflicts - # TODO: get rid of all this indirection on name and other BS - - version = options[:system] - if version == true then - version = Gem::Version.new Gem::VERSION - requirement = Gem::Requirement.new ">= #{Gem::VERSION}" - else - version = Gem::Version.new version - requirement = Gem::Requirement.new version - end - - rubygems_update = Gem::Specification.new - rubygems_update.name = 'rubygems-update' - rubygems_update.version = version - - hig = { - 'rubygems-update' => rubygems_update - } - - gems_to_update = which_to_update hig, options[:args], :system - name, up_ver = gems_to_update.first - current_ver = Gem::Version.new Gem::VERSION - - target = if options[:system] == true then - up_ver - else - version - end - - if current_ver == target then - # if options[:system] != true and version == current_ver then - say "Latest version currently installed. Aborting." - terminate_interaction - end - - update_gem name, target - - installed_gems = Gem::Specification.find_all_by_name 'rubygems-update', requirement - version = installed_gems.last.version - - args = [] - args << '--prefix' << Gem.prefix if Gem.prefix - args << '--no-rdoc' unless options[:generate_rdoc] - args << '--no-ri' unless options[:generate_ri] - args << '--no-format-executable' if options[:no_format_executable] - - update_dir = File.join Gem.dir, 'gems', "rubygems-update-#{version}" - - Dir.chdir update_dir do - say "Installing RubyGems #{version}" - setup_cmd = "#{Gem.ruby} setup.rb #{args.join ' '}" - - # Make sure old rubygems isn't loaded - old = ENV["RUBYOPT"] - ENV.delete("RUBYOPT") if old - installed = system setup_cmd - say "RubyGems system software updated" if installed - ENV["RUBYOPT"] = old if old - end - end - - def which_to_update highest_installed_gems, gem_names, system = false - result = [] - - highest_installed_gems.each do |l_name, l_spec| - next if not gem_names.empty? and - gem_names.all? { |name| /#{name}/ !~ l_spec.name } - - dependency = Gem::Dependency.new l_spec.name, "> #{l_spec.version}" - - fetcher = Gem::SpecFetcher.fetcher - spec_tuples = fetcher.find_matching dependency - - matching_gems = spec_tuples.select do |(name, _, platform),| - name == l_name and Gem::Platform.match platform - end - - highest_remote_gem = matching_gems.sort_by do |(_, version),| - version - end.last - - highest_remote_gem ||= [[nil, Gem::Version.new(0), nil]] # "null" object - highest_remote_ver = highest_remote_gem.first[1] - - if system or (l_spec.version < highest_remote_ver) then - result << [l_spec.name, [l_spec.version, highest_remote_ver].max] - end - end - - result - end - -end - diff --git a/ruby_1_9_3/lib/rubygems/commands/which_command.rb b/ruby_1_9_3/lib/rubygems/commands/which_command.rb deleted file mode 100644 index 6495278a87..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/which_command.rb +++ /dev/null @@ -1,82 +0,0 @@ -require 'rubygems/command' - -class Gem::Commands::WhichCommand < Gem::Command - def initialize - super 'which', 'Find the location of a library file you can require', - :search_gems_first => false, :show_all => false - - add_option '-a', '--[no-]all', 'show all matching files' do |show_all, options| - options[:show_all] = show_all - end - - add_option '-g', '--[no-]gems-first', - 'search gems before non-gems' do |gems_first, options| - options[:search_gems_first] = gems_first - end - end - - def arguments # :nodoc: - "FILE name of file to find" - end - - def defaults_str # :nodoc: - "--no-gems-first --no-all" - end - - def execute - found = false - - options[:args].each do |arg| - arg = arg.sub(/#{Regexp.union(*Gem.suffixes)}$/, '') - dirs = $LOAD_PATH - - spec = Gem::Specification.find_by_path arg - - if spec then - if options[:search_gems_first] then - dirs = gem_paths(spec) + $LOAD_PATH - else - dirs = $LOAD_PATH + gem_paths(spec) - end - end - - # TODO: this is totally redundant and stupid - paths = find_paths arg, dirs - - if paths.empty? then - alert_error "Can't find ruby library file or shared library #{arg}" - else - say paths - found = true - end - end - - terminate_interaction 1 unless found - end - - def find_paths(package_name, dirs) - result = [] - - dirs.each do |dir| - Gem.suffixes.each do |ext| - full_path = File.join dir, "#{package_name}#{ext}" - if File.exist? full_path and not File.directory? full_path then - result << full_path - return result unless options[:show_all] - end - end - end - - result - end - - def gem_paths(spec) - spec.require_paths.collect { |d| File.join spec.full_gem_path, d } - end - - def usage # :nodoc: - "#{program_name} FILE [FILE ...]" - end - -end - |