lib/leftovers/haml.rb in leftovers-0.2.3 vs lib/leftovers/haml.rb in leftovers-0.3.0
- old
+ new
@@ -2,22 +2,19 @@
module Leftovers
module Haml
module_function
- def precompile(file) # rubocop:disable Metrics/MethodLength
- Leftovers.try_require('haml', message: <<~MESSAGE)
- Skipped parsing a haml file, because the haml gem was not available
- `gem install Haml`
+ def precompile(file, name) # rubocop:disable Metrics/MethodLength
+ return '' unless Leftovers.try_require('haml', message: <<~MESSAGE) # rubocop:disable Layout/EmptyLineAfterGuardClause
+ Skipped parsing #{name.relative_path}, because the haml gem was not available
+ `gem install haml`
MESSAGE
- if defined?(::Haml)
- begin
- ::Haml::Engine.new(file).precompiled
- rescue ::Haml::SyntaxError => e
- Leftovers.warn "#{e.class}: #{e.message} #{filename}:#{e.line}"
- ''
- end
- else
+
+ begin
+ ::Haml::Engine.new(file).precompiled
+ rescue ::Haml::SyntaxError => e
+ Leftovers.warn "#{e.class}: #{e.message} #{name.relative_path}:#{e.line}"
''
end
end
end
end