class Dolphin::Setup

set up target servers

Public Instance Methods

app_dir() click to toggle source
# File lib/dolphin/setup.rb, line 29
def app_dir
  menu = [
    "
      sudo mkdir -p #{@app_dir}
      sudo chown #{@user}:#{@user_group} #{@app_dir}
    ",
  ]

  execute menu
end
chruby(version=:master) click to toggle source
# File lib/dolphin/setup.rb, line 5
def chruby(version=:master)
  menu = [
    "
      # git clone
      if [ ! -d 'chruby' ]; then git clone https://github.com/postmodern/chruby.git ; fi
      cd chruby
      # update
      git fetch
      git checkout master
      git rebase origin/master
      # checkout tag
      git checkout #{version}
      # install
      sudo make install
      # system wise
      # sudo echo '[ -n \"$BASH_VERSION\" ] || [ -n \"$ZSH_VERSION\" ] || return' | sudo tee /etc/profile.d/chruby.sh
      # sudo echo 'source /usr/local/share/chruby/chruby.sh' | sudo tee -a /etc/profile.d/chruby.sh
    ",
  ]

  execute menu
end
gems(ruby="ruby-2.3.0") click to toggle source
# File lib/dolphin/setup.rb, line 129
def gems(ruby="ruby-2.3.0")
  menu = [
    %{
      cd #{@app_dir}
      # switch to the target ruby
      chruby #{ruby}
      # first gem-ctags so latter gems can be tagged
      gem install gem-ctags
      # handle gems
      gem install bundler specific_install
      # debugging tools
      gem install letters did_you_mean
      # pry
      gem install pry pry-rescue pry-stack_explorer hirb
      # CLI / deploy
      gem install dolphin boson
      # dir / file tools
      gem install fled markdown2confluence
      # shell tool
      gem install ru
      # github tool
      gem install github
    },
  ]

  execute menu
end
newrelic() click to toggle source
# File lib/dolphin/setup.rb, line 158
def newrelic
  menu = [
    "
      # install bundler
      sudo rpm -Uvh http://download.newrelic.com/pub/newrelic/el5/i386/newrelic-repo-5-3.noarch.rpm
      sudo yum -y install newrelic-sysmond
      sudo nrsysmond-config --set license_key=c55d35d552a49f06d5183c95d41de60cd9754237
    ",
  ]

  execute menu
end
repo() click to toggle source
# File lib/dolphin/setup.rb, line 62
def repo
  # branch 'master' is always created by git
  if @branch == 'master'
    cmd = "git checkout master"
  else
    cmd = "git checkout -b #{@branch} origin/#{@branch}"
  end

  menu = [
    "
      # init git repository
      cd #{@app_dir}
      git clone #{@github}
    ",
    "
      # set up tracking branch
      cd #{@deploy_dir}
      #{cmd}
    ",
  ]

  execute menu
end
rmrb(version, brand='ruby') click to toggle source
# File lib/dolphin/setup.rb, line 100
def rmrb(version, brand='ruby')
  menu = [
    "
      # uninstall ruby
      sudo rm -rf /opt/rubies/#{brand}-#{version}
      rm -rf ~/.rubies/#{brand}-#{version}
      # uninstall gems
      rm -rf ~/.gem/#{brand}/#{version}
    ",
  ]

  execute menu
end
ruby(version="ruby") click to toggle source
# File lib/dolphin/setup.rb, line 87
def ruby(version="ruby")
  menu = [
    "
      # install ruby
      # sudo /usr/local/bin/ruby-install #{version}
      /usr/local/bin/ruby-install #{version}
    ",
  ]

  execute menu
end
ruby_install(version=:master) click to toggle source
# File lib/dolphin/setup.rb, line 41
def ruby_install(version=:master)
  menu = [
    "
      # git clone
      if [ ! -d 'ruby-install' ]; then git clone https://github.com/postmodern/ruby-install.git ; fi
      cd ruby-install
      # update
      git fetch
      git checkout master
      git rebase origin/master
      # checkout tag
      git checkout #{version}
      # install
      sudo make install
    ",
  ]

  execute menu
end
select(dir=nil, version="ruby-2.3.0") click to toggle source
# File lib/dolphin/setup.rb, line 115
def select(dir=nil, version="ruby-2.3.0")
  dir ||= @app_dir
  menu = [
    "
      # select ruby
      cd #{dir}
      echo #{version} > .ruby-version
    ",
  ]

  execute menu
end