[rubygems/rubygems] Normalize end alignment style with Bundler
https://github.com/rubygems/rubygems/commit/f7f504b24c
This commit is contained in:
parent
a892e5599e
commit
f04954d95c
@ -289,14 +289,14 @@ class Gem::BasicSpecification
|
|||||||
|
|
||||||
def lib_dirs_glob
|
def lib_dirs_glob
|
||||||
dirs = if self.raw_require_paths
|
dirs = if self.raw_require_paths
|
||||||
if self.raw_require_paths.size > 1
|
if self.raw_require_paths.size > 1
|
||||||
"{#{self.raw_require_paths.join(',')}}"
|
"{#{self.raw_require_paths.join(',')}}"
|
||||||
else
|
else
|
||||||
self.raw_require_paths.first
|
self.raw_require_paths.first
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
"lib" # default value for require_paths for bundler/inline
|
"lib" # default value for require_paths for bundler/inline
|
||||||
end
|
end
|
||||||
|
|
||||||
"#{self.full_gem_path}/#{dirs}".dup.tap(&Gem::UNTAINT)
|
"#{self.full_gem_path}/#{dirs}".dup.tap(&Gem::UNTAINT)
|
||||||
end
|
end
|
||||||
|
@ -65,9 +65,9 @@ module Gem::BundlerVersionFinder
|
|||||||
return unless gemfile
|
return unless gemfile
|
||||||
|
|
||||||
lockfile = case gemfile
|
lockfile = case gemfile
|
||||||
when "gems.rb" then "gems.locked"
|
when "gems.rb" then "gems.locked"
|
||||||
else "#{gemfile}.lock"
|
else "#{gemfile}.lock"
|
||||||
end.dup.tap(&Gem::UNTAINT)
|
end.dup.tap(&Gem::UNTAINT)
|
||||||
|
|
||||||
return unless File.file?(lockfile)
|
return unless File.file?(lockfile)
|
||||||
|
|
||||||
|
@ -398,10 +398,10 @@ class Gem::Command
|
|||||||
version_to_expire = deprecation["rg_version_to_expire"]
|
version_to_expire = deprecation["rg_version_to_expire"]
|
||||||
|
|
||||||
deprecate_option_msg = if version_to_expire
|
deprecate_option_msg = if version_to_expire
|
||||||
"The \"#{option}\" option has been deprecated and will be removed in Rubygems #{version_to_expire}."
|
"The \"#{option}\" option has been deprecated and will be removed in Rubygems #{version_to_expire}."
|
||||||
else
|
else
|
||||||
"The \"#{option}\" option has been deprecated and will be removed in future versions of Rubygems."
|
"The \"#{option}\" option has been deprecated and will be removed in future versions of Rubygems."
|
||||||
end
|
end
|
||||||
|
|
||||||
extra_msg = deprecation["extra_msg"]
|
extra_msg = deprecation["extra_msg"]
|
||||||
|
|
||||||
|
@ -117,12 +117,12 @@ If no gems are named all gems in GEM_HOME are cleaned.
|
|||||||
|
|
||||||
def get_candidate_gems
|
def get_candidate_gems
|
||||||
@candidate_gems = unless options[:args].empty?
|
@candidate_gems = unless options[:args].empty?
|
||||||
options[:args].map do |gem_name|
|
options[:args].map do |gem_name|
|
||||||
Gem::Specification.find_all_by_name gem_name
|
Gem::Specification.find_all_by_name gem_name
|
||||||
end.flatten
|
end.flatten
|
||||||
else
|
else
|
||||||
Gem::Specification.to_a
|
Gem::Specification.to_a
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_gems_to_cleanup
|
def get_gems_to_cleanup
|
||||||
|
@ -98,20 +98,20 @@ extensions will be restored.
|
|||||||
|
|
||||||
def execute
|
def execute
|
||||||
specs = if options[:all]
|
specs = if options[:all]
|
||||||
Gem::Specification.map
|
Gem::Specification.map
|
||||||
|
|
||||||
# `--extensions` must be explicitly given to pristine only gems
|
# `--extensions` must be explicitly given to pristine only gems
|
||||||
# with extensions.
|
# with extensions.
|
||||||
elsif options[:extensions_set] and
|
elsif options[:extensions_set] and
|
||||||
options[:extensions] and options[:args].empty?
|
options[:extensions] and options[:args].empty?
|
||||||
Gem::Specification.select do |spec|
|
Gem::Specification.select do |spec|
|
||||||
spec.extensions and not spec.extensions.empty?
|
spec.extensions and not spec.extensions.empty?
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
get_all_gem_names.sort.map do |gem_name|
|
get_all_gem_names.sort.map do |gem_name|
|
||||||
Gem::Specification.find_all_by_name(gem_name, options[:version]).reverse
|
Gem::Specification.find_all_by_name(gem_name, options[:version]).reverse
|
||||||
end.flatten
|
end.flatten
|
||||||
end
|
end
|
||||||
|
|
||||||
specs = specs.select{|spec| RUBY_ENGINE == spec.platform || Gem::Platform.local === spec.platform || spec.platform == Gem::Platform::RUBY }
|
specs = specs.select{|spec| RUBY_ENGINE == spec.platform || Gem::Platform.local === spec.platform || spec.platform == Gem::Platform::RUBY }
|
||||||
|
|
||||||
|
@ -52,14 +52,14 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo
|
|||||||
default_gem_server, push_host = get_hosts_for(gem_name)
|
default_gem_server, push_host = get_hosts_for(gem_name)
|
||||||
|
|
||||||
@host = if @user_defined_host
|
@host = if @user_defined_host
|
||||||
options[:host]
|
options[:host]
|
||||||
elsif default_gem_server
|
elsif default_gem_server
|
||||||
default_gem_server
|
default_gem_server
|
||||||
elsif push_host
|
elsif push_host
|
||||||
push_host
|
push_host
|
||||||
else
|
else
|
||||||
options[:host]
|
options[:host]
|
||||||
end
|
end
|
||||||
|
|
||||||
sign_in @host, scope: get_push_scope
|
sign_in @host, scope: get_push_scope
|
||||||
|
|
||||||
|
@ -61,12 +61,12 @@ Use --overwrite to force rebuilding of documentation.
|
|||||||
|
|
||||||
def execute
|
def execute
|
||||||
specs = if options[:all]
|
specs = if options[:all]
|
||||||
Gem::Specification.to_a
|
Gem::Specification.to_a
|
||||||
else
|
else
|
||||||
get_all_gem_names.map do |name|
|
get_all_gem_names.map do |name|
|
||||||
Gem::Specification.find_by_name name, options[:version]
|
Gem::Specification.find_by_name name, options[:version]
|
||||||
end.flatten.uniq
|
end.flatten.uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
if specs.empty?
|
if specs.empty?
|
||||||
alert_error 'No matching gems found'
|
alert_error 'No matching gems found'
|
||||||
|
@ -54,10 +54,10 @@ class Gem::Commands::SetupCommand < Gem::Command
|
|||||||
'List the documentation types you wish to',
|
'List the documentation types you wish to',
|
||||||
'generate. For example: rdoc,ri' do |value, options|
|
'generate. For example: rdoc,ri' do |value, options|
|
||||||
options[:document] = case value
|
options[:document] = case value
|
||||||
when nil then %w[rdoc ri]
|
when nil then %w[rdoc ri]
|
||||||
when false then []
|
when false then []
|
||||||
else value
|
else value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
add_option '--[no-]rdoc',
|
add_option '--[no-]rdoc',
|
||||||
@ -666,10 +666,10 @@ abort "#{deprecation_message}"
|
|||||||
|
|
||||||
def target_bin_path(bin_dir, bin_file)
|
def target_bin_path(bin_dir, bin_file)
|
||||||
bin_file_formatted = if options[:format_executable]
|
bin_file_formatted = if options[:format_executable]
|
||||||
Gem.default_exec_format % bin_file
|
Gem.default_exec_format % bin_file
|
||||||
else
|
else
|
||||||
bin_file
|
bin_file
|
||||||
end
|
end
|
||||||
File.join bin_dir, bin_file_formatted
|
File.join bin_dir, bin_file_formatted
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -140,10 +140,10 @@ Specific fields in the specification can be extracted in YAML format:
|
|||||||
s = s.send field if field
|
s = s.send field if field
|
||||||
|
|
||||||
say case options[:format]
|
say case options[:format]
|
||||||
when :ruby then s.to_ruby
|
when :ruby then s.to_ruby
|
||||||
when :marshal then Marshal.dump s
|
when :marshal then Marshal.dump s
|
||||||
else s.to_yaml
|
else s.to_yaml
|
||||||
end
|
end
|
||||||
|
|
||||||
say "\n"
|
say "\n"
|
||||||
end
|
end
|
||||||
|
@ -233,10 +233,10 @@ command to remove old versions.
|
|||||||
up_ver = gems_to_update.first.version
|
up_ver = gems_to_update.first.version
|
||||||
|
|
||||||
target = if update_latest
|
target = if update_latest
|
||||||
up_ver
|
up_ver
|
||||||
else
|
else
|
||||||
version
|
version
|
||||||
end
|
end
|
||||||
|
|
||||||
return target, requirement
|
return target, requirement
|
||||||
end
|
end
|
||||||
|
@ -281,10 +281,10 @@ if you believe they were disclosed to a third party.
|
|||||||
check_credentials_permissions
|
check_credentials_permissions
|
||||||
|
|
||||||
@api_keys = if File.exist? credentials_path
|
@api_keys = if File.exist? credentials_path
|
||||||
load_file(credentials_path)
|
load_file(credentials_path)
|
||||||
else
|
else
|
||||||
@hash
|
@hash
|
||||||
end
|
end
|
||||||
|
|
||||||
if @api_keys.key? :rubygems_api_key
|
if @api_keys.key? :rubygems_api_key
|
||||||
@rubygems_api_key = @api_keys[:rubygems_api_key]
|
@rubygems_api_key = @api_keys[:rubygems_api_key]
|
||||||
|
@ -117,11 +117,11 @@ class Gem::Doctor
|
|||||||
type = File.directory?(child) ? 'directory' : 'file'
|
type = File.directory?(child) ? 'directory' : 'file'
|
||||||
|
|
||||||
action = if @dry_run
|
action = if @dry_run
|
||||||
'Extra'
|
'Extra'
|
||||||
else
|
else
|
||||||
FileUtils.rm_r(child)
|
FileUtils.rm_r(child)
|
||||||
'Removed'
|
'Removed'
|
||||||
end
|
end
|
||||||
|
|
||||||
say "#{action} #{type} #{sub_directory}/#{File.basename(child)}"
|
say "#{action} #{type} #{sub_directory}/#{File.basename(child)}"
|
||||||
end
|
end
|
||||||
|
@ -42,11 +42,11 @@ class Gem::GemRunner
|
|||||||
cmd.command_names.each do |command_name|
|
cmd.command_names.each do |command_name|
|
||||||
config_args = Gem.configuration[command_name]
|
config_args = Gem.configuration[command_name]
|
||||||
config_args = case config_args
|
config_args = case config_args
|
||||||
when String
|
when String
|
||||||
config_args.split ' '
|
config_args.split ' '
|
||||||
else
|
else
|
||||||
Array(config_args)
|
Array(config_args)
|
||||||
end
|
end
|
||||||
Gem::Command.add_specific_extra_args command_name, config_args
|
Gem::Command.add_specific_extra_args command_name, config_args
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -35,10 +35,10 @@ module Gem::InstallUpdateOptions
|
|||||||
'List the documentation types you wish to',
|
'List the documentation types you wish to',
|
||||||
'generate. For example: rdoc,ri') do |value, options|
|
'generate. For example: rdoc,ri') do |value, options|
|
||||||
options[:document] = case value
|
options[:document] = case value
|
||||||
when nil then %w[ri]
|
when nil then %w[ri]
|
||||||
when false then []
|
when false then []
|
||||||
else value
|
else value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
add_option(:"Install/Update", '--build-root DIR',
|
add_option(:"Install/Update", '--build-root DIR',
|
||||||
|
@ -146,12 +146,12 @@ class Gem::Package
|
|||||||
|
|
||||||
def self.new(gem, security_policy = nil)
|
def self.new(gem, security_policy = nil)
|
||||||
gem = if gem.is_a?(Gem::Package::Source)
|
gem = if gem.is_a?(Gem::Package::Source)
|
||||||
gem
|
gem
|
||||||
elsif gem.respond_to? :read
|
elsif gem.respond_to? :read
|
||||||
Gem::Package::IOSource.new gem
|
Gem::Package::IOSource.new gem
|
||||||
else
|
else
|
||||||
Gem::Package::FileSource.new gem
|
Gem::Package::FileSource.new gem
|
||||||
end
|
end
|
||||||
|
|
||||||
return super unless Gem::Package == self
|
return super unless Gem::Package == self
|
||||||
return super unless gem.present?
|
return super unless gem.present?
|
||||||
@ -353,10 +353,10 @@ EOM
|
|||||||
|
|
||||||
def digest(entry) # :nodoc:
|
def digest(entry) # :nodoc:
|
||||||
algorithms = if @checksums
|
algorithms = if @checksums
|
||||||
@checksums.keys
|
@checksums.keys
|
||||||
else
|
else
|
||||||
[Gem::Security::DIGEST_NAME].compact
|
[Gem::Security::DIGEST_NAME].compact
|
||||||
end
|
end
|
||||||
|
|
||||||
algorithms.each do |algorithm|
|
algorithms.each do |algorithm|
|
||||||
digester = Gem::Security.create_digest(algorithm)
|
digester = Gem::Security.create_digest(algorithm)
|
||||||
|
@ -78,9 +78,9 @@ class Gem::Platform
|
|||||||
cpu = arch.shift
|
cpu = arch.shift
|
||||||
|
|
||||||
@cpu = case cpu
|
@cpu = case cpu
|
||||||
when /i\d86/ then 'x86'
|
when /i\d86/ then 'x86'
|
||||||
else cpu
|
else cpu
|
||||||
end
|
end
|
||||||
|
|
||||||
if arch.length == 2 and arch.last =~ /^\d+(\.\d+)?$/ # for command-line
|
if arch.length == 2 and arch.last =~ /^\d+(\.\d+)?$/ # for command-line
|
||||||
@os, @version = arch
|
@os, @version = arch
|
||||||
@ -91,32 +91,32 @@ class Gem::Platform
|
|||||||
@cpu, os = nil, cpu if os.nil? # legacy jruby
|
@cpu, os = nil, cpu if os.nil? # legacy jruby
|
||||||
|
|
||||||
@os, @version = case os
|
@os, @version = case os
|
||||||
when /aix(\d+)?/ then [ 'aix', $1 ]
|
when /aix(\d+)?/ then [ 'aix', $1 ]
|
||||||
when /cygwin/ then [ 'cygwin', nil ]
|
when /cygwin/ then [ 'cygwin', nil ]
|
||||||
when /darwin(\d+)?/ then [ 'darwin', $1 ]
|
when /darwin(\d+)?/ then [ 'darwin', $1 ]
|
||||||
when /^macruby$/ then [ 'macruby', nil ]
|
when /^macruby$/ then [ 'macruby', nil ]
|
||||||
when /freebsd(\d+)?/ then [ 'freebsd', $1 ]
|
when /freebsd(\d+)?/ then [ 'freebsd', $1 ]
|
||||||
when /hpux(\d+)?/ then [ 'hpux', $1 ]
|
when /hpux(\d+)?/ then [ 'hpux', $1 ]
|
||||||
when /^java$/, /^jruby$/ then [ 'java', nil ]
|
when /^java$/, /^jruby$/ then [ 'java', nil ]
|
||||||
when /^java([\d.]*)/ then [ 'java', $1 ]
|
when /^java([\d.]*)/ then [ 'java', $1 ]
|
||||||
when /^dalvik(\d+)?$/ then [ 'dalvik', $1 ]
|
when /^dalvik(\d+)?$/ then [ 'dalvik', $1 ]
|
||||||
when /^dotnet$/ then [ 'dotnet', nil ]
|
when /^dotnet$/ then [ 'dotnet', nil ]
|
||||||
when /^dotnet([\d.]*)/ then [ 'dotnet', $1 ]
|
when /^dotnet([\d.]*)/ then [ 'dotnet', $1 ]
|
||||||
when /linux-?((?!gnu)\w+)?/ then [ 'linux', $1 ]
|
when /linux-?((?!gnu)\w+)?/ then [ 'linux', $1 ]
|
||||||
when /mingw32/ then [ 'mingw32', nil ]
|
when /mingw32/ then [ 'mingw32', nil ]
|
||||||
when /mingw-?(\w+)?/ then [ 'mingw', $1 ]
|
when /mingw-?(\w+)?/ then [ 'mingw', $1 ]
|
||||||
when /(mswin\d+)(\_(\d+))?/ then
|
when /(mswin\d+)(\_(\d+))?/ then
|
||||||
os, version = $1, $3
|
os, version = $1, $3
|
||||||
@cpu = 'x86' if @cpu.nil? and os =~ /32$/
|
@cpu = 'x86' if @cpu.nil? and os =~ /32$/
|
||||||
[os, version]
|
[os, version]
|
||||||
when /netbsdelf/ then [ 'netbsdelf', nil ]
|
when /netbsdelf/ then [ 'netbsdelf', nil ]
|
||||||
when /openbsd(\d+\.\d+)?/ then [ 'openbsd', $1 ]
|
when /openbsd(\d+\.\d+)?/ then [ 'openbsd', $1 ]
|
||||||
when /bitrig(\d+\.\d+)?/ then [ 'bitrig', $1 ]
|
when /bitrig(\d+\.\d+)?/ then [ 'bitrig', $1 ]
|
||||||
when /solaris(\d+\.\d+)?/ then [ 'solaris', $1 ]
|
when /solaris(\d+\.\d+)?/ then [ 'solaris', $1 ]
|
||||||
# test
|
# test
|
||||||
when /^(\w+_platform)(\d+)?/ then [ $1, $2 ]
|
when /^(\w+_platform)(\d+)?/ then [ $1, $2 ]
|
||||||
else [ 'unknown', nil ]
|
else [ 'unknown', nil ]
|
||||||
end
|
end
|
||||||
when Gem::Platform then
|
when Gem::Platform then
|
||||||
@cpu = arch.cpu
|
@cpu = arch.cpu
|
||||||
@os = arch.os
|
@os = arch.os
|
||||||
@ -180,19 +180,19 @@ class Gem::Platform
|
|||||||
when String then
|
when String then
|
||||||
# This data is from http://gems.rubyforge.org/gems/yaml on 19 Aug 2007
|
# This data is from http://gems.rubyforge.org/gems/yaml on 19 Aug 2007
|
||||||
other = case other
|
other = case other
|
||||||
when /^i686-darwin(\d)/ then ['x86', 'darwin', $1 ]
|
when /^i686-darwin(\d)/ then ['x86', 'darwin', $1 ]
|
||||||
when /^i\d86-linux/ then ['x86', 'linux', nil ]
|
when /^i\d86-linux/ then ['x86', 'linux', nil ]
|
||||||
when 'java', 'jruby' then [nil, 'java', nil ]
|
when 'java', 'jruby' then [nil, 'java', nil ]
|
||||||
when /^dalvik(\d+)?$/ then [nil, 'dalvik', $1 ]
|
when /^dalvik(\d+)?$/ then [nil, 'dalvik', $1 ]
|
||||||
when /dotnet(\-(\d+\.\d+))?/ then ['universal','dotnet', $2 ]
|
when /dotnet(\-(\d+\.\d+))?/ then ['universal','dotnet', $2 ]
|
||||||
when /mswin32(\_(\d+))?/ then ['x86', 'mswin32', $2 ]
|
when /mswin32(\_(\d+))?/ then ['x86', 'mswin32', $2 ]
|
||||||
when /mswin64(\_(\d+))?/ then ['x64', 'mswin64', $2 ]
|
when /mswin64(\_(\d+))?/ then ['x64', 'mswin64', $2 ]
|
||||||
when 'powerpc-darwin' then ['powerpc', 'darwin', nil ]
|
when 'powerpc-darwin' then ['powerpc', 'darwin', nil ]
|
||||||
when /powerpc-darwin(\d)/ then ['powerpc', 'darwin', $1 ]
|
when /powerpc-darwin(\d)/ then ['powerpc', 'darwin', $1 ]
|
||||||
when /sparc-solaris2.8/ then ['sparc', 'solaris', '2.8' ]
|
when /sparc-solaris2.8/ then ['sparc', 'solaris', '2.8' ]
|
||||||
when /universal-darwin(\d)/ then ['universal', 'darwin', $1 ]
|
when /universal-darwin(\d)/ then ['universal', 'darwin', $1 ]
|
||||||
else other
|
else other
|
||||||
end
|
end
|
||||||
|
|
||||||
other = Gem::Platform.new other
|
other = Gem::Platform.new other
|
||||||
else
|
else
|
||||||
|
@ -150,12 +150,12 @@ module Gem::QueryUtils
|
|||||||
fetcher = Gem::SpecFetcher.fetcher
|
fetcher = Gem::SpecFetcher.fetcher
|
||||||
|
|
||||||
spec_tuples = if name.respond_to?(:source) && name.source.empty?
|
spec_tuples = if name.respond_to?(:source) && name.source.empty?
|
||||||
fetcher.detect(specs_type) { true }
|
fetcher.detect(specs_type) { true }
|
||||||
else
|
else
|
||||||
fetcher.detect(specs_type) do |name_tuple|
|
fetcher.detect(specs_type) do |name_tuple|
|
||||||
name === name_tuple.name
|
name === name_tuple.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
output_query_results(spec_tuples)
|
output_query_results(spec_tuples)
|
||||||
end
|
end
|
||||||
|
@ -172,10 +172,10 @@ class Gem::RemoteFetcher
|
|||||||
when nil then # TODO test for local overriding cache
|
when nil then # TODO test for local overriding cache
|
||||||
source_path = if Gem.win_platform? && source_uri.scheme &&
|
source_path = if Gem.win_platform? && source_uri.scheme &&
|
||||||
!source_uri.path.include?(':')
|
!source_uri.path.include?(':')
|
||||||
"#{source_uri.scheme}:#{source_uri.path}"
|
"#{source_uri.scheme}:#{source_uri.path}"
|
||||||
else
|
else
|
||||||
source_uri.path
|
source_uri.path
|
||||||
end
|
end
|
||||||
|
|
||||||
source_path = Gem::UriFormatter.new(source_path).unescape
|
source_path = Gem::UriFormatter.new(source_path).unescape
|
||||||
|
|
||||||
|
@ -56,10 +56,10 @@ class Gem::RequestSet::Lockfile
|
|||||||
|
|
||||||
deps[name] = if [Gem::Resolver::VendorSpecification,
|
deps[name] = if [Gem::Resolver::VendorSpecification,
|
||||||
Gem::Resolver::GitSpecification].include? spec.class
|
Gem::Resolver::GitSpecification].include? spec.class
|
||||||
Gem::Requirement.source_set
|
Gem::Requirement.source_set
|
||||||
else
|
else
|
||||||
requirement
|
requirement
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
deps
|
deps
|
||||||
|
@ -81,12 +81,12 @@ class Gem::Source
|
|||||||
return Gem::Resolver::IndexSet.new self if 'file' == uri.scheme
|
return Gem::Resolver::IndexSet.new self if 'file' == uri.scheme
|
||||||
|
|
||||||
fetch_uri = if uri.host == "rubygems.org"
|
fetch_uri = if uri.host == "rubygems.org"
|
||||||
index_uri = uri.dup
|
index_uri = uri.dup
|
||||||
index_uri.host = "index.rubygems.org"
|
index_uri.host = "index.rubygems.org"
|
||||||
index_uri
|
index_uri
|
||||||
else
|
else
|
||||||
uri
|
uri
|
||||||
end
|
end
|
||||||
|
|
||||||
bundler_api_uri = enforce_trailing_slash(fetch_uri)
|
bundler_api_uri = enforce_trailing_slash(fetch_uri)
|
||||||
|
|
||||||
|
@ -51,13 +51,13 @@ class Gem::SourceList
|
|||||||
require "uri"
|
require "uri"
|
||||||
|
|
||||||
src = case obj
|
src = case obj
|
||||||
when URI
|
when URI
|
||||||
Gem::Source.new(obj)
|
Gem::Source.new(obj)
|
||||||
when Gem::Source
|
when Gem::Source
|
||||||
obj
|
obj
|
||||||
else
|
else
|
||||||
Gem::Source.new(URI.parse(obj))
|
Gem::Source.new(URI.parse(obj))
|
||||||
end
|
end
|
||||||
|
|
||||||
@sources << src unless @sources.include?(src)
|
@sources << src unless @sources.include?(src)
|
||||||
src
|
src
|
||||||
|
@ -191,10 +191,10 @@ class Gem::SpecFetcher
|
|||||||
end
|
end
|
||||||
|
|
||||||
matches = if matches.empty? && type != :prerelease
|
matches = if matches.empty? && type != :prerelease
|
||||||
suggest_gems_from_name gem_name, :prerelease
|
suggest_gems_from_name gem_name, :prerelease
|
||||||
else
|
else
|
||||||
matches.uniq.sort_by {|name, dist| dist }
|
matches.uniq.sort_by {|name, dist| dist }
|
||||||
end
|
end
|
||||||
|
|
||||||
matches.map {|name, dist| name }.uniq.first(num_results)
|
matches.map {|name, dist| name }.uniq.first(num_results)
|
||||||
end
|
end
|
||||||
@ -216,27 +216,27 @@ class Gem::SpecFetcher
|
|||||||
@sources.each_source do |source|
|
@sources.each_source do |source|
|
||||||
begin
|
begin
|
||||||
names = case type
|
names = case type
|
||||||
when :latest
|
when :latest
|
||||||
tuples_for source, :latest
|
tuples_for source, :latest
|
||||||
when :released
|
when :released
|
||||||
tuples_for source, :released
|
tuples_for source, :released
|
||||||
when :complete
|
when :complete
|
||||||
names =
|
names =
|
||||||
tuples_for(source, :prerelease, true) +
|
tuples_for(source, :prerelease, true) +
|
||||||
tuples_for(source, :released)
|
tuples_for(source, :released)
|
||||||
|
|
||||||
names.sort
|
names.sort
|
||||||
when :abs_latest
|
when :abs_latest
|
||||||
names =
|
names =
|
||||||
tuples_for(source, :prerelease, true) +
|
tuples_for(source, :prerelease, true) +
|
||||||
tuples_for(source, :latest)
|
tuples_for(source, :latest)
|
||||||
|
|
||||||
names.sort
|
names.sort
|
||||||
when :prerelease
|
when :prerelease
|
||||||
tuples_for(source, :prerelease)
|
tuples_for(source, :prerelease)
|
||||||
else
|
else
|
||||||
raise Gem::Exception, "Unknown type - :#{type}"
|
raise Gem::Exception, "Unknown type - :#{type}"
|
||||||
end
|
end
|
||||||
rescue Gem::RemoteFetcher::FetchError => e
|
rescue Gem::RemoteFetcher::FetchError => e
|
||||||
errors << Gem::SourceFetchProblem.new(source, e)
|
errors << Gem::SourceFetchProblem.new(source, e)
|
||||||
else
|
else
|
||||||
|
@ -162,15 +162,15 @@ class Gem::Specification < Gem::BasicSpecification
|
|||||||
|
|
||||||
@@default_value.each do |k,v|
|
@@default_value.each do |k,v|
|
||||||
INITIALIZE_CODE_FOR_DEFAULTS[k] = case v
|
INITIALIZE_CODE_FOR_DEFAULTS[k] = case v
|
||||||
when [], {}, true, false, nil, Numeric, Symbol
|
when [], {}, true, false, nil, Numeric, Symbol
|
||||||
v.inspect
|
v.inspect
|
||||||
when String
|
when String
|
||||||
v.dump
|
v.dump
|
||||||
when Numeric
|
when Numeric
|
||||||
"default_value(:#{k})"
|
"default_value(:#{k})"
|
||||||
else
|
else
|
||||||
"default_value(:#{k}).dup"
|
"default_value(:#{k}).dup"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@attributes = @@default_value.keys.sort_by {|s| s.to_s }
|
@@attributes = @@default_value.keys.sort_by {|s| s.to_s }
|
||||||
@ -1268,12 +1268,12 @@ class Gem::Specification < Gem::BasicSpecification
|
|||||||
current_version = CURRENT_SPECIFICATION_VERSION
|
current_version = CURRENT_SPECIFICATION_VERSION
|
||||||
|
|
||||||
field_count = if spec.specification_version > current_version
|
field_count = if spec.specification_version > current_version
|
||||||
spec.instance_variable_set :@specification_version,
|
spec.instance_variable_set :@specification_version,
|
||||||
current_version
|
current_version
|
||||||
MARSHAL_FIELDS[current_version]
|
MARSHAL_FIELDS[current_version]
|
||||||
else
|
else
|
||||||
MARSHAL_FIELDS[spec.specification_version]
|
MARSHAL_FIELDS[spec.specification_version]
|
||||||
end
|
end
|
||||||
|
|
||||||
if array.size < field_count
|
if array.size < field_count
|
||||||
raise TypeError, "invalid Gem::Specification format #{array.inspect}"
|
raise TypeError, "invalid Gem::Specification format #{array.inspect}"
|
||||||
@ -1473,10 +1473,10 @@ class Gem::Specification < Gem::BasicSpecification
|
|||||||
|
|
||||||
def add_dependency_with_type(dependency, type, requirements)
|
def add_dependency_with_type(dependency, type, requirements)
|
||||||
requirements = if requirements.empty?
|
requirements = if requirements.empty?
|
||||||
Gem::Requirement.default
|
Gem::Requirement.default
|
||||||
else
|
else
|
||||||
requirements.flatten
|
requirements.flatten
|
||||||
end
|
end
|
||||||
|
|
||||||
unless dependency.respond_to?(:name) &&
|
unless dependency.respond_to?(:name) &&
|
||||||
dependency.respond_to?(:requirement)
|
dependency.respond_to?(:requirement)
|
||||||
@ -1684,18 +1684,18 @@ class Gem::Specification < Gem::BasicSpecification
|
|||||||
# This is the cleanest, most-readable, faster-than-using-Date
|
# This is the cleanest, most-readable, faster-than-using-Date
|
||||||
# way to do it.
|
# way to do it.
|
||||||
@date = case date
|
@date = case date
|
||||||
when String then
|
when String then
|
||||||
if DateTimeFormat =~ date
|
if DateTimeFormat =~ date
|
||||||
Time.utc($1.to_i, $2.to_i, $3.to_i)
|
Time.utc($1.to_i, $2.to_i, $3.to_i)
|
||||||
else
|
else
|
||||||
raise(Gem::InvalidSpecificationException,
|
raise(Gem::InvalidSpecificationException,
|
||||||
"invalid date format in specification: #{date.inspect}")
|
"invalid date format in specification: #{date.inspect}")
|
||||||
end
|
end
|
||||||
when Time, DateLike then
|
when Time, DateLike then
|
||||||
Time.utc(date.year, date.month, date.day)
|
Time.utc(date.year, date.month, date.day)
|
||||||
else
|
else
|
||||||
TODAY
|
TODAY
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
@ -1801,13 +1801,13 @@ class Gem::Specification < Gem::BasicSpecification
|
|||||||
coder.add 'name', @name
|
coder.add 'name', @name
|
||||||
coder.add 'version', @version
|
coder.add 'version', @version
|
||||||
platform = case @original_platform
|
platform = case @original_platform
|
||||||
when nil, '' then
|
when nil, '' then
|
||||||
'ruby'
|
'ruby'
|
||||||
when String then
|
when String then
|
||||||
@original_platform
|
@original_platform
|
||||||
else
|
else
|
||||||
@original_platform.to_s
|
@original_platform.to_s
|
||||||
end
|
end
|
||||||
coder.add 'platform', platform
|
coder.add 'platform', platform
|
||||||
|
|
||||||
attributes = @@attributes.map(&:to_s) - %w[name version platform]
|
attributes = @@attributes.map(&:to_s) - %w[name version platform]
|
||||||
@ -2024,10 +2024,10 @@ class Gem::Specification < Gem::BasicSpecification
|
|||||||
def base_dir
|
def base_dir
|
||||||
return Gem.dir unless loaded_from
|
return Gem.dir unless loaded_from
|
||||||
@base_dir ||= if default_gem?
|
@base_dir ||= if default_gem?
|
||||||
File.dirname File.dirname File.dirname loaded_from
|
File.dirname File.dirname File.dirname loaded_from
|
||||||
else
|
else
|
||||||
File.dirname File.dirname loaded_from
|
File.dirname File.dirname loaded_from
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
@ -2654,9 +2654,9 @@ class Gem::Specification < Gem::BasicSpecification
|
|||||||
default = self.default_value attribute
|
default = self.default_value attribute
|
||||||
|
|
||||||
value = case default
|
value = case default
|
||||||
when Time, Numeric, Symbol, true, false, nil then default
|
when Time, Numeric, Symbol, true, false, nil then default
|
||||||
else default.dup
|
else default.dup
|
||||||
end
|
end
|
||||||
|
|
||||||
instance_variable_set "@#{attribute}", value
|
instance_variable_set "@#{attribute}", value
|
||||||
end
|
end
|
||||||
|
@ -199,17 +199,17 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
|
|||||||
base = segments.first 2
|
base = segments.first 2
|
||||||
|
|
||||||
recommendation = if (op == '>' || op == '>=') && segments == [0]
|
recommendation = if (op == '>' || op == '>=') && segments == [0]
|
||||||
" use a bounded requirement, such as '~> x.y'"
|
" use a bounded requirement, such as '~> x.y'"
|
||||||
else
|
else
|
||||||
bugfix = if op == '>'
|
bugfix = if op == '>'
|
||||||
", '> #{dep_version}'"
|
", '> #{dep_version}'"
|
||||||
elsif op == '>=' and base != segments
|
elsif op == '>=' and base != segments
|
||||||
", '>= #{dep_version}'"
|
", '>= #{dep_version}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
" if #{dep.name} is semantically versioned, use:\n" \
|
" if #{dep.name} is semantically versioned, use:\n" \
|
||||||
" add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}'#{bugfix}"
|
" add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}'#{bugfix}"
|
||||||
end
|
end
|
||||||
|
|
||||||
warning_messages << ["open-ended dependency on #{dep} is not recommended", recommendation].join("\n") + "\n"
|
warning_messages << ["open-ended dependency on #{dep} is not recommended", recommendation].join("\n") + "\n"
|
||||||
end
|
end
|
||||||
@ -332,11 +332,11 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
|
|||||||
def validate_array_attribute(field)
|
def validate_array_attribute(field)
|
||||||
val = @specification.send(field)
|
val = @specification.send(field)
|
||||||
klass = case field
|
klass = case field
|
||||||
when :dependencies then
|
when :dependencies then
|
||||||
Gem::Dependency
|
Gem::Dependency
|
||||||
else
|
else
|
||||||
String
|
String
|
||||||
end
|
end
|
||||||
|
|
||||||
unless Array === val and val.all? {|x| x.kind_of?(klass) }
|
unless Array === val and val.all? {|x| x.kind_of?(klass) }
|
||||||
error "#{field} must be an Array of #{klass}"
|
error "#{field} must be an Array of #{klass}"
|
||||||
|
@ -36,18 +36,18 @@ class Gem::StubSpecification < Gem::BasicSpecification
|
|||||||
parts = data[PREFIX.length..-1].split(" ".freeze, 4)
|
parts = data[PREFIX.length..-1].split(" ".freeze, 4)
|
||||||
@name = parts[0].freeze
|
@name = parts[0].freeze
|
||||||
@version = if Gem::Version.correct?(parts[1])
|
@version = if Gem::Version.correct?(parts[1])
|
||||||
Gem::Version.new(parts[1])
|
Gem::Version.new(parts[1])
|
||||||
else
|
else
|
||||||
Gem::Version.new(0)
|
Gem::Version.new(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
@platform = Gem::Platform.new parts[2]
|
@platform = Gem::Platform.new parts[2]
|
||||||
@extensions = extensions
|
@extensions = extensions
|
||||||
@full_name = if platform == Gem::Platform::RUBY
|
@full_name = if platform == Gem::Platform::RUBY
|
||||||
"#{name}-#{version}"
|
"#{name}-#{version}"
|
||||||
else
|
else
|
||||||
"#{name}-#{version}-#{platform}"
|
"#{name}-#{version}-#{platform}"
|
||||||
end
|
end
|
||||||
|
|
||||||
path_list = parts.last
|
path_list = parts.last
|
||||||
@require_paths = REQUIRE_PATH_LIST[path_list] || path_list.split("\0".freeze).map! do |x|
|
@require_paths = REQUIRE_PATH_LIST[path_list] || path_list.split("\0".freeze).map! do |x|
|
||||||
@ -116,10 +116,10 @@ class Gem::StubSpecification < Gem::BasicSpecification
|
|||||||
stubline = file.readline.chomp
|
stubline = file.readline.chomp
|
||||||
if stubline.start_with?(PREFIX)
|
if stubline.start_with?(PREFIX)
|
||||||
extensions = if /\A#{PREFIX}/ =~ file.readline.chomp
|
extensions = if /\A#{PREFIX}/ =~ file.readline.chomp
|
||||||
$'.split "\0"
|
$'.split "\0"
|
||||||
else
|
else
|
||||||
StubLine::NO_EXTENSIONS
|
StubLine::NO_EXTENSIONS
|
||||||
end
|
end
|
||||||
|
|
||||||
@data = StubLine.new stubline, extensions
|
@data = StubLine.new stubline, extensions
|
||||||
end
|
end
|
||||||
@ -185,9 +185,9 @@ class Gem::StubSpecification < Gem::BasicSpecification
|
|||||||
|
|
||||||
def to_spec
|
def to_spec
|
||||||
@spec ||= if @data
|
@spec ||= if @data
|
||||||
loaded = Gem.loaded_specs[name]
|
loaded = Gem.loaded_specs[name]
|
||||||
loaded if loaded && loaded.version == version
|
loaded if loaded && loaded.version == version
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec ||= Gem::Specification.load(loaded_from)
|
@spec ||= Gem::Specification.load(loaded_from)
|
||||||
end
|
end
|
||||||
|
@ -200,13 +200,13 @@ class Gem::Uninstaller
|
|||||||
executables = executables.map {|exec| formatted_program_filename exec }
|
executables = executables.map {|exec| formatted_program_filename exec }
|
||||||
|
|
||||||
remove = if @force_executables.nil?
|
remove = if @force_executables.nil?
|
||||||
ask_yes_no("Remove executables:\n" +
|
ask_yes_no("Remove executables:\n" +
|
||||||
"\t#{executables.join ', '}\n\n" +
|
"\t#{executables.join ', '}\n\n" +
|
||||||
"in addition to the gem?",
|
"in addition to the gem?",
|
||||||
true)
|
true)
|
||||||
else
|
else
|
||||||
@force_executables
|
@force_executables
|
||||||
end
|
end
|
||||||
|
|
||||||
if remove
|
if remove
|
||||||
bin_dir = @bin_dir || Gem.bindir(spec.base_dir)
|
bin_dir = @bin_dir || Gem.bindir(spec.base_dir)
|
||||||
|
@ -258,23 +258,23 @@ class Gem::StreamUI
|
|||||||
end
|
end
|
||||||
|
|
||||||
default_answer = case default
|
default_answer = case default
|
||||||
when nil
|
when nil
|
||||||
'yn'
|
'yn'
|
||||||
when true
|
when true
|
||||||
'Yn'
|
'Yn'
|
||||||
else
|
else
|
||||||
'yN'
|
'yN'
|
||||||
end
|
end
|
||||||
|
|
||||||
result = nil
|
result = nil
|
||||||
|
|
||||||
while result.nil? do
|
while result.nil? do
|
||||||
result = case ask "#{question} [#{default_answer}]"
|
result = case ask "#{question} [#{default_answer}]"
|
||||||
when /^y/i then true
|
when /^y/i then true
|
||||||
when /^n/i then false
|
when /^n/i then false
|
||||||
when /^$/ then default
|
when /^$/ then default
|
||||||
else nil
|
else nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -310,12 +310,12 @@ class Gem::Version
|
|||||||
|
|
||||||
def release
|
def release
|
||||||
@@release[self] ||= if prerelease?
|
@@release[self] ||= if prerelease?
|
||||||
segments = self.segments
|
segments = self.segments
|
||||||
segments.pop while segments.any? {|s| String === s }
|
segments.pop while segments.any? {|s| String === s }
|
||||||
self.class.new segments.join('.')
|
self.class.new segments.join('.')
|
||||||
else
|
else
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def segments # :nodoc:
|
def segments # :nodoc:
|
||||||
|
@ -339,10 +339,10 @@ class Gem::TestCase < Test::Unit::TestCase
|
|||||||
ENV["GEM_SPEC_CACHE"] = File.join @tempdir, 'spec_cache'
|
ENV["GEM_SPEC_CACHE"] = File.join @tempdir, 'spec_cache'
|
||||||
|
|
||||||
@orig_ruby = if ENV['RUBY']
|
@orig_ruby = if ENV['RUBY']
|
||||||
ruby = Gem.ruby
|
ruby = Gem.ruby
|
||||||
Gem.ruby = ENV['RUBY']
|
Gem.ruby = ENV['RUBY']
|
||||||
ruby
|
ruby
|
||||||
end
|
end
|
||||||
|
|
||||||
@git = ENV['GIT'] || (win_platform? ? 'git.exe' : 'git')
|
@git = ENV['GIT'] || (win_platform? ? 'git.exe' : 'git')
|
||||||
|
|
||||||
|
@ -135,10 +135,10 @@ class Gem::FakeFetcher
|
|||||||
def download(spec, source_uri, install_dir = Gem.dir)
|
def download(spec, source_uri, install_dir = Gem.dir)
|
||||||
name = File.basename spec.cache_file
|
name = File.basename spec.cache_file
|
||||||
path = if Dir.pwd == install_dir # see fetch_command
|
path = if Dir.pwd == install_dir # see fetch_command
|
||||||
install_dir
|
install_dir
|
||||||
else
|
else
|
||||||
File.join install_dir, "cache"
|
File.join install_dir, "cache"
|
||||||
end
|
end
|
||||||
|
|
||||||
path = File.join path, name
|
path = File.join path, name
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user