An error caused by searching for a dependency that is completely unknown, i.e. has no versions available whatsoever.
A state that encapsulates a set of {#requirements} with an {Array} of possibilities
A state that encapsulates a single possibility to fulfill the given {#requirement}
@!visibility private
Provides information about specifications and dependencies to the resolver, allowing the {Resolver} class to remain generic while still providing power and flexibility.
This module contains the methods that users of Gem::Resolver::Molinillo
must to implement, using knowledge of their own model classes.
@!visibility private @see DependencyGraph#detach_vertex_named
Delegates
all {Gem::Resolver::Molinillo::ResolutionState} methods to a ‘#state` property.
Delegates
all {Gem::Resolver::Molinillo::SpecificationProvider} methods to a ‘#specification_provider` property.
Returns a Matchdata object (or nil
) based on self
and the given pattern
.
Note: also updates Regexp-related global variables.
Computes regexp
by converting pattern
(if not already a Regexp).
regexp = Regexp.new(pattern)
Computes matchdata
, which will be either a MatchData object or nil
(see Regexp#match
):
matchdata = <tt>regexp.match(self)
With no block given, returns the computed matchdata
:
'foo'.match('f') # => #<MatchData "f"> 'foo'.match('o') # => #<MatchData "o"> 'foo'.match('x') # => nil
If Integer argument offset
is given, the search begins at index offset
:
'foo'.match('f', 1) # => nil 'foo'.match('o', 1) # => #<MatchData "o">
With a block given, calls the block with the computed matchdata
and returns the block’s return value:
'foo'.match(/o/) {|matchdata| matchdata } # => #<MatchData "o"> 'foo'.match(/x/) {|matchdata| matchdata } # => nil 'foo'.match(/f/, 1) {|matchdata| matchdata } # => nil
Returns true
or false
based on whether a match is found for self
and pattern
.
Note: does not update Regexp-related global variables.
Computes regexp
by converting pattern
(if not already a Regexp).
regexp = Regexp.new(pattern)
Returns true
if self+.match(regexp)
returns a Matchdata object, false
otherwise:
'foo'.match?(/o/) # => true 'foo'.match?('o') # => true 'foo'.match?(/x/) # => false
If Integer argument offset
is given, the search begins at index offset
:
'foo'.match?('f', 1) # => false 'foo'.match?('o', 1) # => true
Return the matchee associated with this NoMatchingPatternKeyError
exception.
Returns a MatchData
object describing the match, or nil
if there was no match. This is equivalent to retrieving the value of the special variable $~
following a normal match. If the second parameter is present, it specifies the position in the string to begin the search.
/(.)(.)(.)/.match("abc")[2] #=> "b" /(.)(.)/.match("abc", 1)[2] #=> "c"
If a block is given, invoke the block with MatchData
if match succeed, so that you can write
/M(.*)/.match("Matz") do |m| puts m[0] puts m[1] end
instead of
if m = /M(.*)/.match("Matz") puts m[0] puts m[1] end
The return value is a value from block execution in this case.
Returns true
or false
to indicate whether the regexp is matched or not without updating $~ and other related variables. If the second parameter is present, it specifies the position in the string to begin the search.
/R.../.match?("Ruby") #=> true /R.../.match?("Ruby", 1) #=> false /P.../.match?("Ruby") #=> false $& #=> nil
Returns sym.to_s.match
.
Returns sym.to_s.match?
.
Tests whether the given pattern
is matched from the current scan pointer. Returns the length of the match, or nil
. The scan pointer is not advanced.
s = StringScanner.new('test string') p s.match?(/\w+/) # -> 4 p s.match?(/\w+/) # -> 4 p s.match?("test") # -> 4 p s.match?(/\s+/) # -> nil
Returns true
if and only if the last match was successful.
s = StringScanner.new('test string') s.match?(/\w+/) # => 4 s.matched? # => true s.match?(/\d+/) # => nil s.matched? # => false
Returns the last matched string.
s = StringScanner.new('test string') s.match?(/\w+/) # -> 4 s.matched # -> "test"
Returns the captured substring corresponding to the argument. n can be a string or symbol to reference a named capture.
m = /(.)(.)(\d+)(\d)(\w)?/.match("THX1138.") m.match(0) #=> "HX1138" m.match(4) #=> "8" m.match(5) #=> nil m = /(?<foo>.)(.)(?<bar>.+)/.match("hoge") m.match(:foo) #=> "h" m.match(:bar) #=> "ge"
The first form returns the MatchData
object generated by the last successful pattern match. Equivalent to reading the special global variable $~
(see Special global variables in Regexp
for details).
The second form returns the nth field in this MatchData
object. n can be a string or symbol to reference a named capture.
Note that the last_match
is local to the thread and method scope of the method that did the pattern match.
/c(.)t/ =~ 'cat' #=> 0 Regexp.last_match #=> #<MatchData "cat" 1:"a"> Regexp.last_match(0) #=> "cat" Regexp.last_match(1) #=> "a" Regexp.last_match(2) #=> nil /(?<lhs>\w+)\s*=\s*(?<rhs>\w+)/ =~ "var = val" Regexp.last_match #=> #<MatchData "var = val" lhs:"var" rhs:"val"> Regexp.last_match(:lhs) #=> "var" Regexp.last_match(:rhs) #=> "val"
Returns the size of the most recent match in bytes, or nil
if there was no recent match. This is different than matched.size
, which will return the size in characters.
s = StringScanner.new('test string') s.check /\w+/ # -> "test" s.matched_size # -> 4 s.check /\d+/ # -> nil s.matched_size # -> nil