class CitizenCodeScripts::Update

Public Class Methods

description() click to toggle source
# File lib/citizen_code_scripts/update.rb, line 10
def self.description
  "Updates your dev environment automatically"
end
help() click to toggle source
# File lib/citizen_code_scripts/update.rb, line 2
  def self.help
    <<-EOF
citizen update

This script is a way to update your development environment automatically.
EOF
  end

Public Instance Methods

run() click to toggle source
# File lib/citizen_code_scripts/update.rb, line 14
def run
  pull_git
  install_dependencies
  update_db
  remove_old_logs
  restart_rails
end

Private Instance Methods

install_dependencies() click to toggle source
# File lib/citizen_code_scripts/update.rb, line 30
def install_dependencies
  step "Installing dependencies" do
    system! 'gem install bundler --conservative'
    system('bundle check') || system!('bundle install')
  end
end
pull_git() click to toggle source
# File lib/citizen_code_scripts/update.rb, line 24
def pull_git
  step "Pulling from git" do
    system! "git pull --rebase"
  end
end
remove_old_logs() click to toggle source
# File lib/citizen_code_scripts/update.rb, line 43
def remove_old_logs
  step "Removing old logs and tempfiles" do
    system! 'rake log:clear tmp:clear'
  end
end
restart_rails() click to toggle source
# File lib/citizen_code_scripts/update.rb, line 49
def restart_rails
  step "Attempting to restart Rails" do
    output = `bin/rails restart`

    if $?.exitstatus > 0
      puts colorize(
        :light_red,
        "skipping restart, not supported in this version of Rails (needs >= 5)"
      )
    else
      puts output
    end
  end
end
update_db() click to toggle source
# File lib/citizen_code_scripts/update.rb, line 37
def update_db
  step "Updating database" do
    system! 'rake db:migrate'
  end
end