retest 1.6.0 → 1.6.1

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: 357f54e47d0b81d02f32e097cc6a0ed43b850a144bd3d368cd1a29d8d7db9b8a
4
- data.tar.gz: e60ae5e97ffb0a75a4c75792d0ff04e8d79a3daab5ad8eaf30a300ce6ad0a858
3
+ metadata.gz: 1574e44c17347c9a6e737481bfcbff782800cf68baef56f7f1dc2e1006f4f5b6
4
+ data.tar.gz: abe7fda8889c342859457f87b44a91e6e9e4a8cd0d8c764d6738422a8c9ed087
5
5
  SHA512:
6
- metadata.gz: c33d9188ecedb9b19b73b9bd0c0f7e88096d94101aa1e213dae692c6e1fe6b431f081fa7da19fcadaef1fc8984e7e7167e7f0ea269fc055a0d773afa228d6c19
7
- data.tar.gz: 3901346f228ce16d193407fcd47cabadad28989e5d32c4d89d59bbf3344871021033b340663d634e1b3dc4478dc7e479be7351a7a7b546ba914b7de06add19c3
6
+ metadata.gz: 9732e40769bbdc74ec7783dede4255c6cfb64a2517a8a92cffcbb838b54b714cd71f4244f7c06c6e238ce008facbd4e49f5fd0e6a4c5d73e2c225328254cf427
7
+ data.tar.gz: 791f6b3bf4d6b8b1eec931bff738bd6e795d51a41c17263c9ab6c0e47d15e1acfd70d18679387ce40520b871c8aabb184f4298f84a965c8e4c43b0b990465b62
data/bin/debug CHANGED
@@ -1,36 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "retest"
5
4
  require "byebug"
6
5
 
7
- $stdout.sync = true
8
-
9
- options = Retest::Options.new(ARGV)
10
-
11
- if options.help?
12
- $stdout.puts options.help
13
- return
14
- end
15
-
16
- repository = Retest::Repository.new(files: Retest::VersionControl.files)
17
- command = Retest::Command.for_options(options)
18
- runner = Retest::Runners.runner_for(command.to_s)
19
- sounds = Retest::Sounds.for(options)
20
-
21
- sounds.play(:tests_pass)
22
- runner.add_observer(sounds)
23
-
24
- program = Retest::Program.new(
25
- extension: options.extension,
26
- repository: repository,
27
- command: command,
28
- runner: runner
29
- )
30
-
31
- if options.params[:diff]
32
- program.diff(options.params[:diff])
33
- else
34
- program.start # not blocking
35
- sleep
36
- end
6
+ eval(File.read("exe/retest"))
data/exe/retest CHANGED
@@ -20,7 +20,6 @@ sounds.play(:tests_pass)
20
20
  runner.add_observer(sounds)
21
21
 
22
22
  program = Retest::Program.new(
23
- extension: options.extension,
24
23
  repository: repository,
25
24
  command: command,
26
25
  runner: runner
@@ -28,7 +27,21 @@ program = Retest::Program.new(
28
27
 
29
28
  if options.params[:diff]
30
29
  program.diff(options.params[:diff])
31
- else
32
- program.start # not blocking
33
- sleep
30
+ return
34
31
  end
32
+
33
+ # Main action
34
+
35
+ $stdout.puts "Launching Retest..."
36
+ Listen.to('.', only: options.extension, relative: true) do |modified, added, removed|
37
+ begin
38
+ program.run(modified, added, removed)
39
+ rescue => e
40
+ $stdout.puts "Something went wrong: #{e.message}"
41
+ end
42
+ end.start
43
+ $stdout.puts "Ready to refactor! You can make file changes now"
44
+
45
+ # not blocking
46
+
47
+ sleep
@@ -19,10 +19,10 @@ module Retest
19
19
  def_delegators :options, :params, :full_suite?, :auto?
20
20
 
21
21
  attr_accessor :options, :setup
22
- def initialize(options: Options.new, setup: Setup.new, output_stream: STDOUT)
22
+ def initialize(options: Options.new, setup: Setup.new, stdout: $stdout)
23
23
  @options = options
24
24
  @setup = setup
25
- @output_stream = output_stream
25
+ @stdout = stdout
26
26
  end
27
27
 
28
28
  def command
@@ -52,7 +52,7 @@ module Retest
52
52
  end
53
53
 
54
54
  def default_command
55
- @output_stream.puts "Setup identified: [#{type.upcase}]. Using command: '#{setup_command}'"
55
+ @stdout.puts "Setup identified: [#{type.upcase}]. Using command: '#{setup_command}'"
56
56
  setup_command
57
57
  end
58
58
 
@@ -1,17 +1,18 @@
1
1
  module Retest
2
2
  class Program
3
- attr_accessor :runner, :repository, :command, :extension
4
- def initialize(runner: nil, repository: nil, command: nil, extension: /\.rb$/)
3
+ attr_accessor :runner, :repository, :command
4
+ def initialize(runner: nil, repository: nil, command: nil)
5
5
  @runner = runner
6
6
  @repository = repository
7
7
  @command = command
8
- @extension = extension
9
8
  end
10
9
 
11
- def start
12
- puts "Launching Retest..."
13
- build.start
14
- puts "Ready to refactor! You can make file changes now"
10
+ def run(modified, added, removed)
11
+ repository.sync(added: added, removed: removed)
12
+ runner.sync(added: added, removed: removed)
13
+ system('clear 2>/dev/null') || system('cls 2>/dev/null')
14
+
15
+ runner.run (modified + added).first, repository: repository
15
16
  end
16
17
 
17
18
  def diff(branch)
@@ -24,21 +25,5 @@ module Retest
24
25
  puts "Running tests..."
25
26
  runner.run_all_tests command.format_batch(test_files)
26
27
  end
27
-
28
- private
29
-
30
- def build
31
- Listen.to('.', only: extension, relative: true) do |modified, added, removed|
32
- begin
33
- repository.sync(added: added, removed: removed)
34
- runner.sync(added: added, removed: removed)
35
- system('clear 2>/dev/null') || system('cls 2>/dev/null')
36
-
37
- runner.run (modified + added).first, repository: repository
38
- rescue => e
39
- puts "Something went wrong: #{e.message}"
40
- end
41
- end
42
- end
43
28
  end
44
29
  end
@@ -1,12 +1,12 @@
1
1
  module Retest
2
2
  class Repository
3
- attr_accessor :files, :cache, :input_stream, :output_stream
3
+ attr_accessor :files, :cache, :stdin, :stdout
4
4
 
5
- def initialize(files: [], cache: {}, input_stream: nil, output_stream: nil)
6
- @cache = cache
7
- @files = files
8
- @input_stream = input_stream || STDIN
9
- @output_stream = output_stream|| STDOUT
5
+ def initialize(files: [], cache: {}, stdin: $stdin, stdout: $stdout)
6
+ @cache = cache
7
+ @files = files
8
+ @stdin = stdin
9
+ @stdout = stdout
10
10
  end
11
11
 
12
12
  def find_test(path)
@@ -61,7 +61,7 @@ module Retest
61
61
  end
62
62
 
63
63
  def ask_question(tests)
64
- output_stream.puts(<<~QUESTION)
64
+ stdout.puts(<<~QUESTION)
65
65
  We found few tests matching: #{@path}
66
66
  #{list_options(tests)}
67
67
 
@@ -77,7 +77,7 @@ module Retest
77
77
  end
78
78
 
79
79
  def get_input
80
- input_stream.gets.chomp.to_i
80
+ stdin.gets.chomp.to_i
81
81
  end
82
82
  end
83
83
  end
@@ -3,10 +3,10 @@ module Retest
3
3
  class ChangeRunner < Runner
4
4
  def run(changed_file = nil, repository: nil)
5
5
  if changed_file
6
- puts "Changed File Selected: #{changed_file}"
6
+ log("Changed File Selected: #{changed_file}")
7
7
  system_run command.gsub('<changed>', changed_file)
8
8
  else
9
- puts <<~ERROR
9
+ log(<<~ERROR)
10
10
  404 - Test File Not Found
11
11
  Retest could not find a changed file to run.
12
12
  ERROR
@@ -3,8 +3,9 @@ module Retest
3
3
  class Runner
4
4
  include Observable
5
5
 
6
- attr_accessor :command
7
- def initialize(command)
6
+ attr_accessor :command, :stdout
7
+ def initialize(command, stdout: $stdout)
8
+ @stdout = stdout
8
9
  @command = command
9
10
  end
10
11
 
@@ -17,7 +18,7 @@ module Retest
17
18
  end
18
19
 
19
20
  def run_all_tests(tests_string)
20
- puts "Test File Selected: #{tests_string}"
21
+ log("Test File Selected: #{tests_string}")
21
22
  system_run command.gsub('<test>', tests_string)
22
23
  end
23
24
 
@@ -31,6 +32,10 @@ module Retest
31
32
  changed
32
33
  notify_observers(result)
33
34
  end
35
+
36
+ def log(message)
37
+ stdout.puts(message)
38
+ end
34
39
  end
35
40
  end
36
41
  end
@@ -13,10 +13,10 @@ module Retest
13
13
  self.cached_test_file = repository.find_test(changed_file)
14
14
 
15
15
  if cached_test_file
16
- puts "Test File Selected: #{cached_test_file}"
16
+ log("Test File Selected: #{cached_test_file}")
17
17
  system_run command.gsub('<test>', cached_test_file)
18
18
  else
19
- puts <<~ERROR
19
+ log(<<~ERROR)
20
20
  404 - Test File Not Found
21
21
  Retest could not find a matching test file to run.
22
22
  ERROR
@@ -14,7 +14,7 @@ module Retest
14
14
 
15
15
  return print_test_file_not_found unless cached_test_file
16
16
 
17
- puts(<<~FILES)
17
+ log(<<~FILES)
18
18
  Files Selected:
19
19
  - file: #{changed_file}
20
20
  - test: #{cached_test_file}
@@ -33,7 +33,7 @@ module Retest
33
33
  private
34
34
 
35
35
  def print_test_file_not_found
36
- puts <<~ERROR
36
+ log(<<~ERROR)
37
37
  404 - Test File Not Found
38
38
  Retest could not find a matching test file to run.
39
39
  ERROR
@@ -1,3 +1,3 @@
1
1
  module Retest
2
- VERSION = "1.6.0"
2
+ VERSION = "1.6.1"
3
3
  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.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Barret
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-04 00:00:00.000000000 Z
11
+ date: 2022-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: string-similarity