file-tail 1.0.2 → 1.0.3

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/CHANGES CHANGED
@@ -1,3 +1,11 @@
1
+ 2008-04-07 * 1.0.3 * Danny Colligan <danny.colligan@sendori.com> reported a
2
+ memory leak in long running scripts using file-tail. I
3
+ think this might be a ruby related problem, which is
4
+ caused/aggravated by using yield after having &block
5
+ parameter in a method. I changed file-tail to only use
6
+ block.call, which seems to improve the memory behaviour. I
7
+ am still not sure, where the problem actually stems
8
+ from, though.
1
9
  2007-04-19 * 1.0.2 * make_doc.rb was missing from the source archive. Thanks to
2
10
  Rick Ohnemus <rick.ohnemus@systemware.com> for reporting it.
3
11
  2007-04-19 * 1.0.1 * Bugfix: File::Tail::Logfile#open with block, now closes
@@ -55,5 +63,4 @@
55
63
  * The API has changed - but I think very few people
56
64
  care at the moment.
57
65
  * Lots of tests added.
58
-
59
66
  2002-07-30 * 0.0.1 * Initial Release
File without changes
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.2
1
+ 1.0.3
data/examples/pager.rb CHANGED
@@ -6,7 +6,6 @@ require 'file/tail'
6
6
 
7
7
  filename = ARGV.shift or fail "Usage: #$0 filename [height]"
8
8
  height = (ARGV.shift || ENV['LINES'] || 23).to_i - 1
9
- p height
10
9
 
11
10
  File::Tail::Logfile.open(filename, :break_if_eof => true) do |log|
12
11
  begin
data/lib/file/tail.rb CHANGED
@@ -96,7 +96,7 @@ class File
96
96
  #
97
97
  # Every attribute of File::Tail can be set with a <code>:attributename =>
98
98
  # value</code> option.
99
- def self.open(filename, opts = {}) # :yields: file
99
+ def self.open(filename, opts = {}, &block) # :yields: file
100
100
  file = new filename
101
101
  opts.each do |o, v|
102
102
  writer = o.to_s + "="
@@ -118,7 +118,7 @@ class File
118
118
  end
119
119
  if block_given?
120
120
  begin
121
- yield file
121
+ block.call file
122
122
  ensure
123
123
  file.close
124
124
  nil
@@ -128,13 +128,14 @@ class File
128
128
  end
129
129
  end
130
130
 
131
- # Like open, but yields to every new line encountered in the logfile.
132
- def self.tail(filename, opts = {})
131
+ # Like open, but yields to every new line encountered in the logfile in
132
+ # +block+.
133
+ def self.tail(filename, opts = {}, &block)
133
134
  if ([ :forward, :backward ] & opts.keys).empty?
134
135
  opts[:backward] = 0
135
136
  end
136
137
  open(filename, opts) do |log|
137
- log.tail { |line| yield line }
138
+ log.tail { |line| block.call line }
138
139
  end
139
140
  end
140
141
  end
@@ -296,7 +297,7 @@ class File
296
297
  block = lambda { |line| result << line }
297
298
  array_result = true
298
299
  end
299
- preset_atts unless @lines
300
+ preset_attributes unless @lines
300
301
  loop do
301
302
  begin
302
303
  restat
@@ -317,10 +318,10 @@ class File
317
318
 
318
319
  private
319
320
 
320
- def read_line
321
+ def read_line(&block)
321
322
  if @n
322
323
  until @n == 0
323
- yield readline
324
+ block.call readline
324
325
  @lines += 1
325
326
  @no_read = 0
326
327
  @n -= 1
@@ -328,7 +329,7 @@ class File
328
329
  end
329
330
  raise ReturnException
330
331
  else
331
- yield readline
332
+ block.call readline
332
333
  @lines += 1
333
334
  @no_read = 0
334
335
  debug
@@ -344,7 +345,7 @@ class File
344
345
  raise ReopenException
345
346
  end
346
347
 
347
- def preset_atts
348
+ def preset_attributes
348
349
  @reopen_deleted = true if @reopen_deleted.nil?
349
350
  @reopen_suspicious = true if @reopen_suspicious.nil?
350
351
  @break_if_eof = false if @break_if_eof.nil?
@@ -410,13 +411,12 @@ class File
410
411
 
411
412
  def debug
412
413
  $DEBUG or return
413
- h = {
414
+ STDERR.puts({
414
415
  :lines => @lines,
415
416
  :interval => @interval,
416
417
  :no_read => @no_read,
417
418
  :n => @n,
418
- }
419
- $stderr.print h.inspect, "\n"
419
+ }.inspect)
420
420
  end
421
421
  end
422
422
  end
@@ -1,7 +1,7 @@
1
1
  class File
2
2
  module Tail
3
3
  # File::Tail version
4
- VERSION = '1.0.2'
4
+ VERSION = '1.0.3'
5
5
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
6
6
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
7
7
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
metadata CHANGED
@@ -1,63 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
3
- specification_version: 1
4
2
  name: file-tail
5
3
  version: !ruby/object:Gem::Version
6
- version: 1.0.2
7
- date: 2007-04-19 00:00:00 +02:00
8
- summary: File::Tail for Ruby
9
- require_paths:
10
- - lib
11
- email: flori@ping.de
12
- homepage: http://file-tail.rubyforge.org
13
- rubyforge_project: file-tail
14
- description: Library to tail files in Ruby
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 1.0.3
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
6
  authors:
29
7
  - Florian Frank
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-04-07 00:00:00 +02:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Library to tail files in Ruby
17
+ email: flori@ping.de
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
30
24
  files:
31
- - VERSION
32
- - tests
33
- - GPL
34
- - README.en
35
25
  - install.rb
36
- - Rakefile
37
- - examples
38
26
  - lib
39
- - make_doc.rb
40
- - CHANGES
41
- - tests/test_file-tail.rb
42
- - examples/pager.rb
43
- - examples/tail.rb
44
27
  - lib/file
45
28
  - lib/file/tail
46
- - lib/file/tail.rb
47
29
  - lib/file/tail/version.rb
48
- test_files:
30
+ - lib/file/tail.rb
31
+ - make_doc.rb
32
+ - README
33
+ - CHANGES
34
+ - VERSION
35
+ - tests
49
36
  - tests/test_file-tail.rb
37
+ - Rakefile
38
+ - GPL
39
+ - examples
40
+ - examples/tail.rb
41
+ - examples/pager.rb
42
+ has_rdoc: true
43
+ homepage: http://file-tail.rubyforge.org
44
+ post_install_message:
50
45
  rdoc_options:
51
46
  - --title
52
47
  - File::Tail
53
48
  - --line-numbers
54
- extra_rdoc_files: []
55
-
56
- executables: []
57
-
58
- extensions: []
59
-
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ version:
60
63
  requirements: []
61
64
 
62
- dependencies: []
63
-
65
+ rubyforge_project: file-tail
66
+ rubygems_version: 1.0.1
67
+ signing_key:
68
+ specification_version: 2
69
+ summary: File::Tail for Ruby
70
+ test_files:
71
+ - tests/test_file-tail.rb