Class: R10K::Module::SVN

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

Constant Summary

Constants included from Logging

Logging::LOG_LEVELS

Instance Attribute Summary collapse

Attributes inherited from Base

#dirname, #environment, #name, #origin, #owner, #path, #spec_deletable, #title

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

debug_formatter, default_formatter, default_outputter, #logger, #logger_name, parse_level

Methods inherited from Base

#accept, #cachedir, #delete_spec_dir, #maybe_delete_spec_dir, #should_sync?, #version

Constructor Details

#initialize(name, dirname, opts, environment = nil) ⇒ SVN

Returns a new instance of SVN.



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

def initialize(name, dirname, opts, environment=nil)
  super
  setopts(opts, {
    # Standard option interface
    :source   => :url,
    :version  => :expected_revision,
    :type     => ::R10K::Util::Setopts::Ignore,

    # Type-specific options
    :svn      => :url,
    :rev      => :expected_revision,
    :revision => :expected_revision,
    :username => :self,
    :password => :self
  }, :raise_on_unhandled => false)

  @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.



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

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

#passwordObject (readonly)

Returns the value of attribute password.



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

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



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

def username
  @username
end

#working_dirObject (readonly)

Returns the value of attribute working_dir.



39
40
41
# File 'lib/r10k/module/svn.rb', line 39

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.has_key?(:svn) || args[:type].to_s == 'svn'
end

.statically_defined_version(name, args) ⇒ Object



13
14
15
# File 'lib/r10k/module/svn.rb', line 13

def self.statically_defined_version(name, args)
  nil
end

Instance Method Details

#exist?Boolean

Returns:

  • (Boolean)


97
98
99
# File 'lib/r10k/module/svn.rb', line 97

def exist?
  path.exist?
end

#propertiesObject



101
102
103
104
105
106
107
# File 'lib/r10k/module/svn.rb', line 101

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

#statusObject



62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/r10k/module/svn.rb', line 62

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

#sync(opts = {}) ⇒ Boolean

Returns true if the module was updated, false otherwise.

Parameters:

  • opts (Hash) (defaults to: {})

    Deprecated

Returns:

  • (Boolean)

    true if the module was updated, false otherwise



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/r10k/module/svn.rb', line 78

def sync(opts={})
  updated = false
  if should_sync?
    case status
    when :absent
      install
      updated = true
    when :mismatched
      reinstall
      updated = true
    when :outdated
      update
      updated = true
    end
    maybe_delete_spec_dir
  end
  updated
end