rails_surrogate_key_logging 1.4.0 → 1.5.0

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: 0c90ffc261a0cc4de8d88266fd00e0ce40c4c5a1802cf60b2fdaa72c6d345d61
4
- data.tar.gz: 13dfb52ddf21fd49d28930043a4c8a3160c466fb2a03dfc8e9e369ad9b0007ab
3
+ metadata.gz: f5d3a0747a79affaf71480538b5ca2567c962ddf03c6af176661ea082b7427e5
4
+ data.tar.gz: aec5af8fb44ca382501cef61b9d142328a8befa571df08821e4b9f5ef365490c
5
5
  SHA512:
6
- metadata.gz: cc2df820cec2c3c042552fd8e9e7f16c87b5c8592228a9f8c03e9c91e40417d5c0b7cf8cb2e15d729e56837e7ec6cccbb63a75e10c8cfd633ff55c6e029a7668
7
- data.tar.gz: 80ce2c893ef9394acec270591f2c63d4f5603d701fd12eb8562a9b23a9d07555f8af0481a0e1df92692900e080bf826025cd20f77295514e8ac5fe0186a659cd
6
+ metadata.gz: f8ec40ce47168317e745ed14d707ca7c8a35ce7bd9eec78c7224baf4bcaa5f2a92b8eeade6024a745aa66d018ea11bbb65fb5989461923d635df60cf0eb0f060
7
+ data.tar.gz: b245a066710ba8440584f4fb51588bf0a968e969ef41eef0ae52e739bfdf266cc40d63770ccc4866917a806437b7d1ebb8eb5bcfdc48f914ee47df44ca60f26e
@@ -5,11 +5,11 @@ require 'active_support/concern'
5
5
  module SurrogateKeyLogging
6
6
  module ActionController
7
7
  module Params
8
- extend ActiveSupport::Concern
8
+ extend ::ActiveSupport::Concern
9
9
 
10
10
  class_methods do
11
11
  def surrogate_params(*params, action: '*')
12
- @surrogate_params ||= ActiveSupport::HashWithIndifferentAccess.new {|h,k| h[k] = [] }
12
+ @surrogate_params ||= ::ActiveSupport::HashWithIndifferentAccess.new {|h,k| h[k] = [] }
13
13
  params.each do |param|
14
14
  param = param.to_s
15
15
  @surrogate_params[action] << param
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SurrogateKeyLogging
4
4
  module ActionController
5
- extend ActiveSupport::Autoload
5
+ extend ::ActiveSupport::Autoload
6
6
 
7
7
  autoload :LogSubscriber
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SurrogateKeyLogging
4
4
  module ActionDispatch
5
- extend ActiveSupport::Autoload
5
+ extend ::ActiveSupport::Autoload
6
6
 
7
7
  autoload :ParamsFilter
8
8
  autoload :QueryStringFilter
@@ -5,7 +5,7 @@ require 'active_support/concern'
5
5
  module SurrogateKeyLogging
6
6
  module ActiveRecord
7
7
  module Attributes
8
- extend ActiveSupport::Concern
8
+ extend ::ActiveSupport::Concern
9
9
 
10
10
  class_methods do
11
11
  def surrogate_parent_names(*names)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SurrogateKeyLogging
4
4
  module ActiveRecord
5
- extend ActiveSupport::Autoload
5
+ extend ::ActiveSupport::Autoload
6
6
 
7
7
  autoload :Attributes
8
8
  autoload :LogSubscriber
@@ -1,36 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/parameter_filter'
4
-
5
- # Add ability for @mask to be a class/instance/lambda/proc
6
- module ActiveSupport
7
- class ParameterFilter
8
- class CompiledFilter
9
-
10
- def value_for_key(key, value, parents = [], original_params = nil) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
11
- parents.push(key) if deep_regexps
12
- if regexps.any? { |r| r.match?(key.to_s) }
13
- value = @mask.respond_to?(:call) ? @mask.call(key, value, parents, original_params) : @mask
14
- elsif deep_regexps && (joined = parents.join('.')) && deep_regexps.any? { |r| r.match?(joined) } # rubocop:disable Lint/DuplicateBranch
15
- value = @mask.respond_to?(:call) ? @mask.call(key, value, parents, original_params) : @mask
16
- elsif value.is_a?(Hash)
17
- value = call(value, parents, original_params)
18
- elsif value.is_a?(Array)
19
- # If we don't pop the current parent it will be duplicated as we
20
- # process each array value.
21
- parents.pop if deep_regexps
22
- value = value.map { |v| value_for_key(key, v, parents, original_params) }
23
- # Restore the parent stack after processing the array.
24
- parents.push(key) if deep_regexps
25
- elsif blocks.any?
26
- key = key.dup if key.duplicable?
27
- value = value.dup if value.duplicable?
28
- blocks.each { |b| b.arity == 2 ? b.call(key, value) : b.call(key, value, original_params) }
29
- end
3
+ module SurrogateKeyLogging
4
+ module ActiveSupport
5
+ # Add ability for @mask to be a class/instance/lambda/proc
6
+ def value_for_key(key, value, parents = [], original_params = nil) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
7
+ parents.push(key) if deep_regexps
8
+ if regexps.any? { |r| r.match?(key.to_s) }
9
+ value = @mask.respond_to?(:call) ? @mask.call(key, value, parents, original_params) : @mask
10
+ elsif deep_regexps && (joined = parents.join('.')) && deep_regexps.any? { |r| r.match?(joined) } # rubocop:disable Lint/DuplicateBranch
11
+ value = @mask.respond_to?(:call) ? @mask.call(key, value, parents, original_params) : @mask
12
+ elsif value.is_a?(Hash)
13
+ value = call(value, parents, original_params)
14
+ elsif value.is_a?(Array)
15
+ # If we don't pop the current parent it will be duplicated as we
16
+ # process each array value.
30
17
  parents.pop if deep_regexps
31
- value
18
+ value = value.map { |v| value_for_key(key, v, parents, original_params) }
19
+ # Restore the parent stack after processing the array.
20
+ parents.push(key) if deep_regexps
21
+ elsif blocks.any?
22
+ key = key.dup if key.duplicable?
23
+ value = value.dup if value.duplicable?
24
+ blocks.each { |b| b.arity == 2 ? b.call(key, value) : b.call(key, value, original_params) }
32
25
  end
33
-
26
+ parents.pop if deep_regexps
27
+ value
34
28
  end
29
+
35
30
  end
36
31
  end
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SurrogateKeyLogging
4
- class Config < ActiveSupport::OrderedOptions
4
+ class Config < ::ActiveSupport::OrderedOptions
5
5
  end
6
6
 
7
7
  module Configuration
8
- extend ActiveSupport::Concern
8
+ extend ::ActiveSupport::Concern
9
9
 
10
10
  def surrogate_key_logging
11
11
  SurrogateKeyLogging.config
@@ -33,6 +33,7 @@ module SurrogateKeyLogging
33
33
 
34
34
  def call(_key, value, _parents = [], _original_params = nil)
35
35
  return "" if value.blank?
36
+ return value unless SurrogateKeyLogging.config.enabled
36
37
  surrogate = get(value)
37
38
  Rails.logger.tagged('SurrogateKeyLogging') { Rails.logger.info "Surrogate: `#{surrogate}`, value: `#{value}`" } if SurrogateKeyLogging.config.debug
38
39
  surrogate
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SurrogateKeyLogging
4
4
  module KeyStore
5
- extend ActiveSupport::Autoload
5
+ extend ::ActiveSupport::Autoload
6
6
 
7
7
  eager_autoload do
8
8
  autoload :Base
@@ -4,7 +4,7 @@ module SurrogateKeyLogging
4
4
 
5
5
  module Version
6
6
  MAJOR = 1
7
- MINOR = 4
7
+ MINOR = 5
8
8
  PATCH = 0
9
9
 
10
10
  end
@@ -4,7 +4,7 @@ require 'active_support'
4
4
 
5
5
  # Container Module
6
6
  module SurrogateKeyLogging
7
- extend ActiveSupport::Autoload
7
+ extend ::ActiveSupport::Autoload
8
8
 
9
9
  autoload :ActionController
10
10
  autoload :ActionDispatch
@@ -55,7 +55,7 @@ module SurrogateKeyLogging
55
55
  end
56
56
 
57
57
  def filter_for_attributes(attrs)
58
- config.enabled ? ::ActiveSupport::ParameterFilter.new(attrs, mask: key_manager) : attrs
58
+ ::ActiveSupport::ParameterFilter.new(config.enabled ? attrs : [], mask: key_manager)
59
59
  end
60
60
 
61
61
  def key_store
@@ -63,7 +63,7 @@ module SurrogateKeyLogging
63
63
  end
64
64
 
65
65
  def filter_parameters(params)
66
- config.enabled ? parameter_filter.filter(params) : params
66
+ parameter_filter.filter(params)
67
67
  end
68
68
 
69
69
  def surrogate_for(value)
@@ -84,6 +84,8 @@ module SurrogateKeyLogging
84
84
 
85
85
  end
86
86
 
87
+ require 'active_support/parameter_filter'
88
+ ::ActiveSupport::ParameterFilter::CompiledFilter.send(:prepend, ActiveSupport)
87
89
  KeyStore.eager_load!
88
90
  ::Rails::Application::Configuration.send(:include, Configuration)
89
91
  require 'surrogate_key_logging/engine'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_surrogate_key_logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Yelverton