mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rubygems: Update to RubyGems HEAD(fe61e4c112).
this version contains new feature that warn invalid SPDX license identifiers. https://github.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
This commit is contained in:
parent
230b8d533e
commit
59991b6ac5
16 changed files with 510 additions and 85 deletions
|
@ -1,3 +1,11 @@
|
|||
Wed Sep 9 07:46:32 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
||||
|
||||
* lib/rubygems: Update to RubyGems HEAD(fe61e4c112).
|
||||
this version contains new feature that warn invalid SPDX license
|
||||
identifiers. https://github.com/rubygems/rubygems/pull/1249
|
||||
and #1032, #1023, #1332, #1328, #1306, #1321, #1324
|
||||
* test/rubygems: ditto.
|
||||
|
||||
Tue Sep 8 23:17:36 2015 Yuki Nishijima <mail@yukinishijima.net>
|
||||
|
||||
* gems/bundled_gems: Upgrade the did_you_mean gem to 1.0.0.beta2.
|
||||
|
|
|
@ -1203,6 +1203,7 @@ module Gem
|
|||
autoload :DependencyList, 'rubygems/dependency_list'
|
||||
autoload :DependencyResolver, 'rubygems/resolver'
|
||||
autoload :Installer, 'rubygems/installer'
|
||||
autoload :Licenses, 'rubygems/util/licenses'
|
||||
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
|
||||
The default source is https://rubygems.org, but you may have other 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"
|
||||
"GEMNAME name of gem to update"
|
||||
end
|
||||
|
||||
def defaults_str # :nodoc:
|
||||
|
@ -64,7 +64,7 @@ command to remove old versions.
|
|||
end
|
||||
|
||||
def usage # :nodoc:
|
||||
"#{program_name} REGEXP [REGEXP ...]"
|
||||
"#{program_name} GEMNAME [GEMNAME ...]"
|
||||
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
|
||||
rescue Resolv::ResolvError => e
|
||||
verbose "Getting SRV record failed: #{e}"
|
||||
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.
|
||||
# Returns +true+ if the gist or git 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
|
||||
token = get
|
||||
|
||||
case type
|
||||
case token.type
|
||||
when :section then
|
||||
@tokens.skip :newline
|
||||
|
||||
case data
|
||||
case token.value
|
||||
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
|
||||
token = get until @tokens.empty? or peek.first == :section
|
||||
end
|
||||
else
|
||||
raise "BUG: unhandled token #{type} (#{data.inspect}) at line #{line} column #{column}"
|
||||
raise "BUG: unhandled token #{token.type} (#{token.value.inspect}) at line #{token.line} column #{token.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
|
||||
token = @tokens.shift
|
||||
|
||||
type, value, column, line = current_token
|
||||
if expected_types and not Array(expected_types).include? token.type then
|
||||
unget token
|
||||
|
||||
if expected_types and not Array(expected_types).include? type then
|
||||
unget current_token
|
||||
|
||||
message = "unexpected token [#{type.inspect}, #{value.inspect}], " +
|
||||
message = "unexpected token [#{token.type.inspect}, #{token.value.inspect}], " +
|
||||
"expected #{expected_types.inspect}"
|
||||
|
||||
raise Gem::RequestSet::Lockfile::ParseError.new message, column, line, @filename
|
||||
raise Gem::RequestSet::Lockfile::ParseError.new message, token.column, token.line, @filename
|
||||
end
|
||||
|
||||
if expected_value and expected_value != value then
|
||||
unget current_token
|
||||
if expected_value and expected_value != token.value then
|
||||
unget token
|
||||
|
||||
message = "unexpected token [#{type.inspect}, #{value.inspect}], " +
|
||||
message = "unexpected token [#{token.type.inspect}, #{token.value.inspect}], " +
|
||||
"expected [#{expected_types.inspect}, " +
|
||||
"#{expected_value.inspect}]"
|
||||
|
||||
raise Gem::RequestSet::Lockfile::ParseError.new message, column, line, @filename
|
||||
raise Gem::RequestSet::Lockfile::ParseError.new message, token.column, token.line, @filename
|
||||
end
|
||||
|
||||
current_token
|
||||
token
|
||||
end
|
||||
|
||||
def parse_DEPENDENCIES # :nodoc:
|
||||
while not @tokens.empty? and :text == peek.first do
|
||||
_, name, = get :text
|
||||
while not @tokens.empty? and :text == peek.type do
|
||||
token = get :text
|
||||
|
||||
requirements = []
|
||||
|
||||
|
@ -77,17 +75,17 @@ class Gem::RequestSet::Lockfile::Parser
|
|||
when :bang then
|
||||
get :bang
|
||||
|
||||
requirements << pinned_requirement(name)
|
||||
requirements << pinned_requirement(token.value)
|
||||
when :l_paren then
|
||||
get :l_paren
|
||||
|
||||
loop do
|
||||
_, op, = get :requirement
|
||||
_, version, = get :text
|
||||
op = get(:requirement).value
|
||||
version = get(:text).value
|
||||
|
||||
requirements << "#{op} #{version}"
|
||||
|
||||
break unless peek[0] == :comma
|
||||
break unless peek.type == :comma
|
||||
|
||||
get :comma
|
||||
end
|
||||
|
@ -96,13 +94,13 @@ class Gem::RequestSet::Lockfile::Parser
|
|||
|
||||
if peek[0] == :bang then
|
||||
requirements.clear
|
||||
requirements << pinned_requirement(name)
|
||||
requirements << pinned_requirement(token.value)
|
||||
|
||||
get :bang
|
||||
end
|
||||
end
|
||||
|
||||
@set.gem name, *requirements
|
||||
@set.gem token.value, *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
|
||||
data = get(:text).value
|
||||
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
|
||||
while not @tokens.empty? and :text == peek.type do
|
||||
token = get :text
|
||||
name = token.value
|
||||
column = token.column
|
||||
|
||||
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]
|
||||
token = get [:text, :requirement]
|
||||
type = token.type
|
||||
data = token.value
|
||||
|
||||
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
|
||||
repository = get(:text).value
|
||||
|
||||
skip :newline
|
||||
|
||||
get :entry, 'revision'
|
||||
_, revision, = get :text
|
||||
revision = get(:text).value
|
||||
|
||||
skip :newline
|
||||
|
||||
type, value = peek.first 2
|
||||
type = peek.type
|
||||
value = peek.value
|
||||
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
|
||||
while not @tokens.empty? and :text == peek.type do
|
||||
token = get :text
|
||||
name = token.value
|
||||
column = token.column
|
||||
|
||||
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]
|
||||
token = get [:text, :requirement]
|
||||
type = token.type
|
||||
data = token.value
|
||||
|
||||
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
|
||||
directory = get(:text).value
|
||||
|
||||
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
|
||||
token = get :text
|
||||
name = token.value
|
||||
column = token.column
|
||||
|
||||
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]
|
||||
token = get [:text, :requirement]
|
||||
type = token.type
|
||||
data = token.value
|
||||
|
||||
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
|
||||
name = get(:text).value
|
||||
|
||||
@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
|
||||
version = get(:text).value
|
||||
|
||||
requirements = ["#{op} #{version}"]
|
||||
|
||||
while peek[0] == :comma do
|
||||
while peek.type == :comma do
|
||||
get :comma
|
||||
_, op, = get :requirement
|
||||
_, version, = get :text
|
||||
op = get(:requirement).value
|
||||
version = get(:text).value
|
||||
|
||||
requirements << "#{op} #{version}"
|
||||
end
|
||||
|
|
|
@ -2,6 +2,9 @@ require 'strscan'
|
|||
require 'rubygems/request_set/lockfile/parser'
|
||||
|
||||
class Gem::RequestSet::Lockfile::Tokenizer
|
||||
Token = Struct.new :type, :value, :column, :line
|
||||
EOF = Token.new :EOF
|
||||
|
||||
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
|
||||
@tokens.map { |token| [token.type, token.value, token.column, token.line] }
|
||||
end
|
||||
|
||||
def skip type
|
||||
@tokens.shift while not @tokens.empty? and peek.first == type
|
||||
@tokens.shift while not @tokens.empty? and peek.type == type
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -48,7 +51,7 @@ class Gem::RequestSet::Lockfile::Tokenizer
|
|||
alias :shift :next_token
|
||||
|
||||
def peek
|
||||
@tokens.first || [:EOF]
|
||||
@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)]
|
||||
token = Token.new(: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)]
|
||||
Token.new(:text, text, *token_pos(pos))
|
||||
else
|
||||
[:section, s.matched, *token_pos(pos)]
|
||||
Token.new(: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)]
|
||||
Token.new(:entry, s[1], *token_pos(pos))
|
||||
when s.scan(/\(/) then
|
||||
[:l_paren, nil, *token_pos(pos)]
|
||||
Token.new(:l_paren, nil, *token_pos(pos))
|
||||
when s.scan(/\)/) then
|
||||
[:r_paren, nil, *token_pos(pos)]
|
||||
Token.new(:r_paren, nil, *token_pos(pos))
|
||||
when s.scan(/<=|>=|=|~>|<|>|!=/) then
|
||||
[:requirement, s.matched, *token_pos(pos)]
|
||||
Token.new(:requirement, s.matched, *token_pos(pos))
|
||||
when s.scan(/,/) then
|
||||
[:comma, nil, *token_pos(pos)]
|
||||
Token.new(:comma, nil, *token_pos(pos))
|
||||
when s.scan(/!/) then
|
||||
[:bang, nil, *token_pos(pos)]
|
||||
Token.new(:bang, nil, *token_pos(pos))
|
||||
when s.scan(/[^\s),!]*/) then
|
||||
[:text, s.matched, *token_pos(pos)]
|
||||
Token.new(: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.
|
||||
# The most commonly used OSI approved licenses are MIT and Apache-2.0.
|
||||
# GitHub 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']
|
||||
# spec.licenses = ['MIT', 'GPL-2.0']
|
||||
|
||||
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">
|
||||
#
|
||||
# Because patch-level is taken into account, be very careful specifying using
|
||||
# `<=`: `<= 2.2.2` will not match any patch-level of 2.2.2 after the `p0`
|
||||
# release. It is much safer to specify `< 2.2.3` instead
|
||||
#
|
||||
# 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'
|
||||
#
|
||||
# # Only with ruby between 2.2.0 and 2.2.2
|
||||
# spec.required_ruby_version = ['>= 2.2.0', '< 2.2.3']
|
||||
|
||||
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
|
||||
spec.contains_requirable_file? path if spec
|
||||
}
|
||||
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?
|
||||
s.contains_requirable_file? path unless s.nil? || 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 }
|
||||
specs.find_all { |spec| spec.contains_requirable_file? path if spec }
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -2712,11 +2719,18 @@ class Gem::Specification < Gem::BasicSpecification
|
|||
raise Gem::InvalidSpecificationException,
|
||||
"each license must be 64 characters or less"
|
||||
end
|
||||
|
||||
if !Gem::Licenses::IDENTIFIERS.include?(license) && !license.eql?(Gem::Licenses::NONSTANDARD)
|
||||
warning <<-warning
|
||||
WARNING: license value '#{license}' is invalid. Use a license identifier from
|
||||
http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license.
|
||||
warning
|
||||
end
|
||||
}
|
||||
|
||||
warning <<-warning if licenses.empty?
|
||||
licenses is empty, but is recommended. Use a license abbreviation from:
|
||||
http://opensource.org/licenses/alphabetical
|
||||
licenses is empty, but is recommended. Use a license identifier from
|
||||
http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license.
|
||||
warning
|
||||
|
||||
validate_permissions
|
||||
|
@ -2788,23 +2802,26 @@ http://opensource.org/licenses/alphabetical
|
|||
# versioning.
|
||||
|
||||
def validate_dependencies # :nodoc:
|
||||
seen = {}
|
||||
# NOTE: see REFACTOR note in Gem::Dependency about types - this might be brittle
|
||||
seen = Gem::Dependency::TYPES.inject({}) { |types, type| types.merge({ type => {}}) }
|
||||
|
||||
error_messages = []
|
||||
warning_messages = []
|
||||
dependencies.each do |dep|
|
||||
if prev = seen[dep.name] then
|
||||
raise Gem::InvalidSpecificationException, <<-MESSAGE
|
||||
if prev = seen[dep.type][dep.name] then
|
||||
error_messages << <<-MESSAGE
|
||||
duplicate dependency on #{dep}, (#{prev.requirement}) use:
|
||||
add_runtime_dependency '#{dep.name}', '#{dep.requirement}', '#{prev.requirement}'
|
||||
add_#{dep.type}_dependency '#{dep.name}', '#{dep.requirement}', '#{prev.requirement}'
|
||||
MESSAGE
|
||||
end
|
||||
|
||||
seen[dep.name] = dep
|
||||
seen[dep.type][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
|
||||
warning_messages << "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
|
||||
warning_messages << <<-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
|
||||
warning_messages << <<-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
|
||||
if error_messages.any?
|
||||
raise Gem::InvalidSpecificationException, error_messages.join
|
||||
end
|
||||
if warning_messages.any?
|
||||
warning_messages.each { |warning_message| warning warning_message }
|
||||
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__)}"
|
||||
@@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.
|
||||
|
|
309
lib/rubygems/util/licenses.rb
Normal file
309
lib/rubygems/util/licenses.rb
Normal file
|
@ -0,0 +1,309 @@
|
|||
class Gem::Licenses
|
||||
NONSTANDARD = 'Nonstandard'.freeze
|
||||
|
||||
# Software Package Data Exchange (SPDX) standard open-source software
|
||||
# license identifiers
|
||||
IDENTIFIERS = %w(
|
||||
AAL
|
||||
ADSL
|
||||
AFL-1.1
|
||||
AFL-1.2
|
||||
AFL-2.0
|
||||
AFL-2.1
|
||||
AFL-3.0
|
||||
AGPL-1.0
|
||||
AGPL-3.0
|
||||
AMDPLPA
|
||||
AML
|
||||
AMPAS
|
||||
ANTLR-PD
|
||||
APAFML
|
||||
APL-1.0
|
||||
APSL-1.0
|
||||
APSL-1.1
|
||||
APSL-1.2
|
||||
APSL-2.0
|
||||
Abstyles
|
||||
Adobe-2006
|
||||
Adobe-Glyph
|
||||
Afmparse
|
||||
Aladdin
|
||||
Apache-1.0
|
||||
Apache-1.1
|
||||
Apache-2.0
|
||||
Artistic-1.0
|
||||
Artistic-1.0-Perl
|
||||
Artistic-1.0-cl8
|
||||
Artistic-2.0
|
||||
BSD-2-Clause
|
||||
BSD-2-Clause-FreeBSD
|
||||
BSD-2-Clause-NetBSD
|
||||
BSD-3-Clause
|
||||
BSD-3-Clause-Attribution
|
||||
BSD-3-Clause-Clear
|
||||
BSD-3-Clause-LBNL
|
||||
BSD-4-Clause
|
||||
BSD-4-Clause-UC
|
||||
BSD-Protection
|
||||
BSL-1.0
|
||||
Bahyph
|
||||
Barr
|
||||
Beerware
|
||||
BitTorrent-1.0
|
||||
BitTorrent-1.1
|
||||
Borceux
|
||||
CATOSL-1.1
|
||||
CC-BY-1.0
|
||||
CC-BY-2.0
|
||||
CC-BY-2.5
|
||||
CC-BY-3.0
|
||||
CC-BY-4.0
|
||||
CC-BY-NC-1.0
|
||||
CC-BY-NC-2.0
|
||||
CC-BY-NC-2.5
|
||||
CC-BY-NC-3.0
|
||||
CC-BY-NC-4.0
|
||||
CC-BY-NC-ND-1.0
|
||||
CC-BY-NC-ND-2.0
|
||||
CC-BY-NC-ND-2.5
|
||||
CC-BY-NC-ND-3.0
|
||||
CC-BY-NC-ND-4.0
|
||||
CC-BY-NC-SA-1.0
|
||||
CC-BY-NC-SA-2.0
|
||||
CC-BY-NC-SA-2.5
|
||||
CC-BY-NC-SA-3.0
|
||||
CC-BY-NC-SA-4.0
|
||||
CC-BY-ND-1.0
|
||||
CC-BY-ND-2.0
|
||||
CC-BY-ND-2.5
|
||||
CC-BY-ND-3.0
|
||||
CC-BY-ND-4.0
|
||||
CC-BY-SA-1.0
|
||||
CC-BY-SA-2.0
|
||||
CC-BY-SA-2.5
|
||||
CC-BY-SA-3.0
|
||||
CC-BY-SA-4.0
|
||||
CC0-1.0
|
||||
CDDL-1.0
|
||||
CDDL-1.1
|
||||
CECILL-1.0
|
||||
CECILL-1.1
|
||||
CECILL-2.0
|
||||
CECILL-B
|
||||
CECILL-C
|
||||
CNRI-Jython
|
||||
CNRI-Python
|
||||
CNRI-Python-GPL-Compatible
|
||||
CPAL-1.0
|
||||
CPL-1.0
|
||||
CPOL-1.02
|
||||
CUA-OPL-1.0
|
||||
Caldera
|
||||
ClArtistic
|
||||
Condor-1.1
|
||||
Crossword
|
||||
Cube
|
||||
D-FSL-1.0
|
||||
DOC
|
||||
DSDP
|
||||
Dotseqn
|
||||
ECL-1.0
|
||||
ECL-2.0
|
||||
EFL-1.0
|
||||
EFL-2.0
|
||||
EPL-1.0
|
||||
EUDatagrid
|
||||
EUPL-1.0
|
||||
EUPL-1.1
|
||||
Entessa
|
||||
ErlPL-1.1
|
||||
Eurosym
|
||||
FSFUL
|
||||
FSFULLR
|
||||
FTL
|
||||
Fair
|
||||
Frameworx-1.0
|
||||
FreeImage
|
||||
GFDL-1.1
|
||||
GFDL-1.2
|
||||
GFDL-1.3
|
||||
GL2PS
|
||||
GPL-1.0
|
||||
GPL-2.0
|
||||
GPL-3.0
|
||||
Giftware
|
||||
Glide
|
||||
Glulxe
|
||||
HPND
|
||||
HaskellReport
|
||||
IBM-pibs
|
||||
ICU
|
||||
IJG
|
||||
IPA
|
||||
IPL-1.0
|
||||
ISC
|
||||
ImageMagick
|
||||
Imlib2
|
||||
Intel
|
||||
Intel-ACPI
|
||||
JSON
|
||||
JasPer-2.0
|
||||
LGPL-2.0
|
||||
LGPL-2.1
|
||||
LGPL-3.0
|
||||
LGPLLR
|
||||
LPL-1.0
|
||||
LPL-1.02
|
||||
LPPL-1.0
|
||||
LPPL-1.1
|
||||
LPPL-1.2
|
||||
LPPL-1.3a
|
||||
LPPL-1.3c
|
||||
Latex2e
|
||||
Leptonica
|
||||
Libpng
|
||||
MIT
|
||||
MIT-CMU
|
||||
MIT-advertising
|
||||
MIT-enna
|
||||
MIT-feh
|
||||
MITNFA
|
||||
MPL-1.0
|
||||
MPL-1.1
|
||||
MPL-2.0
|
||||
MPL-2.0-no-copyleft-exception
|
||||
MS-PL
|
||||
MS-RL
|
||||
MTLL
|
||||
MakeIndex
|
||||
MirOS
|
||||
Motosoto
|
||||
Multics
|
||||
Mup
|
||||
NASA-1.3
|
||||
NBPL-1.0
|
||||
NCSA
|
||||
NGPL
|
||||
NLPL
|
||||
NOSL
|
||||
NPL-1.0
|
||||
NPL-1.1
|
||||
NPOSL-3.0
|
||||
NRL
|
||||
NTP
|
||||
Naumen
|
||||
NetCDF
|
||||
Newsletr
|
||||
Nokia
|
||||
Noweb
|
||||
Nunit
|
||||
OCLC-2.0
|
||||
ODbL-1.0
|
||||
OFL-1.0
|
||||
OFL-1.1
|
||||
OGTSL
|
||||
OLDAP-1.1
|
||||
OLDAP-1.2
|
||||
OLDAP-1.3
|
||||
OLDAP-1.4
|
||||
OLDAP-2.0
|
||||
OLDAP-2.0.1
|
||||
OLDAP-2.1
|
||||
OLDAP-2.2
|
||||
OLDAP-2.2.1
|
||||
OLDAP-2.2.2
|
||||
OLDAP-2.3
|
||||
OLDAP-2.4
|
||||
OLDAP-2.5
|
||||
OLDAP-2.6
|
||||
OLDAP-2.7
|
||||
OLDAP-2.8
|
||||
OML
|
||||
OPL-1.0
|
||||
OSL-1.0
|
||||
OSL-1.1
|
||||
OSL-2.0
|
||||
OSL-2.1
|
||||
OSL-3.0
|
||||
OpenSSL
|
||||
PDDL-1.0
|
||||
PHP-3.0
|
||||
PHP-3.01
|
||||
Plexus
|
||||
PostgreSQL
|
||||
Python-2.0
|
||||
QPL-1.0
|
||||
Qhull
|
||||
RHeCos-1.1
|
||||
RPL-1.1
|
||||
RPL-1.5
|
||||
RPSL-1.0
|
||||
RSA-MD
|
||||
RSCPL
|
||||
Rdisc
|
||||
Ruby
|
||||
SAX-PD
|
||||
SCEA
|
||||
SGI-B-1.0
|
||||
SGI-B-1.1
|
||||
SGI-B-2.0
|
||||
SISSL
|
||||
SISSL-1.2
|
||||
SMLNJ
|
||||
SNIA
|
||||
SPL-1.0
|
||||
SWL
|
||||
Saxpath
|
||||
SimPL-2.0
|
||||
Sleepycat
|
||||
Spencer-86
|
||||
Spencer-94
|
||||
Spencer-99
|
||||
SugarCRM-1.1.3
|
||||
TCL
|
||||
TMate
|
||||
TORQUE-1.1
|
||||
TOSL
|
||||
UPL-1.0
|
||||
Unicode-TOU
|
||||
Unlicense
|
||||
VOSTROM
|
||||
VSL-1.0
|
||||
Vim
|
||||
W3C
|
||||
W3C-19980720
|
||||
WTFPL
|
||||
Watcom-1.0
|
||||
Wsuipa
|
||||
X11
|
||||
XFree86-1.1
|
||||
XSkat
|
||||
Xerox
|
||||
Xnet
|
||||
YPL-1.0
|
||||
YPL-1.1
|
||||
ZPL-1.1
|
||||
ZPL-2.0
|
||||
ZPL-2.1
|
||||
Zed
|
||||
Zend-2.0
|
||||
Zimbra-1.3
|
||||
Zimbra-1.4
|
||||
Zlib
|
||||
bzip2-1.0.5
|
||||
bzip2-1.0.6
|
||||
diffmark
|
||||
dvipdfm
|
||||
eGenix
|
||||
gSOAP-1.3b
|
||||
gnuplot
|
||||
iMatix
|
||||
libtiff
|
||||
mpich2
|
||||
psfrag
|
||||
psutils
|
||||
xinetd
|
||||
xpp
|
||||
zlib-acknowledgement
|
||||
).freeze
|
||||
end
|
|
@ -10,5 +10,15 @@ class TestConfig < Gem::TestCase
|
|||
assert_equal "#{spec.full_gem_path}/data/a", Gem.datadir('a')
|
||||
end
|
||||
|
||||
def test_good_rake_path_is_escaped
|
||||
path = Gem::TestCase.class_eval('@@good_rake')
|
||||
assert_match(/ruby "[^"]*good_rake.rb"/, path)
|
||||
end
|
||||
|
||||
def test_bad_rake_path_is_escaped
|
||||
path = Gem::TestCase.class_eval('@@bad_rake')
|
||||
assert_match(/ruby "[^"]*bad_rake.rb"/, path)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -1311,7 +1311,7 @@ class TestGem < Gem::TestCase
|
|||
ENV['GEM_PATH'] = path
|
||||
ENV['RUBYGEMS_GEMDEPS'] = "-"
|
||||
|
||||
out = `#{Gem.ruby.dup.untaint} -I #{LIB_PATH.untaint} -rubygems -e "p Gem.loaded_specs.values.map(&:full_name).sort"`
|
||||
out = `#{Gem.ruby.dup.untaint} -I "#{LIB_PATH.untaint}" -rubygems -e "p Gem.loaded_specs.values.map(&:full_name).sort"`
|
||||
|
||||
assert_equal '["a-1", "b-1", "c-1"]', out.strip
|
||||
end
|
||||
|
@ -1343,7 +1343,7 @@ class TestGem < Gem::TestCase
|
|||
|
||||
Dir.mkdir "sub1"
|
||||
out = Dir.chdir "sub1" do
|
||||
`#{Gem.ruby.dup.untaint} -I #{LIB_PATH.untaint} -rubygems -e "p Gem.loaded_specs.values.map(&:full_name).sort"`
|
||||
`#{Gem.ruby.dup.untaint} -I "#{LIB_PATH.untaint}" -rubygems -e "p Gem.loaded_specs.values.map(&:full_name).sort"`
|
||||
end
|
||||
|
||||
Dir.rmdir "sub1"
|
||||
|
|
|
@ -252,6 +252,31 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
|
|||
dns.verify
|
||||
end
|
||||
|
||||
def test_api_endpoint_timeout_warning
|
||||
uri = URI.parse "http://gems.example.com/foo"
|
||||
|
||||
dns = MiniTest::Mock.new
|
||||
def dns.getresource arg, *rest
|
||||
raise Resolv::ResolvError.new('timeout!')
|
||||
end
|
||||
|
||||
fetch = Gem::RemoteFetcher.new nil, dns
|
||||
begin
|
||||
old_verbose, Gem.configuration.verbose = Gem.configuration.verbose, 1
|
||||
endpoint = use_ui @ui do
|
||||
fetch.api_endpoint(uri)
|
||||
end
|
||||
ensure
|
||||
Gem.configuration.verbose = old_verbose
|
||||
end
|
||||
|
||||
assert_equal uri, endpoint
|
||||
|
||||
assert_equal "Getting SRV record failed: timeout!\n", @ui.output
|
||||
|
||||
dns.verify
|
||||
end
|
||||
|
||||
def test_cache_update_path
|
||||
uri = URI 'http://example/file'
|
||||
path = File.join @tempdir, 'file'
|
||||
|
@ -1010,3 +1035,4 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class TestGemRequestSetLockfileTokenizer < Gem::TestCase
|
|||
|
||||
assert_equal :newline, tokenizer.next_token.first
|
||||
|
||||
assert_equal [:EOF], tokenizer.peek
|
||||
assert_equal :EOF, tokenizer.peek.first
|
||||
end
|
||||
|
||||
def test_skip
|
||||
|
|
|
@ -1178,7 +1178,7 @@ dependencies: []
|
|||
s.summary = 'summary'
|
||||
s.description = 'description'
|
||||
s.authors = 'author a', 'author b'
|
||||
s.licenses = 'BSD'
|
||||
s.licenses = 'BSD-2-Clause'
|
||||
s.files = 'lib/file.rb'
|
||||
s.test_files = 'test/file.rb'
|
||||
s.rdoc_options = '--foo'
|
||||
|
@ -2608,12 +2608,14 @@ end
|
|||
end
|
||||
end
|
||||
|
||||
def test_validate_dependencies_open_ended
|
||||
def test_validate_dependencies_duplicates
|
||||
util_setup_validate
|
||||
|
||||
Dir.chdir @tempdir do
|
||||
@a1.add_runtime_dependency 'b', '~> 1.2'
|
||||
@a1.add_runtime_dependency 'b', '>= 1.2.3'
|
||||
@a1.add_development_dependency 'c', '~> 1.2'
|
||||
@a1.add_development_dependency 'c', '>= 1.2.3'
|
||||
|
||||
use_ui @ui do
|
||||
e = assert_raises Gem::InvalidSpecificationException do
|
||||
|
@ -2623,6 +2625,8 @@ end
|
|||
expected = <<-EXPECTED
|
||||
duplicate dependency on b (>= 1.2.3), (~> 1.2) use:
|
||||
add_runtime_dependency 'b', '>= 1.2.3', '~> 1.2'
|
||||
duplicate dependency on c (>= 1.2.3, development), (~> 1.2) use:
|
||||
add_development_dependency 'c', '>= 1.2.3', '~> 1.2'
|
||||
EXPECTED
|
||||
|
||||
assert_equal expected, e.message
|
||||
|
@ -2634,6 +2638,21 @@ duplicate dependency on b (>= 1.2.3), (~> 1.2) use:
|
|||
end
|
||||
end
|
||||
|
||||
def test_validate_dependencies_allowed_duplicates
|
||||
util_setup_validate
|
||||
|
||||
Dir.chdir @tempdir do
|
||||
@a1.add_runtime_dependency 'b', '~> 1.2'
|
||||
@a1.add_development_dependency 'b', '= 1.2.3'
|
||||
|
||||
use_ui @ui do
|
||||
@a1.validate
|
||||
end
|
||||
|
||||
assert_equal '', @ui.error, 'warning'
|
||||
end
|
||||
end
|
||||
|
||||
def test_validate_description
|
||||
util_setup_validate
|
||||
|
||||
|
@ -2832,8 +2851,22 @@ duplicate dependency on b (>= 1.2.3), (~> 1.2) use:
|
|||
end
|
||||
|
||||
assert_match <<-warning, @ui.error
|
||||
WARNING: licenses is empty, but is recommended. Use a license abbreviation from:
|
||||
http://opensource.org/licenses/alphabetical
|
||||
WARNING: licenses is empty, but is recommended. Use a license identifier from
|
||||
http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.
|
||||
warning
|
||||
end
|
||||
|
||||
def test_validate_license_values
|
||||
util_setup_validate
|
||||
|
||||
use_ui @ui do
|
||||
@a1.licenses = ['BSD']
|
||||
@a1.validate
|
||||
end
|
||||
|
||||
assert_match <<-warning, @ui.error
|
||||
WARNING: license value 'BSD' is invalid. Use a license identifier from
|
||||
http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.
|
||||
warning
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue