Closed jperville closed 1 year ago
You could also force the version of Haml to ~> 5.2. Can you send me the gen versions you’re using? Haml::Template.new should be defined in Haml 6.1.
Sure @gkellogg, as I said I forced haml to version 5.2 and when using the combination of
Here is what I put in my Gemfile to force haml 5.2 gem 'haml', '~> 5.2'
Here are the relevant gems in my project (again with rdf-rda forced to version 2.3.0 to avoid the current issue):
julien:api(225m) $ bundle list | egrep 'haml|rdf'
If I try to use haml 6.x (with rdf-rdfa 2.3.0 or 2.3.1) I don't have the bug that I am reporting here but I get the stacktrace at the end of this comment which could be a bug in another rdf-related library.
EDIT : the references to haml_tag come from within the rdf-rdfxml gem.
My relevant gems would look like this:
julien:api(235m) $ bundle list | egrep 'haml|rdf'
Then when running my tests I get the following stacktrace:
NoMethodError:
undefined method `haml_tag' for #<RDF::RDFXML::Writer:0x00007f414d377798 @options={:logger=>#<IO:<STDERR>>, :encoding=>#<Encoding:UTF-8>, :log_depth=>0, :prefixes=>{:rdf=>"http://www.w3.org/1999/02/22-rdf-syntax-ns#", :ns0=>"http://pm.com/"}}, @output=#<StringIO:0x00007f414d3778d8>, @node_id_map={}, @node_id=0, @nodes={}, @logged_errors_at_prolog=0, @uri_to_term_or_curie={"http://pm.com/instance"=>"http://pm.com/instance", "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"=>"rdf:type", "http://pm.com/class"=>"ns0:class", "http://www.w3.org/1999/02/22-rdf-syntax-ns#about"=>"rdf:about"}, @uri_to_prefix={"http://www.w3.org/1999/02/22-rdf-syntax-ns#"=>:rdf, "http://pm.com/"=>"ns0"}, @top_classes=[#<RDF::Vocabulary::Term:0x143ac ID:http://www.w3.org/2000/01/rdf-schema#Class>], @predicate_order=[#<RDF::Vocabulary::Term:0x1c34 ID:http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, #<RDF::Vocabulary::Term:0x14460 ID:http://www.w3.org/2000/01/rdf-schema#label>, #<RDF::URI:0x144ec URI:http://purl.org/dc/terms/title>], @heading_predicates=[#<RDF::Vocabulary::Term:0x14460 ID:http://www.w3.org/2000/01/rdf-schema#label>, #<RDF::URI:0x14500 URI:http://purl.org/dc/terms/title>], @graph=#<RDF::Graph:0x14514(default)>, @force_RDF_about={}, @max_depth=10, @attributes=:none, @lang=nil, @references={#<RDF::URI:0x14528 URI:http://pm.com/class>=>1}, @serialized={#<RDF::URI:0x1453c URI:http://pm.com/instance>=>true}, @subjects={#<RDF::URI:0x1453c URI:http://pm.com/instance>=>true}, @gen_prefix="ns0">
Did you mean? haml_template
# (__TEMPLATE__):7:in `__tilt_70280'
# ./.bundle/ruby/3.1.0/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `bind_call'
# ./.bundle/ruby/3.1.0/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `evaluate'
# ./.bundle/ruby/3.1.0/gems/tilt-2.1.0/lib/tilt/template.rb:109:in `render'
# ./.bundle/ruby/3.1.0/gems/rdf-rdfa-3.2.1/lib/rdf/rdfa/writer.rb:772:in `hamlify'
# ./.bundle/ruby/3.1.0/gems/rdf-rdfa-3.2.1/lib/rdf/rdfa/writer.rb:281:in `render_subject'
# ./.bundle/ruby/3.1.0/gems/rdf-rdfxml-3.2.0/lib/rdf/rdfxml/writer.rb:192:in `render_subject'
# ./.bundle/ruby/3.1.0/gems/rdf-rdfa-3.2.1/lib/rdf/rdfa/writer.rb:558:in `block in render_subject_template'
# ./.bundle/ruby/3.1.0/gems/rdf-rdfa-3.2.1/lib/rdf/rdfa/writer.rb:745:in `with_template'
# ./.bundle/ruby/3.1.0/gems/rdf-rdfa-3.2.1/lib/rdf/rdfa/writer.rb:557:in `render_subject_template'
# ./.bundle/ruby/3.1.0/gems/rdf-rdfa-3.2.1/lib/rdf/rdfa/writer.rb:506:in `subject'
# ./.bundle/ruby/3.1.0/gems/rdf-rdfa-3.2.1/lib/rdf/rdfa/writer.rb:191:in `block in write_epilogue'
# ./.bundle/ruby/3.1.0/gems/rdf-rdfa-3.2.1/lib/rdf/rdfa/writer.rb:231:in `block in render_document'
# ./.bundle/ruby/3.1.0/gems/rdf-rdfa-3.2.1/lib/rdf/rdfa/writer.rb:773:in `block in hamlify'
# (__TEMPLATE__):6:in `block in __tilt_70280'
# (__TEMPLATE__):5:in `each'
# (__TEMPLATE__):5:in `__tilt_70280'
# ./.bundle/ruby/3.1.0/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `bind_call'
# ./.bundle/ruby/3.1.0/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `evaluate'
# ./.bundle/ruby/3.1.0/gems/tilt-2.1.0/lib/tilt/template.rb:109:in `render'
# ./.bundle/ruby/3.1.0/gems/rdf-rdfa-3.2.1/lib/rdf/rdfa/writer.rb:772:in `hamlify'
# ./.bundle/ruby/3.1.0/gems/rdf-rdfa-3.2.1/lib/rdf/rdfa/writer.rb:230:in `render_document'
# ./.bundle/ruby/3.1.0/gems/rdf-rdfxml-3.2.0/lib/rdf/rdfxml/writer.rb:232:in `render_document'
# ./.bundle/ruby/3.1.0/gems/rdf-rdfa-3.2.1/lib/rdf/rdfa/writer.rb:186:in `write_epilogue'
# ./.bundle/ruby/3.1.0/gems/rdf-rdfxml-3.2.0/lib/rdf/rdfxml/writer.rb:134:in `write_epilogue'
# ./.bundle/ruby/3.1.0/gems/rdf-3.2.9/lib/rdf/writer.rb:297:in `initialize'
# ./.bundle/ruby/3.1.0/gems/rdf-rdfa-3.2.1/lib/rdf/rdfa/writer.rb:120:in `initialize'
# ./.bundle/ruby/3.1.0/gems/rdf-rdfxml-3.2.0/lib/rdf/rdfxml/writer.rb:117:in `initialize'
# ./.bundle/ruby/3.1.0/gems/rdf-3.2.9/lib/rdf/writer.rb:220:in `new'
# ./.bundle/ruby/3.1.0/gems/rdf-3.2.9/lib/rdf/writer.rb:220:in `block in buffer'
# ./.bundle/ruby/3.1.0/gems/rdf-3.2.9/lib/rdf/writer.rb:219:in `open'
# ./.bundle/ruby/3.1.0/gems/rdf-3.2.9/lib/rdf/writer.rb:219:in `buffer'
# ./.bundle/ruby/3.1.0/gems/rdf-3.2.9/lib/rdf/writer.rb:198:in `dump'
# ./.bundle/ruby/3.1.0/gems/rdf-3.2.9/lib/rdf/mixin/enumerable.rb:784:in `dump'
# /home/julien/RubymineProjects/exchange-manager/src/ruby/gem/lib/exchange_manager/models/value.rb:54:in `dump'
# ./lib/value_dump.rb:22:in `content'
# ./app/controllers/v1/values_controller.rb:26:in `raw'
# ./.bundle/ruby/3.1.0/gems/actionpack-6.1.7.3/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
# ./.bundle/ruby/3.1.0/gems/actionpack-6.1.7.3/lib/abstract_controller/base.rb:228:in `process_action'
# ./.bundle/ruby/3.1.0/gems/actionpack-6.1.7.3/lib/action_controller/metal/rendering.rb:30:in `process_action'
# ./.bundle/ruby/3.1.0/gems/actionpack-6.1.7.3/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
# ./.bundle/ruby/3.1.0/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:106:in `run_callbacks'
# ./.bundle/ruby/3.1.0/gems/actionpack-6.1.7.3/lib/abstract_controller/callbacks.rb:41:in `process_action'
# ./.bundle/ruby/3.1.0/gems/actionpack-6.1.7.3/lib/action_controller/metal/rescue.rb:22:in `process_action'
# ./.bundle/ruby/3.1.0/gems/actionpack-6.1.7.3/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
# ./.bundle/ruby/3.1.0/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:203:in `block in instrument'
# ./.bundle/ruby/3.1.0/gems/activesupport-6.1.7.3/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
# ./.bundle/ruby/3.1.0/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:203:in `instrument'
# ./.bundle/ruby/3.1.0/gems/actionpack-6.1.7.3/lib/action_controller/metal/instrumentation.rb:33:in `process_action'
# ./.bundle/ruby/3.1.0/gems/actionpack-6.1.7.3/lib/action_controller/metal/params_wrapper.rb:249:in `process_action'
# ./.bundle/ruby/3.1.0/gems/mongoid-7.5.2/lib/mongoid/railties/controller_runtime.rb:21:in `process_action'
# ./.bundle/ruby/3.1.0/gems/actionpack-6.1.7.3/lib/abstract_controller/base.rb:165:in `process'
# ./.bundle/ruby/3.1.0/gems/actionview-6.1.7.3/lib/action_view/rendering.rb:39:in `process'
# ./.bundle/ruby/3.1.0/gems/actionpack-6.1.7.3/lib/action_controller/metal.rb:190:in `dispatch'
# ./.bundle/ruby/3.1.0/gems/actionpack-6.1.7.3/lib/action_controller/test_case.rb:580:in `process_controller_response'
# ./.bundle/ruby/3.1.0/gems/actionpack-6.1.7.3/lib/action_controller/test_case.rb:499:in `process'
# ./.bundle/ruby/3.1.0/gems/rails-controller-testing-1.0.5/lib/rails/controller/testing/template_assertions.rb:62:in `process'
# ./.bundle/ruby/3.1.0/gems/devise-4.9.2/lib/devise/test/controller_helpers.rb:35:in `block in process'
# ./.bundle/ruby/3.1.0/gems/devise-4.9.2/lib/devise/test/controller_helpers.rb:104:in `catch'
# ./.bundle/ruby/3.1.0/gems/devise-4.9.2/lib/devise/test/controller_helpers.rb:104:in `_catch_warden'
# ./.bundle/ruby/3.1.0/gems/devise-4.9.2/lib/devise/test/controller_helpers.rb:35:in `process'
# ./.bundle/ruby/3.1.0/gems/actionpack-6.1.7.3/lib/action_controller/test_case.rb:398:in `get'
# ./.bundle/ruby/3.1.0/gems/rails-controller-testing-1.0.5/lib/rails/controller/testing/integration.rb:16:in `block (2 levels) in <module:Integration>'
# ./spec/controllers/v1/values_controller_spec.rb:45:in `block (7 levels) in <top (required)>'
You might be serializing a graph that is not covered by the tests. Can you provide a reference to the graph you're trying to serialize as RDFa?
Hello, I would have to dig in the tests of our application to find this graph. I will ask my workmates tomorrow if they can help.
I pushed up a change that may help you with Haml detection, if you pull from the 'develop' branch. The code was looking to see if Haml::Template
was defined, which it normally is not in Haml 5.2, but you may be including something else that did define it. It now looks for Haml::VERSION < '6'
.
As for the problems with Haml 6.1, that is coming from the rdf-rdfxml gem, which uses haml_tag
(and uses the RDFa writer), which they removed without replacement. If using Rails, content_tag
is a replacement, but this gem does not depend on that, so I'm working on a replacement for haml_tag
that will work in Haml 6. In the mean time, you should be able to continue with Haml 5.2.
Hello @gkellogg
I did a quick check for the word Template in haml 5.2.2 source and I found a few instances, for example :
The constant Haml::Template seems defined by monkeypatching in haml/template/options.rb and is referenced in haml/template so anything that requires 'haml/template' (such as using the haml railtie) will define the constant.
With haml 5.2.2, the Haml::Template is only defined if requiring 'haml/template' explicitly or using the railtie With haml 6.x, the Haml::Template constant is defined all the time since 'haml/template' is required in haml.rb
julien:gems(1143m|master) $ fgrep -r 'haml/template' */lib
# haml 5.2.2
haml-5.2.2/lib/haml/railtie.rb:require 'haml/template/options'
haml-5.2.2/lib/haml/railtie.rb: require "haml/template" # <--- require in the railtie only
haml-5.2.2/lib/haml/template.rb:require 'haml/template/options'
haml-5.2.2/lib/haml/util.rb: # Overridden in haml/template.rb if this is the case.
# haml 6.1.1
haml-6.1.1/lib/haml.rb:require 'haml/template' # <--- require all the time
haml-6.1.1/lib/haml/rails_template.rb: # https://github.com/haml/haml/blob/4.0.7/lib/haml/template/plugin.rb#L19-L20
haml-6.1.1/lib/haml/util.rb: # Overridden in haml/template.rb if this is the case.
I'm going to try your "develop" version and see if it helps.
Hello @gkellogg , I confirm you that the last change on develop ( https://github.com/ruby-rdf/rdf-rdfa/commit/08fcd25a2d29b263769aa1fcdafa41ad01a39898 ) allows me to run my tests with haml 5.2.2 .
Making a new patch release with this fix should close this issue.
Thanks @gkellogg for the new release (rdf-rdfa 3.2.2), I confirm it fixes this issue.
Hello @gkellogg,
While trying to update an RDF application of ours at Perfect-Memory, I stumbled upon the following exception triggered by the rdf-rdfa gem. We are using haml 5.2.2 (because of another problem about missing "haml_tag" when using haml >= 6).
Forcing rdf-rdfa to version 3.2.0 instead of 3.2.1 fixes the problem.
I believe this is due to recent code https://github.com/ruby-rdf/rdf-rdfa/blame/dda33651cf52c25f62c82a39ea69e5f3453d1ddc/lib/rdf/rdfa/writer.rb#L766-L772 which is supposed to add compatibility with haml 5.x and 6.2.