1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -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:
Fred Wu 2010-03-14 02:21:38 +11:00 committed by José Valim
parent cbd35a846a
commit b8091928a0

View file

@ -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