test-map 0.2.0 → 0.2.1

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: cff4303356d351f21830fabfa15aa8c83074739a7df7b8eb3c05765b6c2a9a18
4
- data.tar.gz: 86c24f5558da531e9aa4cfec819ca21b9a9a7328113b5925509a72b128ffcc3e
3
+ metadata.gz: cd8d77a4693229a3bdc64882a2771830090f7b04ae977df9eec5386e3ffc16e3
4
+ data.tar.gz: dc04407d47b77d1b5a6418072c8e380a327417a82fe27a21f31e1020d7b6b2aa
5
5
  SHA512:
6
- metadata.gz: 0ae009024978af278f98b2fc51c9abcb4907e0d14e575f179fd0edc2247356bcc07f3349b80dae599b8f8932d4e1b9534fab17e51e555d7d1d3e19fa6a00219e
7
- data.tar.gz: 06ffd99ddcc28a9025d6a998a19766c9aa378489a6cb39e92a2f0b401da794fc05a4a9d17c2eb60b5456936088a87e12ce65bceeb4db1353230a62d0a00bbdb3
6
+ metadata.gz: d80247e944cecd9b3c06b48b63bae9052589f97713496f674dc9ad23524ebfe6e8bb0720d38a90d0ba9b0874cb33c6a9422d6cd9bf3c49c2f8db252c26dde011
7
+ data.tar.gz: 1690f86016ea54148386896023ba40e22210e2559c8d7dd175c7b728c458a9e2abdfdaa7f3a73997cbb4da446186e51033313a35df8c3e7e158a1a8cd8359f5a
data/README.md CHANGED
@@ -79,14 +79,15 @@ $ TEST_MAP=1 bundle exec rspec
79
79
  On demand you can adapt the configuration to your needs.
80
80
 
81
81
  ```ruby
82
- TestMap::Configure.configure do |config|
83
- config.logger = Logger.new($stdout) # default logs to dev/null
84
- config.out_file = 'my-test-map.yml' # default is .test-map.yml
82
+ TestMap::Config.configure do |config|
83
+ config[:logger] = Logger.new($stdout) # default logs to dev/null
84
+ config[:merge] = false # merge results (e.g. with multiple testsuites)
85
+ config[:out_file] = 'my-test-map.yml' # default is .test-map.yml
85
86
  # defaults to [%r{^(vendor)/}] }
86
- config.exclude_patterns = [%r{^(vendor|other_libraries)/}]
87
+ config[:exclude_patterns] = [%r{^(vendor|other_libraries)/}]
87
88
  # register a custom rule to match new files; must implement `call(file)`;
88
89
  # defaults to nil
89
- config.natural_mapping = ->(file) { file.sub(%r{^library/}, 'test/') }
90
+ config[:natural_mapping] = ->(file) { file.sub(%r{^library/}, 'test/') }
90
91
  end
91
92
  ```
92
93
 
@@ -94,11 +95,11 @@ end
94
95
 
95
96
  Open list of features:
96
97
 
97
- - [ ] Configure file exclude list (e.g. test files are not needed).
98
+ - [x] Configure file exclude list (e.g. test files are not needed).
98
99
  - [ ] Auto-handle packs, packs with subdirectories.
99
- - [ ] Demonstrate usage with file watchers.
100
+ - [x] Demonstrate usage with file watchers.
100
101
  - [ ] Demonstrate CI pipelines with GitHub actions and GitLab CI.
101
- - [ ] Merge results.
102
+ - [x] Merge results.
102
103
 
103
104
  ```sh
104
105
  $ bundle install # install dependencies
@@ -7,8 +7,7 @@ module TestMap
7
7
  def self.included(_base)
8
8
  TestMap.logger.info 'Registering hooks for Minitest'
9
9
  ::Minitest.after_run do
10
- result = TestMap.reporter.to_yaml
11
- File.write "#{Dir.pwd}/#{Config.config[:out_file]}", result
10
+ TestMap.reporter.write "#{Dir.pwd}/#{Config.config[:out_file]}"
12
11
  end
13
12
  end
14
13
 
@@ -11,7 +11,6 @@ RSpec.configure do |config|
11
11
  end
12
12
 
13
13
  config.after(:suite) do
14
- result = TestMap.reporter.to_yaml
15
- File.write "#{Dir.pwd}/#{TestMap::Config.config[:out_file]}", result
14
+ TestMap.reporter.write "#{Dir.pwd}/#{TestMap::Config.config[:out_file]}"
16
15
  end
17
16
  end
@@ -16,12 +16,21 @@ module TestMap
16
16
  end
17
17
 
18
18
  def write(file)
19
- result = to_yaml
20
- result = YAML.safe_load_file(file).deep_merge(result) if Config.config[:merge]
21
- File.write file, result
19
+ content = if File.exist?(file) && Config.config[:merge]
20
+ merge(results, YAML.safe_load_file(file)).to_yaml
21
+ else
22
+ to_yaml
23
+ end
24
+ File.write file, content
22
25
  end
23
26
 
24
- def results = @results.transform_values { _1.to_a.sort }.sort.to_h
27
+ def results = @results.transform_values { _1.to_a.uniq.sort }.sort.to_h
25
28
  def to_yaml = results.to_yaml
29
+
30
+ def merge(result, current)
31
+ current.merge(result) do |_key, oldval, newval|
32
+ (oldval + newval).uniq.sort
33
+ end
34
+ end
26
35
  end
27
36
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TestMap
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-map
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christoph Lipautz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-26 00:00:00.000000000 Z
11
+ date: 2024-10-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  Track files that are covered by test files to execute only the necessary
@@ -18,11 +18,11 @@ email:
18
18
  executables: []
19
19
  extensions: []
20
20
  extra_rdoc_files:
21
- - LICENSE
21
+ - LICENSE.txt
22
22
  - README.md
23
23
  files:
24
24
  - CHANGELOG.md
25
- - LICENSE
25
+ - LICENSE.txt
26
26
  - README.md
27
27
  - lib/test_map.rb
28
28
  - lib/test_map/config.rb
File without changes