Module: Pickle::Parser::Matchers
- Included in:
- Pickle::Parser
- Defined in:
- lib/pickle/parser/matchers.rb
Instance Method Summary (collapse)
- - (Object) capture_key_and_value_in_field
- - (Object) capture_name_in_label
-
- (Object) capture_number_in_ordinal
special capture methods.
- - (Object) match_factory
- - (Object) match_field
- - (Object) match_fields
- - (Object) match_index
- - (Object) match_indexed_model
- - (Object) match_label
- - (Object) match_labeled_model
- - (Object) match_mapping
- - (Object) match_model
- - (Object) match_ordinal
- - (Object) match_plural_factory
- - (Object) match_predicate
- - (Object) match_prefix
- - (Object) match_quoted
- - (Object) match_value
Instance Method Details
- (Object) capture_key_and_value_in_field
82 83 84 |
# File 'lib/pickle/parser/matchers.rb', line 82 def capture_key_and_value_in_field "(?:(\\w+): #{capture_value})" end |
- (Object) capture_name_in_label
78 79 80 |
# File 'lib/pickle/parser/matchers.rb', line 78 def capture_name_in_label "(?::? \"(#{match_quoted})\")" end |
- (Object) capture_number_in_ordinal
special capture methods
74 75 76 |
# File 'lib/pickle/parser/matchers.rb', line 74 def capture_number_in_ordinal '(?:(\d+)(?:st|nd|rd|th))' end |
- (Object) match_factory
40 41 42 |
# File 'lib/pickle/parser/matchers.rb', line 40 def match_factory "(?:#{config.factories.keys.map{|n| n.gsub('_','[_ ]')}.join('|')})" end |
- (Object) match_field
28 29 30 |
# File 'lib/pickle/parser/matchers.rb', line 28 def match_field "(?:\\w+: #{match_value})" end |
- (Object) match_fields
32 33 34 |
# File 'lib/pickle/parser/matchers.rb', line 32 def match_fields "(?:#{match_field}, )*#{match_field}" end |
- (Object) match_index
8 9 10 |
# File 'lib/pickle/parser/matchers.rb', line 8 def match_index "(?:first|last|#{match_ordinal})" end |
- (Object) match_indexed_model
48 49 50 |
# File 'lib/pickle/parser/matchers.rb', line 48 def match_indexed_model "(?:(?:#{match_index} )?#{match_factory})" end |
- (Object) match_label
20 21 22 |
# File 'lib/pickle/parser/matchers.rb', line 20 def match_label "(?::? \"#{match_quoted}\")" end |
- (Object) match_labeled_model
52 53 54 |
# File 'lib/pickle/parser/matchers.rb', line 52 def match_labeled_model "(?:#{match_factory}#{match_label})" end |
- (Object) match_mapping
36 37 38 |
# File 'lib/pickle/parser/matchers.rb', line 36 def match_mapping "(?:#{config.mappings.map(&:search).join('|')})" end |
- (Object) match_model
56 57 58 |
# File 'lib/pickle/parser/matchers.rb', line 56 def match_model "(?:#{match_mapping}|#{match_prefix}?(?:#{match_indexed_model}|#{match_labeled_model}))" end |
- (Object) match_ordinal
4 5 6 |
# File 'lib/pickle/parser/matchers.rb', line 4 def match_ordinal '(?:\d+(?:st|nd|rd|th))' end |
- (Object) match_plural_factory
44 45 46 |
# File 'lib/pickle/parser/matchers.rb', line 44 def match_plural_factory "(?:#{config.factories.keys.map{|n| n.pluralize.gsub('_','[_ ]')}.join('|')})" end |
- (Object) match_predicate
60 61 62 |
# File 'lib/pickle/parser/matchers.rb', line 60 def match_predicate "(?:#{config.predicates.map{|m| m.to_s.sub(/^has_/,'').sub(/\?$/,'').gsub('_','[_ ]')}.join('|')})" end |
- (Object) match_prefix
12 13 14 |
# File 'lib/pickle/parser/matchers.rb', line 12 def match_prefix '(?:(?:a|an|another|the|that) )' end |
- (Object) match_quoted
16 17 18 |
# File 'lib/pickle/parser/matchers.rb', line 16 def match_quoted '(?:\\\\"|[^\\"]|\\.)*' end |
- (Object) match_value
24 25 26 |
# File 'lib/pickle/parser/matchers.rb', line 24 def match_value "(?:\"#{match_quoted}\"|nil|true|false|[+-]?[0-9_]+(?:\\.\\d+)?)" end |