watchcat 0.2.1-x86_64-linux → 0.3.0-x86_64-linux

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1a3d40bdf9a9bc7f37f4d09c48696ae7d284826c245838c4c265a4f58915d51
4
- data.tar.gz: edbb2fea91f315f7248a86f29f751d7f35c0664a75fb57e783a060cadd723e3c
3
+ metadata.gz: 1a100f98bc642f7e4f8ca785271849ff5bd7c86249aa52e915797325baaeca15
4
+ data.tar.gz: 7ce9498af1556b1ae7a59dcafb9e14eefe9d3e30450f01199b809166b44a7476
5
5
  SHA512:
6
- metadata.gz: 7bb34a1bc339c9e865b8d5ae8eff2742c7d52c87860c0030595a2d7784d4783cf6c93b0ba0a779abd94d9f0fa14a8f1e21b92c84b1b3bdb888ee2fe8f03cd737
7
- data.tar.gz: 894556bfa2fbb66362f167906639936cc7242f62212e25416c38612c09b187fa8aa899f0f44a91fa655daf6287e52fdbabfc96e07abf3b2cb4ee877970ce897b
6
+ metadata.gz: 21bbb0fe635899c9ed7a55857752036500bb213a297629d7148ca3192c4d7bacba497ca2c0b6c88831017f7eddef272b11669727e1f1c02c3dd759d07897807e
7
+ data.tar.gz: 531a6acacdddeb0b8b0c567c621191f020519babaaa2e53a34677ebdb11e599ec7da54ce528a6d3cdecdef031be46a4dcd82c363d9a27f5f6ecc68f7b5db9b61
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.3.0
2
+
3
+ * Support Windows
data/Gemfile.lock CHANGED
@@ -1,57 +1,71 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- watchcat (0.2.1)
5
- drb
4
+ watchcat (0.3.0)
6
5
  rb_sys
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
10
9
  specs:
11
- debug (1.9.2)
10
+ cgi (0.5.0)
11
+ date (3.4.1)
12
+ debug (1.11.0)
12
13
  irb (~> 1.10)
13
14
  reline (>= 0.3.8)
14
- drb (2.2.1)
15
- ffi (1.17.0-arm64-darwin)
16
- ffi (1.17.0-x86_64-darwin)
17
- ffi (1.17.0-x86_64-linux-gnu)
18
- io-console (0.7.2)
19
- irb (1.14.0)
15
+ erb (4.0.4)
16
+ cgi (>= 0.3.3)
17
+ ffi (1.17.1-arm64-darwin)
18
+ ffi (1.17.1-x64-mingw-ucrt)
19
+ ffi (1.17.1-x86_64-darwin)
20
+ ffi (1.17.1-x86_64-linux-gnu)
21
+ io-console (0.8.0)
22
+ irb (1.15.2)
23
+ pp (>= 0.6.0)
20
24
  rdoc (>= 4.0.0)
21
25
  reline (>= 0.4.2)
22
26
  listen (3.9.0)
23
27
  rb-fsevent (~> 0.10, >= 0.10.3)
24
28
  rb-inotify (~> 0.9, >= 0.9.10)
25
- minitest (5.25.2)
26
- minitest-retry (0.2.3)
29
+ minitest (5.25.5)
30
+ minitest-retry (0.2.5)
27
31
  minitest (>= 5.0)
28
- nokogiri (1.16.7-arm64-darwin)
32
+ nokogiri (1.18.1-arm64-darwin)
29
33
  racc (~> 1.4)
30
- nokogiri (1.16.7-x86_64-darwin)
34
+ nokogiri (1.18.1-x64-mingw-ucrt)
31
35
  racc (~> 1.4)
32
- nokogiri (1.16.7-x86_64-linux)
36
+ nokogiri (1.18.1-x86_64-darwin)
33
37
  racc (~> 1.4)
34
- psych (5.1.2)
38
+ nokogiri (1.18.1-x86_64-linux-gnu)
39
+ racc (~> 1.4)
40
+ pp (0.6.2)
41
+ prettyprint
42
+ prettyprint (0.2.0)
43
+ psych (5.2.6)
44
+ date
35
45
  stringio
36
46
  racc (1.8.1)
37
- rake (13.2.1)
38
- rake-compiler (1.2.8)
47
+ rake (13.3.0)
48
+ rake-compiler (1.3.0)
39
49
  rake
50
+ rake-compiler-dock (1.9.1)
40
51
  rb-fsevent (0.11.2)
41
52
  rb-inotify (0.11.1)
42
53
  ffi (~> 1.0)
43
- rb_sys (0.9.103)
44
- rdoc (6.7.0)
54
+ rb_sys (0.9.117)
55
+ rake-compiler-dock (= 1.9.1)
56
+ rdoc (6.14.1)
57
+ erb
45
58
  psych (>= 4.0.0)
46
- reline (0.5.10)
59
+ reline (0.6.1)
47
60
  io-console (~> 0.5)
48
- ruby_memcheck (3.0.0)
61
+ ruby_memcheck (3.0.1)
49
62
  nokogiri
50
- stringio (3.1.1)
63
+ stringio (3.1.7)
51
64
 
52
65
  PLATFORMS
53
66
  arm64-darwin-22
54
67
  arm64-darwin-23
68
+ x64-mingw-ucrt
55
69
  x86_64-darwin-19
56
70
  x86_64-darwin-20
57
71
  x86_64-linux
@@ -67,4 +81,4 @@ DEPENDENCIES
67
81
  watchcat!
68
82
 
69
83
  BUNDLED WITH
70
- 2.5.4
84
+ 2.6.2
data/README.md CHANGED
@@ -27,7 +27,7 @@ Please specify a filename or directory and callback block to `Watchcat.watch`. T
27
27
  ```ruby
28
28
  require "watchcat"
29
29
 
30
- w = Watchcat.watch("/tmp/test") do |e|
30
+ Watchcat.watch("/tmp/test") do |e|
31
31
  pp e.paths, e.kind
32
32
  end
33
33
 
@@ -58,7 +58,7 @@ You can know what event is happened with `Watchcat::EventKind`. For example, wha
58
58
  ```ruby
59
59
  require "watchcat"
60
60
 
61
- w = Watchcat.watch("/tmp/target") do |e|
61
+ Watchcat.watch("/tmp/target") do |e|
62
62
  if e.kind.create?
63
63
  if e.kind.create.file?
64
64
  puts "'#{e.paths[0]}'(File) is added."
Binary file
Binary file
Binary file
Binary file
@@ -1,13 +1,8 @@
1
- require "drb"
2
- require "drb/unix"
3
- require_relative "server"
4
- require_relative "client"
1
+ require_relative "event"
5
2
 
6
3
  module Watchcat
7
4
  class Executor
8
5
  def initialize(paths, recursive:, force_polling:, poll_interval:, wait_until_startup:, ignore_remove:, debounce:, block:)
9
- @service = nil
10
- @child_pid = nil
11
6
  @paths = paths
12
7
  @recursive = recursive
13
8
  @force_polling = force_polling
@@ -17,51 +12,52 @@ module Watchcat
17
12
  @debounce = debounce
18
13
  @block = block
19
14
  @watcher = Watchcat::Watcher.new
15
+ @watch_thread = nil
16
+ @stop_requested = false
20
17
  end
21
18
 
22
19
  def start
23
- server = Server.new(@block)
24
- @service = DRb.start_service("drbunix:", server)
25
- client = nil
26
- client = build_client if @wait_until_startup
20
+ # Always start watching in a background thread to avoid blocking
21
+ @watch_thread = Thread.new do
22
+ Thread.current.name = "watchcat-watcher"
23
+ start_watching
24
+ end
27
25
 
28
- @child_pid = fork do
29
- client = build_client unless @wait_until_startup
30
- Process.setproctitle("watchcat: watcher")
31
- client.run
26
+ # If wait_until_startup is true, give the thread a moment to start
27
+ if @wait_until_startup
28
+ sleep 0.1
32
29
  end
33
30
 
34
- main = Process.pid
35
31
  at_exit do
36
- @exit_status = $!.status if $!.is_a?(SystemExit)
37
- stop if Process.pid == main
38
- exit @exit_status if @exit_status
32
+ stop
39
33
  end
40
34
  end
41
35
 
42
36
  def stop
43
- begin
44
- @watcher.close
45
- Process.kill(:KILL, @child_pid)
46
- rescue Errno::ESRCH
47
- # NOTE: We can ignore this error because there process is already dead.
37
+ @stop_requested = true
38
+ @watcher.close
39
+ if @watch_thread && @watch_thread.alive?
40
+ @watch_thread.join(1) # Wait up to 1 second for thread to finish
48
41
  end
49
- @service.stop_service
50
42
  end
51
43
 
52
44
  private
53
45
 
54
- def build_client
55
- Client.new(
56
- @service.uri,
57
- watcher: @watcher,
58
- paths: @paths,
46
+ def start_watching
47
+ @watcher.watch(
48
+ @paths,
59
49
  recursive: @recursive,
60
50
  force_polling: @force_polling,
61
51
  poll_interval: @poll_interval,
62
- debounce: @debounce,
63
- ignore_remove: @ignore_remove
64
- )
52
+ ignore_remove: @ignore_remove,
53
+ debounce: @debounce
54
+ ) do |kind, paths, raw_kind|
55
+ break if @stop_requested
56
+
57
+ # Create an event object and call the block
58
+ event = Watchcat::Event.new(kind, paths, raw_kind)
59
+ @block.call(event)
60
+ end
65
61
  end
66
62
  end
67
63
  end
@@ -1,3 +1,3 @@
1
1
  module Watchcat
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watchcat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Yuji Yaginuma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-08 00:00:00.000000000 Z
11
+ date: 2025-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: drb
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: debug
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -129,6 +115,7 @@ executables: []
129
115
  extensions: []
130
116
  extra_rdoc_files: []
131
117
  files:
118
+ - CHANGELOG.md
132
119
  - Gemfile
133
120
  - Gemfile.lock
134
121
  - LICENSE.txt
@@ -136,15 +123,13 @@ files:
136
123
  - Rakefile
137
124
  - ext/watchcat/.gitignore
138
125
  - lib/watchcat.rb
139
- - lib/watchcat/3.0/watchcat.so
140
126
  - lib/watchcat/3.1/watchcat.so
141
127
  - lib/watchcat/3.2/watchcat.so
142
128
  - lib/watchcat/3.3/watchcat.so
143
- - lib/watchcat/client.rb
129
+ - lib/watchcat/3.4/watchcat.so
144
130
  - lib/watchcat/event.rb
145
131
  - lib/watchcat/executor.rb
146
132
  - lib/watchcat/kind.rb
147
- - lib/watchcat/server.rb
148
133
  - lib/watchcat/version.rb
149
134
  homepage: https://github.com/y-yagi/watchcat
150
135
  licenses:
@@ -160,17 +145,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
145
  requirements:
161
146
  - - ">="
162
147
  - !ruby/object:Gem::Version
163
- version: '3.0'
148
+ version: '3.1'
164
149
  - - "<"
165
150
  - !ruby/object:Gem::Version
166
- version: 3.4.dev
151
+ version: 3.5.dev
167
152
  required_rubygems_version: !ruby/object:Gem::Requirement
168
153
  requirements:
169
154
  - - ">="
170
155
  - !ruby/object:Gem::Version
171
156
  version: '0'
172
157
  requirements: []
173
- rubygems_version: 3.4.4
158
+ rubygems_version: 3.5.23
174
159
  signing_key:
175
160
  specification_version: 4
176
161
  summary: Simple filesystem notification library for Ruby.
Binary file
@@ -1,26 +0,0 @@
1
- module Watchcat
2
- class Client
3
- def initialize(uri, watcher:, paths:, recursive:, force_polling:, poll_interval:, ignore_remove:, debounce:)
4
- DRb.start_service
5
- @watcher = watcher
6
- @server = DRbObject.new_with_uri(uri)
7
- @paths = paths
8
- @recursive = recursive
9
- @force_polling = force_polling
10
- @poll_interval = poll_interval
11
- @ignore_remove = ignore_remove
12
- @debounce = debounce
13
- end
14
-
15
- def run
16
- @watcher.watch(
17
- @paths,
18
- recursive: @recursive,
19
- force_polling: @force_polling,
20
- poll_interval: @poll_interval,
21
- ignore_remove: @ignore_remove,
22
- debounce: @debounce
23
- ) { |notification| @server.execute(notification) }
24
- end
25
- end
26
- end
@@ -1,14 +0,0 @@
1
- require "watchcat/event"
2
-
3
- module Watchcat
4
- class Server
5
- def initialize(block)
6
- @block = block
7
- end
8
-
9
- def execute(notification)
10
- event = Watchcat::Event.new(notification[0], notification[1], notification[2])
11
- @block.call(event)
12
- end
13
- end
14
- end