judofyr/temple

Miss-behavior using haml 5.0.4 and clockwork 2.0.2

Closed this issue · 1 comments

After my upgrade to rails 5.1 I am seeing this warning

DEPRECATION WARNING: ActionView::Template::Handlers::Erubis is deprecated and will be removed from Rails 5.2. Switch to ActionView::Template::Handlers::ERB::Erubi instead. (called from <top (required)>

When i upgrade the haml gem the template handler changes and the deprecation warning with it but it brings temple gem and with it this runtime error:

RuntimeError:
       Unsupported callback newline
gems/clockwork-2.0.2/lib/clockwork/manager.rb:44:in `on'
gems/clockwork-2.0.2/lib/clockwork.rb:38:in `on'
gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:86:in `dispatcher'
gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:49:in `compile'
gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:7:in `block in on_multi'
gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:7:in `each'
gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:7:in `on_multi'
gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:82:in `dispatcher'
gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:49:in `compile'
gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:45:in `call'
gems/temple-0.8.0/lib/temple/engine.rb:50:in `block in call'
gems/temple-0.8.0/lib/temple/engine.rb:50:in `each'
gems/temple-0.8.0/lib/temple/engine.rb:50:in `inject'
gems/temple-0.8.0/lib/temple/engine.rb:50:in `call'
gems/haml-5.0.4/lib/haml/temple_engine.rb:41:in `compile'
gems/haml-5.0.4/lib/haml/engine.rb:61:in `initialize'

The callback method is also code. Here is the line that is throwing the error
https://github.com/Rykian/clockwork/blob/v2.0.2/lib/clockwork/manager.rb#L44

The issue was that the clock.rb files content was not 'namespaced':

include Clockwork
every(1.hour, ...
...

After moving it under the module the problem was solved:

module Clockwork
  every(1.hour, ...
end

I'm closing it 👍