Class: PoolParty::Plugin::GitRepo

Inherits:
PoolParty::Plugin show all
Defined in:
lib/poolparty/plugins/git.rb

Instance Method Summary collapse

Methods included from PoolParty::Plugin

available

Instance Method Details

#creates_dirObject



76
77
78
# File 'lib/poolparty/plugins/git.rb', line 76

def creates_dir
  "#{::File.join( dir, ::File.basename(name, ::File.extname(name)) )}/.git"
end

#has_git_repositoryObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/poolparty/plugins/git.rb', line 39

def has_git_repository
  has_directory(::File.dirname(dir))
  has_directory(:name => "#{dir}", :requires => get_directory("#{::File.dirname(dir)}"))
  
  has_exec(:name => "git-#{name}", :creates => creates_dir ) do
    # Cloud, GitRepos, Exec
    if requires_user
      command("git clone #{requires_user}@#{repository} #{dir}")
    else
      command("cd #{dir} && git clone #{repository}")
    end
    
    cwd "#{dir if dir}"          
    requires [get_directory("#{dir}"), get_package("git-core")]
  end
  has_exec(:name => "update-#{name}") do
    command "cd #{::File.dirname( creates_dir )} && git pull"
  end
  
  if owner
    has_exec(:name => "chown-#{name}", :cwd => ::File.dirname( creates_dir )) do            
      command "chown #{owner} * -R"
    end
  end
  
  if deploy_key
    raise Exception.new("Cannot find the git deploy key: #{deploy_key}") unless ::File.file?(::File.expand_path(deploy_key))
    ::Suitcase::Zipper.add(::File.expand_path(deploy_key), "keys")
    PoolParty::Provision::DrConfigure.class_commands << "cp -f /var/poolparty/dr_configure/keys/* ~/.ssh"
  end
  
end

#loaded(opts = {}, &block) ⇒ Object



27
28
29
30
31
32
# File 'lib/poolparty/plugins/git.rb', line 27

def loaded(opts={}, &block)
  raise DirectoryMissingError.new unless dir
  
  has_package("git-core")
  has_git_repository
end

#repository(n = nil) ⇒ Object



80
81
82
83
84
85
86
# File 'lib/poolparty/plugins/git.rb', line 80

def repository(n=nil)
  if n
    self.repo = n
  else
    self.repo ? self.repo : name
  end
end

#source(n = nil) ⇒ Object

retrieve/set source. If source is not set, try and use name.



35
36
37
# File 'lib/poolparty/plugins/git.rb', line 35

def source(n=nil)
  n.nil? ? (dsl_options[:source] ? dsl_options[:source] : dsl_options[:source]= name) : dsl_options[:source]=n
end

#to(d) ⇒ Object



72
73
74
# File 'lib/poolparty/plugins/git.rb', line 72

def to(d)
  dir d
end