speculate_about 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6c603b51bd04471204c4584fb1697f5a27dd7b578abd012c805046e7d9a49dc
4
- data.tar.gz: 82f31cc63352e6d3c380b860a40a1f84a2f133b7b4f8a391363176f57d808415
3
+ metadata.gz: 669757a09c549512732274147c0b65dc3d71c3446b73490f961ae61b4e6a7d2b
4
+ data.tar.gz: 68b1e0f9babc9630616b14b16bf5ad60a9974983495dc7c575287dfbb29472a0
5
5
  SHA512:
6
- metadata.gz: bd30e3a46232a0d38b0d0725aa89df98f7d724faef50e350e3bacf106c552e279569087b830f93a656015dca03f5fe1e0ff0c511484a2c12ac3331ebb8e5c51a
7
- data.tar.gz: f48a6400a5bd1d6971780e5c8261d957b64af79c96baa544dd21b4050240343da77bc48141b4d0097da32ee4ee4ff5d065c7d3aa0df65584a71caf99b4724d09
6
+ metadata.gz: 4253cedda25c3f32eaf71b0bbe5a99376f05e42e1dd8ab1e4ca818d12f99d6ac88404883ba25e74318d4de094d4614bad63ac397cde6f71f2835d32109586e5e
7
+ data.tar.gz: 2766bdc6aafb5f70c7ab73ec3b24e82ef025f6bbdfefd95de4d1bc797478de37de60ee60ff50c2895ead4c22e03117f432b6924252abae42419de5f46cf26ab9
@@ -3,7 +3,7 @@ class Speculations::Parser::Context
3
3
  require_relative './context/example'
4
4
  require_relative './context/setup'
5
5
 
6
- attr_reader :filename, :level, :lnb, :name, :orig_filename, :parent, :setup
6
+ attr_reader :filename, :level, :lnb, :name, :orig_filename, :parent, :potential_name, :setup
7
7
 
8
8
  def add_child(name:, lnb:)
9
9
  raise "Illegal nesting" if parent
@@ -12,7 +12,8 @@ class Speculations::Parser::Context
12
12
  end
13
13
 
14
14
  def add_example(lnb:, line:)
15
- examples << Example.new(lnb: lnb, parent: self, line: line)
15
+ examples << Example.new(lnb: lnb, parent: self, line: line, name: potential_name)
16
+ @potential_name = nil
16
17
  examples.last
17
18
  end
18
19
 
@@ -38,6 +39,10 @@ class Speculations::Parser::Context
38
39
  lines.flatten.map{ |line| "#{prefix}#{line.strip}" }.join("\n")
39
40
  end
40
41
 
42
+ def set_name(potential_name)
43
+ @potential_name = potential_name
44
+ end
45
+
41
46
  def set_setup(lnb:)
42
47
  @setup = Setup.new(lnb: lnb, parent: self)
43
48
  end
@@ -24,16 +24,18 @@ class Speculations::Parser::Context::Example
24
24
 
25
25
  private
26
26
 
27
- def initialize(lnb:, line:, parent:)
27
+ def initialize(lnb:, line:, parent:, name: nil)
28
28
  @lnb = lnb
29
29
  @parent = parent
30
- @name = _compute_name(lnb: lnb, line: line, parent: parent)
30
+ @name = _compute_name(lnb: lnb, line: line, parent: parent, name: name)
31
31
  end
32
32
 
33
- def _compute_name(lnb:, parent:, line:)
34
- _, name = NAMED_EXAMPLE.match(line).to_a
33
+ def _compute_name(lnb:, parent:, line:, name:)
34
+ _, name1 = NAMED_EXAMPLE.match(line).to_a
35
35
 
36
- if name&.empty? == false # SIC
36
+ if name1&.empty? == false # SIC
37
+ "#{name1} (#{parent.orig_filename}:#{lnb.succ})"
38
+ elsif name
37
39
  "#{name} (#{parent.orig_filename}:#{lnb.succ})"
38
40
  else
39
41
  "Example from #{parent.orig_filename}:#{lnb.succ}"
@@ -9,6 +9,7 @@ module Speculations::Parser::State extend self
9
9
  EOBLOCK_RGX = %r[\A\s{0,3}```\s*\z]
10
10
  EXAMPLE_RGX = %r[\A\s{0,3}```.*\s:example]
11
11
  INCLUDE_RGX = %r[\A\s{0,3}```.*\s:include]
12
+ NAME_RGX = %r[\A\s{0,3}Example:\s+(.*)]
12
13
 
13
14
  def before_match line
14
15
  BEFORE_RGX =~ line
@@ -31,4 +32,8 @@ module Speculations::Parser::State extend self
31
32
  def include_match line
32
33
  INCLUDE_RGX =~ line
33
34
  end
35
+
36
+ def potential_name line
37
+ NAME_RGX.match(line)
38
+ end
34
39
  end
@@ -18,6 +18,9 @@ module Speculations
18
18
  when State.include_match(line)
19
19
  node = node.add_include(lnb: lnb)
20
20
  [:inc, node]
21
+ when name = State.potential_name(line)
22
+ node.set_name(name[1])
23
+ [:out, node]
21
24
  else
22
25
  [:out, node]
23
26
  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.1.2
4
+ version: 0.2.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: 2020-03-18 00:00:00.000000000 Z
11
+ date: 2020-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec