retest 1.11.0 → 1.13.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: 1e115f99996becceaa5a11f81f938afa18571c8bdcb3e3fe5e500bb4d2eaa647
4
- data.tar.gz: 003bfb6679ddcfc531666fe397121170926248792503834f14e79566022da274
3
+ metadata.gz: 1a3b868e7a077e45f1da38813aa62efe2bdefcc776c504b243d33f9841740420
4
+ data.tar.gz: 1dbb3a5cd581604f4c74122d9902f795aa59e508c3b479b667b6529e8e9d6f55
5
5
  SHA512:
6
- metadata.gz: 7c71cb0291862bdd2cdda6ca37a7d199b6ad95c48812ff099e26ceef5505bb138cd01ea230fcbf7627c051de1760393850f129c59066f4ca45db21310114bf66
7
- data.tar.gz: eac9a20b762eea7d8706d4754f2894659c8aafb4f3930d99d8d5b730fe1e47ae4341538bf1616569e3d01f9a8555b3b1ec5c33be60c4db699d13d639947de285
6
+ metadata.gz: ec65a2b54baf8eabcd7f9159992cf9e90adcf111a71f258a589678305758c79ae7459bf4481d3838abff5bfc0b3acd72d7454c648fdd19105bbecc217a694142
7
+ data.tar.gz: 59f4ff3692c64c50b6a6721d1ee096150b9b8c28501ec8769f788164c8353d3e87865750c045d83c8bb22f37af081b97489ee2b83b79253420b5c364f08404c7
@@ -30,7 +30,7 @@ jobs:
30
30
  ruby: 2.5
31
31
  name: Ruby ${{ matrix.ruby }} test (${{ matrix.os }})
32
32
  steps:
33
- - uses: actions/checkout@v2
33
+ - uses: actions/checkout@v4
34
34
  - name: Set up Ruby
35
35
  uses: ruby/setup-ruby@v1
36
36
  with:
@@ -54,7 +54,7 @@ jobs:
54
54
  - rspec-ruby
55
55
  - bundler-app
56
56
  steps:
57
- - uses: actions/checkout@v2
57
+ - uses: actions/checkout@v4
58
58
  - name: Set up Ruby
59
59
  uses: ruby/setup-ruby@v1
60
60
  with:
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- retest (1.11.0)
5
- listen (~> 3.2)
4
+ retest (1.13.0)
5
+ listen (~> 3.9)
6
6
  string-similarity (~> 2.1)
7
7
  tty-option (~> 0.1)
8
8
 
@@ -10,8 +10,8 @@ GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  byebug (11.1.3)
13
- ffi (1.15.5)
14
- listen (3.8.0)
13
+ ffi (1.16.3)
14
+ listen (3.9.0)
15
15
  rb-fsevent (~> 0.10, >= 0.10.3)
16
16
  rb-inotify (~> 0.9, >= 0.9.10)
17
17
  minitest (5.15.0)
data/README.md CHANGED
@@ -119,7 +119,7 @@ $ retest 'bundle exec rails test <test>'
119
119
 
120
120
  ## Ruby Support
121
121
 
122
- Retest supports ruby 2.4 and above.
122
+ Retest supports ruby 2.5 and above.
123
123
 
124
124
  ## Roadmap
125
125
 
data/bin/debug CHANGED
@@ -3,4 +3,8 @@
3
3
  require "bundler/setup"
4
4
  require "byebug"
5
5
 
6
- eval(File.read("exe/retest"))
6
+ begin
7
+ eval(File.read("exe/retest"))
8
+ rescue LocalJumpError
9
+ # Silence early returns in the eval block
10
+ end
data/exe/retest CHANGED
@@ -13,13 +13,20 @@ if options.help?
13
13
  return
14
14
  end
15
15
 
16
- repository = Retest::Repository.new(files: Retest::VersionControl.files)
16
+ if options.version?
17
+ $stdout.puts Retest::VERSION
18
+ return
19
+ end
20
+
21
+ prompt = Retest::Prompt.new
22
+ repository = Retest::Repository.new(files: Retest::VersionControl.files, prompt: prompt)
17
23
  command = Retest::Command.for_options(options)
18
24
  runner = Retest::Runners.runner_for(command.to_s)
19
25
  sounds = Retest::Sounds.for(options)
20
26
 
21
27
  sounds.play(:start)
22
28
  runner.add_observer(sounds)
29
+ prompt.add_observer(sounds)
23
30
 
24
31
  program = Retest::Program.new(
25
32
  repository: repository,
@@ -85,6 +85,12 @@ module Retest
85
85
  desc "Print usage"
86
86
  end
87
87
 
88
+ flag :version do
89
+ short "-v"
90
+ long "--version"
91
+ desc "Print retest version"
92
+ end
93
+
88
94
  option :polling do
89
95
  long '--polling'
90
96
  desc <<~DESC.strip
@@ -133,6 +139,10 @@ module Retest
133
139
  params[:help]
134
140
  end
135
141
 
142
+ def version?
143
+ params[:version]
144
+ end
145
+
136
146
  def full_suite?
137
147
  params[:all]
138
148
  end
data/lib/retest/prompt.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  module Retest
2
2
  class Prompt
3
+ include Observable
4
+
3
5
  def self.ask_which_test_to_use(path, files)
4
6
  new.ask_which_test_to_use(path, files)
5
7
  end
@@ -15,16 +17,21 @@ module Retest
15
17
  end
16
18
 
17
19
  def ask_which_test_to_use(path, files)
20
+ changed
21
+ notify_observers(:question)
22
+ options = options(files)
23
+
18
24
  output.puts(<<~QUESTION)
19
25
  We found few tests matching: #{path}
20
26
 
21
- #{list_options(files)}
27
+ #{list_options(options.keys)}
22
28
 
23
29
  Which file do you want to use?
24
30
  Enter the file number now:
25
31
  QUESTION
32
+ output.print("> ")
26
33
 
27
- files[input.gets.chomp.to_i]
34
+ options.values[input.gets.chomp.to_i]
28
35
  end
29
36
 
30
37
  def puts(*args)
@@ -37,8 +44,15 @@ module Retest
37
44
 
38
45
  private
39
46
 
40
- def list_options(files)
41
- files
47
+ def options(files, blank_option: 'none')
48
+ result = {}
49
+ files.each { |file| result[file] = file }
50
+ result[blank_option] = nil # blank option last
51
+ result
52
+ end
53
+
54
+ def list_options(options)
55
+ options
42
56
  .map
43
57
  .with_index { |file, index| "[#{index}] - #{file}" }
44
58
  .join("\n")
@@ -12,8 +12,14 @@ module Retest
12
12
  return unless path
13
13
  return if path.empty?
14
14
 
15
- @path = path
16
- cache[@path] ||= select_from MatchingOptions.for(@path, files: files)
15
+ unless cache.key?(path)
16
+ ok_to_cache, test_file = select_from path, MatchingOptions.for(path, files: files)
17
+ if ok_to_cache
18
+ cache[path] = test_file
19
+ end
20
+ end
21
+
22
+ cache[path]
17
23
  end
18
24
 
19
25
  def find_tests(paths)
@@ -49,12 +55,14 @@ module Retest
49
55
 
50
56
  private
51
57
 
52
- def select_from(tests)
53
- case tests.count
54
- when 0, 1
55
- tests.first
58
+ def select_from(path, matching_tests)
59
+ case matching_tests.count
60
+ when 0
61
+ [false, nil]
62
+ when 1
63
+ [true, matching_tests.first]
56
64
  else
57
- prompt.ask_which_test_to_use(@path, tests)
65
+ [true, prompt.ask_which_test_to_use(path, matching_tests)]
58
66
  end
59
67
  end
60
68
  end
data/lib/retest/sounds.rb CHANGED
@@ -26,6 +26,8 @@ module Retest
26
26
  ['afplay', '/System/Library/Sounds/Funk.aiff']
27
27
  when :start
28
28
  ['afplay', '/System/Library/Sounds/Blow.aiff']
29
+ when :question
30
+ ['afplay', '/System/Library/Sounds/Glass.aiff']
29
31
  else
30
32
  raise ArgumentError.new("No sounds were found for type: #{sound}.")
31
33
  end
@@ -40,15 +42,18 @@ end
40
42
  # List of Mac Audio Files:
41
43
  # afplay /System/Library/Sounds/Basso.aiff
42
44
  # afplay /System/Library/Sounds/Bottle.aiff
43
- # afplay /System/Library/Sounds/Funk.aiff
44
45
  # afplay /System/Library/Sounds/Hero.aiff
45
46
  # afplay /System/Library/Sounds/Ping.aiff
46
47
  # afplay /System/Library/Sounds/Purr.aiff
47
48
  # afplay /System/Library/Sounds/Submarine.aiff
48
- # afplay /System/Library/Sounds/Blow.aiff
49
49
  # afplay /System/Library/Sounds/Frog.aiff
50
- # afplay /System/Library/Sounds/Glass.aiff
51
50
  # afplay /System/Library/Sounds/Morse.aiff
52
51
  # afplay /System/Library/Sounds/Pop.aiff
53
- # afplay /System/Library/Sounds/Sosumi.aiff
54
52
  # afplay /System/Library/Sounds/Tink.aiff
53
+
54
+ # USED
55
+
56
+ # fail: afplay /System/Library/Sounds/Sosumi.aiff
57
+ # pass: afplay /System/Library/Sounds/Funk.aiff
58
+ # start: afplay /System/Library/Sounds/Blow.aiff
59
+ # question: afplay /System/Library/Sounds/Glass.aiff
@@ -1,3 +1,3 @@
1
1
  module Retest
2
- VERSION = "1.11.0"
2
+ VERSION = "1.13.0"
3
3
  end
data/lib/retest.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'listen'
2
+
2
3
  require 'string/similarity'
3
4
  require 'observer'
4
5
 
@@ -15,6 +16,8 @@ require "retest/program"
15
16
  require "retest/prompt"
16
17
  require "retest/sounds"
17
18
 
19
+ Listen.adapter_warn_behavior = :log
20
+
18
21
  module Retest
19
22
  class Error < StandardError; end
20
23
 
data/retest.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.summary = "A simple command line tool to watch file change and run its matching spec."
10
10
  spec.homepage = "https://github.com/AlexB52/retest"
11
11
  spec.license = "MIT"
12
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
13
13
 
14
14
  # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
15
15
 
@@ -26,6 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
27
  spec.require_paths = ["lib"]
28
28
  spec.add_runtime_dependency "string-similarity", ["~> 2.1"]
29
- spec.add_runtime_dependency "listen", ["~> 3.2"]
29
+ spec.add_runtime_dependency "listen", ["~> 3.9"]
30
30
  spec.add_runtime_dependency "tty-option", ["~> 0.1"]
31
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: retest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Barret
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-04 00:00:00.000000000 Z
11
+ date: 2024-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: string-similarity
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.2'
33
+ version: '3.9'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.2'
40
+ version: '3.9'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: tty-option
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -121,14 +121,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: 2.3.0
124
+ version: 2.5.0
125
125
  required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  requirements:
127
127
  - - ">="
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  requirements: []
131
- rubygems_version: 3.4.6
131
+ rubygems_version: 3.4.21
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: A simple command line tool to watch file change and run its matching spec.