forked from spree/spree
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tidying up of spree_cmd/installer.rb code
Closes spree#1579
- Loading branch information
Showing
1 changed file
with
8 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,14 +30,14 @@ class Installer < Thor::Group | |
def verify_rails | ||
unless rails_project? | ||
say "#{@app_path} is not a rails project." | ||
exit(1) | ||
exit 1 | ||
end | ||
end | ||
|
||
def verify_image_magick | ||
unless image_magick_installed? | ||
say "Image magick must be installed." | ||
exit(1) | ||
exit 1 | ||
end | ||
end | ||
|
||
|
@@ -80,7 +80,7 @@ def ask_questions | |
@admin_email = ask_string('Admin Email', '[email protected]', /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i) | ||
@admin_password = ask_string('Admin Password', 'spree123', /^\S{5,32}$/) | ||
end | ||
@precompile_assets = options[:precompile_assets] ? ask_with_default('Would you like to precompile assets?') : false | ||
@precompile_assets = options[:precompile_assets] && ask_with_default('Would you like to precompile assets?') | ||
end | ||
|
||
def add_gems | ||
|
@@ -148,7 +148,7 @@ def ask_string(message, default, valid_regex = /\w/) | |
until valid | ||
response = ask "#{message} [#{default}]" | ||
response = default if response.empty? | ||
valid = (response =~ valid_regex) | ||
valid = (valid_regex === response) | ||
end | ||
response | ||
end | ||
|
@@ -157,27 +157,23 @@ def create_rails_app | |
say :create, @app_path | ||
|
||
rails_cmd = "rails new #{@app_path} --skip-bundle" | ||
if options[:template] | ||
rails_cmd += " -m #{options[:template]}" | ||
end | ||
if options[:database] | ||
rails_cmd += " -d #{options[:database]}" | ||
end | ||
rails_cmd << " -m #{options[:template]}" if options[:template] | ||
rails_cmd << " -d #{options[:database]}" if options[:database] | ||
run(rails_cmd) | ||
end | ||
|
||
def rails_project? | ||
File.exists? File.join(@app_path, 'script', 'rails') | ||
end | ||
|
||
def linux? | ||
/linux/i === RbConfig::CONFIG['host_os'] | ||
end | ||
|
||
def mac? | ||
/darwin/i === RbConfig::CONFIG['host_os'] | ||
end | ||
|
||
def windows? | ||
%r{msdos|mswin|djgpp|mingw} === RbConfig::CONFIG['host_os'] | ||
end | ||
|