filewatcher-cli 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ecc2b0f16f8b65900310497d4ba3ed44681a24955cbba174bb49bd46816096a1
4
- data.tar.gz: b4a02f994d6c7f25c2c390baac9ec4593bfd21e98a42b1217932eb251de3f486
3
+ metadata.gz: b6f941a4729f6f4fd84d8343acf978073fc733d55420a8f11b133209ff627eb3
4
+ data.tar.gz: 4992a109feae47f97992af65ebbdc790bcfa0261fc9c46e6f1898ccd85dcf7b9
5
5
  SHA512:
6
- metadata.gz: a0b6b45cac67c1ca798bf95ce79cb27af25f46d0005c27594477e5ea9ff8b26bbda2e8e69c8d87de6f85aeff1b5dc2626a2e902b071727613daa767500fc8e99
7
- data.tar.gz: 99ef03d27a90356182d01e5871830894a06a7ceaf30c378383d173f6b015e576bf5c536ab9aa3277f76ebe5948c171fb5ec846fad068a88b604746e393cf85e8
6
+ metadata.gz: aea329b7ee4998092192c617a413b05836ecbc8ae3e72cb524be8f6b73e518e9e1e80242c2ba3cdb3a8aa9283cf1a016bcfb501e57806d64f35403c9c7621972
7
+ data.tar.gz: 54f9a98af365f1425bb49709204649e13719e96eaf844face8f7e4d6d190c066e511d391e38529102e9e0d21cea0ab0ce02fdb163eed00910de1ade22a0ead3c
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 1.1.0 (2022-11-19)
6
+
7
+ * Return the ability to pass paths separated by spaces.
8
+ * Update development dependencies.
9
+ * Resolve new RuboCop offenses.
10
+
5
11
  ## 1.0.0 (2022-09-09)
6
12
 
7
13
  * Initial release.
@@ -18,7 +18,9 @@ class Filewatcher
18
18
 
19
19
  require_relative 'command/options'
20
20
 
21
- parameter 'FILES', 'file names to scan'
21
+ parameter 'FILES', 'file names to scan' do |string|
22
+ split_files_void_escaped_whitespace string.split unless string.to_s.empty?
23
+ end
22
24
 
23
25
  parameter '[COMMAND]', 'shell command to execute when file changes'
24
26
 
@@ -4,6 +4,6 @@ class Filewatcher
4
4
  module CLI
5
5
  BINDIR = 'exe'
6
6
 
7
- VERSION = '1.0.0'
7
+ VERSION = '1.1.0'
8
8
  end
9
9
  end
@@ -3,5 +3,11 @@
3
3
  require_relative 'shell_watch_run'
4
4
 
5
5
  def dump_to_file(content)
6
- File.write File.join(Filewatcher::CLI::SpecHelper::ShellWatchRun::DUMP_FILE), content
6
+ Filewatcher::CLI::SpecHelper.debug "#{__method__} #{content.inspect}"
7
+
8
+ File.write(
9
+ File.join(Filewatcher::CLI::SpecHelper::ShellWatchRun::DUMP_FILE),
10
+ "#{content}\n",
11
+ mode: 'a+'
12
+ )
7
13
  end
@@ -5,5 +5,5 @@ require_relative '../dump_to_file'
5
5
  dump_to_file(
6
6
  %w[
7
7
  FILENAME BASENAME EVENT DIRNAME ABSOLUTE_FILENAME RELATIVE_FILENAME
8
- ].map { |var| ENV.fetch(var) }.join(', ')
8
+ ].map { |var| ENV.fetch(var) }.join("\n")
9
9
  )
@@ -16,8 +16,10 @@ class Filewatcher
16
16
 
17
17
  DUMP_FILE = File.join(TMP_DIR, 'dump')
18
18
 
19
- def initialize(options:, dumper:, dumper_args:, **rest_args)
19
+ def initialize(watch_path, options:, dumper:, dumper_args:, **rest_args)
20
20
  super(**rest_args)
21
+
22
+ @watch_path = watch_path
21
23
  @options = options
22
24
  @options[:interval] ||= 0.2
23
25
  debug "options = #{options_string}"
@@ -69,7 +71,7 @@ class Filewatcher
69
71
  def spawn_filewatcher
70
72
  dumper_full_command = "#{__dir__}/dumpers/#{@dumper}_dumper.rb #{@dumper_args}"
71
73
  spawn_command =
72
- "#{EXECUTABLE} #{options_string} \"#{@filename}\" \"ruby #{dumper_full_command}\""
74
+ "#{EXECUTABLE} #{options_string} \"#{@watch_path}\" \"ruby #{dumper_full_command}\""
73
75
  debug "spawn_command = #{spawn_command}"
74
76
  @pid = spawn spawn_command, **SPAWN_OPTIONS
75
77
 
@@ -81,7 +83,7 @@ class Filewatcher
81
83
  def make_changes
82
84
  super
83
85
 
84
- wait seconds: 3 do
86
+ wait seconds: 3, interval: 0.5 do
85
87
  dump_file_exists = File.exist?(DUMP_FILE)
86
88
  debug "#{__method__}: File.exist?(DUMP_FILE) = #{dump_file_exists}"
87
89
  debug "#{__method__}: DUMP_FILE content = #{File.read(DUMP_FILE)}" if dump_file_exists
@@ -90,14 +92,12 @@ class Filewatcher
90
92
  end
91
93
 
92
94
  def kill_filewatcher
93
- # debug __method__
95
+ debug __method__
96
+
94
97
  if Gem.win_platform?
95
98
  Process.kill('KILL', @pid)
96
99
  else
97
- ## Problems: https://github.com/thomasfl/filewatcher/pull/83
98
- ## Solution: https://stackoverflow.com/a/45032252/2630849
99
- Process.kill('TERM', -Process.getpgid(@pid))
100
- Process.waitall
100
+ unix_kill_filewatcher
101
101
  end
102
102
  rescue Errno::ESRCH
103
103
  nil ## already killed
@@ -105,6 +105,15 @@ class Filewatcher
105
105
  wait
106
106
  end
107
107
 
108
+ def unix_kill_filewatcher
109
+ ## Problems: https://github.com/thomasfl/filewatcher/pull/83
110
+ ## Solution: https://stackoverflow.com/a/45032252/2630849
111
+ debug 'Process KILL'
112
+ Process.kill('KILL', -Process.getpgid(@pid))
113
+ debug 'Process waitall'
114
+ Process.waitall
115
+ end
116
+
108
117
  def pid_state
109
118
  if Gem.win_platform?
110
119
  match = `tasklist /FI "PID eq #{@pid}" /FO "LIST" /V`.match(/Status:\s+(\w+)/)
@@ -128,8 +137,8 @@ class Filewatcher
128
137
  ps == (Gem.win_platform? ? 'Running' : 'S')
129
138
  end
130
139
 
131
- def wait(seconds: 1)
132
- super seconds: seconds, interval: @options[:interval]
140
+ def wait(seconds: 1, interval: @options[:interval])
141
+ super seconds: seconds, interval: interval
133
142
  end
134
143
  end
135
144
  end
@@ -2,8 +2,6 @@
2
2
 
3
3
  require 'filewatcher/spec_helper'
4
4
 
5
- require_relative 'spec_helper/dump_to_file'
6
-
7
5
  class Filewatcher
8
6
  module CLI
9
7
  ## Helper for CLI specs
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filewatcher-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Flemming
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-09-08 00:00:00.000000000 Z
12
+ date: 2022-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: clamp
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '2.0'
34
+ version: '2.1'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '2.0'
41
+ version: '2.1'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: pry-byebug
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -101,14 +101,14 @@ dependencies:
101
101
  requirements:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: 0.13.1
104
+ version: 0.14.2
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
- version: 0.13.1
111
+ version: 0.14.2
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: codecov
114
114
  requirement: !ruby/object:Gem::Requirement
@@ -157,14 +157,14 @@ dependencies:
157
157
  requirements:
158
158
  - - "~>"
159
159
  - !ruby/object:Gem::Version
160
- version: 1.36.0
160
+ version: 1.39.0
161
161
  type: :development
162
162
  prerelease: false
163
163
  version_requirements: !ruby/object:Gem::Requirement
164
164
  requirements:
165
165
  - - "~>"
166
166
  - !ruby/object:Gem::Version
167
- version: 1.36.0
167
+ version: 1.39.0
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: rubocop-performance
170
170
  requirement: !ruby/object:Gem::Requirement
@@ -185,14 +185,14 @@ dependencies:
185
185
  requirements:
186
186
  - - "~>"
187
187
  - !ruby/object:Gem::Version
188
- version: '2.0'
188
+ version: 2.15.0
189
189
  type: :development
190
190
  prerelease: false
191
191
  version_requirements: !ruby/object:Gem::Requirement
192
192
  requirements:
193
193
  - - "~>"
194
194
  - !ruby/object:Gem::Version
195
- version: '2.0'
195
+ version: 2.15.0
196
196
  description: 'CLI for Filewatcher.
197
197
 
198
198
  '
@@ -246,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
246
246
  - !ruby/object:Gem::Version
247
247
  version: '0'
248
248
  requirements: []
249
- rubygems_version: 3.3.7
249
+ rubygems_version: 3.3.26
250
250
  signing_key:
251
251
  specification_version: 4
252
252
  summary: CLI for Filewatcher