summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-08 22:46:43 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-08 22:46:43 +0000
commit59991b6ac517fcaa4f8122a1da6552a66892449e ()
tree1379ec1662eca3c5a08e02e221c4b4045d08f0a7 /lib
parent230b8d533e67b82654975fdc581693967ff06daf (diff)
* lib/rubygems: Update to RubyGems HEAD(fe61e4c112).
this version contains new feature that warn invalid SPDX license identifiers. https://.com/rubygems/rubygems/pull/1249 and #1032, #1023, #1332, #1328, #1306, #1321, #1324 * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--lib/rubygems.rb1
-rw-r--r--lib/rubygems/commands/sources_command.rb2
-rw-r--r--lib/rubygems/commands/update_command.rb4
-rw-r--r--lib/rubygems/remote_fetcher.rb3
-rw-r--r--lib/rubygems/request_set/gem_dependency_api.rb2
-rw-r--r--lib/rubygems/request_set/lockfile/parser.rb97
-rw-r--r--lib/rubygems/request_set/lockfile/tokenizer.rb29
-rw-r--r--lib/rubygems/specification.rb53
-rw-r--r--lib/rubygems/test_case.rb4
-rw-r--r--lib/rubygems/util/licenses.rb309
10 files changed, 426 insertions, 78 deletions
@@ -1203,6 +1203,7 @@ module Gem
autoload :DependencyList, 'rubygems/dependency_list'
autoload :DependencyResolver, 'rubygems/resolver'
autoload :Installer, 'rubygems/installer'
autoload :PathSupport, 'rubygems/path_support'
autoload :Platform, 'rubygems/platform'
autoload :RequestSet, 'rubygems/request_set'
@@ -102,7 +102,7 @@ Do you want to add this insecure source?
RubyGems fetches gems from the sources you have configured (stored in your
~/.gemrc).
-The default source is https://rubygems.org, but you may have older sources
configured. This guide will help you update your sources or configure
yourself to use your own gem server.
@@ -47,7 +47,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
end
def arguments # :nodoc:
- "REGEXP regexp to search for in gem name"
end
def defaults_str # :nodoc:
@@ -64,7 +64,7 @@ command to remove old versions.
end
def usage # :nodoc:
- "#{program_name} REGEXP [REGEXP ...]"
end
def check_latest_rubygems version # :nodoc:
@@ -91,7 +91,8 @@ class Gem::RemoteFetcher
begin
res = @dns.getresource "_rubygems._tcp.#{host}",
Resolv::DNS::Resource::IN::SRV
- rescue Resolv::ResolvError
uri
else
target = res.target.to_s.strip
@@ -396,7 +396,7 @@ Gem dependencies file #{@path} requires #{name} more than once.
##
# Handles the git: option from +options+ for gem +name+.
#
- # Returns +true+ if the path option was handled.
def gem_git name, options # :nodoc:
if gist = options.delete(:gist) then
@@ -11,13 +11,13 @@ class Gem::RequestSet::Lockfile::Parser
def parse
until @tokens.empty? do
- type, data, column, line = get
- case type
when :section then
@tokens.skip :newline
- case data
when 'DEPENDENCIES' then
parse_DEPENDENCIES
when 'GIT' then
@@ -29,10 +29,10 @@ class Gem::RequestSet::Lockfile::Parser
when 'PLATFORMS' then
parse_PLATFORMS
else
- type, = get until @tokens.empty? or peek.first == :section
end
else
- raise "BUG: unhandled token #{type} (#{data.inspect}) at line #{line} column #{column}"
end
end
end
@@ -41,35 +41,33 @@ class Gem::RequestSet::Lockfile::Parser
# Gets the next token for a Lockfile
def get expected_types = nil, expected_value = nil # :nodoc:
- current_token = @tokens.shift
- type, value, column, line = current_token
- if expected_types and not Array(expected_types).include? type then
- unget current_token
-
- message = "unexpected token [#{type.inspect}, #{value.inspect}], " +
"expected #{expected_types.inspect}"
- raise Gem::RequestSet::Lockfile::ParseError.new message, column, line, @filename
end
- if expected_value and expected_value != value then
- unget current_token
- message = "unexpected token [#{type.inspect}, #{value.inspect}], " +
"expected [#{expected_types.inspect}, " +
"#{expected_value.inspect}]"
- raise Gem::RequestSet::Lockfile::ParseError.new message, column, line, @filename
end
- current_token
end
def parse_DEPENDENCIES # :nodoc:
- while not @tokens.empty? and :text == peek.first do
- _, name, = get :text
requirements = []
@@ -77,17 +75,17 @@ class Gem::RequestSet::Lockfile::Parser
when :bang then
get :bang
- requirements << pinned_requirement(name)
when :l_paren then
get :l_paren
loop do
- _, op, = get :requirement
- _, version, = get :text
requirements << "#{op} #{version}"
- break unless peek[0] == :comma
get :comma
end
@@ -96,13 +94,13 @@ class Gem::RequestSet::Lockfile::Parser
if peek[0] == :bang then
requirements.clear
- requirements << pinned_requirement(name)
get :bang
end
end
- @set.gem name, *requirements
skip :newline
end
@@ -113,7 +111,7 @@ class Gem::RequestSet::Lockfile::Parser
while [:entry, 'remote'] == peek.first(2) do
get :entry, 'remote'
- _, data, = get :text
skip :newline
sources << Gem::Source.new(data)
@@ -128,8 +126,10 @@ class Gem::RequestSet::Lockfile::Parser
set = Gem::Resolver::LockSet.new sources
last_specs = nil
- while not @tokens.empty? and :text == peek.first do
- _, name, column, = get :text
case peek[0]
when :newline then
@@ -139,7 +139,9 @@ class Gem::RequestSet::Lockfile::Parser
when :l_paren then
get :l_paren
- type, data, = get [:text, :requirement]
if type == :text and column == 4 then
version, platform = data.split '-', 2
@@ -169,16 +171,17 @@ class Gem::RequestSet::Lockfile::Parser
def parse_GIT # :nodoc:
get :entry, 'remote'
- _, repository, = get :text
skip :newline
get :entry, 'revision'
- _, revision, = get :text
skip :newline
- type, value = peek.first 2
if type == :entry and %w[branch ref tag].include? value then
get
get :text
@@ -195,8 +198,10 @@ class Gem::RequestSet::Lockfile::Parser
last_spec = nil
- while not @tokens.empty? and :text == peek.first do
- _, name, column, = get :text
case peek[0]
when :newline then
@@ -204,7 +209,9 @@ class Gem::RequestSet::Lockfile::Parser
when :l_paren then
get :l_paren
- type, data, = get [:text, :requirement]
if type == :text and column == 4 then
last_spec = set.add_git_spec name, data, repository, revision, true
@@ -227,7 +234,7 @@ class Gem::RequestSet::Lockfile::Parser
def parse_PATH # :nodoc:
get :entry, 'remote'
- _, directory, = get :text
skip :newline
@@ -239,7 +246,9 @@ class Gem::RequestSet::Lockfile::Parser
last_spec = nil
while not @tokens.empty? and :text == peek.first do
- _, name, column, = get :text
case peek[0]
when :newline then
@@ -247,7 +256,9 @@ class Gem::RequestSet::Lockfile::Parser
when :l_paren then
get :l_paren
- type, data, = get [:text, :requirement]
if type == :text and column == 4 then
last_spec = set.add_vendor_gem name, directory
@@ -270,7 +281,7 @@ class Gem::RequestSet::Lockfile::Parser
def parse_PLATFORMS # :nodoc:
while not @tokens.empty? and :text == peek.first do
- _, name, = get :text
@platforms << name
@@ -285,14 +296,14 @@ class Gem::RequestSet::Lockfile::Parser
def parse_dependency name, op # :nodoc:
return Gem::Dependency.new name, op unless peek[0] == :text
- _, version, = get :text
requirements = ["#{op} #{version}"]
- while peek[0] == :comma do
get :comma
- _, op, = get :requirement
- _, version, = get :text
requirements << "#{op} #{version}"
end
@@ -2,6 +2,9 @@ require 'strscan'
require 'rubygems/request_set/lockfile/parser'
class Gem::RequestSet::Lockfile::Tokenizer
def self.from_file file
new File.read(file), file
end
@@ -19,11 +22,11 @@ class Gem::RequestSet::Lockfile::Tokenizer
end
def to_a
- @tokens
end
def skip type
- @tokens.shift while not @tokens.empty? and peek.first == type
end
##
@@ -48,7 +51,7 @@ class Gem::RequestSet::Lockfile::Tokenizer
alias :shift :next_token
def peek
- @tokens.first || [:EOF]
end
private
@@ -71,7 +74,7 @@ class Gem::RequestSet::Lockfile::Tokenizer
@tokens <<
case
when s.scan(/\r?\n/) then
- token = [:newline, nil, *token_pos(pos)]
@line_pos = s.pos
@line += 1
token
@@ -79,25 +82,25 @@ class Gem::RequestSet::Lockfile::Tokenizer
if leading_whitespace then
text = s.matched
text += s.scan(/[^\s)]*/).to_s # in case of no match
- [:text, text, *token_pos(pos)]
else
- [:section, s.matched, *token_pos(pos)]
end
when s.scan(/([a-z]+):\s/) then
s.pos -= 1 # rewind for possible newline
- [:entry, s[1], *token_pos(pos)]
when s.scan(/\(/) then
- [:l_paren, nil, *token_pos(pos)]
when s.scan(/\)/) then
- [:r_paren, nil, *token_pos(pos)]
when s.scan(/<=|>=|=|~>|<|>|!=/) then
- [:requirement, s.matched, *token_pos(pos)]
when s.scan(/,/) then
- [:comma, nil, *token_pos(pos)]
when s.scan(/!/) then
- [:bang, nil, *token_pos(pos)]
when s.scan(/[^\s),!]*/) then
- [:text, s.matched, *token_pos(pos)]
else
raise "BUG: can't create token for: #{s.string[s.pos..-1].inspect}"
end
@@ -563,7 +563,7 @@ class Gem::Specification < Gem::BasicSpecification
# Ideally you should pick one that is OSI (Open Source Initiative)
# http://opensource.org/licenses/alphabetical approved.
#
- # The most commonly used OSI approved licenses are BSD-3-Clause and MIT.
# also provides a license picker at http://choosealicense.com/.
#
# You should specify a license for your gem so that people know how they are
@@ -592,7 +592,7 @@ class Gem::Specification < Gem::BasicSpecification
# See #license= for more discussion
#
# Usage:
- # spec.licenses = ['MIT', 'GPL-2']
def licenses= licenses
@licenses = Array licenses
@@ -619,6 +619,10 @@ class Gem::Specification < Gem::BasicSpecification
# ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
# #<Gem::Version "2.0.0.247">
#
# Usage:
#
# # This gem will work with 1.8.6 or greater...
@@ -626,6 +630,9 @@ class Gem::Specification < Gem::BasicSpecification
#
# # Only with ruby 2.0.x
# spec.required_ruby_version = '~> 2.0'
def required_ruby_version= req
@required_ruby_version = Gem::Requirement.create req
@@ -1000,7 +1007,7 @@ class Gem::Specification < Gem::BasicSpecification
def self.find_by_path path
stub = stubs.find { |spec|
- spec.contains_requirable_file? path
}
stub && stub.to_spec
end
@@ -1011,7 +1018,7 @@ class Gem::Specification < Gem::BasicSpecification
def self.find_inactive_by_path path
stub = stubs.find { |s|
- s.contains_requirable_file? path unless s.activated?
}
stub && stub.to_spec
end
@@ -1023,7 +1030,7 @@ class Gem::Specification < Gem::BasicSpecification
# TODO: do we need these?? Kill it
specs = unresolved_deps.values.map { |dep| dep.to_specs }.flatten
- specs.find_all { |spec| spec.contains_requirable_file? path }
end
##
@@ -2712,11 +2719,18 @@ class Gem::Specification < Gem::BasicSpecification
raise Gem::InvalidSpecificationException,
"each license must be 64 characters or less"
end
}
warning <<-warning if licenses.empty?
-licenses is empty, but is recommended. Use a license abbreviation from:
-http://opensource.org/licenses/alphabetical
warning
validate_permissions
@@ -2788,23 +2802,26 @@ http://opensource.org/licenses/alphabetical
# versioning.
def validate_dependencies # :nodoc:
- seen = {}
dependencies.each do |dep|
- if prev = seen[dep.name] then
- raise Gem::InvalidSpecificationException, <<-MESSAGE
duplicate dependency on #{dep}, (#{prev.requirement}) use:
- add_runtime_dependency '#{dep.name}', '#{dep.requirement}', '#{prev.requirement}'
MESSAGE
end
- seen[dep.name] = dep
prerelease_dep = dep.requirements_list.any? do |req|
Gem::Requirement.new(req).prerelease?
end
- warning "prerelease dependency on #{dep} is not recommended" if
prerelease_dep
overly_strict = dep.requirement.requirements.length == 1 &&
@@ -2820,7 +2837,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
base = dep_version.segments.first 2
- warning <<-WARNING
pessimistic dependency on #{dep} may be overly strict
if #{dep.name} is semantically versioned, use:
add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}', '>= #{dep_version}'
@@ -2842,13 +2859,19 @@ pessimistic dependency on #{dep} may be overly strict
", '>= #{dep_version}'"
end
- warning <<-WARNING
open-ended dependency on #{dep} is not recommended
if #{dep.name} is semantically versioned, use:
add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}'#{bugfix}
WARNING
end
end
end
##
@@ -1222,8 +1222,8 @@ Also, a list:
end
@@ruby = rubybin
- @@good_rake = "#{rubybin} #{File.expand_path('../../../test/rubygems/good_rake.rb', __FILE__)}"
- @@bad_rake = "#{rubybin} #{File.expand_path('../../../test/rubygems/bad_rake.rb', __FILE__)}"
##
# Construct a new Gem::Dependency.
@@ -0,0 +1,309 @@