iwatcher 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ pkg/
@@ -0,0 +1,14 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ ffi (1.8.1)
5
+ rb-inotify (0.9.0)
6
+ ffi (>= 0.5.0)
7
+ trollop (2.0)
8
+
9
+ PLATFORMS
10
+ ruby
11
+
12
+ DEPENDENCIES
13
+ rb-inotify
14
+ trollop
@@ -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
- system "#{@opts[:command]} #{file}" if event.flags.include? :close_write
40
+ cmd(file) if event.flags.include? :close_write
37
41
  end
38
42
  end
39
43
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'iwatcher'
5
- s.version = '0.0.1'
5
+ s.version = '0.0.2'
6
6
  s.authors = ['Vasiliev D.V.']
7
7
  s.email = %w(vadv.mkn@gmail.com)
8
8
  s.homepage = 'https://github.com/vadv/iwatcher'
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.1
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