io-tail 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,4 @@
1
+ 2012-03-12 * 0.0.2 * Fix tailing files starts at end
1
2
  2012-03-09 * 0.0.1 * Rename Gem. Add support for process tailing and reopening
2
3
  2011-12-24 * 1.0.8 * Support simplecov.
3
4
  2011-07-15 * 1.0.7 * Use gem_hadar to shorten Rakefile.
@@ -234,6 +234,7 @@ class IO
234
234
  elsif file_or_filename.is_a?(::File)
235
235
  @_file = file_or_filename
236
236
  end
237
+ self._file.seek(0, ::File::SEEK_END)
237
238
  end
238
239
 
239
240
  def close
@@ -360,4 +361,4 @@ class IO
360
361
 
361
362
  end
362
363
  end
363
- end
364
+ end
@@ -1,6 +1,6 @@
1
- module IO::Tail
2
- # IO::Tail version
3
- VERSION = '0.0.1'
1
+ module Io::Tail
2
+ # Io::Tail version
3
+ VERSION = '0.0.2'
4
4
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: << File.dirname(__FILE__)
4
+ $: << File.join(File.dirname(__FILE__),'..', 'lib')
5
+
6
+ require 'test_helper'
7
+ require 'io-tail'
8
+ require 'timeout'
9
+ require 'thread'
10
+ Thread.abort_on_exception = true
11
+
12
+ class FileTailTest < Test::Unit::TestCase
13
+
14
+ def setup
15
+ @out = File.new("test.#$$", "wb")
16
+ append(@out, 100)
17
+ @out.flush
18
+ @out.close
19
+ in_file = ::File.new(@out.path, "rb")
20
+ @in = IO::Tail::File.new(in_file)
21
+ @in.interval = 0.4
22
+ @in.max_interval = 0.8
23
+ @in.reopen_deleted = true # is default
24
+ @in.reopen_suspicious = true # is default
25
+ @in.suspicious_interval = 60
26
+ end
27
+
28
+ def test_tail_with_nothing_new_has_nothing
29
+ count = 0
30
+ begin
31
+ timeout(2) do
32
+ @in.tail do |l|
33
+ count += 1
34
+ end
35
+ end
36
+ rescue Timeout::Error
37
+ end
38
+ assert_equal(0, count)
39
+ end
40
+ def teardown
41
+ @in.close
42
+ File.unlink(@out.path)
43
+ end
44
+
45
+ private
46
+ def count(file)
47
+ n = 0
48
+ until file._file.eof?
49
+ file.readline
50
+ n += 1
51
+ end
52
+ return n
53
+ end
54
+
55
+ def append(file, n, size = 70)
56
+ (1..n).each { |x| file << "#{x} #{"A" * size}\n" }
57
+ file.flush
58
+ end
59
+ end
metadata CHANGED
@@ -1,65 +1,87 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: io-tail
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Pierre Baillet
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-03-09 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-03-12 00:00:00 +00:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
15
22
  name: gem_hadar
16
- requirement: &70303751110000 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
17
25
  none: false
18
- requirements:
26
+ requirements:
19
27
  - - ~>
20
- - !ruby/object:Gem::Version
28
+ - !ruby/object:Gem::Version
29
+ hash: 19
30
+ segments:
31
+ - 0
32
+ - 1
33
+ - 4
21
34
  version: 0.1.4
22
35
  type: :development
23
- prerelease: false
24
- version_requirements: *70303751110000
25
- - !ruby/object:Gem::Dependency
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
26
38
  name: test-unit
27
- requirement: &70303751109580 !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
28
41
  none: false
29
- requirements:
42
+ requirements:
30
43
  - - ~>
31
- - !ruby/object:Gem::Version
44
+ - !ruby/object:Gem::Version
45
+ hash: 31
46
+ segments:
47
+ - 2
48
+ - 4
49
+ - 0
32
50
  version: 2.4.0
33
51
  type: :development
34
- prerelease: false
35
- version_requirements: *70303751109580
36
- - !ruby/object:Gem::Dependency
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
37
54
  name: tins
38
- requirement: &70303751109160 !ruby/object:Gem::Requirement
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
39
57
  none: false
40
- requirements:
58
+ requirements:
41
59
  - - ~>
42
- - !ruby/object:Gem::Version
43
- version: '0.3'
60
+ - !ruby/object:Gem::Version
61
+ hash: 13
62
+ segments:
63
+ - 0
64
+ - 3
65
+ version: "0.3"
44
66
  type: :runtime
45
- prerelease: false
46
- version_requirements: *70303751109160
67
+ version_requirements: *id003
47
68
  description: Library to tail files and process in Ruby
48
69
  email: pierre@baillet.name
49
- executables:
70
+ executables:
50
71
  - rtail
51
72
  extensions: []
52
- extra_rdoc_files:
73
+
74
+ extra_rdoc_files:
53
75
  - README.rdoc
54
- - lib/io/tail/group.rb
76
+ - lib/io-tail.rb
55
77
  - lib/io/tail/line_extension.rb
56
- - lib/io/tail/logfile.rb
78
+ - lib/io/tail/version.rb
57
79
  - lib/io/tail/process.rb
58
80
  - lib/io/tail/tailer.rb
59
- - lib/io/tail/version.rb
81
+ - lib/io/tail/logfile.rb
82
+ - lib/io/tail/group.rb
60
83
  - lib/io/tail.rb
61
- - lib/io-tail.rb
62
- files:
84
+ files:
63
85
  - .gitignore
64
86
  - .travis.yml
65
87
  - CHANGES
@@ -80,38 +102,49 @@ files:
80
102
  - lib/io/tail/version.rb
81
103
  - tests/file_tail_group_test.rb
82
104
  - tests/file_tail_test.rb
105
+ - tests/file_tail_test_more.rb
83
106
  - tests/process_tail_test.rb
84
107
  - tests/test_helper.rb
108
+ has_rdoc: true
85
109
  homepage: http://github.com/octplane/ruby-io-tail
86
110
  licenses: []
111
+
87
112
  post_install_message:
88
- rdoc_options:
113
+ rdoc_options:
89
114
  - --title
90
115
  - Io-tail - Io::Tail for Ruby
91
116
  - --main
92
117
  - README.rdoc
93
- require_paths:
118
+ require_paths:
94
119
  - lib
95
- required_ruby_version: !ruby/object:Gem::Requirement
120
+ required_ruby_version: !ruby/object:Gem::Requirement
96
121
  none: false
97
- requirements:
98
- - - ! '>='
99
- - !ruby/object:Gem::Version
100
- version: '0'
101
- required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ hash: 3
126
+ segments:
127
+ - 0
128
+ version: "0"
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
130
  none: false
103
- requirements:
104
- - - ! '>='
105
- - !ruby/object:Gem::Version
106
- version: '0'
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ hash: 3
135
+ segments:
136
+ - 0
137
+ version: "0"
107
138
  requirements: []
139
+
108
140
  rubyforge_project:
109
- rubygems_version: 1.8.11
141
+ rubygems_version: 1.3.7
110
142
  signing_key:
111
143
  specification_version: 3
112
144
  summary: Io::Tail for Ruby
113
- test_files:
114
- - tests/file_tail_group_test.rb
115
- - tests/file_tail_test.rb
145
+ test_files:
146
+ - tests/file_tail_test_more.rb
116
147
  - tests/process_tail_test.rb
148
+ - tests/file_tail_test.rb
149
+ - tests/file_tail_group_test.rb
117
150
  - tests/test_helper.rb