timber-rails 1.0.0 → 1.0.1

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
  SHA256:
3
- metadata.gz: 7f4f0a765269e2b04700d9f0b5e8be9c8c5a1e2b7335ee31decc53379e0c29c6
4
- data.tar.gz: 113255c96a2bcd218ce6d444c665a811f8e4ab47cf09cba3c2cebdc82e998084
3
+ metadata.gz: 67b9d85a00327859acdbe2b7d7f749b334bfe9305a4aa4bd01b150bd3f1a4224
4
+ data.tar.gz: aca39d8017d73c8dea0f03442854dffbb2c4a7248f3d1aad6a369e2527cf8638
5
5
  SHA512:
6
- metadata.gz: b053eb354944ecac2cdae780546d70b00f10ff9ce00c73d1ef9a210fbe6977fe270e6136270e80124d58ad146423ee57e5c23ddd11be177cca9a4143cbc2f725
7
- data.tar.gz: de16848d218e687879c3af22f1ceffe1b84647da03044a7356ae26d009b118b8a308d1d5151f3efdcfb29395fc6c4a25aa82f00a51a9fee1fc102beaec80af89
6
+ metadata.gz: 5cfa79513c8b1501b7ef00b9113f43c7c9274e1a24e07e2c18b595188b4e04e1efdbd35197192224669703200b80db226f4a4d7aab500c2233b7a2ff27bbaa2b
7
+ data.tar.gz: bddc19da37b1ca346ddd08e322c4dd5741a4a91b9c8ce67a99f0b0bfa3bc339d23ef27e4057915f25ec59a6430745fcf366c54f6d35b2b29e0ba6674a6b22b97
data/Gemfile CHANGED
@@ -1,8 +1,3 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- # TODO: REMOVE ME
4
- gem 'timber', git: 'https://github.com/mitchellhenke/timber-ruby.git', branch: '3.0'
5
- gem 'timber-rack', git: 'https://github.com/timberio/timber-ruby-rack.git', branch: 'master'
6
-
7
- # Specify your gem's dependencies in timber-ruby-rails.gemspec
8
3
  gemspec
data/README.md CHANGED
@@ -3,10 +3,9 @@
3
3
  [![ISC License](https://img.shields.io/badge/license-ISC-ff69b4.svg)](LICENSE.md)
4
4
  [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/github/timberio/timber-ruby-rails)
5
5
  [![Build Status](https://travis-ci.org/timberio/timber-ruby-rails.svg?branch=master)](https://travis-ci.org/timberio/timber-ruby-rails)
6
- [![Code Climate](https://codeclimate.com/github/timberio/timber-ruby-rails/badges/gpa.svg)](https://codeclimate.com/github/timberio/timber-ruby-rails)
7
6
 
8
- This library integrates the [`timber` Ruby library][timber_ruby] with the [Rails][rails] framework,
9
- turning your Rails logs into rich structured events.
7
+ This library integrates the [`timber` Ruby library](https://github.com/timberio/timber-ruby) with the [rails](https://github.com/rails/rails) framework,
8
+ turning your rails logs into rich structured events.
10
9
 
11
10
  * **Sign-up: [https://app.timber.io](https://app.timber.io)**
12
11
  * **Documentation: [https://docs.timber.io/setup/languages/ruby/integrations/rails](https://docs.timber.io/setup/languages/ruby/integrations/rails)**
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '~> 3.0.0'
4
4
  # TODO: REMOVE ME
5
- gem 'timber', git: 'https://github.com/timberio/timber-ruby.git', branch: '3.0'
5
+ gem 'timber', git: 'https://github.com/timberio/timber-ruby.git', branch: '3.0-cleanup'
6
6
  gem 'timber-rack', git: 'https://github.com/timberio/timber-ruby-rack.git', branch: 'master'
7
7
 
8
8
  gemspec :path => '../'
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '~> 3.1.0'
4
4
  # TODO: REMOVE ME
5
- gem 'timber', git: 'https://github.com/timberio/timber-ruby.git', branch: '3.0'
5
+ gem 'timber', git: 'https://github.com/timberio/timber-ruby.git', branch: '3.0-cleanup'
6
6
  gem 'timber-rack', git: 'https://github.com/timberio/timber-ruby-rack.git', branch: 'master'
7
7
 
8
8
  gemspec :path => '../'
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '~> 3.2.0'
4
4
  # TODO: REMOVE ME
5
- gem 'timber', git: 'https://github.com/timberio/timber-ruby.git', branch: '3.0'
5
+ gem 'timber', git: 'https://github.com/timberio/timber-ruby.git', branch: '3.0-cleanup'
6
6
  gem 'timber-rack', git: 'https://github.com/timberio/timber-ruby-rack.git', branch: 'master'
7
7
 
8
8
  gemspec :path => '../'
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '~> 4.0.0'
4
4
  # TODO: REMOVE ME
5
- gem 'timber', git: 'https://github.com/timberio/timber-ruby.git', branch: '3.0'
5
+ gem 'timber', git: 'https://github.com/timberio/timber-ruby.git', branch: '3.0-cleanup'
6
6
  gem 'timber-rack', git: 'https://github.com/timberio/timber-ruby-rack.git', branch: 'master'
7
7
 
8
8
  if RUBY_PLATFORM == "java"
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '~> 4.1.0'
4
4
  # TODO: REMOVE ME
5
- gem 'timber', git: 'https://github.com/timberio/timber-ruby.git', branch: '3.0'
5
+ gem 'timber', git: 'https://github.com/timberio/timber-ruby.git', branch: '3.0-cleanup'
6
6
  gem 'timber-rack', git: 'https://github.com/timberio/timber-ruby-rack.git', branch: 'master'
7
7
 
8
8
  if RUBY_PLATFORM == "java"
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '~> 4.2.0'
4
4
  # TODO: REMOVE ME
5
- gem 'timber', git: 'https://github.com/timberio/timber-ruby.git', branch: '3.0'
5
+ gem 'timber', git: 'https://github.com/timberio/timber-ruby.git', branch: '3.0-cleanup'
6
6
  gem 'timber-rack', git: 'https://github.com/timberio/timber-ruby-rack.git', branch: 'master'
7
7
 
8
8
  if RUBY_PLATFORM == "java"
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '~> 5.0.0'
4
4
  # TODO: REMOVE ME
5
- gem 'timber', git: 'https://github.com/timberio/timber-ruby.git', branch: '3.0'
5
+ gem 'timber', git: 'https://github.com/timberio/timber-ruby.git', branch: '3.0-cleanup'
6
6
  gem 'timber-rack', git: 'https://github.com/timberio/timber-ruby-rack.git', branch: 'master'
7
7
 
8
8
  if RUBY_PLATFORM == "java"
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '~> 5.1.0'
4
4
  # TODO: REMOVE ME
5
- gem 'timber', git: 'https://github.com/timberio/timber-ruby.git', branch: '3.0'
5
+ gem 'timber', git: 'https://github.com/timberio/timber-ruby.git', branch: '3.0-cleanup'
6
6
  gem 'timber-rack', git: 'https://github.com/timberio/timber-ruby-rack.git', branch: 'master'
7
7
 
8
8
  if RUBY_PLATFORM == "java"
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '~> 5.2.0'
4
4
  # TODO: REMOVE ME
5
- gem 'timber', git: 'https://github.com/timberio/timber-ruby.git', branch: '3.0'
5
+ gem 'timber', git: 'https://github.com/timberio/timber-ruby.git', branch: '3.0-cleanup'
6
6
  gem 'timber-rack', git: 'https://github.com/timberio/timber-ruby-rack.git', branch: 'master'
7
7
 
8
8
  if RUBY_PLATFORM == "java"
@@ -5,7 +5,7 @@ gem 'arel', git: 'https://github.com/rails/arel', branch: 'master'
5
5
  gem 'rails', git: 'https://github.com/rails/rails', branch: 'master'
6
6
 
7
7
  # TODO: REMOVE ME
8
- gem 'timber', git: 'https://github.com/timberio/timber-ruby.git', branch: '3.0'
8
+ gem 'timber', git: 'https://github.com/timberio/timber-ruby.git', branch: '3.0-cleanup'
9
9
  gem 'timber-rack', git: 'https://github.com/timberio/timber-ruby-rack.git', branch: 'master'
10
10
 
11
11
  gemspec :path => '../'
@@ -2,6 +2,7 @@ require "timber-rails/overrides"
2
2
 
3
3
  require "timber"
4
4
  require "rails"
5
+ require "timber-rails/active_support_log_subscriber"
5
6
  require "timber-rails/config"
6
7
  require "timber-rails/railtie"
7
8
 
@@ -17,6 +18,7 @@ require "timber-rails/action_dispatch"
17
18
  require "timber-rails/action_view"
18
19
  require "timber-rails/active_record"
19
20
 
21
+
20
22
  require "timber-rails/logger"
21
23
 
22
24
  module Timber
@@ -14,9 +14,9 @@ module Timber
14
14
  end
15
15
 
16
16
  def integrate!
17
- return true if Util::ActiveSupportLogSubscriber.subscribed?(:action_controller, TimberLogSubscriber)
17
+ return true if Timber::Integrations::Rails::ActiveSupportLogSubscriber.subscribed?(:action_controller, TimberLogSubscriber)
18
18
 
19
- Util::ActiveSupportLogSubscriber.unsubscribe!(:action_controller, ::ActionController::LogSubscriber)
19
+ Timber::Integrations::Rails::ActiveSupportLogSubscriber.unsubscribe!(:action_controller, ::ActionController::LogSubscriber)
20
20
  TimberLogSubscriber.attach_to(:action_controller)
21
21
  end
22
22
  end
@@ -14,9 +14,9 @@ module Timber
14
14
  end
15
15
 
16
16
  def integrate!
17
- return true if Util::ActiveSupportLogSubscriber.subscribed?(:action_view, TimberLogSubscriber)
17
+ return true if Timber::Integrations::Rails::ActiveSupportLogSubscriber.subscribed?(:action_view, TimberLogSubscriber)
18
18
 
19
- Util::ActiveSupportLogSubscriber.unsubscribe!(:action_view, ::ActionView::LogSubscriber)
19
+ Timber::Integrations::Rails::ActiveSupportLogSubscriber.unsubscribe!(:action_view, ::ActionView::LogSubscriber)
20
20
  TimberLogSubscriber.attach_to(:action_view)
21
21
  end
22
22
  end
@@ -9,9 +9,9 @@ module Timber
9
9
  # @private
10
10
  class LogSubscriber < Integrator
11
11
  def integrate!
12
- return true if Util::ActiveSupportLogSubscriber.subscribed?(:active_record, TimberLogSubscriber)
12
+ return true if Timber::Integrations::Rails::ActiveSupportLogSubscriber.subscribed?(:active_record, TimberLogSubscriber)
13
13
 
14
- Util::ActiveSupportLogSubscriber.unsubscribe!(:active_record, ::ActiveRecord::LogSubscriber)
14
+ Timber::Integrations::Rails::ActiveSupportLogSubscriber.unsubscribe!(:active_record, ::ActiveRecord::LogSubscriber)
15
15
  TimberLogSubscriber.attach_to(:active_record)
16
16
  end
17
17
  end
@@ -0,0 +1,39 @@
1
+ module Timber
2
+ module Integrations
3
+ module Rails
4
+ # @private
5
+ module ActiveSupportLogSubscriber
6
+ extend self
7
+
8
+ def find(component, type)
9
+ ::ActiveSupport::LogSubscriber.log_subscribers.find do |subscriber|
10
+ subscriber.class == type
11
+ end
12
+ end
13
+
14
+ def subscribed?(component, type)
15
+ !find(component, type).nil?
16
+ end
17
+
18
+ # I don't know why this has to be so complicated, but it is. This code was taken from
19
+ # lograge :/
20
+ def unsubscribe!(component, type)
21
+ subscriber = find(component, type)
22
+
23
+ if !subscriber
24
+ raise "We could not find a log subscriber for #{component.inspect} of type #{type.inspect}"
25
+ end
26
+
27
+ events = subscriber.public_methods(false).reject { |method| method.to_s == 'call' }
28
+ events.each do |event|
29
+ ::ActiveSupport::Notifications.notifier.listeners_for("#{event}.#{component}").each do |listener|
30
+ if listener.instance_variable_get('@delegate') == subscriber
31
+ ::ActiveSupport::Notifications.unsubscribe listener
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -11,12 +11,9 @@ module Timber
11
11
  id = get_session_id(env)
12
12
  if id
13
13
  context = Contexts::Session.new(id: id)
14
- CurrentContext.with(context) do
15
- @app.call(env)
16
- end
17
- else
18
- @app.call(env)
14
+ CurrentContext.add(context.to_hash)
19
15
  end
16
+ @app.call(env)
20
17
  end
21
18
 
22
19
  private
@@ -1,7 +1,7 @@
1
1
  module Timber
2
2
  module Integrations
3
3
  module Rails
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  end
6
6
  end
7
7
  end
@@ -34,9 +34,8 @@ Gem::Specification.new do |spec|
34
34
  spec.require_paths = ["lib"]
35
35
 
36
36
  spec.add_runtime_dependency "rails", ">= 3.0.0", "< 6.0.0"
37
- # TODO add these
38
- # spec.add_runtime_dependency "timber", "3.0.0.alpha.0"
39
- # spec.add_runtime_dependency "timber-rack", "1.0.0.alpha.0"
37
+ spec.add_runtime_dependency "timber", "~> 3.0"
38
+ spec.add_runtime_dependency "timber-rack", "~> 1.0"
40
39
 
41
40
  spec.add_development_dependency "bundler", ">= 0.0"
42
41
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timber-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timber Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-08 00:00:00.000000000 Z
11
+ date: 2019-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,6 +30,34 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 6.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: timber
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: timber-rack
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.0'
33
61
  - !ruby/object:Gem::Dependency
34
62
  name: bundler
35
63
  requirement: !ruby/object:Gem::Requirement
@@ -194,6 +222,7 @@ files:
194
222
  - lib/timber-rails/active_record.rb
195
223
  - lib/timber-rails/active_record/log_subscriber.rb
196
224
  - lib/timber-rails/active_record/log_subscriber/timber_log_subscriber.rb
225
+ - lib/timber-rails/active_support_log_subscriber.rb
197
226
  - lib/timber-rails/config.rb
198
227
  - lib/timber-rails/config/action_controller.rb
199
228
  - lib/timber-rails/config/action_view.rb