speculate_about 1.0.5 → 1.0.6
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 +10 -4
- data/lib/speculations/version.rb +1 -1
- data/lib/speculations.rb +14 -8
- 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: d5fd5bedf8d21cdc315dfbb8b3c24b22bc9956f1bfb0c08008902aecb9c83771
|
4
|
+
data.tar.gz: 141662a9daae3a23c62926d77cdc42d728d6108f36815ce169c183f0c9ae2ddc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7a0573301627f5bb460368e2034cf8355985055bbbaa6ba8e61740d6483248335d496d5ad7c309656a5e7d75f695c908044fccb047ce82cd264566c22376097
|
7
|
+
data.tar.gz: 53d9e35f85b1382bd00edc134ccf06e108c8e23127cc544ca415e3b22acb0837f71134b163b7800fad555b0096fcecaf25d0d81ae6d53a69c5367093a5344c34
|
data/lib/speculations/cli.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
module Speculations
|
3
3
|
module CLI extend self
|
4
4
|
def run args
|
5
|
+
debug = false
|
6
|
+
force = false
|
5
7
|
loop do
|
6
8
|
case args.first
|
7
9
|
when "-h", "--help"
|
@@ -9,20 +11,24 @@ module Speculations
|
|
9
11
|
when "-v", "--version"
|
10
12
|
_version
|
11
13
|
when "-d", "--debug"
|
12
|
-
|
14
|
+
debug = true
|
15
|
+
args = args.drop(1)
|
16
|
+
when "-f", "--force"
|
17
|
+
force = true
|
18
|
+
args = args.drop(1)
|
13
19
|
else
|
14
|
-
return _compile_and_maybe_run
|
20
|
+
return _compile_and_maybe_run(args, debug:, force:)
|
15
21
|
end
|
16
22
|
end
|
17
23
|
end
|
18
24
|
|
19
25
|
private
|
20
26
|
|
21
|
-
def _compile_and_maybe_run(args, debug:
|
27
|
+
def _compile_and_maybe_run(args, debug:, force:)
|
22
28
|
require_relative "../speculations"
|
23
29
|
args = Dir.glob(["*.md", "speculations/**/*.md"]) if args.empty?
|
24
30
|
args.each do |input_file|
|
25
|
-
Speculations.compile(input_file, debug:)
|
31
|
+
Speculations.compile(input_file, debug:, force:)
|
26
32
|
end
|
27
33
|
end
|
28
34
|
|
data/lib/speculations/version.rb
CHANGED
data/lib/speculations.rb
CHANGED
@@ -3,24 +3,24 @@ require_relative 'debugging'
|
|
3
3
|
require_relative 'speculations/parser'
|
4
4
|
module Speculations extend self
|
5
5
|
|
6
|
-
|
6
|
+
DISCLAIMER = <<-EOD
|
7
7
|
# DO NOT EDIT!!!
|
8
8
|
# This file was generated from FILENAME with the speculate_about gem, if you modify this file
|
9
9
|
# one of two bad things will happen
|
10
10
|
# - your documentation specs are not correct
|
11
11
|
# - your modifications will be overwritten by the speculate command line
|
12
12
|
# YOU HAVE BEEN WARNED
|
13
|
-
|
13
|
+
EOD
|
14
14
|
|
15
|
-
def compile(infile, outfile=nil, debug: false)
|
15
|
+
def compile(infile, outfile=nil, debug: false, force: false)
|
16
16
|
raise ArgumentError, "#{infile} not found" unless File.readable? infile
|
17
17
|
outfile ||= _speculation_path(infile)
|
18
18
|
if _out_of_date?(outfile, infile)
|
19
19
|
debug__(msg: "recompiling #{infile} -> #{outfile}", debug:)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
_compile(infile:, outfile:, debug:)
|
21
|
+
elsif force
|
22
|
+
debug__(msg: "*** forced recompilation #{infile} -> #{outfile}", debug:)
|
23
|
+
_compile(infile:, outfile:, debug:)
|
24
24
|
else
|
25
25
|
debug__(msg: "#{infile} ignored as it is upto date", debug:)
|
26
26
|
end
|
@@ -29,9 +29,15 @@ module Speculations extend self
|
|
29
29
|
|
30
30
|
private
|
31
31
|
|
32
|
+
def _compile(infile:, outfile:, debug:)
|
33
|
+
ast = Speculations::Parser.new.parse_from_file(infile, debug:)
|
34
|
+
code = _decorated_ast_code ast, infile
|
35
|
+
File.write(outfile, code.join("\n"))
|
36
|
+
end
|
37
|
+
|
32
38
|
def _decorated_ast_code ast, filename
|
33
39
|
[DISCLAIMER.gsub("FILENAME", filename.inspect).split("\n"), %{RSpec.describe #{filename.inspect} do}] +
|
34
|
-
|
40
|
+
ast.to_code + ["end"]
|
35
41
|
end
|
36
42
|
|
37
43
|
def _out_of_date?(outf, inf)
|
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: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Dober
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-25 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
|
Elixir doctest, but from any file.
|