iwatcher 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile.lock +14 -0
- data/bin/iwatcher +7 -3
- data/iwatcher.gemspec +1 -1
- metadata +3 -1
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg/
|
data/Gemfile.lock
ADDED
data/bin/iwatcher
CHANGED
@@ -16,7 +16,7 @@ where [options] are:
|
|
16
16
|
EOS
|
17
17
|
|
18
18
|
opt :dir, 'Dir to watch', :default => '/tmp'
|
19
|
-
opt :command, 'Command execute on in_close_write message', :default => 'logger'
|
19
|
+
opt :command, 'Command execute on in_close_write message, file = _file_', :default => 'logger _file_'
|
20
20
|
end
|
21
21
|
|
22
22
|
def add_dir(dir)
|
@@ -25,15 +25,19 @@ def add_dir(dir)
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
def cmd(file)
|
29
|
+
@cmd ||= @opts[:command].gsub('_file_', file)
|
30
|
+
system @cmd
|
31
|
+
end
|
32
|
+
|
28
33
|
def process_event(event)
|
29
|
-
@logger.info "process event: #{event.inspect}"
|
30
34
|
file = File.join(event.absolute_name)
|
31
35
|
if File.directory? file
|
32
36
|
@logger.info "add dir: #{file} to watch"
|
33
37
|
add_dir(file)
|
34
38
|
else
|
35
39
|
@logger.info "file: #{file} process with flags: #{event.flags}"
|
36
|
-
|
40
|
+
cmd(file) if event.flags.include? :close_write
|
37
41
|
end
|
38
42
|
end
|
39
43
|
|
data/iwatcher.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iwatcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -67,7 +67,9 @@ executables:
|
|
67
67
|
extensions: []
|
68
68
|
extra_rdoc_files: []
|
69
69
|
files:
|
70
|
+
- .gitignore
|
70
71
|
- Gemfile
|
72
|
+
- Gemfile.lock
|
71
73
|
- Rakefile
|
72
74
|
- bin/iwatcher
|
73
75
|
- iwatcher.gemspec
|