Skip to content

Commit

Permalink
Tidying up of spree_cmd/installer.rb code
Browse files Browse the repository at this point in the history
Closes spree#1579
  • Loading branch information
parndt authored and radar committed May 22, 2012
1 parent a6deb62 commit 63e836a
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions cmd/lib/spree_cmd/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 63e836a

Please sign in to comment.