Sha256: 6ad8301e3f9df9e535fb180a01847afdc02c6e197d14205694b6c67121334b93

Contents?: true

Size: 927 Bytes

Versions: 2

Compression:

Stored size: 927 Bytes

Contents

module Miniploy
  module DSL
    attr_accessor :app, :repository, :target, :ssh_args, :bundle_add

    def app_path
      "apps/#{app}"
    end

    def append(filepath, content)
      run "echo \"#{content}\" >> #{filepath}"
    end

    def bundle_run(cmd)
      run "cd #{app_path} && RACK_ENV=production bundle exec #{cmd}"
    end

    def rake(task)
      bundle_run "rake #{task}"
    end

    def run(cmd)
      puts ">> `#{cmd}`"
      raise RuntimeError unless ssh(cmd)
    end

    def run_path
      "#{app_path}/tmp/run"
    end

    def self.hook(*methods)
      methods.each do |method|
        eval <<-eoh
          def #{method}(&block)
            @hooks ||= {}
            if block_given?
              @hooks[:#{method}] = block
            else
              @hooks[:#{method}].call
            end
          end
        eoh
      end
    end

    hook :after_setup, :start, :stop, :after_update
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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