active_template.rb in active_leonardo-0.2.1 vs active_template.rb in active_leonardo-0.2.2
- old
+ new
@@ -12,13 +12,19 @@
puts '*' * 40
puts "* Processing template..."
puts '*' * 40
-use_git = yes?("Do you use git ?")
+test_mode = nil
+ARGV.each{|arg| test_mode = true if arg == "test_mode"}
+puts "**** Starting in test mode! ****" if test_mode
+
+use_git = test_mode || yes?("Do you use git ?")
+
if use_git
git :init
+ remove_file ".gitignore"
file ".gitignore", <<-EOS.gsub(/^ /, '')
# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
@@ -43,55 +49,42 @@
gem "activeadmin", git: 'http://github.com/gregbell/active_admin.git'
gem "active_leonardo"
gem "jquery-turbolinks"
gem "bourbon"
-easy_develop = yes?("Do you want to make development easier?")
+easy_develop = test_mode || yes?("Do you want to make development easier?")
if easy_develop
gem "rack-mini-profiler", :group => :development
- gem "better_errors", :group => :development
- gem "awesome_print", :group => :development
+ gem "better_errors", :group => :development
+ gem "awesome_print", :group => :development
end
#use_editor = yes?("Do you want a wysihtml editor?")
#if use_editor
-# gem 'activeadmin-dragonfly', git: 'http://192.30.252.131/stefanoverna/activeadmin-dragonfly'
-# gem 'activeadmin-wysihtml5', git: 'http://192.30.252.131/stefanoverna/activeadmin-wysihtml5'
-#end
-
-easy_develop = yes?("Do you want to make development easier?")
-if easy_develop
- gem "rack-mini-profiler"
- gem "jquery-turbolinks"
- gem "awesome_print"
-end
-
-#use_editor = yes?("Do you want a wysihtml editor?")
-#if use_editor
# gem 'activeadmin-dragonfly', git: 'https://github.com/stefanoverna/activeadmin-dragonfly'
# gem 'activeadmin-wysihtml5', git: 'https://github.com/stefanoverna/activeadmin-wysihtml5'
#end
-rspec = yes?("Add rspec as testing framework ?")
+rspec = test_mode || yes?("Add rspec as testing framework ?")
if rspec
- gem 'rspec-rails', :group => [:test, :development]
- gem 'capybara', :group => :test
- gem 'launchy', :group => :test
- gem 'database_cleaner', :group => :test
+ gem 'rspec-rails', :group => [:test, :development]
+ gem 'capybara', :group => :test
+ gem 'launchy', :group => :test
+ gem 'database_cleaner', :group => :test
if /1.8.*/ === RUBY_VERSION
- gem 'factory_girl', '2.6.4', :group => :test
- gem 'factory_girl_rails', '1.7.0', :group => :test
+ gem 'factory_girl', '2.6.4', :group => :test
+ gem 'factory_girl_rails', '1.7.0', :group => :test
else
- gem 'factory_girl_rails', :group => :test
+ gem 'factory_girl_rails', :group => :test
end
end
-authentication = yes?("Authentication ?")
+authentication = test_mode || yes?("Authentication ?")
model_name = authorization = nil
if authentication
default_model_name = "User"
- model_name = ask(" Insert model name: [#{default_model_name}]")
+ model_name = test_mode ? "" : ask(" Insert model name: [#{default_model_name}]")
if model_name.empty? || model_name == 'y'
model_name = default_model_name
else
model_name = model_name.classify
stdout = <<-REMEM.gsub(/^ /, '')
@@ -102,23 +95,23 @@
*************************************************************************
REMEM
p stdout
end
-authorization = yes?("Authorization ?")
+ authorization = test_mode || yes?("Authorization ?")
if authorization
gem "cancan"
end
end
-gem 'state_machine' if yes?("Do you have to handle states ?")
+gem 'state_machine' if test_mode || yes?("Do you have to handle states ?")
-dashboard_root = yes?("Would you use dashboard as root ? (recommended)")
-home = yes?("Ok. Would you create home controller as root ?") unless dashboard_root
+dashboard_root = test_mode || yes?("Would you use dashboard as root ? (recommended)")
+home = test_mode || yes?("Ok. Would you create home controller as root ?") unless dashboard_root
-if yes?("Bundle install ?")
- dir = ask(" Insert folder name to install locally: [blank=default gems path]")
+if test_mode || yes?("Bundle install ?")
+ dir = test_mode ? "" : ask(" Insert folder name to install locally: [blank=default gems path]")
run "bundle install #{"--path=#{dir}" unless dir.empty? || dir=='y'}"
end
generate "rspec:install" if rspec
@@ -132,11 +125,12 @@
generate "leolay",
"active", #specify theme
"--auth_class=#{model_name}",
(rspec ? nil : "--skip-rspec"),
(authorization ? nil : "--skip-authorization"),
- (authentication ? nil : "--skip-authentication")
+ (authentication ? nil : "--skip-authentication"),
+ (test_mode ? "--no-verbose" : nil)
if dashboard_root
route "root :to => 'admin/dashboard#index'"
elsif home
@@ -152,6 +146,6 @@
if use_git
git :add => "."
git :commit => %Q{ -m "Initial commit" }
end
-puts "ENJOY!"
+puts "ENJOY!"
\ No newline at end of file