class Libis::Metadata::Parser::BasicParser
New style parsers and converters for metadata. New, not finished and untested.
Public Instance Methods
any_quoted(key = :text)
click to toggle source
# File lib/libis/metadata/parser/basic_parser.rb, line 100 def any_quoted(key = :text) scope { quote.capture(:quote) >> dynamic {|_, c| (str(c.captures[:quote]).absent? >> any).repeat(1)}.maybe.as(key) >> dynamic {|_, c| str(c.captures[:quote])} } end
complement(char)
click to toggle source
# File lib/libis/metadata/parser/basic_parser.rb, line 71 def complement(char) case char when '(' ')' when '{' '}' when '[' ']' else char end end
grouped(foo, left_paren = lparen)
click to toggle source
# File lib/libis/metadata/parser/basic_parser.rb, line 84 def grouped(foo, left_paren = lparen) scope { left_paren.capture(:paren).as(:lparen) >> foo >> dynamic {|_, c| str(complement(c.captures[:paren]))}.as(:rparen) } end
grouped_anonymous(foo, left_paren = lparen)
click to toggle source
# File lib/libis/metadata/parser/basic_parser.rb, line 92 def grouped_anonymous(foo, left_paren = lparen) scope { left_paren.capture(:paren) >> foo >> dynamic {|_, c| str(complement(c.captures[:paren]))} } end
transformer()
click to toggle source
# File lib/libis/metadata/parser/basic_parser.rb, line 108 def transformer self.class::Transformer.new rescue nil end