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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04b56b8ce676f7faaaf972af124ce9cf6e26c78c9c61e29301ee3655052a6f59
4
- data.tar.gz: 9a76ee12d39a91f020c2339a40687d5a61ddf9d734d1dec2059b903ea2c49b0d
3
+ metadata.gz: 365ae0a3c9e3711e7a72b9af2f2fcbfe6fd75e50798ab41d1659ef4531cddce9
4
+ data.tar.gz: 1f6b57c546d7c8bf86bf9b49f2655daf1670564d4dc2eb13912643f40fd3ad5d
5
5
  SHA512:
6
- metadata.gz: 67e9c4e1266573160eb4d85780fdbd9b029544ba0d2fa8d9c1af589beba19adb6222a49454422bd8c5302e3e4fb1048dcd2f053998e3be151eeeebb2b8a822ec
7
- data.tar.gz: f29e6845cae94474864726d9604ad0854c5e8eb563f1990a6cad9c70bb7907df0504efb38660e6066ed2f7c9325bceec51e088978ae6143c268464dd7777463f
6
+ metadata.gz: 489baaac7c3daab8cf18660f9415703f640ba816be584867a0342928e9f285f07401c1d35b96ac74dc94c517b8cc99c91f5f21ef3336271d6ade44ebc537619c
7
+ data.tar.gz: d00250b28a9743f75b008c278b95ad978e95005315e203e113c129e53a40764fe431a91d2fb54be8d0a93e8efd7b616f835d543342670189eb4d155f5bb240c6
@@ -1,40 +1,39 @@
1
-
2
1
  module Speculations
3
2
  module CLI extend self
4
- def run args
5
- debug = false
6
- force = false
7
- loop do
8
- case args.first
9
- when "-h", "--help"
10
- _usage
11
- when "-v", "--version"
12
- _version
13
- when "-d", "--debug"
14
- debug = true
15
- args = args.drop(1)
16
- when "-f", "--force"
17
- force = true
18
- args = args.drop(1)
19
- return _compile_and_maybe_run(args, debug:, force:)
20
- else
21
- return _compile_and_maybe_run(args, debug:, force:)
22
- end
23
- end
24
- end
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
- def _compile_and_maybe_run(args, debug:, force:)
29
- require_relative "../speculations"
30
- args = Dir.glob(["*.md", "speculations/**/*.md"]) if args.empty?
31
- args.each do |input_file|
32
- Speculations.compile(input_file, debug:, force:)
33
- end
34
- end
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
- def _usage
37
- puts <<-EOF
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
- EOF
49
- exit -1
50
- end
46
+ recreate outdated speculations in `spec/speculations/`#{' '}
47
+ EOF
48
+ exit -1
49
+ end
51
50
 
52
- def _version
53
- require_relative 'version'
54
- puts VERSION
55
- exit -2
56
- end
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
- @__lines__ ||= []
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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Speculations
4
- VERSION = "1.1.3"
4
+ VERSION = "1.2.0"
5
5
  end
6
6
  # SPDX-License-Identifier: AGPL-3.0-or-later
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.1.3
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-06-20 00:00:00.000000000 Z
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.