watchcat 0.4.0-x86_64-linux → 0.5.1-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: 39e18906d85d9534153d3cdb2c417635eae3a631c4b8992a9d663f524230ea8c
4
- data.tar.gz: daba78690d4d037271282828df66c81303dd82810b2e2fa64a6c3f99a0969619
3
+ metadata.gz: 321d8d6758be8b5393f6e5a0115fb69eb63d79f328941d009a6de64cb32216a3
4
+ data.tar.gz: 1d34bf0218633c61dc68251ab86e3fd39c7eaa81b0479e08f4713187fb695c36
5
5
  SHA512:
6
- metadata.gz: e2ff13c8c9fcf11a83a69a91b28a1b0420537cefe4302f2268a0d0d7beb8a1327749329aa831e0a776b60eb8ee8b1fc5290bced2f1b3c349be5f1a112a04fe71
7
- data.tar.gz: ab4dcdead0a8acba220c2dbd3a2394fa67124414131375368a520b15aa4fd4a953493ecb9fdc419ccc20be072f1596ec9c91da314c6aa858f9d5064411396d9d
6
+ metadata.gz: 38561a395de662e0ba892f7cdbab4b87d7a7e8ced4e5b5a360c92c316ec03e07188f08f2d401e2514933c30b6a6ffab4754965aba85ece02b7b9642e49c25a5f
7
+ data.tar.gz: 3b9affaa5a0aca9b2368b864d90fb64d19b0604ea507e2e78d4bef00b88d1d5a87123264dc8d21c28b8542bf3dbe28c77987c0d010372d02412beacef95e30ce
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 0.5.1
2
+
3
+ * Fix missing executable files
4
+
5
+ ## 0.5.0
6
+
7
+ * Rework the debounce feature. Now all events are debounced.
8
+ * Add `init` option to CLI
9
+
1
10
  ## 0.4.0
2
11
 
3
12
  * Add CLI
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- watchcat (0.4.0)
4
+ watchcat (0.5.1)
5
5
  psych
6
6
  rb_sys
7
7
 
@@ -28,6 +28,8 @@ GEM
28
28
  rb-fsevent (~> 0.10, >= 0.10.3)
29
29
  rb-inotify (~> 0.9, >= 0.9.10)
30
30
  minitest (5.25.5)
31
+ minitest-fail-fast (0.1.0)
32
+ minitest (~> 5)
31
33
  minitest-retry (0.2.5)
32
34
  minitest (>= 5.0)
33
35
  nokogiri (1.18.1-arm64-darwin)
@@ -75,6 +77,7 @@ DEPENDENCIES
75
77
  debug
76
78
  listen
77
79
  minitest
80
+ minitest-fail-fast
78
81
  minitest-retry
79
82
  rake
80
83
  rake-compiler
data/README.md CHANGED
@@ -120,7 +120,11 @@ end
120
120
  ### Usage
121
121
 
122
122
  ```
123
+ # Run watchcat with a config file
123
124
  $ watchcat -C config.yml
125
+
126
+ # Generate a template config file
127
+ $ watchcat --init config.yml
124
128
  ```
125
129
 
126
130
  ### Configuration File
@@ -150,7 +154,7 @@ Each watch entry supports the following options:
150
154
  |-------------|--------------------------------------------------------|---------|
151
155
  | path | Directory or file path to watch (required) | - |
152
156
  | recursive | Watch a directory recursively or not | `true` |
153
- | debounce | Debounce events for the same file (in milliseconds) | `500` |
157
+ | debounce | Debounce events for the same file (in milliseconds) | `-1` |
154
158
  | filters | Event filters (same as library filters option) | `{}` |
155
159
  | patterns | File patterns to match (using File.fnmatch) | `[]` |
156
160
  | actions | Commands to execute when files change | `[]` |
Binary file
Binary file
Binary file
Binary file
@@ -22,6 +22,41 @@ module Watchcat
22
22
  end
23
23
  end
24
24
 
25
+ def self.generate_template(file_path)
26
+ template = <<~YAML
27
+ # Watchcat Configuration File
28
+
29
+ watches:
30
+ - path: "./src"
31
+ recursive: true
32
+ debounce: 300
33
+ filters:
34
+ ignore_access: true
35
+ patterns:
36
+ - "*.js"
37
+ - "*.ts"
38
+ - "*.css"
39
+ actions:
40
+ - command: "echo 'File changed: {{file_path}}'"
41
+
42
+ - path: "./docs"
43
+ recursive: true
44
+ filters:
45
+ ignore_access: true
46
+ patterns:
47
+ - "*.md"
48
+ actions:
49
+ - command: "echo 'Documentation updated: {{file_name}}'"
50
+ YAML
51
+
52
+ if File.exist?(file_path)
53
+ raise Error, "File already exists: #{file_path}. Won't overwrite."
54
+ end
55
+
56
+ File.write(file_path, template)
57
+ puts "Config template generated at #{file_path}"
58
+ end
59
+
25
60
  private
26
61
 
27
62
  def parse_watches(watches_data)
@@ -31,7 +66,7 @@ module Watchcat
31
66
  recursive: watch_config.fetch("recursive", true),
32
67
  patterns: watch_config["patterns"] || [],
33
68
  actions: watch_config["actions"] || [],
34
- debounce: watch_config.fetch("debounce", 500),
69
+ debounce: watch_config.fetch("debounce", -1),
35
70
  filters: watch_config["filters"]&.transform_keys(&:to_sym) || {},
36
71
  }
37
72
  end
@@ -45,6 +45,7 @@ module Watchcat
45
45
  path,
46
46
  recursive: watch_config[:recursive],
47
47
  filters: watch_config[:filters],
48
+ debounce: watch_config[:debounce],
48
49
  ) do |event|
49
50
  handle_file_event(event, watch_config)
50
51
  end
@@ -53,12 +54,10 @@ module Watchcat
53
54
  end
54
55
 
55
56
  def handle_file_event(event, watch_config)
56
- return if event.kind.access?
57
-
58
57
  event.paths.each do |file_path|
59
58
  next unless should_process_file?(file_path, watch_config[:patterns])
60
59
 
61
- puts "File changed: #{file_path} #{event.kind}"
60
+ puts "File changed: #{file_path}"
62
61
  execute_actions(file_path, event, watch_config[:actions])
63
62
  end
64
63
  end
data/lib/watchcat/cli.rb CHANGED
@@ -9,6 +9,12 @@ module Watchcat
9
9
  class << self
10
10
  def start(argv)
11
11
  options = parse(argv)
12
+
13
+ if options[:init]
14
+ Config.generate_template(options[:init])
15
+ return
16
+ end
17
+
12
18
  config = Config.load(options[:config])
13
19
  watcher = Watcher.new(config)
14
20
  watcher.start
@@ -17,21 +23,28 @@ module Watchcat
17
23
  end
18
24
 
19
25
  def parse(argv)
20
- options = {}
26
+ options = { config: 'watchcat.yml' }
21
27
  OptionParser.new do |opts|
22
28
  opts.banner = "Usage: watchcat [options]"
23
29
 
24
- opts.on("-C", "--config PATH", "Path to the config file") do |v|
30
+ opts.on("-C", "--config PATH", "Path to the config file. Default is 'watchcat.yml'.") do |v|
25
31
  options[:config] = v
26
32
  end
27
33
 
34
+ opts.on("--init PATH", "Generate a template config file at the specified path") do |v|
35
+ options[:init] = v
36
+ end
37
+
28
38
  opts.on("-h", "--help", "Show this help message") do
29
39
  puts opts
30
40
  exit
31
41
  end
32
42
  end.parse!(argv)
33
43
 
34
- raise OptionParser::MissingArgument.new("-C") if options[:config].nil?
44
+ if !options[:init] && options[:config].nil?
45
+ raise OptionParser::MissingArgument.new("-C")
46
+ end
47
+
35
48
  options
36
49
  end
37
50
  end
@@ -9,6 +9,7 @@ module Watchcat
9
9
  @poll_interval = poll_interval
10
10
  @filters = filters || {}
11
11
  @debounce = debounce
12
+ @debouncer = Debouncer.new if @debounce > 0
12
13
  @block = block
13
14
  @watcher = Watchcat::Watcher.new
14
15
  @watch_thread = nil
@@ -46,13 +47,19 @@ module Watchcat
46
47
  ignore_remove: @filters[:ignore_remove],
47
48
  ignore_access: @filters[:ignore_access],
48
49
  ignore_create: @filters[:ignore_create],
49
- ignore_modify: @filters[:ignore_modify],
50
- debounce: @debounce
50
+ ignore_modify: @filters[:ignore_modify]
51
51
  ) do |kind, paths, raw_kind|
52
52
  break if @stop_requested
53
53
 
54
- event = Watchcat::Event.new(kind, paths, raw_kind)
55
- @block.call(event)
54
+ if @debounce > 0 && paths.size == 1
55
+ @debouncer.debounce(paths[0], @debounce) do
56
+ event = Watchcat::Event.new(kind, paths, raw_kind)
57
+ @block.call(event)
58
+ end
59
+ else
60
+ event = Watchcat::Event.new(kind, paths, raw_kind)
61
+ @block.call(event)
62
+ end
56
63
  end
57
64
  end
58
65
  end
@@ -1,3 +1,3 @@
1
1
  module Watchcat
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watchcat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.1
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Yuji Yaginuma
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-09-01 00:00:00.000000000 Z
11
+ date: 2025-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: psych
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest-fail-fast
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rake
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -125,7 +139,8 @@ dependencies:
125
139
  description:
126
140
  email:
127
141
  - yuuji.yaginuma@gmail.com
128
- executables: []
142
+ executables:
143
+ - watchcat
129
144
  extensions: []
130
145
  extra_rdoc_files: []
131
146
  files: