varar-runner 0.8.1 → 0.9.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: 8b5851436b3132a8db0f86e7a70c593650192c6ba01bfe307a901dcafd9502c7
4
- data.tar.gz: 7ef324ac2644295eebe76201fb378b1950f4845ee5552afdce20bc16ab6e8cef
3
+ metadata.gz: 11d0992b5e1c296b7a5198c3c7a095bdc71665c70d45b50cda4482d8824bd54f
4
+ data.tar.gz: b0d3e370635d1eeb15fde239b18319601c11a6ad512dc7b6f28fc64273eb9f32
5
5
  SHA512:
6
- metadata.gz: b1f528bfb4259284edccd9de1f6051b20cbd0e1448e2ac47b885a099280394a8d4a13bff240f26bd898a5b1bdf696806536854193e7ac67b41fad3d70e8768a4
7
- data.tar.gz: 733508b44808f138ac5122c7aa67b0bae3354e61bf56e554ca482fade299931da1589f09cb11300d02a08777f877ca610f5db422c50dc039755d738e360993bc
6
+ metadata.gz: 80cf1dca9e44d91e2df509f518469260683daa449e6a77b6ba0a86c5cdc903aa2aeaaa427bfc13088fdc07b28a527b7ba53f9393b21d27acdb00d4f853b6e119
7
+ data.tar.gz: 34242a8e55333f910d8eb5adf5444c4bd2a8f69b3ff15663b0a27dbbb1f1d3652134a1aab5648a0d45cd4d4c03d1b620d9093de924aeb41f67456c9390f283ef
@@ -1,21 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'fileutils'
4
+ require 'varar/core'
5
+
3
6
  module Varar
4
7
  module Runner
5
8
  # The filesystem BaselineStore: the committed drift baseline lives at the
6
- # project root as varar.lock.json. The core owns the format; this adapter
7
- # only moves raw text. Port of baseline_store.py.
9
+ # project root as varar.lock. A version 2 varar.lock.json is read while it
10
+ # is the only baseline (ADR 0017), and the first write deletes it, so the
11
+ # project is left with exactly one. The core owns the format; this adapter
12
+ # only moves raw text. Port of baseline-store.ts.
8
13
  class FileBaselineStore
9
14
  def initialize(root)
10
- @path = File.join(root.to_s, 'varar.lock.json')
15
+ @path = File.join(root.to_s, Core::Drifts::LOCK_FILE_NAME)
16
+ @legacy_path = File.join(root.to_s, Core::Drifts::LEGACY_LOCK_FILE_NAME)
11
17
  end
12
18
 
13
19
  def read
14
- File.exist?(@path) ? File.read(@path, encoding: 'UTF-8') : nil
20
+ path = [@path, @legacy_path].find { |p| File.exist?(p) }
21
+ path ? File.read(path, encoding: 'UTF-8') : nil
15
22
  end
16
23
 
17
24
  def write(contents)
18
25
  File.write(@path, contents)
26
+ FileUtils.rm_f(@legacy_path)
19
27
  end
20
28
  end
21
29
 
@@ -112,9 +112,34 @@ module Varar
112
112
  File.write(target, content)
113
113
  out.puts "created #{rel}"
114
114
  end
115
+ ensure_gitattributes(cwd, out)
115
116
  0
116
117
  end
117
118
 
119
+ GITATTRIBUTES_ENTRY = 'varar.lock merge=union'
120
+
121
+ # varar.lock holds one example-producing paragraph per line, so git can
122
+ # merge it by keeping both sides' lines; a line left over from the losing
123
+ # side reads as a removed paragraph, not drift, and the next run drops it
124
+ # (ADR 0017). Creates .gitattributes when there is none, appends the entry
125
+ # otherwise, and leaves a file that already has it alone.
126
+ def self.ensure_gitattributes(cwd, out)
127
+ target = File.join(cwd, '.gitattributes')
128
+ unless File.exist?(target)
129
+ File.write(target, "#{GITATTRIBUTES_ENTRY}\n")
130
+ out.puts "created .gitattributes (#{GITATTRIBUTES_ENTRY})"
131
+ return
132
+ end
133
+ source = File.read(target, encoding: 'UTF-8')
134
+ if source.match?(/^varar\.lock\s+merge=union\s*$/)
135
+ out.puts 'skipped .gitattributes (already merges varar.lock by union)'
136
+ return
137
+ end
138
+ sep = source.empty? || source.end_with?("\n") ? '' : "\n"
139
+ File.write(target, "#{source}#{sep}#{GITATTRIBUTES_ENTRY}\n")
140
+ out.puts "updated .gitattributes (added #{GITATTRIBUTES_ENTRY})"
141
+ end
142
+
118
143
  # RSpec when its adapter is installed, Minitest when only that one is,
119
144
  # RSpec as the fallback (matching the tutorial's default track).
120
145
  def self.detect_framework
data/lib/varar/runner.rb CHANGED
@@ -9,7 +9,7 @@ module Varar
9
9
  # rendering, and the filesystem drift baseline store. Depends on the facade
10
10
  # and config; never on a test framework. Port of varar-runner.
11
11
  module Runner
12
- VERSION = '0.8.1'
12
+ VERSION = '0.9.0'
13
13
  end
14
14
  end
15
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: varar-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aslak Hellesøy
@@ -15,28 +15,28 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.8.1
18
+ version: 0.9.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.8.1
25
+ version: 0.9.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: varar-config
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - '='
31
31
  - !ruby/object:Gem::Version
32
- version: 0.8.1
32
+ version: 0.9.0
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - '='
38
38
  - !ruby/object:Gem::Version
39
- version: 0.8.1
39
+ version: 0.9.0
40
40
  description: Oath/step discovery, step loading, planning, failure rendering, and the
41
41
  drift baseline store.
42
42
  email:
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
- rubygems_version: 4.0.16
77
+ rubygems_version: 4.0.20
78
78
  specification_version: 4
79
79
  summary: Markdown-native BDD — imperative shell (discovery, loading, drift)
80
80
  test_files: []