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.



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

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.



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

def expected_revision
  @expected_revision
end

#full_pathObject (readonly)

Returns the value of attribute full_path.



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

def full_path
  @full_path
end

#svn_pathObject (readonly)

Returns the value of attribute svn_path.



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

def svn_path
  @svn_path
end

Class Method Details

.implement?(name, args) ⇒ Boolean

Returns:

  • (Boolean)


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

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

Instance Method Details

#exist?Boolean

Returns:

  • (Boolean)


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

def exist?
  @full_path.exist?
end

#statusObject



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

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



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

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