speculate_about 1.0.4 → 1.0.6

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: 3be4eb68d6f767c2a376eaf6e7f680b1f0705fff031648c9e700d5f3000280ed
4
- data.tar.gz: a9d1aea62f48b208252b0afbc4dab2cf3a3a01bdea7c349ac7e4bca35a110d63
3
+ metadata.gz: d5fd5bedf8d21cdc315dfbb8b3c24b22bc9956f1bfb0c08008902aecb9c83771
4
+ data.tar.gz: 141662a9daae3a23c62926d77cdc42d728d6108f36815ce169c183f0c9ae2ddc
5
5
  SHA512:
6
- metadata.gz: 37e09ca45b41fe4e2226fb95e14057b1d8e30b16417ed93af74364bbf4d292977c32cfd8cf0545308a704ef8c36e88fe20d1b80076114e79d4341e0aa8192763
7
- data.tar.gz: e4c9988e54c0987af9122252c0cfbd10496dc425dd21c5cdd7df91a672cb4fdeaef2e26301a7c5a132eb841591005d54749fce15f3cb757dbf2c55ce7387d9d8
6
+ metadata.gz: c7a0573301627f5bb460368e2034cf8355985055bbbaa6ba8e61740d6483248335d496d5ad7c309656a5e7d75f695c908044fccb047ce82cd264566c22376097
7
+ data.tar.gz: 53d9e35f85b1382bd00edc134ccf06e108c8e23127cc544ca415e3b22acb0837f71134b163b7800fad555b0096fcecaf25d0d81ae6d53a69c5367093a5344c34
data/lib/debugging.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kernel
4
- puts "defining debug__"
5
4
  def debug__(subject=nil, msg: nil, rtrn: nil, debug:)
6
5
  return rtrn || subject unless debug
7
6
 
@@ -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
- return _compile_and_maybe_run(args.drop(1), debug: true)
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 args
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: false)
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
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Speculations
4
- VERSION = "1.0.4"
4
+ VERSION = "1.0.6"
5
5
  end
6
6
  # SPDX-License-Identifier: AGPL-3.0-or-later
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
- DISCLAIMER = <<-EOD
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
- EOD
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
- ast = Speculations::Parser.new.parse_from_file(infile, debug:)
22
- code = _decorated_ast_code ast, infile
23
- File.write(outfile, code.join("\n"))
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
- ast.to_code + ["end"]
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
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-22 00:00:00.000000000 Z
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.