irb-reload 0.1.1 → 0.1.2
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/.ruby-version +1 -0
- data/README.md +0 -3
- data/lib/irb/reload/version.rb +1 -1
- data/lib/irb/reload.rb +29 -21
- metadata +5 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f86b968360d8b04e1a9e4b3de43903209b9b33f86607fc274bf4678610012303
|
|
4
|
+
data.tar.gz: 37a452296c72d81e3c512b89d5325ab200d620e8bd181f997864dd4944b0de15
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9eea4489ae2b03e40fee2a19efedd8fabb9ed6b140748bc68711e384561f236fb5c690c6337ebe116afb6b332e096cb52daf410577d55a7b9974927a626867c7
|
|
7
|
+
data.tar.gz: d7eddd3543f1f508b705fa62bce976a710db463b168bd20bf858cde2759eeceef1c0b278c995acc84b01442d7a4c641fbf0d48fc40790a8c138e7714c6b04c53
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
4.0.1
|
data/README.md
CHANGED
|
@@ -32,12 +32,9 @@ You can tweak the watcher through `IRB.conf`.
|
|
|
32
32
|
```ruby
|
|
33
33
|
IRB.conf[:RELOAD] = {
|
|
34
34
|
paths: %w[app lib], # directories to watch. Default is `lib`.
|
|
35
|
-
listen: { latency: 0.2 }, # options forwarded to Listen
|
|
36
35
|
}
|
|
37
36
|
```
|
|
38
37
|
|
|
39
|
-
Any keys under `:listen` are passed straight to `Listen.to`. Use this to change latency, polling, or ignore patterns.
|
|
40
|
-
|
|
41
38
|
## Development
|
|
42
39
|
|
|
43
40
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to execute the test suite. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/irb/reload/version.rb
CHANGED
data/lib/irb/reload.rb
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "irb"
|
|
4
|
-
require "
|
|
4
|
+
require "set"
|
|
5
|
+
require "watchcat"
|
|
5
6
|
|
|
6
7
|
require_relative "reload/version"
|
|
7
8
|
require_relative "reload/command"
|
|
@@ -10,18 +11,22 @@ module IRB
|
|
|
10
11
|
module Reload
|
|
11
12
|
DEFAULT_PATTERN = /\.rb\z/.freeze
|
|
12
13
|
DEFAULT_PATHS = ["lib"]
|
|
14
|
+
WATCHCAT_FILTERS = {
|
|
15
|
+
ignore_remove: true,
|
|
16
|
+
ignore_access: true
|
|
17
|
+
}.freeze
|
|
13
18
|
|
|
14
19
|
class << self
|
|
15
20
|
def start
|
|
16
21
|
@changed_files = Set.new
|
|
17
22
|
normalized_paths = normalize_paths(config[:paths] || DEFAULT_PATHS)
|
|
18
|
-
listener_options = default_listen_option
|
|
19
23
|
|
|
20
|
-
@
|
|
21
|
-
|
|
24
|
+
@watcher&.stop if defined?(@watcher) && @watcher
|
|
25
|
+
@watcher = Watchcat.watch(normalized_paths, filters: WATCHCAT_FILTERS) do |event|
|
|
26
|
+
record_watchcat_event(event)
|
|
22
27
|
end
|
|
23
28
|
|
|
24
|
-
@
|
|
29
|
+
@watched_paths = normalized_paths
|
|
25
30
|
true
|
|
26
31
|
end
|
|
27
32
|
|
|
@@ -33,9 +38,7 @@ module IRB
|
|
|
33
38
|
end
|
|
34
39
|
|
|
35
40
|
def watched_paths
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
@listener.respond_to?(:directories) ? @listener.directories : []
|
|
41
|
+
@watched_paths || []
|
|
39
42
|
end
|
|
40
43
|
|
|
41
44
|
def config
|
|
@@ -44,13 +47,6 @@ module IRB
|
|
|
44
47
|
|
|
45
48
|
private
|
|
46
49
|
|
|
47
|
-
def default_listen_option
|
|
48
|
-
options = { only: DEFAULT_PATTERN }
|
|
49
|
-
config_options = config.fetch(:listen, {})
|
|
50
|
-
options.merge!(symbolize_keys(config_options))
|
|
51
|
-
options
|
|
52
|
-
end
|
|
53
|
-
|
|
54
50
|
def normalize_paths(paths)
|
|
55
51
|
normalized = Array(paths).map(&:to_s).reject(&:empty?)
|
|
56
52
|
normalized = [Dir.pwd] if normalized.empty?
|
|
@@ -66,6 +62,24 @@ module IRB
|
|
|
66
62
|
end
|
|
67
63
|
end
|
|
68
64
|
|
|
65
|
+
def record_watchcat_event(event)
|
|
66
|
+
return unless actionable_event?(event)
|
|
67
|
+
|
|
68
|
+
paths = Array(event.paths)
|
|
69
|
+
if event.kind.create?
|
|
70
|
+
record_changed_files([], paths)
|
|
71
|
+
else
|
|
72
|
+
record_changed_files(paths, [])
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def actionable_event?(event)
|
|
77
|
+
kind = event&.kind
|
|
78
|
+
return false unless kind
|
|
79
|
+
|
|
80
|
+
kind.create? || kind.modify? || kind.any?
|
|
81
|
+
end
|
|
82
|
+
|
|
69
83
|
def ruby_file?(file)
|
|
70
84
|
File.extname(file) == ".rb"
|
|
71
85
|
end
|
|
@@ -83,12 +97,6 @@ module IRB
|
|
|
83
97
|
ensure
|
|
84
98
|
$VERBOSE = old_verbose
|
|
85
99
|
end
|
|
86
|
-
|
|
87
|
-
def symbolize_keys(hash)
|
|
88
|
-
hash.each_with_object({}) do |(key, value), memo|
|
|
89
|
-
memo[key.to_sym] = value
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
100
|
end
|
|
93
101
|
end
|
|
94
102
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: irb-reload
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yuji Yaginuma
|
|
@@ -24,39 +24,26 @@ dependencies:
|
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '1.13'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
|
-
name:
|
|
27
|
+
name: watchcat
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
32
|
+
version: '0.5'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '
|
|
40
|
-
- !ruby/object:Gem::Dependency
|
|
41
|
-
name: logger
|
|
42
|
-
requirement: !ruby/object:Gem::Requirement
|
|
43
|
-
requirements:
|
|
44
|
-
- - ">="
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: '0'
|
|
47
|
-
type: :runtime
|
|
48
|
-
prerelease: false
|
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
-
requirements:
|
|
51
|
-
- - ">="
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: '0'
|
|
39
|
+
version: '0.5'
|
|
54
40
|
email:
|
|
55
41
|
- yuuji.yaginuma@gmail.com
|
|
56
42
|
executables: []
|
|
57
43
|
extensions: []
|
|
58
44
|
extra_rdoc_files: []
|
|
59
45
|
files:
|
|
46
|
+
- ".ruby-version"
|
|
60
47
|
- CODE_OF_CONDUCT.md
|
|
61
48
|
- LICENSE.txt
|
|
62
49
|
- README.md
|