huyegger 0.2.1 → 0.3.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
  SHA1:
3
- metadata.gz: 8b8bd450e48cb0daa896999b9634abd56da369cd
4
- data.tar.gz: 4e57c71f1cb6a65ebf762c7cde25d6b64eb069c3
3
+ metadata.gz: 7bde524d013159b9bfa72a41535feb11cc636b51
4
+ data.tar.gz: cac1ccda9fd4bc216cf878547c9aaa30d9de6c02
5
5
  SHA512:
6
- metadata.gz: 026347763efcb7c2a06b6c469dfed84b757c97def2ad30182d27e9b379fb0ca3b5375bb7ed9cee1902a43b3416db45aaf8bbf2c4f10ee1c4c49a41352e25f7a4
7
- data.tar.gz: 2fc8dad76f40c84d4c8dbcca9d030b1b61e434b62207e390ca617884414df641c302e12815c9b870846a803542ae1574b22e9a06cceee6e3735323288f204f19
6
+ metadata.gz: 5d856806d0c858f019e5ecda9e10e9500c65e041eb211e83809ab256876acf3b060c5e1a990132c06f3937451233550ecd11e55c02aebae37864562829fca5cb
7
+ data.tar.gz: e054effe733e8b595b5061bc8d03375db8c655194893789328ddf5d4dbbd1dcd86e16800c3c41c44e1920bd4477d9d7b98d1f3a701735bfcf59d63c11a3883a8
data/README.md CHANGED
@@ -67,6 +67,19 @@ class ApplicationController < ActionController::Base
67
67
  end
68
68
  ```
69
69
 
70
+ To use with Sidekiq
71
+
72
+ ```ruby
73
+ # inside config/initializers/sidekiq.rb
74
+
75
+ Sidekiq.configure_server do |config|
76
+ config.server_middleware do |chain|
77
+ chain.add Huyegger::Middlewares::Sidekiq
78
+ end
79
+ end
80
+ ```
81
+
82
+
70
83
  ## Contributing
71
84
 
72
85
  Bug reports and pull requests are welcome on GitHub at https://github.com/mainameiz/huyegger.
@@ -0,0 +1,15 @@
1
+ module Huyegger
2
+ module Middlewares
3
+ class Rails
4
+ def initialize(app)
5
+ @app = app
6
+ end
7
+
8
+ def call(env)
9
+ @app.call(env)
10
+ ensure
11
+ ::Rails.logger.purge_context! if defined?(Huyegger) && ::Rails.logger.is_a?(Huyegger::Logger)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ module Huyegger
2
+ module Middlewares
3
+ class Sidekiq
4
+ def call(worker, msg, queue)
5
+ ::Rails.logger.purge_context! if defined?(Huyegger) && ::Rails.logger.is_a?(Huyegger::Logger)
6
+ yield
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,19 +1,21 @@
1
+ require "huyegger/middlewares/rails"
2
+
1
3
  module Huyegger
2
4
  class Railtie < ::Rails::Railtie
3
5
  initializer "huyegger.insert_middleware" do |app|
4
6
  if ActionDispatch.const_defined? :RequestId
5
- app.config.middleware.insert_after ActionDispatch::RequestId, Huyegger::Middleware
7
+ app.config.middleware.insert_after ActionDispatch::RequestId, Huyegger::Middlewares::Rails
6
8
  else
7
- app.config.middleware.insert_after Rack::MethodOverride, Huyegger::Middleware
9
+ app.config.middleware.insert_after Rack::MethodOverride, Huyegger::Middlewares::Rails
8
10
  end
9
11
 
10
12
  if ActiveSupport.const_defined?(:Reloader) && ActiveSupport::Reloader.respond_to?(:to_complete)
11
13
  ActiveSupport::Reloader.to_complete do
12
- Rails.logger.purge_context! if Rails.logger.is_a?(Huyegger::Logger)
14
+ ::Rails.logger.purge_context! if ::Rails.logger.is_a?(Huyegger::Logger)
13
15
  end
14
16
  elsif ActionDispatch.const_defined?(:Reloader) && ActionDispatch::Reloader.respond_to?(:to_cleanup)
15
17
  ActionDispatch::Reloader.to_cleanup do
16
- Rails.logger.purge_context! if Rails.logger.is_a?(Huyegger::Logger)
18
+ ::Rails.logger.purge_context! if ::Rails.logger.is_a?(Huyegger::Logger)
17
19
  end
18
20
  end
19
21
  end
@@ -1,3 +1,3 @@
1
1
  module Huyegger
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: huyegger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikolay Markov
@@ -70,7 +70,8 @@ files:
70
70
  - lib/huyegger.rb
71
71
  - lib/huyegger/formatter.rb
72
72
  - lib/huyegger/logger.rb
73
- - lib/huyegger/middleware.rb
73
+ - lib/huyegger/middlewares/rails.rb
74
+ - lib/huyegger/middlewares/sidekiq.rb
74
75
  - lib/huyegger/railtie.rb
75
76
  - lib/huyegger/version.rb
76
77
  homepage: http://github.com/mainameiz/huyegger
@@ -1,13 +0,0 @@
1
- module Huyegger
2
- class Middleware
3
- def initialize(app)
4
- @app = app
5
- end
6
-
7
- def call(env)
8
- @app.call(env)
9
- ensure
10
- Rails.logger.purge_context! if Rails.logger.is_a?(Huyegger::Logger)
11
- end
12
- end
13
- end