Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@ jobs:
gemfile: gemfiles/rails_8.1.gemfile
- ruby: "3.1"
gemfile: gemfiles/rails_8.1.gemfile
# NOTE: Rails edge requires Ruby version >= 3.2
# NOTE: Rails edge requires Ruby version >= 3.3.1
- ruby: "2.7"
gemfile: gemfiles/rails_edge.gemfile
- ruby: "3.0"
gemfile: gemfiles/rails_edge.gemfile
- ruby: "3.1"
gemfile: gemfiles/rails_edge.gemfile
- ruby: "3.2"
gemfile: gemfiles/rails_edge.gemfile


env:
Expand All @@ -106,5 +108,20 @@ jobs:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- run: bundle exec rake
# Specs only. Linting is handled once by the `lint` job below: RuboCop
# resolves to a different version on each Ruby, so running it across the
# matrix makes lint results depend on the leg rather than on the code.
- run: bundle exec rake spec

lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
bundler-cache: true

- run: bundle exec rubocop
15 changes: 15 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,28 @@ Lint/AmbiguousBlockAssociation:
Exclude:
- spec/**/*_spec.rb

# The no-op logger methods are intentionally empty. Configured here rather than
# with an inline directive so the suppression is understood by every RuboCop
# version in the CI matrix.
Lint/EmptyBlock:
Exclude:
- lib/lograge/silent_logger.rb

Metrics/AbcSize:
Enabled: false

# RuboCop excludes gemspecs from this cop by default, but a local Exclude
# replaces the default list rather than extending it, so restate it here.
Metrics/BlockLength:
Exclude:
- '**/*.gemspec'
- spec/**/*_spec.rb

# Lograge's public API lives in a single module. See the note on Lint/EmptyBlock.
Metrics/ModuleLength:
Exclude:
- lib/lograge.rb

Style/BlockDelimiters:
Enabled: false

Expand Down
2 changes: 0 additions & 2 deletions lib/lograge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
require 'active_support/core_ext/module/attribute_accessors'
require 'active_support/core_ext/string/inflections'

# rubocop:disable Metrics/ModuleLength
module Lograge
module_function

Expand Down Expand Up @@ -241,6 +240,5 @@ def notification_listeners_for(name)
end
end
end
# rubocop:enable Metrics/ModuleLength

require 'lograge/railtie' if defined?(Rails)
2 changes: 0 additions & 2 deletions lib/lograge/silent_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
module Lograge
class SilentLogger < SimpleDelegator
%i[debug info warn error fatal unknown].each do |method_name|
# rubocop:disable Lint/EmptyBlock
define_method(method_name) { |*_args| }
# rubocop:enable Lint/EmptyBlock
end
end
end
7 changes: 4 additions & 3 deletions lograge.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ Gem::Specification.new do |s|

s.files = `git ls-files lib LICENSE.txt`.split("\n")

# base64, bigdecimal and mutex_m were extracted from the default gems in
# Ruby 3.4; older Rails releases still `require` them, and JRuby (which
# targets Ruby 3.4) does not bundle them, so declare them explicitly.
# base64, benchmark, bigdecimal and mutex_m were extracted from the default
# gems in Ruby 3.4/4.1; older Rails releases still `require` them, and JRuby
# (which targets Ruby 3.4) does not bundle them, so declare them explicitly.
s.add_development_dependency 'base64'
s.add_development_dependency 'benchmark'
s.add_development_dependency 'bigdecimal'
s.add_development_dependency 'mutex_m'
# rdoc 8 depends on rbs, whose C extension cannot be built on JRuby. Keep
Expand Down
2 changes: 1 addition & 1 deletion spec/log_subscribers/action_cable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

context 'with custom_options configured for cee output' do
before do
Lograge.formatter = ->(data) { "My test: #{data.to_json}" }
Lograge.formatter = ->(data) { "My test: #{JSON.dump(data)}" }
end

it 'combines the hash properly for the output' do
Expand Down
2 changes: 1 addition & 1 deletion spec/log_subscribers/action_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

context 'with custom_options configured for cee output' do
before do
Lograge.formatter = ->(data) { "My test: #{data.to_json}" }
Lograge.formatter = ->(data) { "My test: #{JSON.dump(data)}" }
end

it 'combines the hash properly for the output' do
Expand Down
Loading