file-tail 1.0.7 → 1.0.8

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/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
+ *.rbc
1
2
  .*.sw[pon]
2
3
  Gemfile.lock
4
+ coverage
3
5
  pkg
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - ruby-head
6
+ - ree
7
+ # - rbx
8
+ - jruby
data/CHANGES CHANGED
@@ -1,3 +1,4 @@
1
+ 2011-12-24 * 1.0.8 * Support simplecov.
1
2
  2011-07-15 * 1.0.7 * Use gem_hadar to shorten Rakefile.
2
3
  2011-06-25 * 1.0.6 * Create a gem spec file again.
3
4
  * Added a File::Tail::Group to tail multiple files more easily.
data/Gemfile CHANGED
@@ -3,3 +3,6 @@
3
3
  source :rubygems
4
4
 
5
5
  gemspec
6
+ group :development do
7
+ gem 'simplecov'
8
+ end
data/Rakefile CHANGED
@@ -11,11 +11,13 @@ GemHadar do
11
11
  summary "#{path_name.camelize} for Ruby"
12
12
  description 'Library to tail files in Ruby'
13
13
  test_dir 'tests'
14
- ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock'
14
+ ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock', 'coverage', '*.rbc'
15
15
  readme 'README.rdoc'
16
16
 
17
17
  dependency 'tins', '~>0.3'
18
18
 
19
+ development_dependency 'test-unit', '~>2.4.0'
20
+
19
21
  install_library do
20
22
  cd 'lib' do
21
23
  libdir = CONFIG["sitelibdir"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.7
1
+ 1.0.8
data/bin/rtail CHANGED
@@ -28,7 +28,7 @@ $logfiles = File::Tail::Group.new
28
28
 
29
29
  def add_logfiles(logfiles)
30
30
  logfiles = logfiles.map { |l| File.expand_path(l) }
31
- $opt['m'] and logfiles =
31
+ $opt['m'] and logfiles =
32
32
  logfiles.select { |l| !$opt['m'] || File.fnmatch?($opt['m'], File.basename(l)) }
33
33
  for l in logfiles
34
34
  $logfiles.each_file.any? { |f| l == f.path } and next
data/file-tail.gemspec CHANGED
@@ -1,35 +1,38 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  Gem::Specification.new do |s|
4
- s.name = "file-tail"
5
- s.version = "1.0.7"
4
+ s.name = %q{file-tail}
5
+ s.version = "1.0.8"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Florian Frank"]
9
- s.date = "2011-09-25"
10
- s.description = "Library to tail files in Ruby"
11
- s.email = "flori@ping.de"
12
- s.extra_rdoc_files = ["README.rdoc", "lib/file/tail.rb", "lib/file/tail/version.rb", "lib/file/tail/line_extension.rb", "lib/file/tail/tailer.rb", "lib/file/tail/group.rb", "lib/file/tail/logfile.rb", "lib/file-tail.rb"]
13
- s.files = [".gitignore", "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/test_file-tail.rb", "tests/test_file-tail_group.rb"]
14
- s.homepage = "http://github.com/flori/file-tail"
9
+ s.date = %q{2011-12-24}
10
+ s.description = %q{Library to tail files in Ruby}
11
+ s.email = %q{flori@ping.de}
12
+ s.extra_rdoc_files = ["README.rdoc", "lib/file-tail.rb", "lib/file/tail.rb", "lib/file/tail/version.rb", "lib/file/tail/line_extension.rb", "lib/file/tail/tailer.rb", "lib/file/tail/group.rb", "lib/file/tail/logfile.rb"]
13
+ 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"]
14
+ s.homepage = %q{http://github.com/flori/file-tail}
15
15
  s.rdoc_options = ["--title", "File-tail - File::Tail for Ruby", "--main", "README.rdoc"]
16
16
  s.require_paths = ["lib"]
17
- s.rubygems_version = "1.8.10"
18
- s.summary = "File::Tail for Ruby"
19
- s.test_files = ["tests/test_file-tail_group.rb", "tests/test_file-tail.rb"]
17
+ s.rubygems_version = %q{1.5.2}
18
+ s.summary = %q{File::Tail for Ruby}
19
+ s.test_files = ["tests/file_tail_test.rb", "tests/test_helper.rb", "tests/file_tail_group_test.rb"]
20
20
 
21
21
  if s.respond_to? :specification_version then
22
22
  s.specification_version = 3
23
23
 
24
24
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
25
- s.add_development_dependency(%q<gem_hadar>, ["~> 0.1.0"])
25
+ s.add_development_dependency(%q<gem_hadar>, ["~> 0.1.4"])
26
+ s.add_development_dependency(%q<test-unit>, ["~> 2.4.0"])
26
27
  s.add_runtime_dependency(%q<tins>, ["~> 0.3"])
27
28
  else
28
- s.add_dependency(%q<gem_hadar>, ["~> 0.1.0"])
29
+ s.add_dependency(%q<gem_hadar>, ["~> 0.1.4"])
30
+ s.add_dependency(%q<test-unit>, ["~> 2.4.0"])
29
31
  s.add_dependency(%q<tins>, ["~> 0.3"])
30
32
  end
31
33
  else
32
- s.add_dependency(%q<gem_hadar>, ["~> 0.1.0"])
34
+ s.add_dependency(%q<gem_hadar>, ["~> 0.1.4"])
35
+ s.add_dependency(%q<test-unit>, ["~> 2.4.0"])
33
36
  s.add_dependency(%q<tins>, ["~> 0.3"])
34
37
  end
35
38
  end
data/lib/file/tail.rb CHANGED
@@ -26,12 +26,12 @@ class File
26
26
  class BreakException < TailException; end
27
27
 
28
28
  # The ReopenException is raised internally if File::Tail
29
- # gets suspicious something unusual has happend to
29
+ # gets suspicious something unusual has happend to
30
30
  # the tailed file, e. g., it was rotated away. The exception
31
31
  # is caught and an attempt to reopen it is made.
32
32
  class ReopenException < TailException
33
33
  attr_reader :mode
34
-
34
+
35
35
  # Creates an ReopenException object. The mode defaults to
36
36
  # <code>:bottom</code> which indicates that the file
37
37
  # should be tailed beginning from the end. <code>:top</code>
@@ -111,7 +111,7 @@ class File
111
111
  #
112
112
  # The additional argument <code>bufsize</code> is
113
113
  # used to determine the buffer size that is used to step through
114
- # the file backwards. It defaults to the block size of the
114
+ # the file backwards. It defaults to the block size of the
115
115
  # filesystem this file belongs to or 8192 bytes if this cannot
116
116
  # be determined.
117
117
  def backward(n = 0, bufsize = nil)
@@ -188,7 +188,7 @@ class File
188
188
  end
189
189
  end
190
190
  end
191
-
191
+
192
192
  private
193
193
 
194
194
  def read_line(&block)
@@ -265,7 +265,7 @@ class File
265
265
  sleep @interval
266
266
  @no_read += @interval
267
267
  end
268
-
268
+
269
269
  def reopen_file(mode)
270
270
  $DEBUG and $stdout.print "Reopening '#{path}', mode = #{mode}.\n"
271
271
  @no_read = 0
@@ -274,7 +274,7 @@ class File
274
274
  backward
275
275
  end
276
276
  rescue Errno::ESTALE, Errno::ENOENT
277
- if @reopen_deleted
277
+ if @reopen_deleted
278
278
  sleep @max_interval
279
279
  retry
280
280
  else
@@ -284,7 +284,7 @@ class File
284
284
 
285
285
  def output_debug_information
286
286
  $DEBUG or return
287
- STDERR.puts({
287
+ STDERR.puts({
288
288
  :path => path,
289
289
  :lines => @lines,
290
290
  :interval => @interval,
@@ -42,7 +42,7 @@ class File
42
42
  def self.open(filename, opts = {}, &block) # :yields: file
43
43
  file = new filename
44
44
  opts.each do |o, v|
45
- writer = o.to_s + "="
45
+ writer = o.to_s + "="
46
46
  file.__send__(writer, v) if file.respond_to? writer
47
47
  end
48
48
  if opts.key?(:wind) or opts.key?(:rewind)
@@ -4,19 +4,26 @@ class File
4
4
  # lines until the Tail::Group fetches and processes them.
5
5
  class Tailer < ::Thread
6
6
 
7
- # True if there are any lines pending on this Tailer, false
8
- # otherwise.
7
+ # True if there are any lines pending on this Tailer, false otherwise.
9
8
  def pending_lines?
10
9
  !queue.empty?
11
10
  end
12
11
 
13
- # Fetch all the pending lines from this Tailer and thereby remove them from the Tailer's queue.
12
+ # Fetch all the pending lines from this Tailer and thereby remove them
13
+ # from the Tailer's queue.
14
14
  def pending_lines
15
15
  Array.new(queue.size) { queue.deq(true) }
16
16
  end
17
17
 
18
18
  alias stop exit # Stop tailing this file and remove it from its File::Tail::Group.
19
19
 
20
+ # Return true if the thread local variable +id+ is defined or if this
21
+ # object responds to the method +id+.
22
+ def respond_to?(id)
23
+ !self[id].nil? || super
24
+ end
25
+
26
+ # Return the thread local variable +id+ if it is defined.
20
27
  def method_missing(id, *args, &block)
21
28
  if args.empty? && !(value = self[id]).nil?
22
29
  value
@@ -1,6 +1,6 @@
1
1
  module File::Tail
2
2
  # File::Tail version
3
- VERSION = '1.0.7'
3
+ VERSION = '1.0.8'
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:
@@ -1,19 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- base = File.basename(Dir.pwd)
4
- if base == 'tests' || base =~ /file-tail/
5
- Dir.chdir('..') if base == 'tests'
6
- $LOAD_PATH.unshift(File.join(Dir.pwd, 'lib'))
7
- end
8
-
9
- require 'test/unit'
3
+ require 'test_helper'
10
4
  require 'file/tail'
11
5
  require 'timeout'
12
6
  require 'thread'
13
7
  require 'tempfile'
14
8
  Thread.abort_on_exception = true
15
9
 
16
- class TestFileTailGroup < Test::Unit::TestCase
10
+ class FileTailGroupTest < Test::Unit::TestCase
17
11
  include File::Tail
18
12
 
19
13
  def test_create_group
@@ -1,18 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- base = File.basename(Dir.pwd)
4
- if base == 'tests' || base =~ /file-tail/
5
- Dir.chdir('..') if base == 'tests'
6
- $LOAD_PATH.unshift(File.join(Dir.pwd, 'lib'))
7
- end
8
-
9
- require 'test/unit'
3
+ require 'test_helper'
10
4
  require 'file/tail'
11
5
  require 'timeout'
12
6
  require 'thread'
13
7
  Thread.abort_on_exception = true
14
8
 
15
- class TestFileTail < Test::Unit::TestCase
9
+ class FileTailTest < Test::Unit::TestCase
16
10
  include File::Tail
17
11
 
18
12
  def setup
@@ -0,0 +1,7 @@
1
+ if ENV['START_SIMPLECOV'].to_i == 1
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ add_filter "#{File.basename(File.dirname(__FILE__))}/"
5
+ end
6
+ end
7
+ require 'test/unit'
metadata CHANGED
@@ -1,53 +1,88 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: file-tail
3
- version: !ruby/object:Gem::Version
4
- version: 1.0.7
3
+ version: !ruby/object:Gem::Version
4
+ hash: 7
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 8
10
+ version: 1.0.8
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Florian Frank
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2011-09-25 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2011-12-24 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
15
22
  name: gem_hadar
16
- requirement: &2160366040 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ type: :development
25
+ requirement: &id001 !ruby/object:Gem::Requirement
17
26
  none: false
18
- requirements:
27
+ requirements:
19
28
  - - ~>
20
- - !ruby/object:Gem::Version
21
- version: 0.1.0
22
- type: :development
29
+ - !ruby/object:Gem::Version
30
+ hash: 19
31
+ segments:
32
+ - 0
33
+ - 1
34
+ - 4
35
+ version: 0.1.4
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: test-unit
23
39
  prerelease: false
24
- version_requirements: *2160366040
25
- - !ruby/object:Gem::Dependency
26
- name: tins
27
- requirement: &2160365480 !ruby/object:Gem::Requirement
40
+ type: :development
41
+ requirement: &id002 !ruby/object:Gem::Requirement
28
42
  none: false
29
- requirements:
43
+ requirements:
30
44
  - - ~>
31
- - !ruby/object:Gem::Version
32
- version: '0.3'
33
- type: :runtime
45
+ - !ruby/object:Gem::Version
46
+ hash: 31
47
+ segments:
48
+ - 2
49
+ - 4
50
+ - 0
51
+ version: 2.4.0
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: tins
34
55
  prerelease: false
35
- version_requirements: *2160365480
56
+ type: :runtime
57
+ requirement: &id003 !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ hash: 13
63
+ segments:
64
+ - 0
65
+ - 3
66
+ version: "0.3"
67
+ version_requirements: *id003
36
68
  description: Library to tail files in Ruby
37
69
  email: flori@ping.de
38
70
  executables: []
71
+
39
72
  extensions: []
40
- extra_rdoc_files:
73
+
74
+ extra_rdoc_files:
41
75
  - README.rdoc
76
+ - lib/file-tail.rb
42
77
  - lib/file/tail.rb
43
78
  - lib/file/tail/version.rb
44
79
  - lib/file/tail/line_extension.rb
45
80
  - lib/file/tail/tailer.rb
46
81
  - lib/file/tail/group.rb
47
82
  - lib/file/tail/logfile.rb
48
- - lib/file-tail.rb
49
- files:
83
+ files:
50
84
  - .gitignore
85
+ - .travis.yml
51
86
  - CHANGES
52
87
  - COPYING
53
88
  - Gemfile
@@ -65,36 +100,47 @@ files:
65
100
  - lib/file/tail/logfile.rb
66
101
  - lib/file/tail/tailer.rb
67
102
  - lib/file/tail/version.rb
68
- - tests/test_file-tail.rb
69
- - tests/test_file-tail_group.rb
103
+ - tests/file_tail_group_test.rb
104
+ - tests/file_tail_test.rb
105
+ - tests/test_helper.rb
106
+ has_rdoc: true
70
107
  homepage: http://github.com/flori/file-tail
71
108
  licenses: []
109
+
72
110
  post_install_message:
73
- rdoc_options:
111
+ rdoc_options:
74
112
  - --title
75
113
  - File-tail - File::Tail for Ruby
76
114
  - --main
77
115
  - README.rdoc
78
- require_paths:
116
+ require_paths:
79
117
  - lib
80
- required_ruby_version: !ruby/object:Gem::Requirement
118
+ required_ruby_version: !ruby/object:Gem::Requirement
81
119
  none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ hash: 3
124
+ segments:
125
+ - 0
126
+ version: "0"
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
128
  none: false
88
- requirements:
89
- - - ! '>='
90
- - !ruby/object:Gem::Version
91
- version: '0'
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ hash: 3
133
+ segments:
134
+ - 0
135
+ version: "0"
92
136
  requirements: []
137
+
93
138
  rubyforge_project:
94
- rubygems_version: 1.8.10
139
+ rubygems_version: 1.5.2
95
140
  signing_key:
96
141
  specification_version: 3
97
142
  summary: File::Tail for Ruby
98
- test_files:
99
- - tests/test_file-tail_group.rb
100
- - tests/test_file-tail.rb
143
+ test_files:
144
+ - tests/file_tail_test.rb
145
+ - tests/test_helper.rb
146
+ - tests/file_tail_group_test.rb