speculate_about 0.5.1 → 0.5.2

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: 50dd660d1e2e984b66f854df6f71e1f280ddef2e162d2848a3cf363ffe5751a4
4
- data.tar.gz: 56ed0de10d7ee9751ae86deb247e7f8ad8d6b90f3a2e71623d83b0d169f18f59
3
+ metadata.gz: d7347969c0f7e0d357050ba84401e3c069366c052b028a3e123c94ee355b9829
4
+ data.tar.gz: 277902ff252cfade683c395485015f03700028839dcd986d965dbfc5f6c1a425
5
5
  SHA512:
6
- metadata.gz: cd78c231bd7ab5eb1146c8d1f2fb3b19bea52951c30001d373981b748a77404bd5a5b87477bef989fa9707ff1049d9d7d6a91e2c3a0fa1cdc4533351c2a214bc
7
- data.tar.gz: dbb334195b9354655edc06a11e52a0e77bee6be0961cc545fafc19ca6f2e0de5ba2c7c818ccde14bbf0fc2b2ba14b42f10fa02b114eb3f39b679763ea8427e2e
6
+ metadata.gz: 62daedfb2b2e00c7d9d1cac4fbe5c5fefcbfbb6dbfd49fed4cbdb4c224c37c54f80edd53aeb23215ca2192e0957a323dd7669c190917443b412e73976b8abbeb
7
+ data.tar.gz: 2a8626af0e4d46e63b514416d0341aaa61aa504f28ccf777827c701230ed1dddd08aa6b63314a066820799e05bb490b221f3481002eff144853c79732ce96464
@@ -2,18 +2,33 @@ require 'fileutils'
2
2
  require_relative 'speculations/parser'
3
3
  module Speculations extend self
4
4
 
5
+ DISCLAIMER = <<-EOD
6
+ # DO NOT EDIT!!!
7
+ # This file was generated from FILENAME with the speculate_about gem, if you modify this file
8
+ # one of two bad things will happen
9
+ # - your documentation specs are not correct
10
+ # - your modifications will be overwritten by the speculate rake task
11
+ # YOU HAVE BEEN WARNED
12
+ EOD
13
+
5
14
  def compile(infile, outfile=nil)
6
15
  raise ArgumentError, "#{infile} not found" unless File.readable? infile
7
16
  outfile ||= _speculation_path(infile)
8
17
  if _out_of_date?(outfile, infile)
9
18
  ast = Speculations::Parser.new.parse_from_file(infile)
10
- File.write(outfile, ast.to_code.join("\n"))
19
+ code = _decorated_ast_code ast, infile
20
+ File.write(outfile, code.join("\n"))
11
21
  end
12
22
  outfile
13
23
  end
14
24
 
15
25
  private
16
26
 
27
+ def _decorated_ast_code ast, filename
28
+ [DISCLAIMER.gsub("FILENAME", filename.inspect).split("\n"), %{RSpec.describe #{filename.inspect} do}] +
29
+ ast.to_code + ["end"]
30
+ end
31
+
17
32
  def _out_of_date?(outf, inf)
18
33
  return true unless File.exists? outf
19
34
  return File.lstat(outf).mtime <= File.lstat(inf).mtime
@@ -4,15 +4,6 @@ module Speculations
4
4
  require_relative './context/include'
5
5
  require_relative './context/example'
6
6
 
7
- DISCLAIMER = <<-EOD
8
- # DO NOT EDIT!!!
9
- # This file was generated from FILENAME with the speculate_about gem, if you modify this file
10
- # one of two bad things will happen
11
- # - your documentation specs are not correct
12
- # - your modifications will be overwritten by the speculate rake task
13
- # YOU HAVE BEEN WARNED
14
- EOD
15
-
16
7
  attr_reader :filename, :level, :lnb, :title, :parent, :root, :tree_level
17
8
 
18
9
  def new_context(title:, lnb:, level: )
@@ -94,14 +85,10 @@ module Speculations
94
85
  if parent
95
86
  map_lines(%{# #{filename}:#{lnb}}, %{context "#{title}" do}, indent: -1)
96
87
  else
97
- _root_header
88
+ []
98
89
  end
99
90
  end
100
91
 
101
- def _root_header
102
- map_lines(DISCLAIMER.gsub("FILENAME", filename.inspect).split("\n"), %{RSpec.describe #{filename.inspect} do}, indent: -1)
103
- end
104
-
105
92
  def _init_from_parent
106
93
  @root = parent.root
107
94
  @filename = parent.filename
@@ -109,7 +96,11 @@ module Speculations
109
96
  end
110
97
 
111
98
  def _footer
112
- map_lines("end", indent: -1)
99
+ if parent
100
+ map_lines("end", indent: -1)
101
+ else
102
+ []
103
+ end
113
104
  end
114
105
 
115
106
  def _realign_levels new_parent
@@ -1,3 +1,3 @@
1
1
  module Speculations
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: speculate_about
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Dober
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2021-01-02 00:00:00.000000000 Z
@@ -64,7 +64,7 @@ homepage: https://github.com/robertdober/speculate
64
64
  licenses:
65
65
  - Apache-2.0
66
66
  metadata: {}
67
- post_install_message:
67
+ post_install_message:
68
68
  rdoc_options: []
69
69
  require_paths:
70
70
  - lib
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  version: '0'
81
81
  requirements: []
82
82
  rubygems_version: 3.2.3
83
- signing_key:
83
+ signing_key:
84
84
  specification_version: 4
85
85
  summary: Extract RSpecs from Markdown
86
86
  test_files: []