Class: R10K::Module::Git

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

Instance Attribute Summary collapse

Attributes inherited from Base

#basedir, #name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#full_path

Constructor Details

#initialize(name, basedir, args) ⇒ Git

Returns a new instance of Git.



19
20
21
22
23
24
25
26
27
# File 'lib/r10k/module/git.rb', line 19

def initialize(name, basedir, args)
  @name, @basedir, @args = name, basedir, args

  parse_options(args)

  @full_path = Pathname.new(File.join(basedir, name))

  @working_dir = R10K::Git::WorkingDir.new(@ref, @remote, @basedir, @name)
end

Instance Attribute Details

#working_dirObject (readonly)

Returns the value of attribute working_dir.



17
18
19
# File 'lib/r10k/module/git.rb', line 17

def working_dir
  @working_dir
end

Class Method Details

.implement?(name, args) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
# File 'lib/r10k/module/git.rb', line 8

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

Instance Method Details

#statusObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/r10k/module/git.rb', line 45

def status
  if not @working_dir.exist?
    return :absent
  elsif not @working_dir.git?
    return :mismatched
  elsif not @remote == @working_dir.remote
    return :mismatched
  end

  if @working_dir.outdated?
    return :outdated
  end

  return :insync
end

#syncObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/r10k/module/git.rb', line 33

def sync
  case status
  when :absent
    install
  when :mismatched
    uninstall
    install
  when :outdated
    @working_dir.sync
  end
end

#versionObject



29
30
31
# File 'lib/r10k/module/git.rb', line 29

def version
  @ref
end