filewatch 0.2.1 → 0.2.2

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.
Files changed (3) hide show
  1. data/bin/gtail +4 -1
  2. data/lib/filewatch/tailglob.rb +7 -1
  3. metadata +5 -5
data/bin/gtail CHANGED
@@ -32,7 +32,10 @@ def main(args)
32
32
 
33
33
  tail = FileWatch::TailGlob.new
34
34
  ARGV.each do |path|
35
- tail.tail(path, :exclude => exclude_patterns)
35
+ tail.tail(path, :exclude => exclude_patterns) do |fullpath|
36
+ p :new => fullpath
37
+ end
38
+
36
39
  end
37
40
 
38
41
  buffer = BufferedTokenizer.new
@@ -21,11 +21,12 @@ class FileWatch::TailGlob
21
21
  # Options is a hash of:
22
22
  # :exclude => array of globs to ignore.
23
23
  public
24
- def tail(path, options)
24
+ def tail(path, options={}, &block)
25
25
  what_to_watch = [ :create, :modify, :delete ]
26
26
 
27
27
  # Save glob options
28
28
  @options[path] = options
29
+ @options[path][:new_follow_callback] = block
29
30
 
30
31
  @watch.watch(path, *what_to_watch) do |path|
31
32
  # Save per-path options
@@ -33,6 +34,7 @@ class FileWatch::TailGlob
33
34
 
34
35
  # for each file found by the glob, open it.
35
36
  follow_file(path, :end)
37
+
36
38
  end # @watch.watch
37
39
  end # def watch
38
40
 
@@ -54,6 +56,10 @@ class FileWatch::TailGlob
54
56
  end
55
57
  end
56
58
 
59
+ if options.include?(:new_follow_callback)
60
+ options[:new_follow_callback].call(path)
61
+ end
62
+
57
63
  close(path) if @files.include?(path)
58
64
  @files[path] = File.new(path, "r")
59
65
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filewatch
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease:
4
+ hash: 19
5
+ prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jordan Sissel
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  requirements: []
87
87
 
88
88
  rubyforge_project:
89
- rubygems_version: 1.6.2
89
+ rubygems_version: 1.3.7
90
90
  signing_key:
91
91
  specification_version: 3
92
92
  summary: filewatch - file watching for ruby