init commit
This commit is contained in:
parent
93efff9452
commit
9ba1224867
307 changed files with 11053 additions and 0 deletions
51
install/prepare.rb
Normal file
51
install/prepare.rb
Normal file
|
@ -0,0 +1,51 @@
|
|||
module Install
|
||||
class << self
|
||||
def prepare(env)
|
||||
puts green " == Starting for ENV=#{env} ..."
|
||||
puts "rvm detected" if is_rvm?
|
||||
|
||||
bundler
|
||||
db(env)
|
||||
|
||||
puts green " == Done! Now you can start server"
|
||||
end
|
||||
|
||||
def bundler
|
||||
command 'gem install bundler'
|
||||
command 'bundle install'
|
||||
end
|
||||
|
||||
def db(env)
|
||||
command "bundle exec rake db:setup RAILS_ENV=#{env}"
|
||||
command "bundle exec rake db:seed_fu RAILS_ENV=#{env}"
|
||||
end
|
||||
|
||||
def is_rvm?
|
||||
`type rvm | head -1` =~ /^rvm is/
|
||||
end
|
||||
|
||||
def colorize(text, color_code)
|
||||
"\033[#{color_code}#{text}\033[0m"
|
||||
end
|
||||
|
||||
def red(text)
|
||||
colorize(text, "31m")
|
||||
end
|
||||
|
||||
def green(text)
|
||||
colorize(text, "32m")
|
||||
end
|
||||
|
||||
def command(string)
|
||||
`#{string}`
|
||||
if $?.to_i > 0
|
||||
puts red " == #{string} - FAIL"
|
||||
puts red " == Error during configure"
|
||||
exit
|
||||
else
|
||||
puts green " == #{string} - OK"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue