riemann-babbler 1.3.1 → 1.3.2

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.
@@ -22,20 +22,21 @@ module Beefcake
22
22
  end
23
23
  end
24
24
 
25
- class IO
26
- TAIL_BUF_LENGTH = 1 << 16
27
-
25
+ class File
28
26
  def tail(n)
29
- return [] if n < 1
30
-
31
- seek -TAIL_BUF_LENGTH, SEEK_END
32
-
33
- buf = ""
34
- while buf.count("\n") <= n
35
- buf = read(TAIL_BUF_LENGTH) + buf
36
- seek 2 * -TAIL_BUF_LENGTH, SEEK_CUR
37
- end
38
-
39
- buf.split("\n")[-n..-1]
27
+ buffer = 1024
28
+ idx = (size - buffer).abs
29
+ chunks = []
30
+ lines = 0
31
+ begin
32
+ seek(idx)
33
+ chunk = read(buffer)
34
+ lines += chunk.count("\n")
35
+ chunks.unshift chunk
36
+ idx -= buffer
37
+ end while lines < ( n + 1 ) && pos != 0
38
+ tail_of_file = chunks.join('')
39
+ ary = tail_of_file.split(/\n/)
40
+ lines_to_return = ary[ ary.size - n, ary.size - 1 ]
40
41
  end
41
42
  end
@@ -1,5 +1,5 @@
1
1
  module Riemann
2
2
  class Babbler
3
- VERSION = '1.3.1'
3
+ VERSION = '1.3.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riemann-babbler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: