rack-logs 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rack/logs/version.rb +1 -1
- data/lib/rack/logs/viewer.rb +17 -4
- data/spec/unit/rack/logs/viewer_spec.rb +5 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69a6f50b97b494a90f92e1add5f1035070664cd8
|
4
|
+
data.tar.gz: 3c43793be423daa785e0a2fba594eaa6bfad8f95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 863295e75ba0b0e61800fb7d1bb79ddc69cd50030c43b8ebed78a2ce44e72f37fc8b2e65e328746ca3f9a43410107910af03508d9a0061e46e9025f34432f193
|
7
|
+
data.tar.gz: a091fa3ed21370358b59e1da7f22209e7d0689463c33c731cdb69e511904acd6379e4658259629884e9cc4eba7b87fed3ee51ddcf29f5876503bf420ac7b9e9f
|
data/lib/rack/logs/version.rb
CHANGED
data/lib/rack/logs/viewer.rb
CHANGED
@@ -8,7 +8,7 @@ module Rack
|
|
8
8
|
attr_reader :config
|
9
9
|
|
10
10
|
def call env
|
11
|
-
[200, headers,
|
11
|
+
[200, headers, joined_logs]
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
@@ -19,12 +19,25 @@ module Rack
|
|
19
19
|
}
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
class JoinedFiles
|
23
|
+
def initialize filenames
|
24
|
+
@filenames = filenames
|
25
|
+
end
|
26
|
+
|
27
|
+
def each &block
|
28
|
+
@filenames.each do |filename|
|
29
|
+
block.call "## #{filename}\n\n"
|
30
|
+
::File.open(filename) do |file|
|
31
|
+
file.each(&block)
|
32
|
+
end
|
33
|
+
end
|
25
34
|
end
|
26
35
|
end
|
27
36
|
|
37
|
+
def joined_logs
|
38
|
+
JoinedFiles.new files
|
39
|
+
end
|
40
|
+
|
28
41
|
def logs
|
29
42
|
files.inject({}) do |hash, filename|
|
30
43
|
hash[filename] = ::File.read(filename)
|
@@ -31,7 +31,11 @@ describe 'Rack::Logs::Viewer' do
|
|
31
31
|
expect(response[2].respond_to? :each).to be true
|
32
32
|
end
|
33
33
|
it 'returns the contents of the logs' do
|
34
|
-
|
34
|
+
contents = ""
|
35
|
+
response[2].each do |fragment|
|
36
|
+
contents << fragment
|
37
|
+
end
|
38
|
+
expect(contents).to eq "## tmp/my_log.doge\n\nMuch log, such information"
|
35
39
|
end
|
36
40
|
end
|
37
41
|
end
|