philiprehberger-file_watcher 0.2.0 → 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 +12 -0
- data/README.md +35 -8
- data/lib/philiprehberger/file_watcher/version.rb +1 -1
- data/lib/philiprehberger/file_watcher/watcher.rb +29 -0
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 72955a87c0c7532aaae1770f832fa481ebdb5e8e7486a6256cd3efe22b96980a
|
|
4
|
+
data.tar.gz: 30fe17eb9808992fdbb081af22539beeef4ee3b8eeeda33db86222a95fc77d3d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 932825e2603306e53383ce80b69c1aeac3690bc3e5de594b71cf65b065c6cb33adc685dc63d39e7aa829f3616bb118fa81d674e2271cc0039446826fa73f7cf1
|
|
7
|
+
data.tar.gz: e271b72444e9221cc59954c4f2d9c4c1a601b79ce90386848638f018d3a6c4aecf9a11108acf97df96c39caefb535d5a9556e492ef7540b0bc2e4b89bba5276a
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.3.0] - 2026-04-10
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Pause and resume support via `Watcher#pause`, `Watcher#resume`, and `Watcher#paused?`
|
|
15
|
+
- Changes that occur while paused are silently ignored on resume
|
|
16
|
+
|
|
17
|
+
## [0.2.1] - 2026-03-31
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
- Standardize README badges, support section, and license format
|
|
21
|
+
|
|
10
22
|
## [0.2.0] - 2026-03-28
|
|
11
23
|
|
|
12
24
|
### Added
|
data/README.md
CHANGED
|
@@ -2,12 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/philiprehberger/rb-file-watcher/actions/workflows/ci.yml)
|
|
4
4
|
[](https://rubygems.org/gems/philiprehberger-file_watcher)
|
|
5
|
-
[](https://github.com/philiprehberger/rb-file-watcher/releases)
|
|
6
5
|
[](https://github.com/philiprehberger/rb-file-watcher/commits/main)
|
|
7
|
-
[](LICENSE)
|
|
8
|
-
[](https://github.com/philiprehberger/rb-file-watcher/issues?q=is%3Aissue+is%3Aopen+label%3Abug)
|
|
9
|
-
[](https://github.com/philiprehberger/rb-file-watcher/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement)
|
|
10
|
-
[](https://github.com/sponsors/philiprehberger)
|
|
11
6
|
|
|
12
7
|
File system change detection with polling and callbacks
|
|
13
8
|
|
|
@@ -106,6 +101,24 @@ watcher.on(:any) { |change| puts change }
|
|
|
106
101
|
watcher.start
|
|
107
102
|
```
|
|
108
103
|
|
|
104
|
+
### Pause and Resume
|
|
105
|
+
|
|
106
|
+
```ruby
|
|
107
|
+
require "philiprehberger/file_watcher"
|
|
108
|
+
|
|
109
|
+
watcher = Philiprehberger::FileWatcher::Watcher.new("./src", interval: 0.5)
|
|
110
|
+
watcher.on(:any) { |change| puts change }
|
|
111
|
+
watcher.start
|
|
112
|
+
|
|
113
|
+
# Pause during bulk operations to avoid a flood of events
|
|
114
|
+
watcher.pause
|
|
115
|
+
|
|
116
|
+
FileUtils.cp_r("./backup", "./src")
|
|
117
|
+
|
|
118
|
+
# Resume with a fresh snapshot — changes during pause are ignored
|
|
119
|
+
watcher.resume
|
|
120
|
+
```
|
|
121
|
+
|
|
109
122
|
### Snapshot
|
|
110
123
|
|
|
111
124
|
```ruby
|
|
@@ -144,6 +157,9 @@ Blocking method. Stops on `Interrupt` (Ctrl+C).
|
|
|
144
157
|
| `#start` | Start watching in a background thread |
|
|
145
158
|
| `#stop` | Stop watching and join the thread |
|
|
146
159
|
| `#running?` | Returns `true` if the watcher is active |
|
|
160
|
+
| `#pause` | Pause change detection; polling thread stays alive |
|
|
161
|
+
| `#resume` | Resume change detection with a fresh snapshot |
|
|
162
|
+
| `#paused?` | Returns `true` if the watcher is currently paused |
|
|
147
163
|
| `#snapshot` | Returns a hash of `{path => {mtime:, size:}}` for all tracked files |
|
|
148
164
|
|
|
149
165
|
### `FileWatcher::Change`
|
|
@@ -164,10 +180,21 @@ bundle exec rubocop
|
|
|
164
180
|
|
|
165
181
|
## Support
|
|
166
182
|
|
|
167
|
-
If you find this
|
|
183
|
+
If you find this project useful:
|
|
184
|
+
|
|
185
|
+
⭐ [Star the repo](https://github.com/philiprehberger/rb-file-watcher)
|
|
186
|
+
|
|
187
|
+
🐛 [Report issues](https://github.com/philiprehberger/rb-file-watcher/issues?q=is%3Aissue+is%3Aopen+label%3Abug)
|
|
188
|
+
|
|
189
|
+
💡 [Suggest features](https://github.com/philiprehberger/rb-file-watcher/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement)
|
|
190
|
+
|
|
191
|
+
❤️ [Sponsor development](https://github.com/sponsors/philiprehberger)
|
|
192
|
+
|
|
193
|
+
🌐 [All Open Source Projects](https://philiprehberger.com/open-source-packages)
|
|
194
|
+
|
|
195
|
+
💻 [GitHub Profile](https://github.com/philiprehberger)
|
|
168
196
|
|
|
169
|
-
[
|
|
170
|
-
[](https://philiprehberger.com/open-source-packages)
|
|
197
|
+
🔗 [LinkedIn Profile](https://www.linkedin.com/in/philiprehberger)
|
|
171
198
|
|
|
172
199
|
## License
|
|
173
200
|
|
|
@@ -24,6 +24,7 @@ module Philiprehberger
|
|
|
24
24
|
@mutex = Mutex.new
|
|
25
25
|
@thread = nil
|
|
26
26
|
@running = false
|
|
27
|
+
@paused = false
|
|
27
28
|
@snapshot = {}
|
|
28
29
|
@pending_debounce = {}
|
|
29
30
|
end
|
|
@@ -78,6 +79,33 @@ module Philiprehberger
|
|
|
78
79
|
@mutex.synchronize { @running }
|
|
79
80
|
end
|
|
80
81
|
|
|
82
|
+
# Pause change detection. The polling thread stays alive but skips detection.
|
|
83
|
+
#
|
|
84
|
+
# @return [self]
|
|
85
|
+
def pause
|
|
86
|
+
@mutex.synchronize { @paused = true }
|
|
87
|
+
self
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Resume change detection with a fresh snapshot.
|
|
91
|
+
#
|
|
92
|
+
# Changes that occurred while paused are silently ignored.
|
|
93
|
+
#
|
|
94
|
+
# @return [self]
|
|
95
|
+
def resume
|
|
96
|
+
@mutex.synchronize do
|
|
97
|
+
@snapshot = take_snapshot
|
|
98
|
+
@pending_debounce.clear
|
|
99
|
+
@paused = false
|
|
100
|
+
end
|
|
101
|
+
self
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# @return [Boolean] true if the watcher is currently paused
|
|
105
|
+
def paused?
|
|
106
|
+
@mutex.synchronize { @paused }
|
|
107
|
+
end
|
|
108
|
+
|
|
81
109
|
# Return a hash of all currently tracked files with their mtime and size.
|
|
82
110
|
#
|
|
83
111
|
# @return [Hash{String => Hash}] mapping of path to {mtime:, size:}
|
|
@@ -100,6 +128,7 @@ module Philiprehberger
|
|
|
100
128
|
while running?
|
|
101
129
|
sleep @interval
|
|
102
130
|
next unless running?
|
|
131
|
+
next if paused?
|
|
103
132
|
|
|
104
133
|
changes = detect_changes
|
|
105
134
|
next if changes.empty?
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: philiprehberger-file_watcher
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Philip Rehberger
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-04-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Watch files and directories for changes using polling. Detects created,
|
|
14
14
|
modified, and deleted files with configurable intervals and glob patterns.
|
|
@@ -25,11 +25,11 @@ files:
|
|
|
25
25
|
- lib/philiprehberger/file_watcher/change.rb
|
|
26
26
|
- lib/philiprehberger/file_watcher/version.rb
|
|
27
27
|
- lib/philiprehberger/file_watcher/watcher.rb
|
|
28
|
-
homepage: https://
|
|
28
|
+
homepage: https://philiprehberger.com/open-source-packages/ruby/philiprehberger-file_watcher
|
|
29
29
|
licenses:
|
|
30
30
|
- MIT
|
|
31
31
|
metadata:
|
|
32
|
-
homepage_uri: https://
|
|
32
|
+
homepage_uri: https://philiprehberger.com/open-source-packages/ruby/philiprehberger-file_watcher
|
|
33
33
|
source_code_uri: https://github.com/philiprehberger/rb-file-watcher
|
|
34
34
|
changelog_uri: https://github.com/philiprehberger/rb-file-watcher/blob/main/CHANGELOG.md
|
|
35
35
|
bug_tracker_uri: https://github.com/philiprehberger/rb-file-watcher/issues
|