tailog 0.1.3 → 0.1.4
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 +5 -13
- data/app/views/index.erb +2 -2
- data/lib/tailog/ext/file.rb +19 -0
- data/lib/tailog/version.rb +1 -1
- data/lib/tailog.rb +5 -32
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZmE1NjdhZmZmYjMwYzE5YTRiMTE4ZTIzYjY3NDI1N2RhZDZjMjE1Mw==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fa5ccc4fd2d81e1b79f13d137f3ab99122e4a861
|
4
|
+
data.tar.gz: 4b3bb33bbb3aca08b6ecde0cf8e3886d275cf4d3
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
M2Q0OWIzMDVhN2NkNWI3NzI5YjcyZjA3NGMwOGRiY2IxZWRiNDI4ZjZlMDA2
|
11
|
-
OWE4ZDQzMmE3ZDIxYWJhYzFlMDc2NjhiMzY2NzI3NWU1YjMxZGE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NDk5MzI2YmFmYTQxYjM5NzdmOTA4Y2M1YjdkMzQwZDE2NzljZjIzMTJjNzU4
|
14
|
-
M2FkMzY4MDUwYzg1YTI0ZjE1MDYzMGE0YzY0Y2M3ZDA5YzI1NmFjYzdjZDE5
|
15
|
-
YzRiNTRhN2E1YWVjYmIwMzhkZmNhYTU2YWFhNmJlYTMxNDIzNGI=
|
6
|
+
metadata.gz: 412f9df31e82346139ef4af38eb22799b537ee30689d392d1a2a0f4d914c00c6b3e695a9ba6d9d2d89b99b4051756eaea75ae92e8fbe4fbdc1ac7413444d0dfb
|
7
|
+
data.tar.gz: a0ff25025f9c809ab1da1756410819c556f17b30f559fd76d53d0f176415d9e6c418bf06c540f124581f2c35da4e0d5c62b33ef4dda32bc5cf06b20f5fe8e7b7
|
data/app/views/index.erb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
3
|
<head>
|
4
|
-
<title>
|
4
|
+
<title>TAILOG</title>
|
5
5
|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.min.js"></script>
|
6
6
|
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css">
|
7
7
|
<style type="text/css">
|
@@ -40,7 +40,7 @@
|
|
40
40
|
</div>
|
41
41
|
<div id="navbar" class="navbar-collapse collapse">
|
42
42
|
<ul class="nav navbar-nav">
|
43
|
-
<li class="active"><a href="#">
|
43
|
+
<li class="active"><a href="#">Logs</a></li>
|
44
44
|
</ul>
|
45
45
|
<ul class="nav navbar-nav navbar-right">
|
46
46
|
<form class="navbar-form navbar-left" method="get">
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class File
|
2
|
+
def tail(n)
|
3
|
+
buffer = 1024
|
4
|
+
idx = size > buffer ? size - buffer : 0
|
5
|
+
chunks = []
|
6
|
+
lines = 0
|
7
|
+
|
8
|
+
begin
|
9
|
+
seek(idx)
|
10
|
+
chunk = read(buffer)
|
11
|
+
break unless chunk
|
12
|
+
lines += chunk.count("\n")
|
13
|
+
chunks.unshift chunk
|
14
|
+
idx -= buffer
|
15
|
+
end while lines < ( n + 1 ) && idx >= 0
|
16
|
+
|
17
|
+
chunks.join('').split(/\n/).last(n)
|
18
|
+
end
|
19
|
+
end
|
data/lib/tailog/version.rb
CHANGED
data/lib/tailog.rb
CHANGED
@@ -1,38 +1,13 @@
|
|
1
1
|
require 'tailog/version'
|
2
|
+
require 'tailog/ext/file'
|
2
3
|
require 'sinatra/base'
|
3
|
-
|
4
|
-
class File
|
5
|
-
|
6
|
-
def tail(n)
|
7
|
-
buffer = 1024
|
8
|
-
idx = size > buffer ? size - buffer : 0
|
9
|
-
chunks = []
|
10
|
-
lines = 0
|
11
|
-
|
12
|
-
begin
|
13
|
-
seek(idx)
|
14
|
-
chunk = read(buffer)
|
15
|
-
break unless chunk
|
16
|
-
lines += chunk.count("\n")
|
17
|
-
chunks.unshift chunk
|
18
|
-
idx -= buffer
|
19
|
-
end while lines < ( n + 1 ) && idx >= 0
|
20
|
-
|
21
|
-
chunks.join('').split(/\n/).last(n)
|
22
|
-
end
|
23
|
-
end
|
4
|
+
require 'active_support/configurable'
|
24
5
|
|
25
6
|
module Tailog
|
7
|
+
include ActiveSupport::Configurable
|
26
8
|
|
27
|
-
|
28
|
-
|
29
|
-
attr_accessor :basic_auth
|
30
|
-
end
|
31
|
-
|
32
|
-
self.log_path = File.expand_path("log", Dir.pwd)
|
33
|
-
self.basic_auth = proc do |username, password|
|
34
|
-
username == (ENV['TAILOG_USERNAME'] || 'tailog') and
|
35
|
-
password == (ENV['TAILOG_USERNAME'] || 'password')
|
9
|
+
config_accessor :log_path do
|
10
|
+
File.expand_path("log", Dir.pwd)
|
36
11
|
end
|
37
12
|
|
38
13
|
class App < Sinatra::Base
|
@@ -40,8 +15,6 @@ module Tailog
|
|
40
15
|
set :public_folder do "#{root}/assets" end
|
41
16
|
set :views do "#{root}/views" end
|
42
17
|
|
43
|
-
use Rack::Auth::Basic, "Restricted Area", &Tailog.basic_auth
|
44
|
-
|
45
18
|
helpers do
|
46
19
|
def h(text)
|
47
20
|
Rack::Utils.escape_html(text)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tailog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bbtfr
|
@@ -14,28 +14,28 @@ dependencies:
|
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.11'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.11'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
description: Sinatra App to serve log in browser
|
@@ -45,7 +45,7 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- .gitignore
|
48
|
+
- ".gitignore"
|
49
49
|
- CODE_OF_CONDUCT.md
|
50
50
|
- Gemfile
|
51
51
|
- README.md
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- bin/console
|
56
56
|
- bin/setup
|
57
57
|
- lib/tailog.rb
|
58
|
+
- lib/tailog/ext/file.rb
|
58
59
|
- lib/tailog/version.rb
|
59
60
|
- tailog.gemspec
|
60
61
|
homepage: https://github.com/bbtfr/tailog
|
@@ -67,19 +68,18 @@ require_paths:
|
|
67
68
|
- lib
|
68
69
|
required_ruby_version: !ruby/object:Gem::Requirement
|
69
70
|
requirements:
|
70
|
-
- -
|
71
|
+
- - ">="
|
71
72
|
- !ruby/object:Gem::Version
|
72
73
|
version: '0'
|
73
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
75
|
requirements:
|
75
|
-
- -
|
76
|
+
- - ">="
|
76
77
|
- !ruby/object:Gem::Version
|
77
78
|
version: '0'
|
78
79
|
requirements: []
|
79
80
|
rubyforge_project:
|
80
|
-
rubygems_version: 2.4.
|
81
|
+
rubygems_version: 2.4.6
|
81
82
|
signing_key:
|
82
83
|
specification_version: 4
|
83
84
|
summary: tail -f to the web-browser
|
84
85
|
test_files: []
|
85
|
-
has_rdoc:
|