Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby asciidoctor-kroki Failed to load AsciiDoc document on post request #277

Closed
demagnevalCegelec opened this issue Jul 8, 2021 · 3 comments
Labels
🐞 bug Something isn't working 💎 Ruby

Comments

@demagnevalCegelec
Copy link
Contributor

demagnevalCegelec commented Jul 8, 2021

Launching the command :

bundle exec asciidoctor -a toc -r asciidoctor-kroki Figures.adoc -D public

return

asciidoctor: FAILED: documentation/Figures.adoc: Failed to load AsciiDoc document - undefined method `request_post' for Net::HTTP:Class
@demagnevalCegelec
Copy link
Contributor Author

demagnevalCegelec commented Jul 8, 2021

NoMethodError: asciidoctor: FAILED: documentation/Figures.adoc: Failed to load AsciiDoc document - undefined method `request_post' for Net::HTTP:Class
  /usr/local/bundle/gems/asciidoctor-kroki-0.5.0/lib/asciidoctor/extensions/asciidoctor_kroki/extension.rb:380:in `post'
  /usr/local/bundle/gems/asciidoctor-kroki-0.5.0/lib/asciidoctor/extensions/asciidoctor_kroki/extension.rb:356:in `get_image'
  /usr/local/bundle/gems/asciidoctor-kroki-0.5.0/lib/asciidoctor/extensions/asciidoctor_kroki/extension.rb:291:in `save'
  /usr/local/bundle/gems/asciidoctor-kroki-0.5.0/lib/asciidoctor/extensions/asciidoctor_kroki/extension.rb:221:in `create_image_src'
  /usr/local/bundle/gems/asciidoctor-kroki-0.5.0/lib/asciidoctor/extensions/asciidoctor_kroki/extension.rb:160:in `process'
  /usr/local/bundle/gems/asciidoctor-kroki-0.5.0/lib/asciidoctor/extensions/asciidoctor_kroki/extension.rb:30:in `process'
  /usr/local/bundle/gems/asciidoctor-2.0.15/lib/asciidoctor/parser.rb:1047:in `[]'
  /usr/local/bundle/gems/asciidoctor-2.0.15/lib/asciidoctor/parser.rb:1047:in `build_block'
  /usr/local/bundle/gems/asciidoctor-2.0.15/lib/asciidoctor/parser.rb:895:in `next_block'
  /usr/local/bundle/gems/asciidoctor-2.0.15/lib/asciidoctor/parser.rb:385:in `next_section'
  /usr/local/bundle/gems/asciidoctor-2.0.15/lib/asciidoctor/parser.rb:370:in `next_section'
  /usr/local/bundle/gems/asciidoctor-2.0.15/lib/asciidoctor/parser.rb:370:in `next_section'
  /usr/local/bundle/gems/asciidoctor-2.0.15/lib/asciidoctor/parser.rb:97:in `parse'
  /usr/local/bundle/gems/asciidoctor-2.0.15/lib/asciidoctor/document.rb:538:in `parse'
  /usr/local/bundle/gems/asciidoctor-2.0.15/lib/asciidoctor/load.rb:83:in `load'
  /usr/local/bundle/gems/asciidoctor-2.0.15/lib/asciidoctor/convert.rb:77:in `convert'
  /usr/local/bundle/gems/asciidoctor-2.0.15/lib/asciidoctor/convert.rb:189:in `block in convert_file'
  /usr/local/bundle/gems/asciidoctor-2.0.15/lib/asciidoctor/convert.rb:189:in `open'
  /usr/local/bundle/gems/asciidoctor-2.0.15/lib/asciidoctor/convert.rb:189:in `convert_file'
  /usr/local/bundle/gems/asciidoctor-2.0.15/lib/asciidoctor/cli/invoker.rb:130:in `block in invoke!'
  /usr/local/bundle/gems/asciidoctor-2.0.15/lib/asciidoctor/cli/invoker.rb:113:in `each'
  /usr/local/bundle/gems/asciidoctor-2.0.15/lib/asciidoctor/cli/invoker.rb:113:in `invoke!'
  /usr/local/bundle/gems/asciidoctor-2.0.15/bin/asciidoctor:15:in `<top (required)>'
  /usr/local/bundle/bin/asciidoctor:17:in `load'
  /usr/local/bundle/bin/asciidoctor:17:in `<top (required)>'

@ggrossetie
Copy link
Member

I think I misread the Ruby stdlib documentation. It seems that ::Net::HTTP.request_post does not exist:

https://github.com/Mogztter/asciidoctor-kroki/blob/5dcaf20108353a2f86dbae98bdea34cfade136a9/ruby/lib/asciidoctor/extensions/asciidoctor_kroki/extension.rb#L380-L381

I believe that the code should be:

res = ::Net::HTTP.post(URI(uri), data, "Content-Type" => "text/plain")
res.body

@ggrossetie ggrossetie added 🐞 bug Something isn't working 💎 Ruby labels Jul 8, 2021
@demagnevalCegelec
Copy link
Contributor Author

I have tested youre tips and it works fine

demagnevalCegelec added a commit to demagnevalCegelec/asciidoctor-kroki that referenced this issue Jul 9, 2021
demagnevalCegelec added a commit to demagnevalCegelec/asciidoctor-kroki that referenced this issue Jul 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 💎 Ruby
Projects
None yet
Development

No branches or pull requests

2 participants