Class: R10K::Module::SVN

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

Instance Attribute Summary collapse

Attributes inherited from Base

#basedir, #name

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, basedir, args) ⇒ SVN

Returns a new instance of SVN.



27
28
29
30
31
32
33
34
35
# File 'lib/r10k/module/svn.rb', line 27

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

  parse_options(args)

  @full_path = Pathname.new(File.join(@basedir, @name))
  @working_dir = R10K::SVN::WorkingDir.new(@full_path)
end

Instance Attribute Details

#expected_revisionObject (readonly) Also known as: expected_version

Returns the value of attribute expected_revision.



16
17
18
# File 'lib/r10k/module/svn.rb', line 16

def expected_revision
  @expected_revision
end

#full_pathObject (readonly)

Returns the value of attribute full_path.



25
26
27
# File 'lib/r10k/module/svn.rb', line 25

def full_path
  @full_path
end

#svn_pathObject (readonly)

Returns the value of attribute svn_path.



21
22
23
# File 'lib/r10k/module/svn.rb', line 21

def svn_path
  @svn_path
end

Class Method Details

.implement?(name, args) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/r10k/module/svn.rb', line 10

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

Instance Method Details

#exist?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/r10k/module/svn.rb', line 62

def exist?
  @full_path.exist?
end

#statusObject



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/r10k/module/svn.rb', line 37

def status
  if not self.exist?
    :absent
  elsif not @working_dir.is_svn?
    :mismatched
  elsif not @url == @working_dir.url
    :mismatched
  elsif not @expected_revision == @working_dir.revision
    :outdated
  else
    :insync
  end
end

#syncObject



51
52
53
54
55
56
57
58
59
60
# File 'lib/r10k/module/svn.rb', line 51

def sync
  case status
  when :absent
    install
  when :mismatched
    reinstall
  when :outdated
    update
  end
end