Class: Resource::Git

Inherits:
Base
  • Object
show all
Defined in:
lib/resource/git.rb

Instance Method Summary collapse

Methods inherited from Base

inherited, #not_if, #set_base_defaults, #should_skip?, #unix_mode

Methods included from ClassAttr

included

Methods included from BlockAttr

included

Constructor Details

#initialize(repository, &block) ⇒ Git

Returns a new instance of Git.



9
10
11
12
13
14
15
16
17
18
# File 'lib/resource/git.rb', line 9

def initialize repository, &block
  set_base_defaults
  @repository      = repository
  @sandbox_path    = '/tmp'
  @sandbox_name    = 'repository_sandbox'
  @always_run      = true
  @timestamped     = true
  @swaping_branch  = 'master'
  self.instance_eval(&block)
end

Instance Method Details

#runObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/resource/git.rb', line 20

def run
  clone unless cloned?
  fetch_and_pull
  revision = revision(@branch)
  checkout revision
  key = @timestamped ? Time.now.strftime('%Y%m%d%H%M%S') : revision
  my_release_path = @release_path + key
  relocate my_release_path
  encapsulate_object revision, my_release_path, key
end