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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e41cba44bb13dd1cb47253fe02c2e098a53df2de
4
- data.tar.gz: 498c846612eb65afc5bc9c8bbe27d24c66804434
3
+ metadata.gz: 69a6f50b97b494a90f92e1add5f1035070664cd8
4
+ data.tar.gz: 3c43793be423daa785e0a2fba594eaa6bfad8f95
5
5
  SHA512:
6
- metadata.gz: 9f2adf14ab42fb7e2b08a7cdb6adb6be8cb881f084abd81c547393e69be5c6c4a9af731fcfe667dfbb61d678ba25dbb759559814bab8fc7901fd3cb25acc3efb
7
- data.tar.gz: eb243ac4724ba8ec15b4fe622f2bb4e218646ed11cc8ab8996b4abdc21e93798717e89ea96150fc54526f56d71bae988a2fe48d66f0a5f60e6a59c4d24c965eb
6
+ metadata.gz: 863295e75ba0b0e61800fb7d1bb79ddc69cd50030c43b8ebed78a2ce44e72f37fc8b2e65e328746ca3f9a43410107910af03508d9a0061e46e9025f34432f193
7
+ data.tar.gz: a091fa3ed21370358b59e1da7f22209e7d0689463c33c731cdb69e511904acd6379e4658259629884e9cc4eba7b87fed3ee51ddcf29f5876503bf420ac7b9e9f
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module Logs
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -8,7 +8,7 @@ module Rack
8
8
  attr_reader :config
9
9
 
10
10
  def call env
11
- [200, headers, [joined_logs]]
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
- def joined_logs
23
- logs.inject("") do |string, (filename, contents)|
24
- string + "## " + filename + "\n\n" + contents
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
- expect(response[2]).to eq ["## tmp/my_log.doge\n\nMuch log, such information"]
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-logs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Rowe