rematch 0.0.1 → 1.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: '049981ef362bab9fa4ec53dc1794bdb7e083f670991a57c51cbbd16b82fb1a24'
4
- data.tar.gz: 01b2c7c801cf8134ea6da3b9e99f0534e045bae129e52086a3f5f3315302bea5
3
+ metadata.gz: a1813bfb1bfccc23e799726c867fd49509f9ae93935206a57a295259b5ca4533
4
+ data.tar.gz: f595fc1f3d2057969f68f8f2417831d7f22ff71d2abdff1341cd62df853b7e4a
5
5
  SHA512:
6
- metadata.gz: 68a13f561594b0c79bc10bfb27e339900f0c517ff364111456c6de0820ceed3b178da87c240195306e98b2558d142ace04a3857705a7b64e23623aa4830f6375
7
- data.tar.gz: 78baa00c6a04c6b39e2005f71743e8136b019b45851d9aa4a8221722f8f2e5679f92a5ba24c2f206661a51762d4905edcb08a6951c8c4a47add2f7e0803cebc9
6
+ metadata.gz: 907b7286d879fa6678598fcd60b1476b2e1f652cc4060bee23eaaab14b1a2dac7c3cbb6549e2391261e73ab9278e7276fbf00ee4fe2240ff6bd441436280f9eb
7
+ data.tar.gz: eb3ef411ce825152c59028f8cad7553971cdee632b252f43297acd3133241dc83cc5cedd683f208c5067c8eb748eb0cb144c4fd8ed72ef30ac49934140471171
@@ -4,10 +4,15 @@ require 'rematch'
4
4
 
5
5
  # Implement the minitest plugin
6
6
  module Minitest
7
+ def self.plugin_rematch_options(opts, _options)
8
+ opts.on '--rematch-refresh-only', 'ONLY Refresh the stored values with the current values' do
9
+ Rematch.refresh = true
10
+ end
11
+ end
7
12
  class Test
8
13
  def before_setup
9
- @rematch = Rematch.new(path: method(name).source_location.first, id: location)
10
14
  super
15
+ @rematch = Rematch.new(path: method(name).source_location.first, id: location)
11
16
  end
12
17
  end
13
18
  module Assertions
data/lib/rematch.rb CHANGED
@@ -1,16 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'yaml/store'
4
- require 'rematch/tasks'
4
+ require 'fileutils'
5
5
 
6
6
  # Implement the key/value store
7
7
  class Rematch
8
- VERSION = '0.0.1'
8
+ VERSION = '1.0'
9
9
  EXT = '.rematch'
10
10
 
11
+ @refreshed = []
12
+ class << self
13
+ attr_accessor :refresh
14
+
15
+ def check_refresh(path)
16
+ return unless @refresh && !@refreshed.include?(path)
17
+ FileUtils.rm_f(path)
18
+ @refreshed << path
19
+ puts "Refresh #{path}"
20
+ end
21
+ end
22
+
11
23
  # path and unique id of the test being run
12
24
  def initialize(path:, id:)
13
- @store = YAML::Store.new("#{path}#{EXT}", true)
25
+ path = "#{path}#{EXT}"
26
+ self.class.check_refresh(path)
27
+ @store = YAML::Store.new(path, true)
14
28
  @id = id
15
29
  @count = 0
16
30
  end
metadata CHANGED
@@ -1,18 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rematch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: '1.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Domizio Demichelis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-17 00:00:00.000000000 Z
11
+ date: 2021-05-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: With rematch you can completely declutter your test files from hardcoded
14
- expected data and update them automatically in a few seconds instead of hours when
15
- your code changes
13
+ description: Declutter your test files from large hardcoded data and update them automatically
14
+ when your code changes
16
15
  email:
17
16
  - dd.nexus@gmail.com
18
17
  executables: []
@@ -22,7 +21,6 @@ files:
22
21
  - LICENSE.txt
23
22
  - lib/minitest/rematch_plugin.rb
24
23
  - lib/rematch.rb
25
- - lib/rematch/tasks.rb
26
24
  homepage: https://github.com/ddnexus/rematch
27
25
  licenses:
28
26
  - MIT
@@ -35,7 +33,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
35
33
  requirements:
36
34
  - - ">"
37
35
  - !ruby/object:Gem::Version
38
- version: '2.5'
36
+ version: '2.1'
39
37
  required_rubygems_version: !ruby/object:Gem::Requirement
40
38
  requirements:
41
39
  - - ">="
@@ -45,5 +43,5 @@ requirements: []
45
43
  rubygems_version: 3.2.15
46
44
  signing_key:
47
45
  specification_version: 4
48
- summary: Rematch expected values with automatically stored values in tests
46
+ summary: Rematch expected test values with automatically stored values
49
47
  test_files: []
data/lib/rematch/tasks.rb DELETED
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rake'
4
-
5
- class Rematch
6
- module Tasks
7
- extend Rake::DSL
8
- namespace :rematch do
9
- desc 'Delete all the rematch stores below the tree=/path/to/test/dir (or current tree if omitted)'
10
- task :reset do
11
- pattern = Pathname.new(ENV['tree'] || '').join('**','*.rematch')
12
- Dir.glob(pattern).each { |f| File.delete(f) }
13
- end
14
- end
15
- end
16
- end