core-watch 0.0.1 → 0.0.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/CHANGELOG.md +6 -0
- data/lib/core/watch/snapshot.rb +40 -35
- data/lib/core/watch/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7214e1588d42429020551b10a17cb1259b66b7a794589b4d0048403abb3da14d
|
4
|
+
data.tar.gz: e3437fc62e1d34e5c9e8ce3429d3dc2f07d1a7b7bf5f57c87df16b7a43802819
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57964374546b40461c94a72f958b7e5e3e3df4f3fa7503f3063a8062de789cd3e6553f7456b05fda072da746b27db1b73c77acd445e3386198e4694ea73b3a46
|
7
|
+
data.tar.gz: 46c5c6a2e0dd0a9203729c2c719ff004f03bacd60f08fac8c1d678c3a471d62bf67c741fd19f10a527a388be9328f0547d5631da3d94052c8572fcfc2d3c66bd
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## [v0.0.2](https://github.com/metabahn/corerb/releases/tag/2021-05-22)
|
2
|
+
|
3
|
+
*released on 2021-05-22*
|
4
|
+
|
5
|
+
* `chg` [#30](https://github.com/metabahn/corerb/pull/30) Performance improvements to watch snapshots ([bryanp](https://github.com/bryanp))
|
6
|
+
|
1
7
|
## [v0.0.0](https://github.com/metabahn/corerb/releases/tag/2021-04-03)
|
2
8
|
|
3
9
|
*released on 2021-04-03*
|
data/lib/core/watch/snapshot.rb
CHANGED
@@ -17,8 +17,7 @@ module Core
|
|
17
17
|
|
18
18
|
def initialize(*paths, ignore: [], strategy: self.class.default_strategy)
|
19
19
|
@ignore = ignore
|
20
|
-
@
|
21
|
-
@files = {}
|
20
|
+
@watched = {}
|
22
21
|
@strategy = strategy.new
|
23
22
|
|
24
23
|
track(*paths)
|
@@ -39,35 +38,33 @@ module Core
|
|
39
38
|
untrackable = []
|
40
39
|
diff = Diff.new
|
41
40
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
41
|
+
@watched.each do |path, object|
|
42
|
+
case object[:type]
|
43
|
+
when :directory
|
44
|
+
# The mtime of the parent directory changes when its contents have changed (e.g. a file is added or removed).
|
45
|
+
# So, do the minimum amount of work necessary to detect added/removed files, then detect file changes below.
|
46
|
+
#
|
47
|
+
if @strategy.identify(path) != object[:identity]
|
48
|
+
path.glob("*") do |each_path|
|
49
|
+
unless @watched.include?(each_path)
|
50
|
+
next if ignore?(each_path)
|
51
|
+
|
52
|
+
diff.added(each_path)
|
53
|
+
trackable << each_path
|
54
|
+
end
|
56
55
|
end
|
57
|
-
end
|
58
56
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
untrackable << path
|
67
|
-
elsif @strategy.identify(path) != current
|
68
|
-
diff.changed(path)
|
69
|
-
trackable << path
|
57
|
+
trackable << path
|
58
|
+
end
|
59
|
+
when :file
|
60
|
+
if @strategy.identify(path) != object[:identity]
|
61
|
+
diff.changed(path)
|
62
|
+
trackable << path
|
63
|
+
end
|
70
64
|
end
|
65
|
+
rescue Errno::ENOENT
|
66
|
+
diff.removed(path)
|
67
|
+
untrackable << path
|
71
68
|
end
|
72
69
|
|
73
70
|
track(*trackable)
|
@@ -82,13 +79,22 @@ module Core
|
|
82
79
|
paths.each do |path|
|
83
80
|
next if ignore?(path)
|
84
81
|
|
85
|
-
if path.file?
|
86
|
-
|
82
|
+
type = if path.file?
|
83
|
+
:file
|
87
84
|
elsif path.directory?
|
88
|
-
|
89
|
-
|
85
|
+
:directory
|
86
|
+
end
|
87
|
+
|
88
|
+
if type
|
89
|
+
object = {
|
90
|
+
type: type,
|
91
|
+
identity: @strategy.identify(path)
|
92
|
+
}
|
93
|
+
|
94
|
+
existed = @watched.include?(path)
|
95
|
+
@watched[path] = object
|
90
96
|
|
91
|
-
|
97
|
+
if type == :directory && !existed
|
92
98
|
track(*path.glob("*"))
|
93
99
|
end
|
94
100
|
else
|
@@ -101,8 +107,7 @@ module Core
|
|
101
107
|
#
|
102
108
|
private def untrack(*paths)
|
103
109
|
paths.each do |path|
|
104
|
-
@
|
105
|
-
@directories.delete(path)
|
110
|
+
@watched.delete(path)
|
106
111
|
end
|
107
112
|
end
|
108
113
|
end
|
data/lib/core/watch/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: core-watch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Powell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: core-async
|