joi 0.0.2 → 0.0.3
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 +4 -4
- data/.github/workflows/ruby-tests.yml +1 -1
- data/CHANGELOG.md +6 -0
- data/README.md +5 -1
- data/lib/joi/cli.rb +20 -3
- data/lib/joi/presets/default.rb +3 -5
- data/lib/joi/runner.rb +26 -3
- data/lib/joi/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 328ef14f30303e44cae5529081331cef7e478fbfc732d8e5214d448ea7d6f940
|
4
|
+
data.tar.gz: 30164290023480375dea64e69237efad2681fb6d40c8f8e9f37a0ead6f6dabb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a323d5232ba8cc662af4c9d0ce1dbea7d6e02849a4f9ca18f111650284598ac29ef28283e2d1f93a7228e29641ef1e8a36d90cf8d35853f61107a17b93eb3274
|
7
|
+
data.tar.gz: 541b1b87129f2de4c084952b5f2341acd571406d82b56acb98971bf67aca10c76ba83bb9755c1b69a7e739dc6e1db3b08abcaac19cec460d0ea6b140fa70f807
|
data/CHANGELOG.md
CHANGED
@@ -11,6 +11,12 @@ Prefix your message with one of the following:
|
|
11
11
|
- [Security] in case of vulnerabilities.
|
12
12
|
-->
|
13
13
|
|
14
|
+
## v0.0.3
|
15
|
+
|
16
|
+
- [Fixed] Only listen to `.rb` files.
|
17
|
+
- [Added] `--debug` will output additional info to help you understand why or
|
18
|
+
why not tests are being executed.
|
19
|
+
|
14
20
|
## v0.0.2
|
15
21
|
|
16
22
|
- [Changed] SIGINT (ctrl-c) will run all tests.
|
data/README.md
CHANGED
@@ -26,7 +26,8 @@ $ joi -h
|
|
26
26
|
Usage: joi [OPTIONS]
|
27
27
|
-b, --[no-]bundler Use bundler to run commands.
|
28
28
|
--rails Use this in Rails projects.
|
29
|
-
|
29
|
+
--debug Enable debug output.
|
30
|
+
-h, --help Prints this help.
|
30
31
|
```
|
31
32
|
|
32
33
|
Only `.rb` files are watched. Changes on `lib/**/*.rb` and `app/**/*.rb` files
|
@@ -35,6 +36,9 @@ will run only matching test files (e.g. `app/models/user.rb` changes will run
|
|
35
36
|
tests are executed. Any `.rb` file that's either created or removed file will
|
36
37
|
also trigger a full suite run.
|
37
38
|
|
39
|
+
To avoid passing `--rails`, you can create a `.rails` file at the project's root
|
40
|
+
directory.
|
41
|
+
|
38
42
|
You can use `SIGINT` (ctrl-c) to run all tests. To stop joi, use `SIGQUIT`
|
39
43
|
(ctrl-\\).
|
40
44
|
|
data/lib/joi/cli.rb
CHANGED
@@ -8,10 +8,20 @@ module Joi
|
|
8
8
|
@argv = argv
|
9
9
|
end
|
10
10
|
|
11
|
+
def dot_rails_file?
|
12
|
+
File.file?(File.join(Dir.pwd, ".rails"))
|
13
|
+
end
|
14
|
+
|
15
|
+
def gemfile?
|
16
|
+
File.file?(File.join(Dir.pwd, "Gemfile")) ||
|
17
|
+
File.file?(File.join(Dir.pwd, "gems.rb"))
|
18
|
+
end
|
19
|
+
|
11
20
|
def options
|
12
21
|
@options ||= {
|
13
|
-
rails:
|
14
|
-
bundler:
|
22
|
+
rails: dot_rails_file?,
|
23
|
+
bundler: gemfile?,
|
24
|
+
debug: false
|
15
25
|
}
|
16
26
|
end
|
17
27
|
|
@@ -29,7 +39,11 @@ module Joi
|
|
29
39
|
options[:rails] = rails
|
30
40
|
end
|
31
41
|
|
32
|
-
parser.on("
|
42
|
+
parser.on("--debug", "Enable debug output.") do |debug|
|
43
|
+
options[:debug] = debug
|
44
|
+
end
|
45
|
+
|
46
|
+
parser.on("-h", "--help", "Prints this help.") do
|
33
47
|
puts parser
|
34
48
|
exit
|
35
49
|
end
|
@@ -38,6 +52,9 @@ module Joi
|
|
38
52
|
|
39
53
|
runner = Runner.new(options: options)
|
40
54
|
|
55
|
+
runner.debug(".rails file found?", dot_rails_file?)
|
56
|
+
runner.debug("options:", options)
|
57
|
+
|
41
58
|
trap("INT") { runner.run_all }
|
42
59
|
trap("QUIT") { exit! }
|
43
60
|
|
data/lib/joi/presets/default.rb
CHANGED
@@ -93,12 +93,10 @@ module Joi
|
|
93
93
|
end
|
94
94
|
|
95
95
|
def run(env, command)
|
96
|
-
|
97
|
-
"\e[37m$",
|
96
|
+
runner.log_command([
|
98
97
|
*command.map {|arg| Shellwords.shellescape(arg) },
|
99
|
-
env_vars(env)
|
100
|
-
|
101
|
-
].compact.join(" ")
|
98
|
+
env_vars(env)
|
99
|
+
].join(" "))
|
102
100
|
|
103
101
|
system(env || {}, *command)
|
104
102
|
end
|
data/lib/joi/runner.rb
CHANGED
@@ -2,13 +2,14 @@
|
|
2
2
|
|
3
3
|
module Joi
|
4
4
|
class Runner
|
5
|
-
attr_reader :root_dir, :watchers, :preset
|
5
|
+
attr_reader :root_dir, :watchers, :preset, :options
|
6
6
|
|
7
7
|
def initialize(
|
8
8
|
options:,
|
9
9
|
root_dir: Dir.pwd,
|
10
10
|
preset: Presets::Default.new(self, options)
|
11
11
|
)
|
12
|
+
@options = options
|
12
13
|
@root_dir = Pathname.new(root_dir)
|
13
14
|
@watchers = []
|
14
15
|
@preset = preset
|
@@ -25,12 +26,19 @@ module Joi
|
|
25
26
|
|
26
27
|
listener = Listen.to(
|
27
28
|
root_dir.to_s,
|
28
|
-
ignore: [%r{(public|node_modules|assets|vendor)/}]
|
29
|
+
ignore: [%r{(public|node_modules|assets|vendor)/}],
|
30
|
+
only: [/\.(rb)$/]
|
29
31
|
) do |modified, added, removed|
|
30
32
|
modified = convert_to_relative_paths(modified)
|
31
33
|
added = convert_to_relative_paths(added)
|
32
34
|
removed = convert_to_relative_paths(removed)
|
33
35
|
|
36
|
+
if options[:debug]
|
37
|
+
debug("added files:", added.map(&:to_s).inspect)
|
38
|
+
debug("modified files:", modified.map(&:to_s).inspect)
|
39
|
+
debug("removed files:", removed.map(&:to_s).inspect)
|
40
|
+
end
|
41
|
+
|
34
42
|
watchers.each do |watcher|
|
35
43
|
run_watcher(
|
36
44
|
watcher,
|
@@ -46,6 +54,16 @@ module Joi
|
|
46
54
|
sleep
|
47
55
|
end
|
48
56
|
|
57
|
+
def debug(*args)
|
58
|
+
return unless options[:debug]
|
59
|
+
|
60
|
+
puts ["\e[37m[debug]\e[0m", *args].join(" ")
|
61
|
+
end
|
62
|
+
|
63
|
+
def log_command(command)
|
64
|
+
puts ["\e[37m$ ", command, "\e[0m"].join
|
65
|
+
end
|
66
|
+
|
49
67
|
def run_watcher(watcher, modified:, added:, removed:)
|
50
68
|
paths = []
|
51
69
|
paths += modified if watcher[:on].include?(:modified)
|
@@ -55,7 +73,12 @@ module Joi
|
|
55
73
|
watcher[:pattern].any? {|pattern| path.to_s.match?(pattern) }
|
56
74
|
end
|
57
75
|
|
58
|
-
|
76
|
+
unless paths.any?
|
77
|
+
debug("skipping watcher:", watcher.slice(:on, :pattern))
|
78
|
+
return
|
79
|
+
end
|
80
|
+
|
81
|
+
debug("running watcher:", watcher.slice(:on, :pattern))
|
59
82
|
|
60
83
|
watcher[:thread]&.kill
|
61
84
|
watcher[:thread] = Thread.new { watcher[:command].call(paths) }
|
data/lib/joi/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.3
|
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-
|
11
|
+
date: 2022-03-20 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.
|
167
|
-
changelog_uri: https://github.com/fnando/joi/tree/v0.0.
|
168
|
-
documentation_uri: https://github.com/fnando/joi/tree/v0.0.
|
169
|
-
license_uri: https://github.com/fnando/joi/tree/v0.0.
|
166
|
+
source_code_uri: https://github.com/fnando/joi/tree/v0.0.3
|
167
|
+
changelog_uri: https://github.com/fnando/joi/tree/v0.0.3/CHANGELOG.md
|
168
|
+
documentation_uri: https://github.com/fnando/joi/tree/v0.0.3/README.md
|
169
|
+
license_uri: https://github.com/fnando/joi/tree/v0.0.3/LICENSE.md
|
170
170
|
post_install_message:
|
171
171
|
rdoc_options: []
|
172
172
|
require_paths:
|