grape_logging 2.1.1 → 3.0.0

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
  SHA256:
3
- metadata.gz: c221ae5f7be5a9f4a5818689a276d1637144cf5c0a3845e3fd1d20a15455a5e7
4
- data.tar.gz: 1208a13208efba0ef1ddd1ee9e6e5306a35acbe0bd623603fbda16ad1821eee1
3
+ metadata.gz: 06aaf18280f4233ee64c9ec952860f1db9e6119ea832efc5a29d93601b73f0ce
4
+ data.tar.gz: bab90314228b6b136cb6b726328bcf06753ca808c6dd49d42b548356672f5e8f
5
5
  SHA512:
6
- metadata.gz: 82f1f1e940a7ace4f9e30f8623b56d4a2880bb4a2eeee1a8d654382662b5efe336a875e2e501275dc48594cc1ded59204e9eee44e43fb62204c84d0978e9a525
7
- data.tar.gz: 866d9f113fdfd414f48c710814902eae481982e5cf8a453b840904410eae3d368a09423bb6489e3ec455b21b348cadd2023082224e604db493f816d040532958
6
+ metadata.gz: 81ad7895d92bfdbc1a581d2d618875419c5dc5eed78172d6b4785cf4ec62b466e634eab831a28f39b799c126d430643a5bf438d14ba31bba4e93bba368790e57
7
+ data.tar.gz: d917cfb3390d1b205133ee84d16b86b5b9904e3a8a16fdc05d987057a7fefb06df005a6e5b65b708c15546b973bfa8ebf64472ac9d471cc1c42b4f3dfea0d445
@@ -20,4 +20,17 @@ jobs:
20
20
  - name: Install dependencies
21
21
  run: bundle install
22
22
  - name: Run tests
23
- run: bundle exec rspec spec/
23
+ run: bundle exec rake spec
24
+ lint:
25
+ runs-on: ubuntu-latest
26
+ steps:
27
+ - name: Checkout code
28
+ uses: actions/checkout@v4
29
+ - uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: "3.4"
32
+ bundler-cache: true
33
+ - name: Install dependencies
34
+ run: bundle install
35
+ - name: Run RuboCop
36
+ run: bundle exec rake rubocop
data/.rubocop.yml ADDED
@@ -0,0 +1,14 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ NewCops: enable
5
+
6
+ Metrics/BlockLength:
7
+ CountAsOne: [array, hash, heredoc, method_call]
8
+
9
+ Metrics/ClassLength:
10
+ CountAsOne: [array, hash, heredoc, method_call]
11
+
12
+ Metrics/MethodLength:
13
+ CountAsOne: [array, hash, heredoc, method_call]
14
+ Max: 20
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,160 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2025-07-10 10:25:51 UTC using RuboCop version 1.77.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 3
10
+ # Configuration parameters: EnforcedStyle, AllowedGems, Include.
11
+ # SupportedStyles: Gemfile, gems.rb, gemspec
12
+ # Include: **/*.gemspec, **/Gemfile, **/gems.rb
13
+ Gemspec/DevelopmentDependencies:
14
+ Exclude:
15
+ - "grape_logging.gemspec"
16
+
17
+ # Offense count: 1
18
+ # This cop supports safe autocorrection (--autocorrect).
19
+ # Configuration parameters: Severity, Include.
20
+ # Include: **/*.gemspec
21
+ Gemspec/RequireMFA:
22
+ Exclude:
23
+ - "grape_logging.gemspec"
24
+
25
+ # Offense count: 1
26
+ # Configuration parameters: Severity, Include.
27
+ # Include: **/*.gemspec
28
+ Gemspec/RequiredRubyVersion:
29
+ Exclude:
30
+ - "grape_logging.gemspec"
31
+
32
+ # Offense count: 1
33
+ # Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
34
+ Lint/DuplicateBranch:
35
+ Exclude:
36
+ - "lib/grape_logging/util/parameter_filter.rb"
37
+
38
+ # Offense count: 1
39
+ # Configuration parameters: AllowedParentClasses.
40
+ Lint/MissingSuper:
41
+ Exclude:
42
+ - "lib/grape_logging/loggers/filter_parameters.rb"
43
+
44
+ # Offense count: 3
45
+ # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
46
+ Metrics/AbcSize:
47
+ Max: 38
48
+
49
+ # Offense count: 8
50
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
51
+ # AllowedMethods: refine
52
+ Metrics/BlockLength:
53
+ Max: 90
54
+
55
+ # Offense count: 3
56
+ # Configuration parameters: AllowedMethods, AllowedPatterns.
57
+ Metrics/CyclomaticComplexity:
58
+ Max: 18
59
+
60
+ # Offense count: 2
61
+ # Configuration parameters: AllowedMethods, AllowedPatterns.
62
+ Metrics/PerceivedComplexity:
63
+ Max: 19
64
+
65
+ # Offense count: 2
66
+ # Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
67
+ # SupportedStyles: snake_case, normalcase, non_integer
68
+ # AllowedIdentifiers: TLS1_1, TLS1_2, capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
69
+ Naming/VariableNumber:
70
+ Exclude:
71
+ - "spec/lib/grape_logging/formatters/rails_spec.rb"
72
+
73
+ # Offense count: 3
74
+ # This cop supports unsafe autocorrection (--autocorrect-all).
75
+ # Configuration parameters: MinBranchesCount.
76
+ Style/CaseLikeIf:
77
+ Exclude:
78
+ - "lib/grape_logging/formatters/default.rb"
79
+ - "lib/grape_logging/formatters/logstash.rb"
80
+ - "lib/grape_logging/formatters/rails.rb"
81
+
82
+ # Offense count: 17
83
+ # Configuration parameters: AllowedConstants.
84
+ Style/Documentation:
85
+ Enabled: false
86
+
87
+ # Offense count: 29
88
+ # This cop supports unsafe autocorrection (--autocorrect-all).
89
+ # Configuration parameters: EnforcedStyle.
90
+ # SupportedStyles: always, always_true, never
91
+ Style/FrozenStringLiteralComment:
92
+ Enabled: false
93
+
94
+ # Offense count: 1
95
+ # This cop supports unsafe autocorrection (--autocorrect-all).
96
+ Style/GlobalStdStream:
97
+ Exclude:
98
+ - "lib/grape_logging/reporters/logger_reporter.rb"
99
+
100
+ # Offense count: 1
101
+ # This cop supports unsafe autocorrection (--autocorrect-all).
102
+ # Configuration parameters: EnforcedStyle.
103
+ # SupportedStyles: literals, strict
104
+ Style/MutableConstant:
105
+ Exclude:
106
+ - "lib/grape_logging/version.rb"
107
+
108
+ # Offense count: 10
109
+ Style/OpenStructUse:
110
+ Exclude:
111
+ - "spec/lib/grape_logging/loggers/client_env_spec.rb"
112
+ - "spec/lib/grape_logging/loggers/filter_parameters_spec.rb"
113
+ - "spec/lib/grape_logging/loggers/request_headers_spec.rb"
114
+ - "spec/lib/grape_logging/loggers/response_spec.rb"
115
+
116
+ # Offense count: 3
117
+ # This cop supports unsafe autocorrection (--autocorrect-all).
118
+ # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
119
+ # AllowedMethods: present?, blank?, presence, try, try!
120
+ Style/SafeNavigation:
121
+ Exclude:
122
+ - "lib/grape_logging/formatters/rails.rb"
123
+
124
+ # Offense count: 1
125
+ # This cop supports unsafe autocorrection (--autocorrect-all).
126
+ Style/SlicingWithRange:
127
+ Exclude:
128
+ - "lib/grape_logging/loggers/request_headers.rb"
129
+
130
+ # Offense count: 1
131
+ # This cop supports unsafe autocorrection (--autocorrect-all).
132
+ # Configuration parameters: RequireEnglish, EnforcedStyle.
133
+ # SupportedStyles: use_perl_names, use_english_names, use_builtin_english_names
134
+ Style/SpecialGlobalVars:
135
+ Exclude:
136
+ - "spec/spec_helper.rb"
137
+
138
+ # Offense count: 3
139
+ # This cop supports unsafe autocorrection (--autocorrect-all).
140
+ # Configuration parameters: Mode.
141
+ Style/StringConcatenation:
142
+ Exclude:
143
+ - "lib/grape_logging/formatters/json.rb"
144
+ - "lib/grape_logging/formatters/lograge.rb"
145
+ - "lib/grape_logging/formatters/logstash.rb"
146
+
147
+ # Offense count: 1
148
+ # This cop supports unsafe autocorrection (--autocorrect-all).
149
+ # Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments.
150
+ # AllowedMethods: define_method
151
+ Style/SymbolProc:
152
+ Exclude:
153
+ - "lib/grape_logging/util/parameter_filter.rb"
154
+
155
+ # Offense count: 11
156
+ # This cop supports safe autocorrection (--autocorrect).
157
+ # Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
158
+ # URISchemes: http, https
159
+ Layout/LineLength:
160
+ Max: 203
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.0.0] - 2025-08-07
4
+
5
+ ### Changed
6
+ - [#93](https://github.com/aserafin/grape_logging/pull/93) RequestLogger middleware to handle Grape 2.4 breaking change - [@devsigner](https://github.com/devsigner) and [@samsonjs](https://github.com/samsonjs).
7
+
8
+ [3.0.0]: https://github.com/aserafin/grape_logging/compare/v2.1.1...v3.0.0
9
+
3
10
  ## [2.1.1] - 2025-07-09
4
11
 
5
12
  ### Fixed
data/Rakefile CHANGED
@@ -1,9 +1,17 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
3
4
 
4
- RSpec::Core::RakeTask.new(:spec)
5
+ RSpec::Core::RakeTask.new(:spec) do |spec|
6
+ spec.rspec_opts = ['-fd -c']
7
+ spec.pattern = FileList['spec/**/*_spec.rb']
8
+ end
9
+
10
+ RuboCop::RakeTask.new(:rubocop) do |t|
11
+ t.patterns = ['lib/**/*.rb', 'spec/**/*.rb', 'Rakefile', 'Gemfile', 'grape_logging.gemspec']
12
+ end
5
13
 
6
- task default: :spec
14
+ task default: %i[spec rubocop]
7
15
 
8
16
  desc 'Release gem and create GitHub release'
9
17
  task github_release: :release do
@@ -14,9 +22,9 @@ task github_release: :release do
14
22
  # Check if gh CLI is available
15
23
  unless system('which gh > /dev/null 2>&1')
16
24
  puts "\n⚠️ GitHub CLI (gh) not found"
17
- puts "To create a GitHub release with auto-generated changelog, install gh:"
18
- puts " brew install gh # macOS with Homebrew"
19
- puts " # or visit: https://github.com/cli/cli#installation"
25
+ puts 'To create a GitHub release with auto-generated changelog, install gh:'
26
+ puts ' brew install gh # macOS with Homebrew'
27
+ puts ' # or visit: https://github.com/cli/cli#installation'
20
28
  puts "\nYou can manually create the release with:"
21
29
  puts " gh release create v#{GrapeLogging::VERSION} --generate-notes"
22
30
  next
@@ -28,8 +36,8 @@ task github_release: :release do
28
36
  if system('gh', 'release', 'create', version, '--generate-notes', '--verify-tag')
29
37
  puts "✅ GitHub release #{version} created successfully"
30
38
  else
31
- puts "❌ Failed to create GitHub release"
32
- puts "You can manually create it with:"
39
+ puts '❌ Failed to create GitHub release'
40
+ puts 'You can manually create it with:'
33
41
  puts " gh release create '#{version}' --generate-notes --verify-tag"
34
42
  end
35
43
  end
@@ -1,4 +1,4 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'grape_logging/version'
4
4
 
@@ -16,13 +16,17 @@ Gem::Specification.new do |spec|
16
16
  spec.license = 'MIT'
17
17
 
18
18
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
- spec.bindir = "exe"
19
+ spec.bindir = 'exe'
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ['lib']
22
22
 
23
- spec.add_dependency 'grape', '< 2.4.0'
23
+ spec.add_dependency 'grape', '>= 2.4.0'
24
24
  spec.add_dependency 'rack'
25
25
 
26
26
  spec.add_development_dependency 'rake', '~> 13.3'
27
27
  spec.add_development_dependency 'rspec', '~> 3.5'
28
+
29
+ # This is pinned to an exact version otherwise we can't know which rules
30
+ # are in play at any given time in different environments.
31
+ spec.add_development_dependency 'rubocop', '1.77.0'
28
32
  end
@@ -18,6 +18,7 @@ module GrapeLogging
18
18
  end
19
19
 
20
20
  private
21
+
21
22
  def format_hash(hash)
22
23
  hash.keys.sort.map { |key| "#{key}=#{hash[key]}" }.join(' ')
23
24
  end
@@ -3,9 +3,9 @@ module GrapeLogging
3
3
  class Logstash
4
4
  def call(severity, datetime, _, data)
5
5
  {
6
- :'@timestamp' => datetime.iso8601,
7
- :'@version' => '1',
8
- :severity => severity
6
+ '@timestamp': datetime.iso8601,
7
+ '@version': '1',
8
+ severity: severity
9
9
  }.merge!(format(data)).to_json + "\n"
10
10
  end
11
11
 
@@ -3,7 +3,6 @@ require 'rack/utils'
3
3
  module GrapeLogging
4
4
  module Formatters
5
5
  class Rails
6
-
7
6
  def call(severity, datetime, _, data)
8
7
  if data.is_a?(String)
9
8
  "#{severity[0..0]} [#{datetime}] #{severity} -- : #{data}\n"
@@ -24,7 +23,7 @@ module GrapeLogging
24
23
  [
25
24
  "#{exception.message} (#{exception.class})",
26
25
  backtrace_array.join("\n")
27
- ].reject{|line| line == ""}.join("\n")
26
+ ].reject { |line| line == '' }.join("\n")
28
27
  end
29
28
 
30
29
  def format_hash(hash)
@@ -32,7 +31,7 @@ module GrapeLogging
32
31
  # Completed 200 OK in 958ms (Views: 951.1ms | ActiveRecord: 3.8ms)
33
32
  # See: actionpack/lib/action_controller/log_subscriber.rb
34
33
 
35
- message = ""
34
+ message = ''
36
35
  additions = []
37
36
  status = hash.delete(:status)
38
37
  params = hash.delete(:params)
@@ -47,13 +46,12 @@ module GrapeLogging
47
46
  message << " Parameters: #{params.inspect}\n" if params
48
47
 
49
48
  message << "Completed #{status} #{::Rack::Utils::HTTP_STATUS_CODES[status]} in #{total_time}ms"
50
- message << " (#{additions.join(" | ".freeze)})" if additions.size > 0
49
+ message << " (#{additions.join(' | '.freeze)})" unless additions.empty?
51
50
  message << "\n"
52
51
  message << "\n" if defined?(::Rails.env) && ::Rails.env.development?
53
52
 
54
53
  message
55
54
  end
56
-
57
55
  end
58
56
  end
59
57
  end
@@ -1,7 +1,7 @@
1
1
  module GrapeLogging
2
2
  module Loggers
3
3
  class Base
4
- def parameters(request, response)
4
+ def parameters(_request, _response)
5
5
  {}
6
6
  end
7
7
  end
@@ -2,7 +2,7 @@ module GrapeLogging
2
2
  module Loggers
3
3
  class ClientEnv < GrapeLogging::Loggers::Base
4
4
  def parameters(request, _)
5
- { ip: request.env["HTTP_X_FORWARDED_FOR"] || request.env["REMOTE_ADDR"], ua: request.env["HTTP_USER_AGENT"] }
5
+ { ip: request.env['HTTP_X_FORWARDED_FOR'] || request.env['REMOTE_ADDR'], ua: request.env['HTTP_USER_AGENT'] }
6
6
  end
7
7
  end
8
8
  end
@@ -3,7 +3,7 @@ module GrapeLogging
3
3
  class FilterParameters < GrapeLogging::Loggers::Base
4
4
  AD_PARAMS = 'action_dispatch.request.parameters'.freeze
5
5
 
6
- def initialize(filter_parameters = nil, replacement = nil, exceptions = %w(controller action format))
6
+ def initialize(filter_parameters = nil, replacement = nil, exceptions = %w[controller action format])
7
7
  @filter_parameters = filter_parameters || (defined?(::Rails.application) ? ::Rails.application.config.filter_parameters : [])
8
8
  @replacement = replacement || '[FILTERED]'
9
9
  @exceptions = exceptions
@@ -30,8 +30,8 @@ module GrapeLogging
30
30
 
31
31
  def clean_parameters(parameters)
32
32
  original_encoding_map = build_encoding_map(parameters)
33
- params = transform_key_encoding(parameters, Hash.new{ |h, _| [Encoding::ASCII_8BIT, h] })
34
- cleaned_params = parameter_filter.filter(params).reject{ |key, _value| @exceptions.include?(key) }
33
+ params = transform_key_encoding(parameters, Hash.new { |h, _| [Encoding::ASCII_8BIT, h] })
34
+ cleaned_params = parameter_filter.filter(params).reject { |key, _value| @exceptions.include?(key) }
35
35
  transform_key_encoding(cleaned_params, original_encoding_map)
36
36
  end
37
37
 
@@ -1,7 +1,6 @@
1
1
  module GrapeLogging
2
2
  module Loggers
3
3
  class RequestHeaders < GrapeLogging::Loggers::Base
4
-
5
4
  HTTP_PREFIX = 'HTTP_'.freeze
6
5
 
7
6
  def parameters(request, _)
@@ -16,7 +15,6 @@ module GrapeLogging
16
15
 
17
16
  { headers: headers }
18
17
  end
19
-
20
18
  end
21
19
  end
22
20
  end
@@ -11,12 +11,11 @@ module GrapeLogging
11
11
  # For example, if you POST on a PUT endpoint, response.body is egal to """".
12
12
  # It's strange, but it's the Grape behavior...
13
13
  def serialized_response_body(response)
14
-
15
14
  if response.respond_to?(:body)
16
15
  # Rack responses
17
16
  begin
18
- response.body.map{ |body| JSON.parse(body.to_s) }
19
- rescue # No reason to have "=> e" here when we don't use it..
17
+ response.body.map { |body| JSON.parse(body.to_s) }
18
+ rescue StandardError # No reason to have "=> e" here when we don't use it..
20
19
  response.body
21
20
  end
22
21
  else
@@ -3,25 +3,27 @@ require 'grape'
3
3
  module GrapeLogging
4
4
  module Middleware
5
5
  class RequestLogger < Grape::Middleware::Base
6
-
7
- ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
8
- event = ActiveSupport::Notifications::Event.new(*args)
9
- GrapeLogging::Timings.append_db_runtime(event)
10
- end if defined?(ActiveRecord)
6
+ if defined?(ActiveRecord)
7
+ ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
8
+ event = ActiveSupport::Notifications::Event.new(*args)
9
+ GrapeLogging::Timings.append_db_runtime(event)
10
+ end
11
+ end
11
12
 
12
13
  # Persist response status & response (body)
13
14
  # to use int in parameters
14
15
  attr_accessor :response_status, :response_body
15
16
 
16
- def initialize(app, options = {})
17
+ def initialize(app, **options)
17
18
  super
18
19
 
19
20
  @included_loggers = @options[:include] || []
20
- @reporter = if options[:instrumentation_key]
21
- Reporters::ActiveSupportReporter.new(@options[:instrumentation_key])
22
- else
23
- Reporters::LoggerReporter.new(@options[:logger], @options[:formatter], @options[:log_level])
24
- end
21
+ @reporter =
22
+ if options[:instrumentation_key]
23
+ Reporters::ActiveSupportReporter.new(@options[:instrumentation_key])
24
+ else
25
+ Reporters::LoggerReporter.new(@options[:logger], @options[:formatter], @options[:log_level])
26
+ end
25
27
  end
26
28
 
27
29
  def before
@@ -99,7 +101,7 @@ module GrapeLogging
99
101
  path: request.path,
100
102
  params: request.params,
101
103
  host: request.host,
102
- request_id: env['action_dispatch.request_id'],
104
+ request_id: env['action_dispatch.request_id']
103
105
  }
104
106
  end
105
107
 
@@ -5,11 +5,11 @@ module GrapeLogging
5
5
  end
6
6
 
7
7
  def write(*args)
8
- @targets.each {|t| t.write(*args)}
8
+ @targets.each { |t| t.write(*args) }
9
9
  end
10
10
 
11
11
  def close
12
12
  @targets.each(&:close)
13
13
  end
14
14
  end
15
- end
15
+ end
@@ -8,4 +8,4 @@ module Reporters
8
8
  ActiveSupport::Notifications.instrument @instrumentation_key, params
9
9
  end
10
10
  end
11
- end
11
+ end
@@ -3,9 +3,7 @@ module Reporters
3
3
  def initialize(logger, formatter, log_level)
4
4
  @logger = logger.clone || Logger.new(STDOUT)
5
5
  @log_level = log_level || :info
6
- if @logger.respond_to?(:formatter=)
7
- @logger.formatter = formatter || @logger.formatter || GrapeLogging::Formatters::Default.new
8
- end
6
+ @logger.formatter = formatter || @logger.formatter || GrapeLogging::Formatters::Default.new if @logger.respond_to?(:formatter=)
9
7
  end
10
8
 
11
9
  def perform(params)
@@ -1,21 +1,19 @@
1
1
  module GrapeLogging
2
2
  module Timings
3
- extend self
4
-
5
- def db_runtime=(value)
3
+ def self.db_runtime=(value)
6
4
  Thread.current[:grape_db_runtime] = value
7
5
  end
8
6
 
9
- def db_runtime
7
+ def self.db_runtime
10
8
  Thread.current[:grape_db_runtime] ||= 0
11
9
  end
12
10
 
13
- def reset_db_runtime
11
+ def self.reset_db_runtime
14
12
  self.db_runtime = 0
15
13
  end
16
14
 
17
- def append_db_runtime(event)
15
+ def self.append_db_runtime(event)
18
16
  self.db_runtime += event.duration
19
17
  end
20
18
  end
21
- end
19
+ end
@@ -1,4 +1,4 @@
1
- if defined?(::Rails.application)
1
+ if defined?(Rails.application)
2
2
  if Gem::Version.new(Rails.version) < Gem::Version.new('6.0.0')
3
3
  class ParameterFilter < ActionDispatch::Http::ParameterFilter
4
4
  def initialize(_replacement, filter_parameters)
@@ -6,7 +6,7 @@ if defined?(::Rails.application)
6
6
  end
7
7
  end
8
8
  else
9
- require "active_support/parameter_filter"
9
+ require 'active_support/parameter_filter'
10
10
 
11
11
  class ParameterFilter < ActiveSupport::ParameterFilter
12
12
  def initialize(_replacement, filter_parameters)
@@ -37,9 +37,11 @@ else
37
37
 
38
38
  class CompiledFilter # :nodoc:
39
39
  def self.compile(replacement, filters)
40
- return lambda { |params| params.dup } if filters.empty?
40
+ return ->(params) { params.dup } if filters.empty?
41
41
 
42
- strings, regexps, blocks = [], [], []
42
+ strings = []
43
+ regexps = []
44
+ blocks = []
43
45
 
44
46
  filters.each do |item|
45
47
  case item
@@ -52,8 +54,8 @@ else
52
54
  end
53
55
  end
54
56
 
55
- deep_regexps, regexps = regexps.partition { |r| r.to_s.include?("\\.".freeze) }
56
- deep_strings, strings = strings.partition { |s| s.include?("\\.".freeze) }
57
+ deep_regexps, regexps = regexps.partition { |r| r.to_s.include?('\\.'.freeze) }
58
+ deep_strings, strings = strings.partition { |s| s.include?('\\.'.freeze) }
57
59
 
58
60
  regexps << Regexp.new(strings.join('|'.freeze), true) unless strings.empty?
59
61
  deep_regexps << Regexp.new(deep_strings.join('|'.freeze), true) unless deep_strings.empty?
@@ -67,7 +69,7 @@ else
67
69
  @replacement = replacement
68
70
  @regexps = regexps
69
71
  @deep_regexps = deep_regexps.any? ? deep_regexps : nil
70
- @blocks = blocks
72
+ @blocks = blocks
71
73
  end
72
74
 
73
75
  def call(original_params, parents = [])
@@ -1,3 +1,3 @@
1
1
  module GrapeLogging
2
- VERSION = '2.1.1'
2
+ VERSION = '3.0.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape_logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - aserafin
@@ -14,14 +14,14 @@ dependencies:
14
14
  name: grape
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "<"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 2.4.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "<"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.4.0
27
27
  - !ruby/object:Gem::Dependency
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 1.77.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.77.0
69
83
  description: This gem provides simple request logging for Grape with just few lines
70
84
  of code you have to put in your project! In return you will get response codes,
71
85
  paths, parameters and more!
@@ -78,6 +92,8 @@ extra_rdoc_files: []
78
92
  files:
79
93
  - ".github/workflows/ci.yml"
80
94
  - ".gitignore"
95
+ - ".rubocop.yml"
96
+ - ".rubocop_todo.yml"
81
97
  - CHANGELOG.md
82
98
  - CONTRIBUTING.md
83
99
  - Gemfile