core-watch 0.0.1 → 0.3.0
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 +24 -0
- data/lib/core/watch/callback.rb +4 -0
- data/lib/core/watch/callbacks/path.rb +3 -0
- data/lib/core/watch/callbacks/regexp.rb +4 -0
- data/lib/core/watch/diff.rb +3 -0
- data/lib/core/watch/snapshot.rb +44 -35
- data/lib/core/watch/status.rb +5 -0
- data/lib/core/watch/strategies/digest.rb +3 -0
- data/lib/core/watch/strategies/timestamp.rb +4 -0
- data/lib/core/watch/strategy.rb +4 -0
- data/lib/core/watch/system.rb +3 -0
- data/lib/core/watch/version.rb +1 -1
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95539be18091e3862a8c38087ff09cf98303e24a7a505c30bfd684175e0857ab
|
4
|
+
data.tar.gz: e167fa98d5a04d4b06f3641d4bae9caecf12c959a846d320582ee7a7f7699645
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d91acb6055f35e945c9996f964c726d9fa253d1cf873db677d17e735eaf3eb54f68e360720069ca4eeb0daf2af5b68c0015c72b0c162f41071a361f9953fe514
|
7
|
+
data.tar.gz: 7a0adabcace940051770dad54fd234fb64811125d62861e656e393adb5033e2b9672fbf63d471d6e43b6e7e454b87a0569ec347219bdab598dcfbcd05466ec25
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,27 @@
|
|
1
|
+
## [v0.3.0](https://github.com/metabahn/corerb/releases/tag/2021-10-24)
|
2
|
+
|
3
|
+
*released on 2021-10-24*
|
4
|
+
|
5
|
+
* `chg` [#83](https://github.com/metabahn/corerb/pull/83) Drop Ruby 2 support from core-watch ([bryanp](https://github.com/bryanp))
|
6
|
+
|
7
|
+
## [v0.2.0](https://github.com/metabahn/corerb/releases/tag/2021-07-15)
|
8
|
+
|
9
|
+
*released on 2021-07-15*
|
10
|
+
|
11
|
+
* `add` [#56](https://github.com/metabahn/corerb/pull/56) Make all watch objects inspectable ([bryanp](https://github.com/bryanp))
|
12
|
+
|
13
|
+
## [v0.1.0](https://github.com/metabahn/corerb/releases/tag/2021-07-07)
|
14
|
+
|
15
|
+
*released on 2021-07-07*
|
16
|
+
|
17
|
+
* `chg` [#45](https://github.com/metabahn/corerb/pull/45) Drop Ruby 2.6 support from core-watch ([bryanp](https://github.com/bryanp))
|
18
|
+
|
19
|
+
## [v0.0.2](https://github.com/metabahn/corerb/releases/tag/2021-05-22)
|
20
|
+
|
21
|
+
*released on 2021-05-22*
|
22
|
+
|
23
|
+
* `chg` [#30](https://github.com/metabahn/corerb/pull/30) Performance improvements to watch snapshots ([bryanp](https://github.com/bryanp))
|
24
|
+
|
1
25
|
## [v0.0.0](https://github.com/metabahn/corerb/releases/tag/2021-04-03)
|
2
26
|
|
3
27
|
*released on 2021-04-03*
|
data/lib/core/watch/callback.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "is/inspectable"
|
4
|
+
|
3
5
|
module Core
|
4
6
|
module Watch
|
5
7
|
# [public] Callback for a watched system.
|
@@ -22,6 +24,8 @@ module Core
|
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
27
|
+
include Is::Inspectable
|
28
|
+
|
25
29
|
def initialize(&block)
|
26
30
|
@block = block
|
27
31
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "is/inspectable"
|
3
4
|
require "pathname"
|
4
5
|
|
5
6
|
module Core
|
@@ -8,6 +9,8 @@ module Core
|
|
8
9
|
# [public] Callback that wraps a path.
|
9
10
|
#
|
10
11
|
class Path < Callback
|
12
|
+
include Is::Inspectable
|
13
|
+
|
11
14
|
def initialize(value, **kwargs, &block)
|
12
15
|
super(**kwargs, &block)
|
13
16
|
|
@@ -1,11 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "is/inspectable"
|
4
|
+
|
3
5
|
module Core
|
4
6
|
module Watch
|
5
7
|
module Callbacks
|
6
8
|
# [public] Callback that wraps a regular expression.
|
7
9
|
#
|
8
10
|
class Regexp < Callback
|
11
|
+
include Is::Inspectable
|
12
|
+
|
9
13
|
def initialize(regexp, **kwargs, &block)
|
10
14
|
super(**kwargs, &block)
|
11
15
|
|
data/lib/core/watch/diff.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "is/inspectable"
|
3
4
|
require "pathname"
|
4
5
|
|
5
6
|
module Core
|
@@ -7,6 +8,8 @@ module Core
|
|
7
8
|
# [public] Contains changes to a watched system, organized by operation.
|
8
9
|
#
|
9
10
|
class Diff
|
11
|
+
include Is::Inspectable
|
12
|
+
|
10
13
|
OPERATIONS = %i[added changed removed].freeze
|
11
14
|
|
12
15
|
def initialize
|
data/lib/core/watch/snapshot.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "is/inspectable"
|
4
|
+
|
3
5
|
require_relative "diff"
|
4
6
|
|
5
7
|
module Core
|
@@ -15,10 +17,11 @@ module Core
|
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
20
|
+
include Is::Inspectable
|
21
|
+
|
18
22
|
def initialize(*paths, ignore: [], strategy: self.class.default_strategy)
|
19
23
|
@ignore = ignore
|
20
|
-
@
|
21
|
-
@files = {}
|
24
|
+
@watched = {}
|
22
25
|
@strategy = strategy.new
|
23
26
|
|
24
27
|
track(*paths)
|
@@ -39,35 +42,33 @@ module Core
|
|
39
42
|
untrackable = []
|
40
43
|
diff = Diff.new
|
41
44
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
45
|
+
@watched.each do |path, object|
|
46
|
+
case object[:type]
|
47
|
+
when :directory
|
48
|
+
# The mtime of the parent directory changes when its contents have changed (e.g. a file is added or removed).
|
49
|
+
# So, do the minimum amount of work necessary to detect added/removed files, then detect file changes below.
|
50
|
+
#
|
51
|
+
if @strategy.identify(path) != object[:identity]
|
52
|
+
path.glob("*") do |each_path|
|
53
|
+
unless @watched.include?(each_path)
|
54
|
+
next if ignore?(each_path)
|
55
|
+
|
56
|
+
diff.added(each_path)
|
57
|
+
trackable << each_path
|
58
|
+
end
|
56
59
|
end
|
57
|
-
end
|
58
|
-
|
59
|
-
trackable << path
|
60
|
-
end
|
61
|
-
end
|
62
60
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
61
|
+
trackable << path
|
62
|
+
end
|
63
|
+
when :file
|
64
|
+
if @strategy.identify(path) != object[:identity]
|
65
|
+
diff.changed(path)
|
66
|
+
trackable << path
|
67
|
+
end
|
70
68
|
end
|
69
|
+
rescue Errno::ENOENT
|
70
|
+
diff.removed(path)
|
71
|
+
untrackable << path
|
71
72
|
end
|
72
73
|
|
73
74
|
track(*trackable)
|
@@ -82,13 +83,22 @@ module Core
|
|
82
83
|
paths.each do |path|
|
83
84
|
next if ignore?(path)
|
84
85
|
|
85
|
-
if path.file?
|
86
|
-
|
86
|
+
type = if path.file?
|
87
|
+
:file
|
87
88
|
elsif path.directory?
|
88
|
-
|
89
|
-
|
89
|
+
:directory
|
90
|
+
end
|
91
|
+
|
92
|
+
if type
|
93
|
+
object = {
|
94
|
+
type: type,
|
95
|
+
identity: @strategy.identify(path)
|
96
|
+
}
|
97
|
+
|
98
|
+
existed = @watched.include?(path)
|
99
|
+
@watched[path] = object
|
90
100
|
|
91
|
-
|
101
|
+
if type == :directory && !existed
|
92
102
|
track(*path.glob("*"))
|
93
103
|
end
|
94
104
|
else
|
@@ -101,8 +111,7 @@ module Core
|
|
101
111
|
#
|
102
112
|
private def untrack(*paths)
|
103
113
|
paths.each do |path|
|
104
|
-
@
|
105
|
-
@directories.delete(path)
|
114
|
+
@watched.delete(path)
|
106
115
|
end
|
107
116
|
end
|
108
117
|
end
|
data/lib/core/watch/status.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "is/inspectable"
|
4
|
+
|
3
5
|
module Core
|
4
6
|
module Watch
|
5
7
|
# [public] The status of a system watch.
|
6
8
|
#
|
7
9
|
class Status
|
10
|
+
include Is::Inspectable
|
11
|
+
inspects without: [:@mutex]
|
12
|
+
|
8
13
|
STATES = %i[running paused stopped].freeze
|
9
14
|
|
10
15
|
def initialize
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "is/inspectable"
|
3
4
|
require "openssl"
|
4
5
|
|
5
6
|
require_relative "../strategy"
|
@@ -10,6 +11,8 @@ module Core
|
|
10
11
|
# [public] Identifies a path by digest or modified time (for directories).
|
11
12
|
#
|
12
13
|
class Digest
|
14
|
+
include Is::Inspectable
|
15
|
+
|
13
16
|
BUFFER_LENGTH = 16_384
|
14
17
|
|
15
18
|
# [public]
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "is/inspectable"
|
4
|
+
|
3
5
|
require_relative "../strategy"
|
4
6
|
|
5
7
|
module Core
|
@@ -8,6 +10,8 @@ module Core
|
|
8
10
|
# [public] Identifies a path by modified time.
|
9
11
|
#
|
10
12
|
class Timestamp
|
13
|
+
include Is::Inspectable
|
14
|
+
|
11
15
|
# [public]
|
12
16
|
#
|
13
17
|
def identify(path)
|
data/lib/core/watch/strategy.rb
CHANGED
data/lib/core/watch/system.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "is/inspectable"
|
3
4
|
require "pathname"
|
4
5
|
|
5
6
|
require "core/async"
|
@@ -14,6 +15,8 @@ module Core
|
|
14
15
|
#
|
15
16
|
class System
|
16
17
|
include Is::Async
|
18
|
+
include Is::Inspectable
|
19
|
+
inspects without: [:@mutex, :@working]
|
17
20
|
|
18
21
|
# [public] The configured polling interval.
|
19
22
|
#
|
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.3.0
|
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-
|
11
|
+
date: 2021-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: core-async
|
@@ -16,14 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.8'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: core-inspect
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.0'
|
27
41
|
description: Watches the filesystem for changes.
|
28
42
|
email: bryan@metabahn.com
|
29
43
|
executables: []
|
@@ -56,14 +70,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
56
70
|
requirements:
|
57
71
|
- - ">="
|
58
72
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
73
|
+
version: '3.0'
|
60
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
75
|
requirements:
|
62
76
|
- - ">="
|
63
77
|
- !ruby/object:Gem::Version
|
64
78
|
version: '0'
|
65
79
|
requirements: []
|
66
|
-
rubygems_version: 3.2.
|
80
|
+
rubygems_version: 3.2.22
|
67
81
|
signing_key:
|
68
82
|
specification_version: 4
|
69
83
|
summary: Watches the filesystem for changes.
|