tailog 0.4.8 → 0.5.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 79779a30138ae7a4a7b10f0bd9aece7310f7ba7c
4
- data.tar.gz: acc191ea3c11df4edb2b5d9ca7182e16e8d31699
3
+ metadata.gz: 8fd13eb77482d1cfc13d6fd7bdf053372ea3e07c
4
+ data.tar.gz: 82e8eb42eeff66351af20e5313f233be08305657
5
5
  SHA512:
6
- metadata.gz: 28639b931c44126ab323048be617aea51f7870dad66bb3bee1f2ac96e292748cddead104c66f9716355f80a48051f1cc6d6c11504040f95c00d9ce390f28c23e
7
- data.tar.gz: 14a95094b5a68ff36720db4f0f19b0f35c49f9c8d4656c9d4c83e14b9e073fed7534abd245ab2fe8d0eb518f12bee9378a8e3161332dc842d1244b651ed8d264
6
+ metadata.gz: 043d74d639c9e52b0f9160059a5d6dab788bcdc22af765b04de13f5423a9d6a05f6f166ba1504e418edf0f807221224dc0fe8c4484b28b415dc76f6677f59a62
7
+ data.tar.gz: 1fb5736d9bbe35af4cc5f3e49ffaea1373bf825cdfb1a9115d50927e5cf1d25c11838d2cd140c29ee7ab3a8263f418684f6c3e85ca02779421b01d4fa2dcd2d3
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ install:
3
+ - gem uninstall -a bundler
4
+ - gem install bundler
5
+ - bundle --version
6
+ - bundle install
7
+ script: "bundle exec rake"
8
+ rvm:
9
+ - 1.9.3
10
+ - 2.0.0
11
+ - 2.1.5
12
+ - 2.2.1
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
1
  require "bundler/gem_tasks"
2
- task :default => :spec
2
+ task :default => :build
@@ -40,22 +40,10 @@ p {
40
40
  background: #EEE;
41
41
  }
42
42
 
43
- .dl-horizontal dt {
44
- width: 320px;
45
- padding-right: 20px;
46
- overflow-x: scroll;
47
- text-overflow: initial;
48
- }
49
-
50
- .dl-horizontal dd {
51
- margin-left: 320px;
43
+ .table td:not(:first-child) {
52
44
  word-break: break-all;
53
45
  }
54
46
 
55
- .dl-hover dt:hover + dd, .dl-hover dd:hover {
56
- background: #EEE;
57
- }
58
-
59
47
  .script select.form-control {
60
48
  display: inline-block;
61
49
  width: 100px;
data/app/views/env.erb CHANGED
@@ -1,6 +1,16 @@
1
- <dl class="dl-horizontal dl-hover">
2
- <% ENV.each do |key, value| %>
3
- <dt><%= key %></dt>
4
- <dd><%= value %></dd>
5
- <% end %>
6
- </dl>
1
+ <table class="table table-striped table-hover">
2
+ <thead>
3
+ <tr>
4
+ <th>Key</th>
5
+ <th>Value</th>
6
+ </tr>
7
+ </thead>
8
+ <tbody>
9
+ <% ENV.each do |key, value| %>
10
+ <tr>
11
+ <td><%= key %></td>
12
+ <td><%= value %></td>
13
+ </tr>
14
+ <% end %>
15
+ </tbody>
16
+ </table>
@@ -110,12 +110,19 @@
110
110
  $.post(window.location.href, { seek: window.fileSize }, function(json) {
111
111
  try {
112
112
  var data = JSON.parse(json);
113
+ var empty = !window.fileSize[data.server_hostname] && data.file_size === 0;
113
114
 
114
115
  var fileSizeKey = data.server_hostname + '-' + data.file_size;
115
116
  if (window.fileSizeDone[fileSizeKey]) return;
116
117
  window.fileSizeDone[fileSizeKey] = true;
117
118
  window.fileSize[data.server_hostname] = data.file_size;
118
119
 
120
+ if (empty) {
121
+ $content
122
+ .append('<span class="text-info">' + data.server_hostname + ' - ' + data.file_size + '</span>')
123
+ .append('<p><span class="text-danger">There is nothing in this file.</span></p>');
124
+ }
125
+
119
126
  if (!data.content) return;
120
127
  var shouldScrollToBottom = $window.scrollTop() + $window.height() == $document.height();
121
128
 
@@ -144,10 +151,33 @@
144
151
  </script>
145
152
 
146
153
  <% else %>
147
- <% Dir[File.join Tailog.log_path, '**/*.log'].each do |file| %>
148
- <% relative_file = Pathname.new(file).relative_path_from(Pathname.new(Tailog.log_path)) %>
149
- <p><a href="?file=<%= relative_file %>"><%= file %></a></p>
150
- <% end %>
154
+ <table class="table table-striped table-hover">
155
+ <thead>
156
+ <tr>
157
+ <th>File name</th>
158
+ <th>Size</th>
159
+ <th>Updated at</th>
160
+ </tr>
161
+ </thead>
162
+ <tbody>
163
+ <% Dir[File.join Tailog.log_path, '**/*.log'].each do |file| %>
164
+ <% relative_file = Pathname.new(file).relative_path_from(Pathname.new(Tailog.log_path)) %>
165
+ <% stat = File.stat(file) %>
166
+
167
+ <tr>
168
+ <td>
169
+ <a href="?file=<%= relative_file %>"><%= file %></a>
170
+ </td>
171
+ <td>
172
+ <%= stat.size.to_filesize %>
173
+ </td>
174
+ <td>
175
+ <%= stat.mtime %>
176
+ </td>
177
+ </tr>
178
+ <% end %>
179
+ </tbody>
180
+ </table>
151
181
  <% end %>
152
182
 
153
183
  <% rescue => error %>
@@ -1,33 +1,15 @@
1
1
  <% begin %>
2
2
 
3
- <% # redefine print, puts & p
4
-
5
- OUTPUT = StringIO.new
6
-
7
- def print *args
8
- OUTPUT.print *args
9
- end
10
-
11
- def puts *args
12
- OUTPUT.puts *args
13
- end
14
-
15
- def p *args
16
- OUTPUT.puts *args.map(&:inspect)
17
- end
18
-
19
- %>
3
+ <% input = StringIO.new(script) %>
4
+ <% output = StringIO.new %>
5
+ <% binding = Object.new.send :binding %>
20
6
 
21
7
  <% begin %>
22
- <% binding = Object.new.send :binding %>
23
- <% binding.eval(script, "(script)", 1) %>
24
- <% OUTPUT.string.each_line do |line| %>
25
- <p><%= h line %></p>
26
- <% end %>
8
+ <% Pry.start binding, input: input, output: output %>
9
+ <%= h output.string %>
27
10
  <% rescue => error %>
28
11
  <p class="text-danger"><%= h error.class %>: <%= h error.message %></p>
29
12
  <% error.backtrace.each do |backtrace| %>
30
- <% next unless backtrace.start_with? "(script)" %>
31
13
  <p class="text-danger"> <%= h backtrace %></p>
32
14
  <% end %>
33
15
  <% end %>
@@ -0,0 +1,11 @@
1
+ class Integer
2
+ def to_filesize
3
+ {
4
+ 'B' => 1024,
5
+ 'KB' => 1024 * 1024,
6
+ 'MB' => 1024 * 1024 * 1024,
7
+ 'GB' => 1024 * 1024 * 1024 * 1024,
8
+ 'TB' => 1024 * 1024 * 1024 * 1024 * 1024
9
+ }.each_pair { |e, s| return "#{(self.to_f / (s / 1024)).round(2)}#{e}" if self < s }
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module Tailog
2
- VERSION = "0.4.8"
2
+ VERSION = "0.5.0"
3
3
  end
data/lib/tailog.rb CHANGED
@@ -3,6 +3,7 @@ require 'tailog/eval'
3
3
  require 'tailog/request_id'
4
4
  require 'tailog/watch_methods'
5
5
  require 'tailog/ext/file'
6
+ require 'tailog/ext/integer'
6
7
 
7
8
  require 'sinatra/base'
8
9
  require 'socket'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tailog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.8
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bbtfr
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-17 00:00:00.000000000 Z
11
+ date: 2016-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -61,6 +61,7 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - ".codeclimate.yml"
63
63
  - ".gitignore"
64
+ - ".travis.yml"
64
65
  - Gemfile
65
66
  - LICENSE.md
66
67
  - README.md
@@ -94,6 +95,7 @@ files:
94
95
  - lib/tailog.rb
95
96
  - lib/tailog/eval.rb
96
97
  - lib/tailog/ext/file.rb
98
+ - lib/tailog/ext/integer.rb
97
99
  - lib/tailog/request_id.rb
98
100
  - lib/tailog/version.rb
99
101
  - lib/tailog/watch_methods.rb