Class: DeployDocus::Deployer

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/deploy_docus/deployer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, ssh_key, deploy_task) ⇒ Deployer

Manages cloning and deploying the repository This class is agnostic of any web interface and can be used as a library

DeployDocus::Deployer(“[email protected]:evome/evome.git”, “~/.ssh/evome_key”, “cap staging deploy”)

It will clone the repository in a random directory located in /tmp. And execute the deploy_task on it.



24
25
26
27
# File 'lib/deploy_docus/deployer.rb', line 24

def initialize(repository, ssh_key, deploy_task)
  ssh_key = File.expand_path(ssh_key) if ssh_key
  @repository, @ssh_key, @deploy_task = repository, ssh_key, deploy_task
end

Instance Attribute Details

#deploy_taskObject (readonly)

Returns the value of attribute deploy_task.



8
9
10
# File 'lib/deploy_docus/deployer.rb', line 8

def deploy_task
  @deploy_task
end

#repositoryObject (readonly)

Returns the value of attribute repository.



8
9
10
# File 'lib/deploy_docus/deployer.rb', line 8

def repository
  @repository
end

#ssh_keyObject (readonly)

Returns the value of attribute ssh_key.



8
9
10
# File 'lib/deploy_docus/deployer.rb', line 8

def ssh_key
  @ssh_key
end

#wrapperObject

Returns the value of attribute wrapper.



9
10
11
# File 'lib/deploy_docus/deployer.rb', line 9

def wrapper
  @wrapper
end

Instance Method Details

#deploy!Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/deploy_docus/deployer.rb', line 29

def deploy!
  if self.valid?
    GitSSHWrapper.with_wrapper(:private_key_path => ssh_key) do |w|
      @wrapper = w

      clone && run_deploy
    end
  else
    false
  end
end