Class: R10K::SVN::WorkingDir Private

Inherits:
Object
  • Object
show all
Includes:
Logging, Util::Setopts
Defined in:
lib/r10k/svn/working_dir.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Manage an SVN working copy.

If SVN authentication is required, both username and password must be specified.

Since:

  • 1.2.0

Constant Summary

Constants included from Logging

Logging::LOG_LEVELS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

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

Constructor Details

#initialize(path, opts = {}) ⇒ WorkingDir

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of WorkingDir.

Parameters:

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

Options Hash (opts):

  • :username (String)
  • :password (String)

Since:

  • 1.2.0



37
38
39
40
41
42
43
44
45
# File 'lib/r10k/svn/working_dir.rb', line 37

def initialize(path, opts = {})
  @path = path

  setopts(opts, {:username => :self, :password => :self})

  if !!(@username) ^ !!(@password)
    raise ArgumentError, _("Both username and password must be specified")
  end
end

Instance Attribute Details

#passwordObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.2.0



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

def password
  @password
end

#pathObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.2.0



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

def path
  @path
end

#usernameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.2.0



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

def username
  @username
end

Instance Method Details

#checkout(url, revision = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.2.0



73
74
75
76
77
78
79
80
81
# File 'lib/r10k/svn/working_dir.rb', line 73

def checkout(url, revision = nil)
  argv = ['checkout', url]
  argv << '-r' << revision if revision
  argv << @path.basename.to_s
  argv.concat(auth)
  argv << '-q'

  svn(argv, :cwd => @path.parent)
end

#is_svn?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Is the directory at this path actually an SVN repository?

Returns:

  • (Boolean)

Since:

  • 1.2.0



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

def is_svn?
  dot_svn = @path + '.svn'
  dot_svn.exist?
end

#revisionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.2.0



53
54
55
# File 'lib/r10k/svn/working_dir.rb', line 53

def revision
  info.slice(/^Revision: (\d+)$/, 1)
end

#rootObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.2.0



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

def root
  info.slice(/^Repository Root: (.*)$/, 1)
end

#update(revision = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.2.0



65
66
67
68
69
70
71
# File 'lib/r10k/svn/working_dir.rb', line 65

def update(revision = nil)
  argv = %w[update]
  argv << '-r' << revision if revision
  argv.concat(auth)

  svn(argv, :cwd => @path)
end

#urlObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.2.0



57
58
59
# File 'lib/r10k/svn/working_dir.rb', line 57

def url
  info.slice(/^URL: (.*)$/, 1)
end