Sha256: 77e103a5b806182677d940ede43e83096b6f0d331c170b29dd576eda660855f8

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

module Miniploy
  class Deploy
    include Miniploy::DSL

    def initialize(filepath = 'config/miniploy.rb')
      instance_eval File.read(filepath) + <<-eoh
        local_variables.each do |v|
          self.send "\#{v}=", eval(v.to_s) rescue nil
        end
      eoh
    end

    def setup
      run "git clone --depth 1 #{repository} #{app_path}"
      run "mkdir -p #{app_path}/tmp/run"
      setup_bundler
      rake 'db:create'
      rake 'db:migrate'
      after_setup
    end

    def setup_bundler
      return unless use_bundler?
      bundle_add.each do |gem|
        append "#{app_path}/Gemfile", "gem 'unicorn'"
      end
      run <<-eoh.gsub(/\A +/, '').chomp
        bundle install --without development test \\
          --gemfile #{app_path}/Gemfile --path $HOME/.bundle
      eoh
    end

    def ssh(cmd)
      system('ssh', ssh_args, target, cmd)
    end

    def update
      run "cd #{app_path} && git fetch origin && git reset --hard origin"
      setup_bundler
      rake 'db:migrate'
      after_update
    end

    def use_bundler?
      ssh "test -f #{app_path}/Gemfile"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
miniploy-0.0.2 lib/miniploy/deploy.rb
miniploy-0.0.1 lib/miniploy/deploy.rb