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

Add haml 6 support #10

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,15 @@ end
appraise 'haml-5.2' do
gem 'haml', '>= 5.2', '< 5.3'
end

appraise 'haml-6.0' do
gem 'haml', '>= 6.0', '< 6.1'
end

appraise 'haml-6.1' do
gem 'haml', '>= 6.1', '< 6.2'
end

appraise 'haml-6.2' do
gem 'haml', '>= 6.2', '< 6.3'
end
15 changes: 11 additions & 4 deletions lib/rails-route-checker/parsers/haml_parser/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@ def initialize(source)
@source_lines = @source.split(/\r\n|\r|\n/)

version = Gem::Version.new(Haml::VERSION).approximate_recommendation
options = Haml::Options.new

original_tree = case version
when '~> 4.0', '~> 4.1' then Haml::Parser.new(@source, options).parse
when '~> 5.0', '~> 5.1', '~> 5.2' then Haml::Parser.new(options).call(@source)
else raise "Cannot handle Haml version: #{version}"
when '~> 4.0', '~> 4.1'
options = Haml::Options.new
Haml::Parser.new(@source, options).parse
when '~> 5.0', '~> 5.1', '~> 5.2'
options = Haml::Options.new
Haml::Parser.new(options).call(@source)
when '~> 6.0', '~> 6.1', '~> 6.2'
Haml::Parser.new({}).call(@source)
else
raise "Cannot handle Haml version: #{version}"
end

@tree = process_tree(original_tree)
Expand Down