module Pickle::Parser::Matchers
Public Instance Methods
capture_key_and_value_in_field()
click to toggle source
# File lib/pickle/parser/matchers.rb, line 82 def capture_key_and_value_in_field "(?:(\\w+): #{capture_value})" end
capture_name_in_label()
click to toggle source
# File lib/pickle/parser/matchers.rb, line 78 def capture_name_in_label "(?::? \"(#{match_quoted})\")" end
capture_number_in_ordinal()
click to toggle source
special capture methods
# File lib/pickle/parser/matchers.rb, line 74 def capture_number_in_ordinal '(?:(\d+)(?:st|nd|rd|th))' end
match_factory()
click to toggle source
# File lib/pickle/parser/matchers.rb, line 40 def match_factory "(?:#{config.factories.keys.map{|n| n.gsub('_','[_ ]')}.join('|')})" end
match_field()
click to toggle source
# File lib/pickle/parser/matchers.rb, line 28 def match_field "(?:\\w+: #{match_value})" end
match_fields()
click to toggle source
# File lib/pickle/parser/matchers.rb, line 32 def match_fields "(?:#{match_field}, )*#{match_field}" end
match_index()
click to toggle source
# File lib/pickle/parser/matchers.rb, line 8 def match_index "(?:first|last|#{match_ordinal})" end
match_indexed_model()
click to toggle source
# File lib/pickle/parser/matchers.rb, line 48 def match_indexed_model "(?:(?:#{match_index} )?#{match_factory})" end
match_label()
click to toggle source
# File lib/pickle/parser/matchers.rb, line 20 def match_label "(?::? \"#{match_quoted}\")" end
match_labeled_model()
click to toggle source
# File lib/pickle/parser/matchers.rb, line 52 def match_labeled_model "(?:#{match_factory}#{match_label})" end
match_mapping()
click to toggle source
# File lib/pickle/parser/matchers.rb, line 36 def match_mapping "(?:#{config.mappings.map(&:search).join('|')})" end
match_model()
click to toggle source
# File lib/pickle/parser/matchers.rb, line 56 def match_model "(?:#{match_mapping}|#{match_prefix}?(?:#{match_indexed_model}|#{match_labeled_model}))" end
match_ordinal()
click to toggle source
# File lib/pickle/parser/matchers.rb, line 4 def match_ordinal '(?:\d+(?:st|nd|rd|th))' end
match_plural_factory()
click to toggle source
# File lib/pickle/parser/matchers.rb, line 44 def match_plural_factory "(?:#{config.factories.keys.map{|n| n.pluralize.gsub('_','[_ ]')}.join('|')})" end
match_predicate()
click to toggle source
# File lib/pickle/parser/matchers.rb, line 60 def match_predicate "(?:#{config.predicates.map{|m| m.to_s.sub(/^has_/,'').sub(/\?$/,'').gsub('_','[_ ]')}.join('|')})" end
match_prefix()
click to toggle source
# File lib/pickle/parser/matchers.rb, line 12 def match_prefix '(?:(?:a|an|another|the|that) )' end
match_quoted()
click to toggle source
# File lib/pickle/parser/matchers.rb, line 16 def match_quoted '(?:\\\\"|[^\\"]|\\.)*' end
match_value()
click to toggle source
# File lib/pickle/parser/matchers.rb, line 24 def match_value "(?:\"#{match_quoted}\"|nil|true|false|[+-]?[0-9_]+(?:\\.\\d+)?)" end