speculate_about 1.1.3 → 1.2.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 +4 -4
- data/lib/speculations/cli.rb +39 -40
- data/lib/speculations/parser/context/example.rb +36 -4
- data/lib/speculations/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 365ae0a3c9e3711e7a72b9af2f2fcbfe6fd75e50798ab41d1659ef4531cddce9
|
4
|
+
data.tar.gz: 1f6b57c546d7c8bf86bf9b49f2655daf1670564d4dc2eb13912643f40fd3ad5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 489baaac7c3daab8cf18660f9415703f640ba816be584867a0342928e9f285f07401c1d35b96ac74dc94c517b8cc99c91f5f21ef3336271d6ade44ebc537619c
|
7
|
+
data.tar.gz: d00250b28a9743f75b008c278b95ad978e95005315e203e113c129e53a40764fe431a91d2fb54be8d0a93e8efd7b616f835d543342670189eb4d155f5bb240c6
|
data/lib/speculations/cli.rb
CHANGED
@@ -1,40 +1,39 @@
|
|
1
|
-
|
2
1
|
module Speculations
|
3
2
|
module CLI extend self
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
3
|
+
def run args
|
4
|
+
debug = false
|
5
|
+
force = false
|
6
|
+
loop do
|
7
|
+
case args.first
|
8
|
+
when "-h", "--help"
|
9
|
+
_usage
|
10
|
+
when "-v", "--version"
|
11
|
+
_version
|
12
|
+
when "-d", "--debug"
|
13
|
+
debug = true
|
14
|
+
args = args.drop(1)
|
15
|
+
when "-f", "--force"
|
16
|
+
force = true
|
17
|
+
args = args.drop(1)
|
18
|
+
return _compile_and_maybe_run(args, debug:, force:)
|
19
|
+
else
|
20
|
+
return _compile_and_maybe_run(args, debug:, force:)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
25
24
|
|
26
25
|
private
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
27
|
+
def _compile_and_maybe_run(args, debug:, force:)
|
28
|
+
require_relative "../speculations"
|
29
|
+
args = Dir.glob(["*.md", "speculations/**/*.md"]) if args.empty?
|
30
|
+
args.each do |input_file|
|
31
|
+
Speculations.compile(input_file, debug:, force:)
|
32
|
+
end
|
33
|
+
end
|
35
34
|
|
36
|
-
|
37
|
-
|
35
|
+
def _usage
|
36
|
+
puts <<-EOF
|
38
37
|
usage:
|
39
38
|
#{$0} [options] [filenames]
|
40
39
|
|
@@ -44,15 +43,15 @@ module Speculations
|
|
44
43
|
|
45
44
|
filenames (default to all markdown files in the project directory and its speculations subdirectories)
|
46
45
|
|
47
|
-
recreate outdated speculations in `spec/speculations
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
recreate outdated speculations in `spec/speculations/`#{' '}
|
47
|
+
EOF
|
48
|
+
exit -1
|
49
|
+
end
|
51
50
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
51
|
+
def _version
|
52
|
+
require_relative 'version'
|
53
|
+
puts VERSION
|
54
|
+
exit -2
|
55
|
+
end
|
57
56
|
end
|
58
57
|
end
|
@@ -2,14 +2,13 @@ class Speculations::Parser::Context::Example
|
|
2
2
|
|
3
3
|
attr_reader :lnb, :title, :parent
|
4
4
|
|
5
|
-
|
6
5
|
def add_line line
|
7
|
-
lines << line
|
6
|
+
lines << _format_line(line)
|
8
7
|
self
|
9
8
|
end
|
10
9
|
|
11
10
|
def lines
|
12
|
-
|
11
|
+
@__lines__ ||= []
|
13
12
|
end
|
14
13
|
|
15
14
|
def to_code
|
@@ -20,7 +19,6 @@ class Speculations::Parser::Context::Example
|
|
20
19
|
|
21
20
|
|
22
21
|
private
|
23
|
-
|
24
22
|
def initialize(lnb:, parent:, title:)
|
25
23
|
@lnb = lnb
|
26
24
|
@parent = parent
|
@@ -34,4 +32,38 @@ class Speculations::Parser::Context::Example
|
|
34
32
|
def _example_head
|
35
33
|
%{it "#{title}" do}
|
36
34
|
end
|
35
|
+
|
36
|
+
ShortcutFormatsRgx = %r{
|
37
|
+
\A (\s*) (.*?) \s+ (==>|!=>) \s+ (.*) \z
|
38
|
+
}x
|
39
|
+
def _format_line(line)
|
40
|
+
case ShortcutFormatsRgx.match(line)&.captures
|
41
|
+
in [indent, lhs, operator, rhs]
|
42
|
+
_mk_equls_or_not(indent, lhs, operator, rhs)
|
43
|
+
else
|
44
|
+
line
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
Shortcuts = {
|
49
|
+
"==>" => "to eq",
|
50
|
+
"!=>" => "not_to eq",
|
51
|
+
}
|
52
|
+
|
53
|
+
def _format_op(operator)
|
54
|
+
Shortcuts.fetch(operator) { raise ArgumentError, "Illegal Shortcut Operator #{operator}" }
|
55
|
+
end
|
56
|
+
|
57
|
+
def _mk_equls_or_not(indent, lhs, operator, rhs)
|
58
|
+
[
|
59
|
+
indent,
|
60
|
+
"expect(",
|
61
|
+
lhs.strip,
|
62
|
+
").",
|
63
|
+
_format_op(operator),
|
64
|
+
"(",
|
65
|
+
rhs.strip,
|
66
|
+
")"
|
67
|
+
].join
|
68
|
+
end
|
37
69
|
end
|
data/lib/speculations/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: speculate_about
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Dober
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-09-27 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
description: Allows Markdown or other text files to be used as literal specs, à la
|
13
13
|
Elixir doctest, but from any file.
|