summaryrefslogtreecommitdiff
path: root/lib/rubygems/request_set/lockfile
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-21 10:20:47 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-21 10:20:47 +0000
commit5335ce0e060c7a2a0b01c57f8f8a64254f2658e1 (patch)
treec63321cb7c7c5c15454a79d81123c7188be2c51e /lib/rubygems/request_set/lockfile
parent2f023c5dbaadede9ceac3eb9ac0e73f3050e5ada (diff)
Merge master branch from rubygems/rubygems upstream.
* Enable Style/MethodDefParentheses in Rubocop https://github.com/rubygems/rubygems/pull/2478 * Enable Style/MultilineIfThen in Rubocop https://github.com/rubygems/rubygems/pull/2479 * Fix required_ruby_version with prereleases and improve error message https://github.com/rubygems/rubygems/pull/2344 * Fix bundler rubygems binstub not properly looking for bundler https://github.com/rubygems/rubygems/pull/2426 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/request_set/lockfile')
-rw-r--r--lib/rubygems/request_set/lockfile/parser.rb26
-rw-r--r--lib/rubygems/request_set/lockfile/tokenizer.rb18
2 files changed, 22 insertions, 22 deletions
diff --git a/lib/rubygems/request_set/lockfile/parser.rb b/lib/rubygems/request_set/lockfile/parser.rb
index 368b56e6e6..0fe0405e32 100644
--- a/lib/rubygems/request_set/lockfile/parser.rb
+++ b/lib/rubygems/request_set/lockfile/parser.rb
@@ -3,7 +3,7 @@ class Gem::RequestSet::Lockfile::Parser
###
# Parses lockfiles
- def initialize tokenizer, set, platforms, filename = nil
+ def initialize(tokenizer, set, platforms, filename = nil)
@tokens = tokenizer
@filename = filename
@set = set
@@ -41,10 +41,10 @@ class Gem::RequestSet::Lockfile::Parser
##
# Gets the next token for a Lockfile
- def get expected_types = nil, expected_value = nil # :nodoc:
+ def get(expected_types = nil, expected_value = nil) # :nodoc:
token = @tokens.shift
- if expected_types and not Array(expected_types).include? token.type then
+ if expected_types and not Array(expected_types).include? token.type
unget token
message = "unexpected token [#{token.type.inspect}, #{token.value.inspect}], " +
@@ -53,7 +53,7 @@ class Gem::RequestSet::Lockfile::Parser
raise Gem::RequestSet::Lockfile::ParseError.new message, token.column, token.line, @filename
end
- if expected_value and expected_value != token.value then
+ if expected_value and expected_value != token.value
unget token
message = "unexpected token [#{token.type.inspect}, #{token.value.inspect}], " +
@@ -93,7 +93,7 @@ class Gem::RequestSet::Lockfile::Parser
get :r_paren
- if peek[0] == :bang then
+ if peek[0] == :bang
requirements.clear
requirements << pinned_requirement(token.value)
@@ -144,7 +144,7 @@ class Gem::RequestSet::Lockfile::Parser
type = token.type
data = token.value
- if type == :text and column == 4 then
+ if type == :text and column == 4
version, platform = data.split '-', 2
platform =
@@ -183,7 +183,7 @@ class Gem::RequestSet::Lockfile::Parser
type = peek.type
value = peek.value
- if type == :entry and %w[branch ref tag].include? value then
+ if type == :entry and %w[branch ref tag].include? value
get
get :text
@@ -214,7 +214,7 @@ class Gem::RequestSet::Lockfile::Parser
type = token.type
data = token.value
- if type == :text and column == 4 then
+ if type == :text and column == 4
last_spec = set.add_git_spec name, data, repository, revision, true
else
dependency = parse_dependency name, data
@@ -261,7 +261,7 @@ class Gem::RequestSet::Lockfile::Parser
type = token.type
data = token.value
- if type == :text and column == 4 then
+ if type == :text and column == 4
last_spec = set.add_vendor_gem name, directory
else
dependency = parse_dependency name, data
@@ -294,7 +294,7 @@ class Gem::RequestSet::Lockfile::Parser
# Parses the requirements following the dependency +name+ and the +op+ for
# the first token of the requirements and returns a Gem::Dependency object.
- def parse_dependency name, op # :nodoc:
+ def parse_dependency(name, op) # :nodoc:
return Gem::Dependency.new name, op unless peek[0] == :text
version = get(:text).value
@@ -314,7 +314,7 @@ class Gem::RequestSet::Lockfile::Parser
private
- def skip type # :nodoc:
+ def skip(type) # :nodoc:
@tokens.skip type
end
@@ -325,7 +325,7 @@ class Gem::RequestSet::Lockfile::Parser
@tokens.peek
end
- def pinned_requirement name # :nodoc:
+ def pinned_requirement(name) # :nodoc:
requirement = Gem::Dependency.new name
specification = @set.sets.flat_map { |set|
set.find_all(requirement)
@@ -337,7 +337,7 @@ class Gem::RequestSet::Lockfile::Parser
##
# Ungets the last token retrieved by #get
- def unget token # :nodoc:
+ def unget(token) # :nodoc:
@tokens.unshift token
end
end
diff --git a/lib/rubygems/request_set/lockfile/tokenizer.rb b/lib/rubygems/request_set/lockfile/tokenizer.rb
index a758743dda..bb69c85fb4 100644
--- a/lib/rubygems/request_set/lockfile/tokenizer.rb
+++ b/lib/rubygems/request_set/lockfile/tokenizer.rb
@@ -5,11 +5,11 @@ class Gem::RequestSet::Lockfile::Tokenizer
Token = Struct.new :type, :value, :column, :line
EOF = Token.new :EOF
- def self.from_file file
+ def self.from_file(file)
new File.read(file), file
end
- def initialize input, filename = nil, line = 0, pos = 0
+ def initialize(input, filename = nil, line = 0, pos = 0)
@line = line
@line_pos = pos
@tokens = []
@@ -17,7 +17,7 @@ class Gem::RequestSet::Lockfile::Tokenizer
tokenize input
end
- def make_parser set, platforms
+ def make_parser(set, platforms)
Gem::RequestSet::Lockfile::Parser.new self, set, platforms, @filename
end
@@ -25,7 +25,7 @@ class Gem::RequestSet::Lockfile::Tokenizer
@tokens.map { |token| [token.type, token.value, token.column, token.line] }
end
- def skip type
+ def skip(type)
@tokens.shift while not @tokens.empty? and peek.type == type
end
@@ -33,7 +33,7 @@ class Gem::RequestSet::Lockfile::Tokenizer
# Calculates the column (by byte) and the line of the current token based on
# +byte_offset+.
- def token_pos byte_offset # :nodoc:
+ def token_pos(byte_offset) # :nodoc:
[byte_offset - @line_pos, @line]
end
@@ -41,7 +41,7 @@ class Gem::RequestSet::Lockfile::Tokenizer
@tokens.empty?
end
- def unshift token
+ def unshift(token)
@tokens.unshift token
end
@@ -56,7 +56,7 @@ class Gem::RequestSet::Lockfile::Tokenizer
private
- def tokenize input
+ def tokenize(input)
require 'strscan'
s = StringScanner.new input
@@ -65,7 +65,7 @@ class Gem::RequestSet::Lockfile::Tokenizer
pos = s.pos if leading_whitespace = s.scan(/ +/)
- if s.scan(/[<|=>]{7}/) then
+ if s.scan(/[<|=>]{7}/)
message = "your #{@filename} contains merge conflict markers"
column, line = token_pos pos
@@ -80,7 +80,7 @@ class Gem::RequestSet::Lockfile::Tokenizer
@line += 1
token
when s.scan(/[A-Z]+/) then
- if leading_whitespace then
+ if leading_whitespace
text = s.matched
text += s.scan(/[^\s)]*/).to_s # in case of no match
Token.new(:text, text, *token_pos(pos))