timber 2.0.15 → 2.0.16

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: 4fb5d7f9bf8255145cfbe6e05c58072f6eb06d1a
4
- data.tar.gz: cc7cc1da9a3da82a14077f6ac2d64fff33adf203
3
+ metadata.gz: 1038cc42a24a78320336990a6773fd333c622798
4
+ data.tar.gz: adc0a024f67b5bf31c8c11fde6c322daf790d621
5
5
  SHA512:
6
- metadata.gz: f192dc532458f33e061d2d4912e0507e9f268e15b60693120e40251093e6cb93f7d61bbf34cd5ae03647cd5070979abdefc34eff03237d7f0b129f99ddae3ad7
7
- data.tar.gz: b2b7fd1d672662d0a80bb4f72536b39470b6190b8c0bd0a16a37c40cb6ce0b7156eb6d5d23670a1df2c13ce449ed14afaf37aad289dc6e3fd5d2c1e6e238aabe
6
+ metadata.gz: 4b5e9b1d8a39a5bf05b7f36c552192629f8384737533e8970f301308ef1971da83a1eca589f3cce588a391544e8487ba4db16e2a8d743b2d8bf9811fdf82e8bb
7
+ data.tar.gz: 08a59f9d54d3e01f12f73ea627593dbe3f5b98493947deee31a6fe05c675fb2839083e3c9eea9cd29bee062bb682c7ca0fc57836b5969412d987587a04216d5f
@@ -3,24 +3,64 @@ module Timber
3
3
  # Module for Rails specific code, such as the Railtie and any methods that assist
4
4
  # with Rails setup.
5
5
  module Rails
6
+ # Because of the crazy way Rails sorts it's initializers, it is
7
+ # impossible for Timber to be inserted after Devise's omnitauth
8
+ # middlewares.
9
+ # See: https://github.com/plataformatec/devise/blob/master/lib/devise/rails.rb#L22
10
+ # As such, we take a brute force approach here, ensuring we are inserted last
11
+ # no matter what. This ensures that we come after authentication so that we can
12
+ # properly set the user context.
13
+ #
14
+ # @private
15
+ module MiddlewareStackProxyFix
16
+ def self.included(klass)
17
+ klass.class_eval do
18
+ attr_accessor :timber_operations
19
+
20
+ alias old_merge_into merge_into
21
+
22
+ # This method does not exist for older versions of rails
23
+ begin
24
+ alias old_plus +
25
+ rescue NameError
26
+ end
27
+
28
+ def +(*args)
29
+ result = old_plus(*args)
30
+ result.timber_operations = timber_operations
31
+ result
32
+ end
33
+
34
+ def merge_into(*args)
35
+ if timber_operations
36
+ @operations -= timber_operations
37
+ @operations += timber_operations
38
+ end
39
+ old_merge_into(*args)
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ ::Rails::Configuration::MiddlewareStackProxy.send(:include, MiddlewareStackProxyFix)
46
+
6
47
  # Installs Timber into your Rails app automatically.
7
48
  class Railtie < ::Rails::Railtie
8
49
  config.timber = Config.instance
9
50
 
10
51
  # Initialize Timber immediately after the logger in case anything uses the logger
11
52
  # during the initialization process.
12
- initializer(:timber, group: :all, after: :initialize_logger) do
53
+ initializer(:timber, after: :initialize_logger) do
13
54
  logger = Rails.ensure_timber_logger(::Rails.logger)
14
55
  Rails.set_logger(logger)
15
56
 
16
57
  Integrations.integrate!
17
- end
18
58
 
19
- # Ensures that we insert the middlewares last. We need to insert these last
20
- # because initializers, such as Omniauth, insert middleware. If we are not
21
- # after these initializers we will not capture user context, for example.
22
- initializer(:timber_middlewares, after: :engines_blank_point) do
23
- Rails.configure_middlewares(config.app_middleware)
59
+ timber_operations = Integrations::Rack.middlewares.collect do |middleware_class|
60
+ [:use, [middleware_class], nil]
61
+ end
62
+
63
+ config.app_middleware.timber_operations = timber_operations
24
64
  end
25
65
  end
26
66
 
@@ -60,17 +100,6 @@ module Timber
60
100
  ::ActiveRecord::Base.logger = logger if defined?(::ActiveRecord::Base) && ::ActiveRecord::Base.respond_to?(:logger=)
61
101
  ::Rails.logger = logger
62
102
  end
63
-
64
- def self.configure_middlewares(middleware)
65
- var_name = :"@_timber_middlewares_inserted"
66
- return true if middleware.instance_variable_defined?(var_name) && middleware.instance_variable_get(var_name) == true
67
-
68
- # Rails uses a proxy :/, so we need to do this instance variable hack
69
- middleware.instance_variable_set(var_name, true)
70
- Integrations::Rack.middlewares.each do |middleware_class|
71
- middleware.use middleware_class
72
- end
73
- end
74
103
  end
75
104
  end
76
105
  end
@@ -1,3 +1,3 @@
1
1
  module Timber
2
- VERSION = "2.0.15"
2
+ VERSION = "2.0.16"
3
3
  end
@@ -0,0 +1,10 @@
1
+ require "spec_helper"
2
+
3
+ describe Timber::Util::HTTPEvent, :rails_23 => true do
4
+ describe ".normalize_headers" do
5
+ it "should ignore nils" do
6
+ result = described_class.normalize_headers({"key" => nil})
7
+ expect(result).to eq({"key" => nil})
8
+ end
9
+ end
10
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timber
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.15
4
+ version: 2.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timber Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-20 00:00:00.000000000 Z
11
+ date: 2017-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -243,6 +243,7 @@ files:
243
243
  - spec/timber/log_devices/http_spec.rb
244
244
  - spec/timber/log_entry_spec.rb
245
245
  - spec/timber/logger_spec.rb
246
+ - spec/timber/util/http_event_spec.rb
246
247
  - timber.gemspec
247
248
  homepage: https://github.com/timberio/timber-ruby
248
249
  licenses: []
@@ -299,3 +300,4 @@ test_files:
299
300
  - spec/timber/log_devices/http_spec.rb
300
301
  - spec/timber/log_entry_spec.rb
301
302
  - spec/timber/logger_spec.rb
303
+ - spec/timber/util/http_event_spec.rb