joi 0.0.1 → 0.0.2

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: f7cc69aec6c0ff97384aa4526c8c34e9d72e4f027e397b08db528222f371bc10
4
- data.tar.gz: ed35398a0f6dec5506a69f7679b8d6ed208231f0610628663a6b6d4d50c004b0
3
+ metadata.gz: 2c6c04eeb7bc068e1f782ab77368df567c7978ba971a9da566b488c838d8a22a
4
+ data.tar.gz: 73791ad41fd9e8db850a98f286407b97a23fc6f99bc6ae7f3991e4b27e198e2a
5
5
  SHA512:
6
- metadata.gz: d71d0534070f0b501f3bedc5616b5470d5a1b08e009e76faef9eca2965577a5410b13ea15d958d1ede630fd773190b6fce6ff8acba25ff221a6b19183dffd508
7
- data.tar.gz: be05a5964988d6edaf918ef1e1e9c3e35eef91184bb4f4616670120c64f9847430cf91a555a5d82656120b72b036732093e036ead67c397f4e2ec72bd6ee5633
6
+ metadata.gz: 17635fc54038b47297d1b51e403d14f39bb956095149c407964c17b76d6eed95fe71a83e4c7c6dd04365ab9b40ddd610b43a7cb5e162312014fc34705eaa4589
7
+ data.tar.gz: 7523240dcb28b9b7b51d42e4bfcfb6f12e2888c0b05ff68afc3b2d0d49bc9ceb23038de9441b3791d6158001df5fa1b1ae8bb349f57e83da4a817fe3377ba50b
@@ -24,7 +24,7 @@ jobs:
24
24
  - Gemfile
25
25
 
26
26
  steps:
27
- - uses: actions/checkout@v1
27
+ - uses: actions/checkout@v2.4.0
28
28
 
29
29
  - uses: actions/cache@v2
30
30
  with:
data/CHANGELOG.md CHANGED
@@ -11,6 +11,11 @@ Prefix your message with one of the following:
11
11
  - [Security] in case of vulnerabilities.
12
12
  -->
13
13
 
14
+ ## v0.0.2
15
+
16
+ - [Changed] SIGINT (ctrl-c) will run all tests.
17
+ - [Added] SIGQUIT (ctrl-\\) will stop joi.
18
+
14
19
  ## v0.0.1
15
20
 
16
21
  - Initial release.
data/README.md CHANGED
@@ -35,6 +35,9 @@ will run only matching test files (e.g. `app/models/user.rb` changes will run
35
35
  tests are executed. Any `.rb` file that's either created or removed file will
36
36
  also trigger a full suite run.
37
37
 
38
+ You can use `SIGINT` (ctrl-c) to run all tests. To stop joi, use `SIGQUIT`
39
+ (ctrl-\\).
40
+
38
41
  Joi is even more useful if you use
39
42
  [test_notifier](https://github.com/fnando/test_notifier).
40
43
 
data/lib/joi/cli.rb CHANGED
@@ -36,11 +36,12 @@ module Joi
36
36
 
37
37
  parser.parse!(argv)
38
38
 
39
- runner = Runner.new
39
+ runner = Runner.new(options: options)
40
40
 
41
- trap("SIGINT") { exit! }
41
+ trap("INT") { runner.run_all }
42
+ trap("QUIT") { exit! }
42
43
 
43
- runner.start(options: options)
44
+ runner.start
44
45
  end
45
46
  end
46
47
  end
@@ -3,7 +3,14 @@
3
3
  module Joi
4
4
  module Presets
5
5
  class Default
6
- def self.run_all(options)
6
+ attr_reader :options, :runner
7
+
8
+ def initialize(runner, options)
9
+ @runner = runner
10
+ @options = options
11
+ end
12
+
13
+ def run_all
7
14
  if options[:rails]
8
15
  run_rails_test(options, [])
9
16
  else
@@ -11,7 +18,7 @@ module Joi
11
18
  end
12
19
  end
13
20
 
14
- def self.call(runner, options)
21
+ def register
15
22
  run = lambda do |paths|
16
23
  system("clear")
17
24
 
@@ -54,7 +61,7 @@ module Joi
54
61
  )
55
62
  end
56
63
 
57
- def self.run_rails_test(options, test_paths)
64
+ def run_rails_test(options, test_paths)
58
65
  command = []
59
66
  command += %w[bundle exec] if options[:bundler]
60
67
  command += %w[rails test]
@@ -63,7 +70,7 @@ module Joi
63
70
  run(nil, command)
64
71
  end
65
72
 
66
- def self.run_rake_test(options, test_paths)
73
+ def run_rake_test(options, test_paths)
67
74
  command = []
68
75
  command += %w[bundle exec] if options[:bundler]
69
76
  command += %w[rake test]
@@ -77,7 +84,7 @@ module Joi
77
84
  end
78
85
  end
79
86
 
80
- def self.env_vars(env)
87
+ def env_vars(env)
81
88
  return unless env
82
89
 
83
90
  env
@@ -85,7 +92,7 @@ module Joi
85
92
  .join(" ")
86
93
  end
87
94
 
88
- def self.run(env, command)
95
+ def run(env, command)
89
96
  puts [
90
97
  "\e[37m$",
91
98
  *command.map {|arg| Shellwords.shellescape(arg) },
data/lib/joi/runner.rb CHANGED
@@ -2,16 +2,26 @@
2
2
 
3
3
  module Joi
4
4
  class Runner
5
- attr_reader :root_dir, :watchers
5
+ attr_reader :root_dir, :watchers, :preset
6
6
 
7
- def initialize(root_dir = Dir.pwd)
7
+ def initialize(
8
+ options:,
9
+ root_dir: Dir.pwd,
10
+ preset: Presets::Default.new(self, options)
11
+ )
8
12
  @root_dir = Pathname.new(root_dir)
9
13
  @watchers = []
14
+ @preset = preset
10
15
  end
11
16
 
12
- def start(options:, preset: Presets::Default)
13
- preset.call(self, options)
14
- preset.run_all(options)
17
+ def run_all
18
+ watchers.each {|watcher| watcher[:thread]&.kill }
19
+ preset.run_all
20
+ end
21
+
22
+ def start
23
+ preset.register
24
+ run_all
15
25
 
16
26
  listener = Listen.to(
17
27
  root_dir.to_s,
data/lib/joi/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Joi
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: joi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-25 00:00:00.000000000 Z
11
+ date: 2022-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: listen
@@ -163,10 +163,10 @@ metadata:
163
163
  rubygems_mfa_required: 'true'
164
164
  homepage_uri: https://github.com/fnando/joi
165
165
  bug_tracker_uri: https://github.com/fnando/joi/issues
166
- source_code_uri: https://github.com/fnando/joi/tree/v0.0.1
167
- changelog_uri: https://github.com/fnando/joi/tree/v0.0.1/CHANGELOG.md
168
- documentation_uri: https://github.com/fnando/joi/tree/v0.0.1/README.md
169
- license_uri: https://github.com/fnando/joi/tree/v0.0.1/LICENSE.md
166
+ source_code_uri: https://github.com/fnando/joi/tree/v0.0.2
167
+ changelog_uri: https://github.com/fnando/joi/tree/v0.0.2/CHANGELOG.md
168
+ documentation_uri: https://github.com/fnando/joi/tree/v0.0.2/README.md
169
+ license_uri: https://github.com/fnando/joi/tree/v0.0.2/LICENSE.md
170
170
  post_install_message:
171
171
  rdoc_options: []
172
172
  require_paths: