Class: Integrity::SCM::Subversion

Inherits:
Object
  • Object
show all
Defined in:
lib/integrity/scm/subversion.rb,
lib/integrity/scm/subversion/uri.rb

Defined Under Namespace

Classes: URI

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, branch, working_directory = nil) ⇒ Subversion

Returns a new instance of Subversion.



19
20
21
22
23
# File 'lib/integrity/scm/subversion.rb', line 19

def initialize(uri, branch, working_directory = nil)
  @uri = uri.to_s
  @branch = branch.to_s
  @working_directory = working_directory
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



6
7
8
# File 'lib/integrity/scm/subversion.rb', line 6

def branch
  @branch
end

#uriObject (readonly)

Returns the value of attribute uri.



6
7
8
# File 'lib/integrity/scm/subversion.rb', line 6

def uri
  @uri
end

#working_directoryObject (readonly)

Returns the value of attribute working_directory.



6
7
8
# File 'lib/integrity/scm/subversion.rb', line 6

def working_directory
  @working_directory
end

Class Method Details

.is_this_my_home?(location) ⇒ Boolean

check the uri and see if it is a subversion url There is a lot that can be a subversion url

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/integrity/scm/subversion.rb', line 14

def self.is_this_my_home?( location )
  uri = Addressable::URI.parse( location )
  %w[ svn+ssh svn http https file ].include?( uri.scheme )
end

.working_tree_path(uri) ⇒ Object



8
9
10
# File 'lib/integrity/scm/subversion.rb', line 8

def self.working_tree_path(uri)
  Subversion::URI.new( uri ).working_tree_path
end

Instance Method Details

#headObject



35
36
37
38
39
40
# File 'lib/integrity/scm/subversion.rb', line 35

def head
  log "Getting the HEAD of '#{uri}'"
  xml = %x[ svn info --non-interactive --xml #{uri} ]
  doc = Hpricot::XML( xml )
  return doc.at("commit")['revision']
end

#info(revision) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/integrity/scm/subversion.rb', line 42

def info( revision )
  log "Retrieving info for revision #{revision}"
  xml = %x[  svn log --non-interactive --xml --revision #{revision} #{uri} ]
  doc = Hpricot::XML( xml )
  h = {}
  h['author']       = doc.at('author').inner_html + " <noemail>"
  h['message']      = doc.at('msg').inner_html
  h['committed_at'] = Time.parse(doc.at('date').inner_html).iso8601
  return h
end

#nameObject



31
32
33
# File 'lib/integrity/scm/subversion.rb', line 31

def name
  self.class.name.split("::").last
end

#with_revision(revision) ⇒ Object



25
26
27
28
29
# File 'lib/integrity/scm/subversion.rb', line 25

def with_revision(revision)
  initial_checkout unless already_out?
  update_to(revision)
  yield
end