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.



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

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.



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.



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

def full_path
  @full_path
end

#passwordObject (readonly)

Returns the value of attribute password.



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

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



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

def username
  @username
end

#working_dirObject (readonly)

Returns the value of attribute working_dir.



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

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


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

def exist?
  path.exist?
end

#propertiesObject



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

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

#statusObject



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

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



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

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