eventmachine-tail 0.1.2788 → 0.1.2801

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.
data/lib/em/filetail.rb CHANGED
@@ -94,6 +94,7 @@ class EventMachine::FileTail
94
94
  handle_fstat(fstat)
95
95
  end # def eof
96
96
 
97
+ private
97
98
  def handle_fstat(fstat)
98
99
  if (fstat.ino != @fstat.ino)
99
100
  open # Reopen if the inode has changed
@@ -42,12 +42,13 @@ class EventMachine::FileGlobWatch
42
42
  end # class EventMachine::FileGlobWatch
43
43
 
44
44
  class EventMachine::FileGlobWatchTail
45
- def initialize(handler=nil)
45
+ def initialize(handler=nil, *args)
46
46
  @handler = handler
47
+ @args = args
47
48
  end
48
49
 
49
50
  def file_found(path)
50
- EventMachine::file_tail(path, @handler)
51
+ EventMachine::file_tail(path, @handler, *@args)
51
52
  end
52
53
 
53
54
  def file_removed(path)
data/samples/tail.rb ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Simple 'tail -f' example.
4
+ # Usage example:
5
+ # tail.rb /var/log/messages
6
+
7
+ require "rubygems"
8
+ require "eventmachine"
9
+ require "eventmachine-tail"
10
+
11
+ class Reader < EventMachine::FileTail
12
+ def initialize(path, startpos=0)
13
+ super(path, startpos)
14
+ @buffer = BufferedTokenizer.new
15
+ end
16
+
17
+ def receive_data(data)
18
+ @buffer.extract(data).each do |line|
19
+ puts "#{path}: #{line}"
20
+ end
21
+ end
22
+ end
23
+
24
+ def main(args)
25
+ if args.length == 0
26
+ puts "Usage: #{$0} <path> [path2] [...]"
27
+ return 1
28
+ end
29
+
30
+ EventMachine.run do
31
+ args.each do |path|
32
+ EventMachine::file_tail(path, Reader)
33
+ end
34
+ end
35
+ end # def main
36
+
37
+ exit(main(ARGV))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventmachine-tail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2788
4
+ version: 0.1.2801
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Sissel
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-04-12 00:00:00 -07:00
12
+ date: 2010-04-14 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -34,6 +34,7 @@ files:
34
34
  - lib/eventmachine-tail.rb
35
35
  - lib/em/filetail.rb
36
36
  - lib/em/globwatcher.rb
37
+ - samples/tail.rb
37
38
  - samples/glob-tail.rb
38
39
  has_rdoc: true
39
40
  homepage: http://code.google.com/p/semicomplete/wiki/EventMachineTail