Sha256: 16653fdfea565a27b88d88fc4d0953623c971dca70f9cccf138ebf61f6372c7e

Contents?: true

Size: 882 Bytes

Versions: 7

Compression:

Stored size: 882 Bytes

Contents

module EY
  class Task

    attr_reader :config
    alias :c :config

    def initialize(conf)
      @config = conf
      @roles = :all
    end

    def require_custom_tasks
      deploy_file = ["config/eydeploy.rb", "eydeploy.rb"].detect do |file|
        File.exists?(File.join(c.repository_cache, file))
      end
      require File.join(c.repository_cache, deploy_file) if deploy_file
    end

    def roles(*task_roles)
      raise "Roles must be passed a block" unless block_given?

      begin
        @roles = task_roles
        yield
      ensure
        @roles = :all
      end
    end

    def run(cmd)
      EY::Server.from_roles(@roles).each do |server|
        server.run %|sh -c \\"#{cmd} 2>&1\\"|
      end
    end

    def sudo(cmd)
      EY::Server.from_roles(@roles).each do |server|
        server.run %|sudo sh -c \\"#{cmd} 2>&1\\"|
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ey-deploy-0.2.7 lib/ey-deploy/task.rb
ey-deploy-0.2.6 lib/ey-deploy/task.rb
ey-deploy-0.2.5 lib/ey-deploy/task.rb
ey-deploy-0.2.4 lib/ey-deploy/task.rb
ey-deploy-0.2.4.pre2 lib/ey-deploy/task.rb
ey-deploy-0.2.4.pre1 lib/ey-deploy/task.rb
ey-deploy-0.2.4.pre lib/ey-deploy/task.rb