Class: R10K::Module::SVN

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

Constant Summary collapse

INITIALIZE_OPTS =
{
  :svn => :url,
  :rev => :expected_revision,
  :revision => :expected_revision,
  :username => :self,
  :password => :self
}

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, #version

Constructor Details

#initialize(name, dirname, opts) ⇒ SVN

Returns a new instance of SVN.



48
49
50
51
52
# File 'lib/r10k/module/svn.rb', line 48

def initialize(name, dirname, opts)
  super
  setopts(opts, INITIALIZE_OPTS)
  @working_dir = R10K::SVN::WorkingDir.new(@path, :username => @username, :password => @password)
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.



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

def full_path
  @full_path
end

#passwordObject (readonly)

Returns the value of attribute password.



31
32
33
# File 'lib/r10k/module/svn.rb', line 31

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



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

def username
  @username
end

#working_dirObject (readonly)

Returns the value of attribute working_dir.



36
37
38
# File 'lib/r10k/module/svn.rb', line 36

def working_dir
  @working_dir
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)


79
80
81
# File 'lib/r10k/module/svn.rb', line 79

def exist?
  path.exist?
end

#propertiesObject



83
84
85
86
87
88
89
# File 'lib/r10k/module/svn.rb', line 83

def properties
  {
    :expected => expected_revision,
    :actual   => (@working_dir.revision rescue "(unresolvable)"),
    :type     => :svn,
  }
end

#statusObject



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/r10k/module/svn.rb', line 54

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



68
69
70
71
72
73
74
75
76
77
# File 'lib/r10k/module/svn.rb', line 68

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