mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-10 08:08:00 -05:00
A more user friendly way of checking the existence of Haml.
Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
@@ -16,7 +16,7 @@ class DeviseViewsGenerator < Rails::Generators::Base
|
||||
when "erb"
|
||||
directory "devise", "app/views/devise/#{scope}"
|
||||
when "haml"
|
||||
require 'haml'
|
||||
verify_haml_existence
|
||||
verify_haml_version
|
||||
create_and_copy_haml_views
|
||||
end
|
||||
@@ -24,6 +24,20 @@ class DeviseViewsGenerator < Rails::Generators::Base
|
||||
|
||||
protected
|
||||
|
||||
def verify_haml_existence
|
||||
unless Module.const_defined? "Haml"
|
||||
say "HAML is not installed, or it is not specified in your Gemfile."
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
def verify_haml_version
|
||||
unless Haml.version[:major] >= 2 and Haml.version[:minor] >= 3
|
||||
say "To generate HAML templates, you need to install HAML 2.3 or above."
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
def create_and_copy_haml_views
|
||||
devise_html_source_root = "#{DeviseViewsGenerator.source_root}/devise"
|
||||
devise_haml_source_root = "#{DeviseViewsGenerator.source_root}/devise-haml"
|
||||
@@ -41,11 +55,4 @@ class DeviseViewsGenerator < Rails::Generators::Base
|
||||
|
||||
directory devise_haml_source_root, "app/views/devise/#{scope}"
|
||||
end
|
||||
|
||||
def verify_haml_version
|
||||
unless Haml.version[:major] >= 2 and Haml.version[:minor] >= 3
|
||||
say "To generate HAML templates, you need to install HAML 2.3 or above."
|
||||
exit
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user