speculate_about 1.3.0 → 1.3.2
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 +4 -4
- data/lib/speculations/data.rb +3 -2
- data/lib/speculations/debugging.rb +23 -0
- data/lib/speculations/parser/state/context_maker.rb +1 -0
- data/lib/speculations/parser/state/includes.rb +3 -1
- data/lib/speculations/parser/state/specify_block.rb +0 -1
- data/lib/speculations/parser/state/triggers.rb +1 -1
- data/lib/speculations/parser/state.rb +0 -1
- data/lib/speculations/parser.rb +3 -4
- data/lib/speculations/version.rb +1 -1
- data/lib/speculations.rb +5 -4
- metadata +18 -5
- data/lib/debugging.rb +0 -18
- data/lib/speculations/parser/state/spec_context.rb +0 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bec8c1ea49a9e43ea7e174e2505a6bba43785bac98e53267a4c662bf194a0027
|
|
4
|
+
data.tar.gz: 14f2d1f6d251187eb3125a1f2eea5d34c9b573f28184bf33e7f2db4fe45fbb5f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: afb73ccfc87fc19f1bac309942f2f920a2609c47a0739f7c7060ce7b65e52769f5259c518b0f143c016ce235e84961ee39f1d8f535ee628351462316efc16c67
|
|
7
|
+
data.tar.gz: c0687c470470b498dd295b95a57a7366daea2a68587a94d8d3470e005d69c99350349ab7a3ffe7f33bda38f186489ff9e14784c8f7f3d88e35c8c2e62ad29ee7
|
data/lib/speculations/data.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Speculations
|
|
4
4
|
class Data
|
|
5
|
-
attr_reader :ctxt, :debug, :line, :lnb, :node, :state
|
|
5
|
+
attr_reader :ctxt, :debug, :filename, :line, :lnb, :node, :state
|
|
6
6
|
|
|
7
7
|
def info(label) = node.info(label)
|
|
8
8
|
|
|
@@ -19,9 +19,10 @@ module Speculations
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
private
|
|
22
|
-
def initialize(line:, lnb:, state:, node:, ctxt: nil, debug: false)
|
|
22
|
+
def initialize(line:, lnb:, state:, node:, filename: nil, ctxt: nil, debug: false)
|
|
23
23
|
@ctxt = ctxt
|
|
24
24
|
@debug = debug
|
|
25
|
+
@filename = filename
|
|
25
26
|
@line = line
|
|
26
27
|
@lnb = lnb
|
|
27
28
|
@node = node
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'l43/simple_color'
|
|
4
|
+
module Speculations
|
|
5
|
+
module Debugging
|
|
6
|
+
S = L43::SimpleColor
|
|
7
|
+
|
|
8
|
+
def debug__(subject=nil, msg: nil, rtrn: nil, debug:)
|
|
9
|
+
return rtrn || subject unless debug
|
|
10
|
+
|
|
11
|
+
S.putc(msg) if msg
|
|
12
|
+
S.putc(3, :bold_green, subject.inspect) if subject
|
|
13
|
+
rtrn || subject
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def dbg_match(msg, data)
|
|
17
|
+
designation = name.split("::").last.downcase
|
|
18
|
+
debug__(msg: [:blue, "#{data.lnb.succ}", :reset, " #{msg} match in :#{designation}"], debug: data.debug)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
@@ -5,13 +5,15 @@ module Speculations
|
|
|
5
5
|
module Includes extend self
|
|
6
6
|
include ContextMaker
|
|
7
7
|
|
|
8
|
-
# def parse line, lnb, node, _ctxt, debug: true
|
|
9
8
|
def parse(data)
|
|
10
9
|
line = data.line
|
|
11
10
|
case
|
|
12
11
|
when match = State.context_match(line)
|
|
13
12
|
#dbg_match("context", data)
|
|
14
13
|
make_new_context(data, match: match)
|
|
14
|
+
when match = State.spec_context_line(line)
|
|
15
|
+
#dbg_match("specify context", data)
|
|
16
|
+
make_spec_context(data, title: data.line.strip)
|
|
15
17
|
when match = State.maybe_include(line)
|
|
16
18
|
#dbg_match("maybe_include", data)
|
|
17
19
|
data.update(state: :candidate, ctxt: :inc)
|
|
@@ -6,7 +6,7 @@ module Speculations::Parser::State::Triggers
|
|
|
6
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
|
-
SPEC_CONTEXT_RGX = %r[
|
|
9
|
+
SPEC_CONTEXT_RGX = %r[(?:\sfollowing examples:\s*)|(?:\sas follows:\s*)\z]
|
|
10
10
|
THEN_RGX = %r[\A\s{0,3}(?:Then|But|And|Also|Or|However|Furhermore)\b\s*(?<title>.*)]
|
|
11
11
|
|
|
12
12
|
def blank_line(line) = BLANK_RGX.match(line)
|
|
@@ -4,7 +4,6 @@ module Speculations::Parser::State extend self
|
|
|
4
4
|
require_relative './state/in'
|
|
5
5
|
require_relative './state/includes'
|
|
6
6
|
require_relative './state/out'
|
|
7
|
-
require_relative './state/spec_context'
|
|
8
7
|
require_relative './state/specify_block'
|
|
9
8
|
require_relative './state/triggers'
|
|
10
9
|
|
data/lib/speculations/parser.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative '
|
|
3
|
+
require_relative 'debugging'
|
|
4
4
|
require_relative './parser/context'
|
|
5
5
|
require_relative './parser/state'
|
|
6
6
|
module Speculations
|
|
@@ -13,7 +13,6 @@ module Speculations
|
|
|
13
13
|
in: State::In,
|
|
14
14
|
includes: State::Includes,
|
|
15
15
|
out: State::Out,
|
|
16
|
-
spec_context: State::SpecContext,
|
|
17
16
|
specify_block: State::SpecifyBlock
|
|
18
17
|
}
|
|
19
18
|
end
|
|
@@ -31,13 +30,13 @@ module Speculations
|
|
|
31
30
|
|
|
32
31
|
def parse!(debug:)
|
|
33
32
|
root = node = Context.new(filename: @filename)
|
|
34
|
-
data = Data.new(node:, lnb: 0, line: nil, state: :out, debug:)
|
|
33
|
+
data = Data.new(node:, lnb: 0, line: nil, filename: @filename, state: :out, debug:)
|
|
35
34
|
@input.each_with_index do |line, lnb|
|
|
36
35
|
data.update(line:, lnb:)
|
|
37
36
|
parser = self.class.parsers.fetch(data.state)
|
|
38
37
|
old_state = data.state
|
|
39
38
|
data = parser.parse(data)
|
|
40
|
-
|
|
39
|
+
debug_state(old_state:, data:)
|
|
41
40
|
end
|
|
42
41
|
root
|
|
43
42
|
end
|
data/lib/speculations/version.rb
CHANGED
data/lib/speculations.rb
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
require 'fileutils'
|
|
2
|
-
require_relative 'debugging'
|
|
2
|
+
require_relative 'speculations/debugging'
|
|
3
3
|
require_relative 'speculations/data'
|
|
4
4
|
require_relative 'speculations/parser'
|
|
5
5
|
module Speculations extend self
|
|
6
|
+
include Debugging
|
|
6
7
|
|
|
7
8
|
HELPER_FILE = 'speculations_helper'
|
|
8
9
|
HELPER_PATH = "spec/#{HELPER_FILE}.rb"
|
|
@@ -20,13 +21,13 @@ module Speculations extend self
|
|
|
20
21
|
raise ArgumentError, "#{infile} not found" unless File.readable? infile
|
|
21
22
|
outfile ||= _speculation_path(infile)
|
|
22
23
|
if _out_of_date?(outfile, infile)
|
|
23
|
-
debug__(msg: "recompiling
|
|
24
|
+
debug__(msg: ["recompiling ", :b_blue, infile, :reset, " -> ", :b_blue, outfile], debug:)
|
|
24
25
|
_compile(infile:, outfile:, debug:)
|
|
25
26
|
elsif force
|
|
26
|
-
debug__(msg: "*** forced recompilation
|
|
27
|
+
debug__(msg: [:b_yellow, "*** forced recompilation ", :b_blue, infile, :reset, " -> ", :b_blue, outfile], debug:)
|
|
27
28
|
_compile(infile:, outfile:, debug:)
|
|
28
29
|
else
|
|
29
|
-
debug__(msg:
|
|
30
|
+
debug__(msg: [:green, infile, :reset, " ignored as it is upto date"], debug:)
|
|
30
31
|
end
|
|
31
32
|
outfile
|
|
32
33
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: speculate_about
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Robert Dober
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-04-
|
|
11
|
-
dependencies:
|
|
10
|
+
date: 2026-04-30 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: l43_simple_color
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: 0.1.0
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: 0.1.0
|
|
12
26
|
description: Allows Markdown or other text files to be used as literal specs, à la
|
|
13
27
|
Elixir doctest, but from any file.
|
|
14
28
|
email: robert.dober@gmail.com
|
|
@@ -19,11 +33,11 @@ extra_rdoc_files: []
|
|
|
19
33
|
files:
|
|
20
34
|
- LICENSE
|
|
21
35
|
- bin/speculate
|
|
22
|
-
- lib/debugging.rb
|
|
23
36
|
- lib/speculate_about.rb
|
|
24
37
|
- lib/speculations.rb
|
|
25
38
|
- lib/speculations/cli.rb
|
|
26
39
|
- lib/speculations/data.rb
|
|
40
|
+
- lib/speculations/debugging.rb
|
|
27
41
|
- lib/speculations/parser.rb
|
|
28
42
|
- lib/speculations/parser/context.rb
|
|
29
43
|
- lib/speculations/parser/context/example.rb
|
|
@@ -35,7 +49,6 @@ files:
|
|
|
35
49
|
- lib/speculations/parser/state/in.rb
|
|
36
50
|
- lib/speculations/parser/state/includes.rb
|
|
37
51
|
- lib/speculations/parser/state/out.rb
|
|
38
|
-
- lib/speculations/parser/state/spec_context.rb
|
|
39
52
|
- lib/speculations/parser/state/specify_block.rb
|
|
40
53
|
- lib/speculations/parser/state/triggers.rb
|
|
41
54
|
- lib/speculations/version.rb
|
data/lib/debugging.rb
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Kernel
|
|
4
|
-
def debug__(subject=nil, msg: nil, rtrn: nil, debug:)
|
|
5
|
-
return rtrn || subject unless debug
|
|
6
|
-
|
|
7
|
-
$stderr.puts(msg) if msg
|
|
8
|
-
$stderr.puts(subject.inspect) if subject
|
|
9
|
-
rtrn || subject
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def dbg_match(msg, data)
|
|
13
|
-
designation = name.split("::").last.downcase
|
|
14
|
-
debug__(msg: "#{data.lnb.succ}: #{msg} match in :#{designation}", debug: data.debug)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
end
|
|
18
|
-
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Speculations
|
|
4
|
-
class Parser
|
|
5
|
-
module State
|
|
6
|
-
module SpecContext extend self
|
|
7
|
-
extend ContextMaker
|
|
8
|
-
|
|
9
|
-
def parse line, lnb, node, title, debug: false
|
|
10
|
-
# node.info(:spec_context)
|
|
11
|
-
if State.ruby_code_block(line)
|
|
12
|
-
#dbg_match("examples", lnb, debug:)
|
|
13
|
-
make_spec_context(lnb:, node:, title:)
|
|
14
|
-
else
|
|
15
|
-
#dbg_match("abandon spec context", lnb, debug:)
|
|
16
|
-
[:out, node]
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
# SPDX-License-Identifier: AGPL-3.0-or-later
|