Commit 8a8e77d54f558e5f8edf9cbe9076b5189323abf5

Authored by gitlabhq
1 parent d03f2687

update.rb

Showing 2 changed files with 27 additions and 5 deletions   Show diff stats
lib/color.rb
... ... @@ -11,6 +11,10 @@ module Color
11 11 colorize(text, "32m")
12 12 end
13 13  
  14 + def yellow(text)
  15 + colorize(text, "93m")
  16 + end
  17 +
14 18 def command(string)
15 19 `#{string}`
16 20 if $?.to_i > 0
... ...
update.rb
... ... @@ -2,6 +2,10 @@ root_path = File.expand_path(File.dirname(__FILE__))
2 2 require File.join(root_path, "lib", "color")
3 3 include Color
4 4  
  5 +def version
  6 + File.read("VERSION")
  7 +end
  8 +
5 9 #
6 10 # ruby ./update.rb development # or test or production (default)
7 11 #
... ... @@ -12,15 +16,29 @@ env = if envs.include?(ARGV[0])
12 16 "production"
13 17 end
14 18  
15   -puts green " == Update for ENV=#{env}"
  19 +puts yellow "== RAILS ENV | #{env}"
  20 +current_version = version
  21 +puts yellow "Your version is #{current_version}"
  22 +puts yellow "Check for new version: $ git pull origin"
  23 +`git pull origin` # pull from origin
16 24  
17   -# pull from github
18   -`git pull`
  25 +# latest version
  26 +if version == current_version
  27 + puts yellow "You have a latest version"
  28 +else
  29 + puts green "Update to #{version}"
19 30  
20 31 `bundle install`
21 32  
22   -# migrate db
  33 + # migrate db
  34 +if env == "development"
  35 +`bundle exec rake db:migrate RAILS_ENV=development`
  36 +`bundle exec rake db:migrate RAILS_ENV=test`
  37 +else
23 38 `bundle exec rake db:migrate RAILS_ENV=#{env}`
  39 +end
  40 +
  41 + puts green "== Done! Now you can start/restart server"
  42 +end
24 43  
25 44  
26   -puts green " == Done! Now you can start/restart server"
... ...