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:
parent
cbd35a846a
commit
b8091928a0
1 changed files with 15 additions and 8 deletions
|
@ -16,7 +16,7 @@ class DeviseViewsGenerator < Rails::Generators::Base
|
||||||
when "erb"
|
when "erb"
|
||||||
directory "devise", "app/views/devise/#{scope}"
|
directory "devise", "app/views/devise/#{scope}"
|
||||||
when "haml"
|
when "haml"
|
||||||
require 'haml'
|
verify_haml_existence
|
||||||
verify_haml_version
|
verify_haml_version
|
||||||
create_and_copy_haml_views
|
create_and_copy_haml_views
|
||||||
end
|
end
|
||||||
|
@ -24,6 +24,20 @@ class DeviseViewsGenerator < Rails::Generators::Base
|
||||||
|
|
||||||
protected
|
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
|
def create_and_copy_haml_views
|
||||||
devise_html_source_root = "#{DeviseViewsGenerator.source_root}/devise"
|
devise_html_source_root = "#{DeviseViewsGenerator.source_root}/devise"
|
||||||
devise_haml_source_root = "#{DeviseViewsGenerator.source_root}/devise-haml"
|
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}"
|
directory devise_haml_source_root, "app/views/devise/#{scope}"
|
||||||
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
|
|
||||||
end
|
end
|
Loading…
Reference in a new issue