peephole 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c1e1d86e93630e38593455701a77a55da123ae9
4
- data.tar.gz: 128d0ed52547503ad721e48e84c975f4cd9ff0c3
3
+ metadata.gz: f090c1d2889e5d2ae0125b4a6fef59cd1cac05e1
4
+ data.tar.gz: 9c6d83692b3463e8dfeb4ed44c3d3b334e823b28
5
5
  SHA512:
6
- metadata.gz: 9debb5b6a4edc80500caa2f70337427cc926d961783527e3bd20a8a85c43eb5fcc16c78f532f1e7f2adf72b6066cd097ceff986e7576b879f26a7c27ba4d12de
7
- data.tar.gz: b436052310debd50fd478c75e9e3c9934380145b654ae889f974627b64d1cea9c057578441041e03a4c78e754cad05030bd0fe96197b307987b29c792df9ad90
6
+ metadata.gz: 75b0b3e79a68ccb3e3eabedc258cf9807aebb782db3d9bee4ac488f87d0f62d93cd898c08882bb7aae9b735b171a3f5b285d01be5a54da9addd4a94772cec404
7
+ data.tar.gz: ded4ef21d79c9247afd81ca2ea2db4985eaeefca5f3c6817db4c20c4a54b6dd70705214dda1ee397c8f5349d64069b9d3633a8495bfabf55b3e211b4432f684d
@@ -42,15 +42,11 @@ module Peephole
42
42
  end
43
43
 
44
44
  def size
45
- File.size(path) / 1024
45
+ (File.size(path) / 1024.0).ceil
46
46
  end
47
47
 
48
48
  def updated_at
49
49
  File.mtime(path)
50
50
  end
51
-
52
- def gz?
53
- File.extname(path) == '.gz'
54
- end
55
51
  end
56
52
  end
@@ -44,13 +44,29 @@ module Peephole
44
44
  end
45
45
 
46
46
  def bytes(path, page)
47
- eof = false
47
+ eof = true
48
48
  raw = ''
49
- open(path) do |f|
50
- f.seek(first_byte(page))
51
- raw = f.read(Peephole.config.bytes_per)
52
- eof = f.eof?
49
+
50
+ case path.to_s
51
+ when /\.gz\z/
52
+ Zlib::GzipReader.open(path) do |f|
53
+ f.each do |line|
54
+ next if f.pos < first_byte(page)
55
+ if f.pos >= last_byte(page)
56
+ eof = false
57
+ break
58
+ end
59
+ raw << line
60
+ end
61
+ end
62
+ else
63
+ open(path) do |f|
64
+ f.seek(first_byte(page))
65
+ raw = f.read(Peephole.config.bytes_per)
66
+ eof = f.eof?
67
+ end
53
68
  end
69
+
54
70
  [raw, eof]
55
71
  end
56
72
 
@@ -11,9 +11,7 @@
11
11
  <td><%= logfile.updated_at %></td>
12
12
  <td class="text-right">
13
13
  <div class="btn-group btn-group-sm">
14
- <% unless logfile.gz? %>
15
- <%= link_to 'Raw', raw_logfile_path(logfile), class: 'btn btn-default' %>
16
- <% end %>
14
+ <%= link_to 'Raw', raw_logfile_path(logfile), class: 'btn btn-default' %>
17
15
  <%= link_to 'Download', download_logfile_path(logfile), class: 'btn btn-default' %>
18
16
  </div>
19
17
  </td>
@@ -1,3 +1,3 @@
1
1
  module Peephole
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peephole
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - tnantoka