speculate_about 0.6.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68c9156823395a28b426d374248458dd846e438e3ab0d6b31330e0357db4473e
4
- data.tar.gz: 6ac9fb5014c33af83186983cf26f0770ebf7f4f2ef07c070d067f2f30477e658
3
+ metadata.gz: 691aa57b9ad1035ca6eb20fe75f89b818414dcd33e05acd9d6621e13ee1cfb23
4
+ data.tar.gz: 286766d1c5243bc9c1c6eb205c6e38ee97b3d06c90f4d77b6d84638a56d465e2
5
5
  SHA512:
6
- metadata.gz: ee238e533857ea54f7bc47059824e06f264018419e07551338a33b8f319a64c070d59169f37e2c4f266a750cea7603c9d5fc9b45caf5ef3d9f94359fa37aed5d
7
- data.tar.gz: b84407b46a432412f6a78e84e2cc3d07c3f381a6a93cbc18a45d5d3ea9c19b5f77209aa79bf8cef4cc9f811a1806ea7f84c6e8e208d025ccc3312475f75d4566
6
+ metadata.gz: cea1cc7dc006a7315fac53026959d444ae5a9bdcad161a94f57df7fdf3bead8cf5ee23aac5b9eaecdd68bc888cbf0df9e290acc4e09435f2b5bd771113ce38c3
7
+ data.tar.gz: 6dcd950c3ea0bace47c8ecf3e42dd38ff41d747ac92918c30c08e2403e0c6c2471dcf69c1f3eddc04049988c40d555b07f470ee6a3e873cf8c36aa1223828690
@@ -11,17 +11,17 @@ module Speculations
11
11
  new_parent = node.parent_of_level(level.pred)
12
12
  node = new_parent.new_context(title: match[2], lnb: lnb, level: level)
13
13
  [:out, node]
14
- when match = State.maybe_example(line)
15
- [:candidate, node, match[:title]]
16
14
  when match = State.maybe_include(line)
17
15
  [:candidate, node, :inc]
16
+ when match = State.maybe_example(line)
17
+ [:candidate, node, match[:title]]
18
18
  when match = State.ruby_code_block(line)
19
19
  if ctxt == :inc
20
20
  node = node.new_include(lnb: lnb)
21
21
  else
22
22
  node = node.new_example(title: ctxt, lnb: lnb)
23
23
  end
24
- [:in, node]
24
+ [:in, node, (ctxt == :inc ? :includes : :out)]
25
25
  else
26
26
  [:out, node]
27
27
  end
@@ -6,9 +6,9 @@ module Speculations
6
6
  def parse line, _lnb, node, ctxt
7
7
  case
8
8
  when State.eoblock_match(line)
9
- [:out, node.parent]
9
+ [ctxt, node.parent]
10
10
  else
11
- [:in, node.add_line(line)]
11
+ [:in, node.add_line(line), ctxt]
12
12
  end
13
13
  end
14
14
  end
@@ -0,0 +1,31 @@
1
+ module Speculations
2
+ class Parser
3
+ module State
4
+ module Includes extend self
5
+
6
+ def parse line, lnb, node, _ctxt
7
+ case
8
+ when match = State.context_match(line)
9
+ make_new_context(lnb: lnb, node: node, match: match)
10
+ when match = State.maybe_include(line)
11
+ [:candidate, node, :inc]
12
+ when match = State.maybe_example(line)
13
+ [:candidate, node, match[:title]]
14
+ else
15
+ [:includes, node]
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def make_new_context(lnb:, match:, node:)
22
+ level = match[:level].size
23
+ new_parent = node.parent_of_level(level.pred)
24
+ node = new_parent.new_context(title: match[:title], lnb: lnb, level: level)
25
+ [:out, node]
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+ end
@@ -3,7 +3,7 @@ module Speculations::Parser::State::Triggers
3
3
  BLANK_RGX = %r{\A\s*\z}
4
4
  CONTEXT_RGX = %r[\A\s{0,3}(?<level>\#{1,7})\s+Context:?\s+(?<title>.*)]
5
5
  EOBLOCK_RGX = %r[\A\s{0,3}```\s*\z]
6
- GIVEN_RGX = %r[\A\s{0,3}(?:Given|When)\b]
6
+ GIVEN_RGX = %r[\A\s{0,3}(?:Given|When|And)\b]
7
7
  EXAMPLE_RGX = %r[\A\s{0,3}Example:?\s+(<?title>.*)]
8
8
  RUBY_RGX = %r[\A\s{0,3}```ruby]
9
9
  THEN_RGX = %r[\A\s{0,3}(?:Then|But|And|Also|Or)\b\s*(?<title>.*)]
@@ -1,6 +1,7 @@
1
1
  module Speculations::Parser::State extend self
2
2
  require_relative './state/candidate'
3
3
  require_relative './state/in'
4
+ require_relative './state/includes'
4
5
  require_relative './state/out'
5
6
  require_relative './state/triggers'
6
7
 
@@ -8,6 +8,7 @@ module Speculations
8
8
  @__parsers__ ||= {
9
9
  candidate: State::Candidate,
10
10
  in: State::In,
11
+ includes: State::Includes,
11
12
  out: State::Out
12
13
  }
13
14
  end
@@ -31,7 +32,8 @@ module Speculations
31
32
  root = node = Context.new(filename: @filename)
32
33
  ctxt = nil
33
34
  @input.each_with_index do |line, lnb|
34
- @state, node, ctxt = self.class.parsers.fetch(@state).parse(line, lnb.succ, node, ctxt)
35
+ parser = self.class.parsers.fetch(@state)
36
+ @state, node, ctxt = parser.parse(line, lnb.succ, node, ctxt)
35
37
  end
36
38
  root
37
39
  end
@@ -1,3 +1,3 @@
1
1
  module Speculations
2
- VERSION = "0.6.1"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: speculate_about
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Dober
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-22 00:00:00.000000000 Z
11
+ date: 2022-01-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Allows Markdown or other text files to be used as literal specs, à la
14
14
  Elixr doctest, but from any file.
@@ -29,6 +29,7 @@ files:
29
29
  - lib/speculations/parser/state.rb
30
30
  - lib/speculations/parser/state/candidate.rb
31
31
  - lib/speculations/parser/state/in.rb
32
+ - lib/speculations/parser/state/includes.rb
32
33
  - lib/speculations/parser/state/out.rb
33
34
  - lib/speculations/parser/state/triggers.rb
34
35
  - lib/speculations/version.rb