Module: Speculations::Parser::State::Triggers

Included in:
Speculations::Parser::State
Defined in:
lib/speculations/parser/state/triggers.rb

Constant Summary collapse

BLANK_RGX =
%r{\A\s*\z}
CONTEXT_RGX =
%r[\A\s{0,3}(?<level>\#{1,7})\s+Context:?\s+(?<title>.*)]
EOBLOCK_RGX =
%r[\A\s{0,3}```\s*\z]
GIVEN_RGX =
%r[\A\s{0,3}(?:Given|When|And)\b]
EXAMPLE_RGX =
%r[\A\s{0,3}Example\:?\s+(?<title>.*)]
RUBY_RGX =
%r[\A\s{0,3}```ruby]
SPEC_CONTEXT_RGX =
%r[following examples:\s*\z]
THEN_RGX =
%r[\A\s{0,3}(?:Then|But|And|Also|Or|However|Furhermore)\b\s*(?<title>.*)]

Instance Method Summary collapse

Instance Method Details

#blank_line(line) ⇒ Object



12
# File 'lib/speculations/parser/state/triggers.rb', line 12

def blank_line(line) = BLANK_RGX.match(line)

#context_match(line) ⇒ Object



14
# File 'lib/speculations/parser/state/triggers.rb', line 14

def context_match(line) = CONTEXT_RGX.match(line)

#eoblock_match(line) ⇒ Object



16
# File 'lib/speculations/parser/state/triggers.rb', line 16

def eoblock_match(line) = EOBLOCK_RGX.match(line)

#maybe_example(line) ⇒ Object



18
19
20
21
# File 'lib/speculations/parser/state/triggers.rb', line 18

def maybe_example line
  EXAMPLE_RGX.match(line) ||
    THEN_RGX.match(line)
end

#maybe_include(line) ⇒ Object



23
# File 'lib/speculations/parser/state/triggers.rb', line 23

def maybe_include(line) = GIVEN_RGX.match(line)

#ruby_code_block(line) ⇒ Object



25
# File 'lib/speculations/parser/state/triggers.rb', line 25

def ruby_code_block(line) = RUBY_RGX.match(line)

#spec_context_line(line) ⇒ Object



27
# File 'lib/speculations/parser/state/triggers.rb', line 27

def spec_context_line(line) = SPEC_CONTEXT_RGX.match(line)