class HamlLint::Adapter

Determines the adapter to use for the current Haml version

Public Class Methods

detect_class() click to toggle source

Detects the adapter to use for the current Haml version

@example

HamlLint::Adapter.detect_class.new('%div')

@api public @return [Class] the adapter class @raise [HamlLint::Exceptions::UnknownHamlVersion]

# File lib/haml_lint/adapter.rb, line 18
def self.detect_class
  version = haml_version
  case version
  when '~> 4.0' then HamlLint::Adapter::Haml4
  when '~> 5.0', '~> 5.1', '~> 5.2' then HamlLint::Adapter::Haml5
  else fail HamlLint::Exceptions::UnknownHamlVersion, "Cannot handle Haml version: #{version}"
  end
end

Private Class Methods

haml_version() click to toggle source

Determines the approximate version of Haml that is installed

@api private @return [String] the approximate Haml version

# File lib/haml_lint/adapter.rb, line 31
def self.haml_version
  Gem::Version
    .new(Haml::VERSION)
    .approximate_recommendation
end