Class: R10K::Module::Git

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

Instance Attribute Summary collapse

Attributes inherited from Base

#dirname, #name, #owner, #path, #title

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#accept, #full_path

Constructor Details

#initialize(title, dirname, args, environment = nil) ⇒ Git

Returns a new instance of Git.



26
27
28
29
30
31
32
# File 'lib/r10k/module/git.rb', line 26

def initialize(title, dirname, args, environment=nil)
  super

  parse_options(@args)

  @repo = R10K::Git::StatefulRepository.new(@remote, @dirname, @name)
end

Instance Attribute Details

#desired_refObject (readonly)

Returns the value of attribute desired_ref.



24
25
26
# File 'lib/r10k/module/git.rb', line 24

def desired_ref
  @desired_ref
end

#repoObject (readonly)

Returns the value of attribute repo.



19
20
21
# File 'lib/r10k/module/git.rb', line 19

def repo
  @repo
end

Class Method Details

.implement?(name, args) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
# File 'lib/r10k/module/git.rb', line 10

def self.implement?(name, args)
  args.is_a? Hash and args.has_key?(:git)
rescue
  false
end

Instance Method Details

#propertiesObject



38
39
40
41
42
43
44
# File 'lib/r10k/module/git.rb', line 38

def properties
  {
    :expected => version,
    :actual   => (@repo.head || "(unresolvable)"),
    :type     => :git,
  }
end

#statusObject



51
52
53
# File 'lib/r10k/module/git.rb', line 51

def status
  @repo.status(version)
end

#sync(opts = {}) ⇒ Object



46
47
48
49
# File 'lib/r10k/module/git.rb', line 46

def sync(opts={})
  force = opts && opts.fetch(:force, true)
  @repo.sync(version, force)
end

#versionObject



34
35
36
# File 'lib/r10k/module/git.rb', line 34

def version
  validate_ref(@desired_ref, @default_ref)
end