file-tail 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -6
- data/VERSION +1 -1
- data/file-tail.gemspec +26 -26
- data/lib/file/tail.rb +7 -7
- data/lib/file/tail/version.rb +1 -1
- data/tests/file_tail_test.rb +35 -35
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebfb5840fe564aca285742374f4039c40b26fd28
|
4
|
+
data.tar.gz: 94b0aa1507f2fa225f1527e58f6149612c000fd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09e0d765e5965cdca0b8a9e0f65e03fcd95b7e0826be8dd3874c262d6a34a7f9a0d7f587320264e588b89fbb8f1008cd48fe0c6f10c6e256d155b0290e3083e3
|
7
|
+
data.tar.gz: fd48a7ec2ecc5aae8924dd8551c33951aad5a0115154649a67d9b909ef28a9693247efedb6ce83f7ea95402b2c7b58af74a567b41a15b2fa7df6f86929f64735
|
data/.travis.yml
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.1
|
data/file-tail.gemspec
CHANGED
@@ -1,40 +1,40 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: file-tail 1.1.
|
2
|
+
# stub: file-tail 1.1.1 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
|
-
s.name = "file-tail"
|
6
|
-
s.version = "1.1.
|
5
|
+
s.name = "file-tail".freeze
|
6
|
+
s.version = "1.1.1"
|
7
7
|
|
8
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
|
-
s.require_paths = ["lib"]
|
10
|
-
s.authors = ["Florian Frank"]
|
11
|
-
s.date = "
|
12
|
-
s.description = "Library to tail files in Ruby"
|
13
|
-
s.email = "flori@ping.de"
|
14
|
-
s.extra_rdoc_files = ["README.rdoc", "lib/file-tail.rb", "lib/file/tail.rb", "lib/file/tail/group.rb", "lib/file/tail/line_extension.rb", "lib/file/tail/logfile.rb", "lib/file/tail/tailer.rb", "lib/file/tail/version.rb"]
|
15
|
-
s.files = [".gitignore", ".travis.yml", "CHANGES", "COPYING", "Gemfile", "README.rdoc", "Rakefile", "VERSION", "bin/rtail", "examples/pager.rb", "examples/tail.rb", "file-tail.gemspec", "lib/file-tail.rb", "lib/file/tail.rb", "lib/file/tail/group.rb", "lib/file/tail/line_extension.rb", "lib/file/tail/logfile.rb", "lib/file/tail/tailer.rb", "lib/file/tail/version.rb", "tests/file_tail_group_test.rb", "tests/file_tail_test.rb", "tests/test_helper.rb"]
|
16
|
-
s.homepage = "http://github.com/flori/file-tail"
|
17
|
-
s.licenses = ["GPL-2.0"]
|
18
|
-
s.rdoc_options = ["--title", "File-tail - File::Tail for Ruby", "--main", "README.rdoc"]
|
19
|
-
s.rubygems_version = "2.
|
20
|
-
s.summary = "File::Tail for Ruby"
|
21
|
-
s.test_files = ["tests/file_tail_group_test.rb", "tests/file_tail_test.rb", "tests/test_helper.rb"]
|
8
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
|
+
s.require_paths = ["lib".freeze]
|
10
|
+
s.authors = ["Florian Frank".freeze]
|
11
|
+
s.date = "2016-04-19"
|
12
|
+
s.description = "Library to tail files in Ruby".freeze
|
13
|
+
s.email = "flori@ping.de".freeze
|
14
|
+
s.extra_rdoc_files = ["README.rdoc".freeze, "lib/file-tail.rb".freeze, "lib/file/tail.rb".freeze, "lib/file/tail/group.rb".freeze, "lib/file/tail/line_extension.rb".freeze, "lib/file/tail/logfile.rb".freeze, "lib/file/tail/tailer.rb".freeze, "lib/file/tail/version.rb".freeze]
|
15
|
+
s.files = [".gitignore".freeze, ".travis.yml".freeze, "CHANGES".freeze, "COPYING".freeze, "Gemfile".freeze, "README.rdoc".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/rtail".freeze, "examples/pager.rb".freeze, "examples/tail.rb".freeze, "file-tail.gemspec".freeze, "lib/file-tail.rb".freeze, "lib/file/tail.rb".freeze, "lib/file/tail/group.rb".freeze, "lib/file/tail/line_extension.rb".freeze, "lib/file/tail/logfile.rb".freeze, "lib/file/tail/tailer.rb".freeze, "lib/file/tail/version.rb".freeze, "tests/file_tail_group_test.rb".freeze, "tests/file_tail_test.rb".freeze, "tests/test_helper.rb".freeze]
|
16
|
+
s.homepage = "http://github.com/flori/file-tail".freeze
|
17
|
+
s.licenses = ["GPL-2.0".freeze]
|
18
|
+
s.rdoc_options = ["--title".freeze, "File-tail - File::Tail for Ruby".freeze, "--main".freeze, "README.rdoc".freeze]
|
19
|
+
s.rubygems_version = "2.6.3".freeze
|
20
|
+
s.summary = "File::Tail for Ruby".freeze
|
21
|
+
s.test_files = ["tests/file_tail_group_test.rb".freeze, "tests/file_tail_test.rb".freeze, "tests/test_helper.rb".freeze]
|
22
22
|
|
23
23
|
if s.respond_to? :specification_version then
|
24
24
|
s.specification_version = 4
|
25
25
|
|
26
26
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
27
|
-
s.add_development_dependency(%q<gem_hadar
|
28
|
-
s.add_development_dependency(%q<test-unit
|
29
|
-
s.add_runtime_dependency(%q<tins
|
27
|
+
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.7.1"])
|
28
|
+
s.add_development_dependency(%q<test-unit>.freeze, ["~> 2.4.0"])
|
29
|
+
s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.0"])
|
30
30
|
else
|
31
|
-
s.add_dependency(%q<gem_hadar
|
32
|
-
s.add_dependency(%q<test-unit
|
33
|
-
s.add_dependency(%q<tins
|
31
|
+
s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.7.1"])
|
32
|
+
s.add_dependency(%q<test-unit>.freeze, ["~> 2.4.0"])
|
33
|
+
s.add_dependency(%q<tins>.freeze, ["~> 1.0"])
|
34
34
|
end
|
35
35
|
else
|
36
|
-
s.add_dependency(%q<gem_hadar
|
37
|
-
s.add_dependency(%q<test-unit
|
38
|
-
s.add_dependency(%q<tins
|
36
|
+
s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.7.1"])
|
37
|
+
s.add_dependency(%q<test-unit>.freeze, ["~> 2.4.0"])
|
38
|
+
s.add_dependency(%q<tins>.freeze, ["~> 1.0"])
|
39
39
|
end
|
40
40
|
end
|
data/lib/file/tail.rb
CHANGED
@@ -125,7 +125,6 @@ class File
|
|
125
125
|
if bufsize < size
|
126
126
|
seek(0, File::SEEK_END)
|
127
127
|
while n > 0 and tell > 0 do
|
128
|
-
start = tell
|
129
128
|
seek(-bufsize, File::SEEK_CUR)
|
130
129
|
buffer = read(bufsize)
|
131
130
|
n -= buffer.count("\n")
|
@@ -170,7 +169,7 @@ class File
|
|
170
169
|
block = lambda { |line| result << line }
|
171
170
|
array_result = true
|
172
171
|
end
|
173
|
-
preset_attributes unless @lines
|
172
|
+
preset_attributes unless defined? @lines
|
174
173
|
loop do
|
175
174
|
begin
|
176
175
|
restat
|
@@ -182,7 +181,7 @@ class File
|
|
182
181
|
@n -= 1 if @n
|
183
182
|
end
|
184
183
|
reopen_file(e.mode)
|
185
|
-
@after_reopen.call self if @after_reopen
|
184
|
+
@after_reopen.call self if defined? @after_reopen
|
186
185
|
rescue ReturnException
|
187
186
|
return array_result ? result : nil
|
188
187
|
end
|
@@ -219,15 +218,16 @@ class File
|
|
219
218
|
end
|
220
219
|
|
221
220
|
def preset_attributes
|
222
|
-
@reopen_deleted = true
|
223
|
-
@reopen_suspicious = true
|
224
|
-
@break_if_eof = false
|
225
|
-
@return_if_eof = false
|
221
|
+
@reopen_deleted = true unless defined? @reopen_deleted
|
222
|
+
@reopen_suspicious = true unless defined? @reopen_suspicious
|
223
|
+
@break_if_eof = false unless defined? @break_if_eof
|
224
|
+
@return_if_eof = false unless defined? @return_if_eof
|
226
225
|
@max_interval ||= 10
|
227
226
|
@interval ||= @max_interval
|
228
227
|
@suspicious_interval ||= 60
|
229
228
|
@lines = 0
|
230
229
|
@no_read = 0
|
230
|
+
@stat = nil
|
231
231
|
end
|
232
232
|
|
233
233
|
def restat
|
data/lib/file/tail/version.rb
CHANGED
data/tests/file_tail_test.rb
CHANGED
@@ -59,58 +59,58 @@ class FileTailTest < Test::Unit::TestCase
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_tail_with_block_without_n
|
62
|
-
timeout(10) do
|
62
|
+
Timeout::timeout(10) do
|
63
63
|
lines = []
|
64
64
|
@in.backward(1)
|
65
|
-
assert_raises(
|
66
|
-
timeout(1) { @in.tail { |l| lines << l } }
|
65
|
+
assert_raises(Timeout::Error) do
|
66
|
+
Timeout::timeout(1) { @in.tail { |l| lines << l } }
|
67
67
|
end
|
68
68
|
assert_equal(1, lines.size)
|
69
69
|
#
|
70
70
|
lines = []
|
71
71
|
@in.backward(10)
|
72
|
-
assert_raises(
|
73
|
-
timeout(1) { @in.tail { |l| lines << l } }
|
72
|
+
assert_raises(Timeout::Error) do
|
73
|
+
Timeout::timeout(1) { @in.tail { |l| lines << l } }
|
74
74
|
end
|
75
75
|
assert_equal(10, lines.size)
|
76
76
|
#
|
77
77
|
lines = []
|
78
78
|
@in.backward(100)
|
79
|
-
assert_raises(
|
80
|
-
timeout(1) { @in.tail { |l| lines << l } }
|
79
|
+
assert_raises(Timeout::Error) do
|
80
|
+
Timeout::timeout(1) { @in.tail { |l| lines << l } }
|
81
81
|
end
|
82
82
|
assert_equal(100, lines.size)
|
83
83
|
#
|
84
84
|
lines = []
|
85
85
|
@in.backward(101)
|
86
|
-
assert_raises(
|
87
|
-
timeout(1) { @in.tail { |l| lines << l } }
|
86
|
+
assert_raises(Timeout::Error) do
|
87
|
+
Timeout::timeout(1) { @in.tail { |l| lines << l } }
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
92
|
def test_tail_with_block_with_n
|
93
|
-
timeout(10) do
|
93
|
+
Timeout::timeout(10) do
|
94
94
|
@in.backward(1)
|
95
95
|
lines = []
|
96
|
-
timeout(1) { @in.tail(0) { |l| lines << l } }
|
96
|
+
Timeout::timeout(1) { @in.tail(0) { |l| lines << l } }
|
97
97
|
assert_equal(0, lines.size)
|
98
98
|
#
|
99
99
|
@in.backward(1)
|
100
100
|
lines = []
|
101
|
-
timeout(1) { @in.tail(1) { |l| lines << l } }
|
101
|
+
Timeout::timeout(1) { @in.tail(1) { |l| lines << l } }
|
102
102
|
assert_equal(1, lines.size)
|
103
103
|
#
|
104
104
|
@in.backward(10)
|
105
105
|
lines = []
|
106
|
-
timeout(1) { @in.tail(10) { |l| lines << l } }
|
106
|
+
Timeout::timeout(1) { @in.tail(10) { |l| lines << l } }
|
107
107
|
assert_equal(10, lines.size)
|
108
108
|
#
|
109
109
|
@in.backward(100)
|
110
110
|
lines = []
|
111
111
|
@in.backward(1)
|
112
|
-
assert_raises(
|
113
|
-
timeout(1) { @in.tail(2) { |l| lines << l } }
|
112
|
+
assert_raises(Timeout::Error) do
|
113
|
+
Timeout::timeout(1) { @in.tail(2) { |l| lines << l } }
|
114
114
|
end
|
115
115
|
assert_equal(1, lines.size)
|
116
116
|
#
|
@@ -118,27 +118,27 @@ class FileTailTest < Test::Unit::TestCase
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def test_tail_without_block_with_n
|
121
|
-
timeout(10) do
|
121
|
+
Timeout::timeout(10) do
|
122
122
|
@in.backward(1)
|
123
123
|
lines = []
|
124
|
-
timeout(1) { lines += @in.tail(0) }
|
124
|
+
Timeout::timeout(1) { lines += @in.tail(0) }
|
125
125
|
assert_equal(0, lines.size)
|
126
126
|
#
|
127
127
|
@in.backward(1)
|
128
128
|
lines = []
|
129
|
-
timeout(1) { lines += @in.tail(1) }
|
129
|
+
Timeout::timeout(1) { lines += @in.tail(1) }
|
130
130
|
assert_equal(1, lines.size)
|
131
131
|
#
|
132
132
|
@in.backward(10)
|
133
133
|
lines = []
|
134
|
-
timeout(1) { lines += @in.tail(10) }
|
134
|
+
Timeout::timeout(1) { lines += @in.tail(10) }
|
135
135
|
assert_equal(10, lines.size)
|
136
136
|
#
|
137
137
|
@in.backward(100)
|
138
138
|
lines = []
|
139
139
|
@in.backward(1)
|
140
|
-
assert_raises(
|
141
|
-
timeout(1) { lines += @in.tail(2) }
|
140
|
+
assert_raises(Timeout::Error) do
|
141
|
+
Timeout::timeout(1) { lines += @in.tail(2) }
|
142
142
|
end
|
143
143
|
assert_equal(0, lines.size)
|
144
144
|
end
|
@@ -149,8 +149,8 @@ class FileTailTest < Test::Unit::TestCase
|
|
149
149
|
lines = []
|
150
150
|
logger = Thread.new do
|
151
151
|
begin
|
152
|
-
timeout(1) { @in.tail { |l| lines << l } }
|
153
|
-
rescue
|
152
|
+
Timeout::timeout(1) { @in.tail { |l| lines << l } }
|
153
|
+
rescue Timeout::Error
|
154
154
|
end
|
155
155
|
end
|
156
156
|
appender = Thread.new { append(@out, 10) }
|
@@ -164,12 +164,12 @@ class FileTailTest < Test::Unit::TestCase
|
|
164
164
|
lines = []
|
165
165
|
logger = Thread.new do
|
166
166
|
begin
|
167
|
-
timeout(10) do
|
167
|
+
Timeout::timeout(10) do
|
168
168
|
@in.tail do |l|
|
169
169
|
lines << l
|
170
170
|
end
|
171
171
|
end
|
172
|
-
rescue
|
172
|
+
rescue Timeout::Error
|
173
173
|
end
|
174
174
|
end
|
175
175
|
appender = Thread.new do
|
@@ -194,12 +194,12 @@ class FileTailTest < Test::Unit::TestCase
|
|
194
194
|
lines = []
|
195
195
|
logger = Thread.new do
|
196
196
|
begin
|
197
|
-
timeout(2) do
|
197
|
+
Timeout::timeout(2) do
|
198
198
|
@in.tail do |l|
|
199
199
|
lines << l
|
200
200
|
end
|
201
201
|
end
|
202
|
-
rescue
|
202
|
+
rescue Timeout::Error
|
203
203
|
end
|
204
204
|
end
|
205
205
|
appender = Thread.new do
|
@@ -225,12 +225,12 @@ class FileTailTest < Test::Unit::TestCase
|
|
225
225
|
lines = []
|
226
226
|
logger = Thread.new do
|
227
227
|
begin
|
228
|
-
timeout(2) do
|
228
|
+
Timeout::timeout(2) do
|
229
229
|
@in.tail do |l|
|
230
230
|
lines << l
|
231
231
|
end
|
232
232
|
end
|
233
|
-
rescue
|
233
|
+
rescue Timeout::Error
|
234
234
|
end
|
235
235
|
end
|
236
236
|
appender = Thread.new do
|
@@ -261,12 +261,12 @@ class FileTailTest < Test::Unit::TestCase
|
|
261
261
|
lines = []
|
262
262
|
logger = Thread.new do
|
263
263
|
begin
|
264
|
-
timeout(2) do
|
264
|
+
Timeout::timeout(2) do
|
265
265
|
@in.tail(15) do |l|
|
266
266
|
lines << l
|
267
267
|
end
|
268
268
|
end
|
269
|
-
rescue
|
269
|
+
rescue Timeout::Error
|
270
270
|
end
|
271
271
|
end
|
272
272
|
appender = Thread.new do
|
@@ -298,12 +298,12 @@ class FileTailTest < Test::Unit::TestCase
|
|
298
298
|
lines = []
|
299
299
|
logger = Thread.new do
|
300
300
|
begin
|
301
|
-
timeout(2) do
|
301
|
+
Timeout::timeout(2) do
|
302
302
|
@in.tail(110) do |l|
|
303
303
|
lines << l
|
304
304
|
end
|
305
305
|
end
|
306
|
-
rescue
|
306
|
+
rescue Timeout::Error
|
307
307
|
end
|
308
308
|
end
|
309
309
|
appender = Thread.new do
|
@@ -331,12 +331,12 @@ class FileTailTest < Test::Unit::TestCase
|
|
331
331
|
lines = []
|
332
332
|
logger = Thread.new do
|
333
333
|
begin
|
334
|
-
timeout(2) do
|
334
|
+
Timeout::timeout(2) do
|
335
335
|
@in.tail(110) do |l|
|
336
336
|
lines << l
|
337
337
|
end
|
338
338
|
end
|
339
|
-
rescue
|
339
|
+
rescue Timeout::Error
|
340
340
|
end
|
341
341
|
end
|
342
342
|
appender = Thread.new do
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: file-tail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.7.1
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.7.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: test-unit
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 2.4.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.4.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: tins
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.0'
|
55
55
|
description: Library to tail files in Ruby
|
@@ -66,8 +66,8 @@ extra_rdoc_files:
|
|
66
66
|
- lib/file/tail/tailer.rb
|
67
67
|
- lib/file/tail/version.rb
|
68
68
|
files:
|
69
|
-
- .gitignore
|
70
|
-
- .travis.yml
|
69
|
+
- ".gitignore"
|
70
|
+
- ".travis.yml"
|
71
71
|
- CHANGES
|
72
72
|
- COPYING
|
73
73
|
- Gemfile
|
@@ -94,25 +94,25 @@ licenses:
|
|
94
94
|
metadata: {}
|
95
95
|
post_install_message:
|
96
96
|
rdoc_options:
|
97
|
-
- --title
|
97
|
+
- "--title"
|
98
98
|
- File-tail - File::Tail for Ruby
|
99
|
-
- --main
|
99
|
+
- "--main"
|
100
100
|
- README.rdoc
|
101
101
|
require_paths:
|
102
102
|
- lib
|
103
103
|
required_ruby_version: !ruby/object:Gem::Requirement
|
104
104
|
requirements:
|
105
|
-
- -
|
105
|
+
- - ">="
|
106
106
|
- !ruby/object:Gem::Version
|
107
107
|
version: '0'
|
108
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
|
-
- -
|
110
|
+
- - ">="
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.
|
115
|
+
rubygems_version: 2.6.3
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: File::Tail for Ruby
|