Class: DocRSpec::Parser

Inherits:
Object
  • Object
show all
Includes:
Debugging
Defined in:
lib/doc_rspec/parser.rb

Defined Under Namespace

Classes: InternalError, SyntaxError

Constant Summary collapse

COMMENT_LINE =
%r{\A \s* \#}x
CONTEXT_DEFINITION =
%r{\A \s* \# \s ={1,7} \s (.*)}x
EXAMPLE_LINE =
%r{\A \s* \# \s{4,} (.*)}x
SHORT_EQUALS =
%r{\s \=\=\> \s}x
SHORT_MATCHES =
%r{\s \~\> \s}x
SHORT_PREDICATE =
%r{\s is\! \s}x
SHORT_ANTIPREDICATE =
%r{\s not\! \s}x
START_EXAMPLE =
%r{\A \s* \# \s{4,} \# \s example: \s (.*)}x
SHORTCUTS =
[
  [ SHORT_EQUALS, "to", "eq(%%%)" ],
  [ SHORT_MATCHES, "to", "match(%%%)" ],
  [ SHORT_PREDICATE, "to", "be_%%%" ],
  [ SHORT_ANTIPREDICATE, "not_to", "be_%%%" ],
]

Constants included from Debugging

Debugging::DEBUG_ENV_VAR_NAME

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Debugging

#debug_level, #debugging?

Instance Attribute Details

#astObject (readonly)

Returns the value of attribute ast.



30
31
32
# File 'lib/doc_rspec/parser.rb', line 30

def ast
  @ast
end

#linesObject (readonly)

Returns the value of attribute lines.



30
31
32
# File 'lib/doc_rspec/parser.rb', line 30

def lines
  @lines
end

#stateObject (readonly)

Returns the value of attribute state.



30
31
32
# File 'lib/doc_rspec/parser.rb', line 30

def state
  @state
end

Instance Method Details

#parseObject



32
33
34
35
36
37
# File 'lib/doc_rspec/parser.rb', line 32

def parse
  lines.each_with_index do |line, lnb|
    parse_line(line, lnb.succ)
  end
  ast.reject(&:empty?)
end