Skip to content

Commit

Permalink
resolves #257 pass logger as config (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggrossetie authored May 21, 2021
1 parent 7951918 commit db0d99b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/build-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-ruby@v1
- uses: ruby/setup-ruby@v1
with:
ruby-version: '2.6'
- run: bundle install
working-directory: ./ruby
ruby-version: 2.7
bundler-cache: true
working-directory: ./ruby
- run: bundle exec rake
working-directory: ./ruby
env:
RUBYOPT: "W:deprecated"
2 changes: 1 addition & 1 deletion ruby/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ DEPENDENCIES
rubocop (~> 0.74.0)

BUNDLED WITH
1.17.3
2.2.17
12 changes: 6 additions & 6 deletions ruby/lib/asciidoctor/extensions/asciidoctor_kroki/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class KrokiBlockProcessor < Extensions::BlockProcessor

# @param name [String] name of the block macro (optional)
# @param config [Hash] a config hash (optional)
# @param logger [Logger] a logger used to log warning and errors (optional)
# - :logger a logger used to log warning and errors (optional)
#
def initialize(name = nil, config = {}, logger: ::Asciidoctor::LoggerManager.logger)
def initialize(name = nil, config = {})
@logger = (config || {}).delete(:logger) { ::Asciidoctor::LoggerManager.logger }
super(name, config)
@logger = logger
end

def process(parent, reader, attrs)
Expand All @@ -44,11 +44,11 @@ class KrokiBlockMacroProcessor < Asciidoctor::Extensions::BlockMacroProcessor

# @param name [String] name of the block macro (optional)
# @param config [Hash] a config hash (optional)
# @param logger [Logger] a logger used to log warning and errors (optional)
# - :logger a logger used to log warning and errors (optional)
#
def initialize(name = nil, config = {}, logger: ::Asciidoctor::LoggerManager.logger)
def initialize(name = nil, config = {})
@logger = (config || {}).delete(:logger) { ::Asciidoctor::LoggerManager.logger }
super(name, config)
@logger = logger
end

def process(parent, target, attrs)
Expand Down
11 changes: 11 additions & 0 deletions ruby/spec/asciidoctor_kroki_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,17 @@
</div>)
end
end
context 'instantiate' do
it 'should instantiate block processor without warning' do
original_stderr = $stderr
$stderr = StringIO.new
::AsciidoctorExtensions::KrokiBlockProcessor.new 'plantuml'.to_sym, {}
output = $stderr.string
(expect output).to eql ''
ensure
$stderr = original_stderr
end
end
end

describe ::AsciidoctorExtensions::Kroki do
Expand Down

0 comments on commit db0d99b

Please sign in to comment.