logput 0.0.2 → 0.0.3

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: bcf996c334e9c8bd54c66b78402180034082c1ea
4
- data.tar.gz: b18636e63e3c9b52088c30f5c95c1949f3e72865
3
+ metadata.gz: 7cbacb1dd5d03161a1b94546de8454b44fd66084
4
+ data.tar.gz: cbcc16f6c0207a1b9d47f6c2e51d9a166a9520c4
5
5
  SHA512:
6
- metadata.gz: 2dc24bb10c3ebd667d7c028dbb69e69b7c795fc51b730bbaf22314e4f6cf48bce4ba9d83fa976db92e866e9560f7bdfa6ac10035f7a95110f236c0913e07d3aa
7
- data.tar.gz: fd2ed287036550895d81682c43555b60fbaa0e255f7a36fffc2a08e245ac92c089756d15b5a3eb4c6fa4ede6c0cded8bb2b379166b22c260910f16e6ee093c39
6
+ metadata.gz: 9f2af5f8a8eca97c8e94c465c558087467340feb61aaaa975102ee9949c611f4e7c15464d2ee370ed1e574bcb2167d1684aa10d6b4d0e40a6d4724146fc47962
7
+ data.tar.gz: 4d9ba7d77cecfcb8e4c52c6237a9dbf73de61a0d4b30b369bf9f4d1437b30bcb10f8cae10af233d7fbaa158a0e553c07a0a18da9176f61578fbd524b16f47076
data/Fudgefile CHANGED
@@ -15,7 +15,7 @@ task_group :duplication do
15
15
  end
16
16
 
17
17
  task_group :complexity do
18
- task :flog, :exclude => '^\.\/spec\/', :max => 14.6, :average => 7.2, :methods => true
18
+ task :flog, :exclude => '^\.\/spec\/', :max => 7.7, :average => 5.7, :methods => true
19
19
  end
20
20
 
21
21
  build :default do
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Logput
2
2
 
3
- [![Build Status](https://travis-ci.org/chrisbarber86/logput.svg?branch=add_travis)](https://travis-ci.org/chrisbarber86/logput)
3
+ [![Build Status](https://api.travis-ci.org/asmega/logput.svg)](https://travis-ci.org/asmega/logput)
4
4
 
5
5
  Rack middleware to sit in a rails app to put put the current environments log to a webpage. eg /logput
6
6
 
@@ -25,17 +25,21 @@ module Logput
25
25
  private
26
26
 
27
27
  def default_path_to_log_file(env)
28
- raise Exception, 'Must specify path to log file' unless defined? Rails
29
-
30
- if Rails.version >= "4.0.0"
31
- logger(env).instance_variable_get(:@logdev).instance_variable_get(:@dev).path
32
- else
33
- logger(env).instance_variable_get(:@logger).instance_variable_get(:@log_dest).path
34
- end
28
+ raise Exception, 'Must specify path to Rails log file' unless defined? Rails
29
+ path(logger(env)) || raise(Exception, "#{logger(env).class} not supported.")
35
30
  end
36
31
 
37
32
  def logger(env)
38
33
  env['action_dispatch.logger']
39
34
  end
35
+
36
+ def path(logger)
37
+ case logger
38
+ when ::ActiveSupport::TaggedLogging
39
+ logger.instance_variable_get(:@logger).instance_variable_get(:@log_dest).path
40
+ when ::Logger
41
+ logger.instance_variable_get(:@logdev).filename
42
+ end
43
+ end
40
44
  end
41
45
  end
@@ -1,5 +1,5 @@
1
1
  # Logput
2
2
  module Logput
3
3
  # Gem version
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.3"
5
5
  end
@@ -1,5 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
+ module ActiveSupport; class TaggedLogging; end; end
4
+ class Logger; end
5
+ class Rails; end
6
+
3
7
  describe Logput::Middleware do
4
8
  subject{ described_class.new(app, :path_to_log_file => './spec/support/test.log') }
5
9
 
@@ -31,47 +35,37 @@ describe Logput::Middleware do
31
35
  end
32
36
 
33
37
  context 'when rails is defined' do
34
- let(:logger) { double }
38
+ let(:path) { './spec/support/test.log' }
35
39
  let(:logvar) { double }
36
- let(:logdest) { double(:path => './spec/support/test.log') }
40
+ let(:logdev) { double(:filename => path) }
41
+ let(:log_dest) { double(:path => path) }
37
42
 
38
- before :each do
39
- class Rails
40
- def self.version
41
- @rails_version
42
- end
43
-
44
- def self.version=(v)
45
- @rails_version = v
46
- end
47
- end
48
- end
43
+ context 'TaggedLogging' do
44
+ let(:logger) { ::ActiveSupport::TaggedLogging.new }
49
45
 
50
- context 'Rails 4' do
51
46
  before :each do
52
- Rails.version = '4.0.0'
53
- allow(logger).to receive(:instance_variable_get).with(:@logdev).and_return(logvar)
54
- allow(logvar).to receive(:instance_variable_get).with(:@dev).and_return(logdest)
47
+ allow(logger).to receive(:instance_variable_get).with(:@logger).and_return(logvar)
48
+ allow(logvar).to receive(:instance_variable_get).with(:@log_dest).and_return(log_dest)
55
49
 
56
50
  @request = server.get('/logput', { 'action_dispatch.logger' => logger })
57
51
  end
58
52
 
59
53
  it 'accesses the correct log file' do
60
- expect(@request.status).to eq(200)
54
+ expect(server.get('/logput').status).to eq(200)
61
55
  end
62
56
  end
63
57
 
64
- context 'Rails 3' do
58
+ context 'Logger' do
59
+ let(:logger) { ::Logger.new }
60
+
65
61
  before :each do
66
- Rails.version = '3.0.0'
67
- allow(logger).to receive(:instance_variable_get).with(:@logger).and_return(logvar)
68
- allow(logvar).to receive(:instance_variable_get).with(:@log_dest).and_return(logdest)
62
+ allow(logger).to receive(:instance_variable_get).with(:@logdev).and_return(logdev)
69
63
 
70
64
  @request = server.get('/logput', { 'action_dispatch.logger' => logger })
71
65
  end
72
66
 
73
67
  it 'accesses the correct log file' do
74
- expect(server.get('/logput').status).to eq(200)
68
+ expect(@request.status).to eq(200)
75
69
  end
76
70
  end
77
71
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logput
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Lee