Class: Piston::Svn::Repository

Inherits:
Repository show all
Defined in:
lib/piston/svn/repository.rb

Instance Attribute Summary

Attributes inherited from Repository

#url

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Repository

#==, add_handler, guess, handlers, #initialize, logger, #logger, #to_s

Constructor Details

This class inherits a constructor from Piston::Repository

Class Method Details

.clientObject



25
26
27
# File 'lib/piston/svn/repository.rb', line 25

def client
  @@client ||= Piston::Svn::Client.instance
end

.repository_typeObject



33
34
35
# File 'lib/piston/svn/repository.rb', line 33

def repository_type
  'svn'
end

.svn(*args) ⇒ Object



29
30
31
# File 'lib/piston/svn/repository.rb', line 29

def svn(*args)
  client.svn(*args)
end

.understands_url?(url) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/piston/svn/repository.rb', line 10

def understands_url?(url)
  uri = URI.parse(url)
  case uri.scheme
  when "svn", /^svn\+/
    true
  when "http", "https", "file"
    # Have to contact server to know
    result = svn(:info, url) rescue :failed
    result == :failed ? false : true
  else
    # Don't know how to handle this scheme.
    # Let someone else handle it
  end
end

Instance Method Details

#at(revision) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/piston/svn/repository.rb', line 42

def at(revision)
  if revision.respond_to?(:keys) then
    rev = revision[Piston::Svn::REMOTE_REV]
    Piston::Svn::Revision.new(self, rev, revision)
  else
    case
    when revision == :head
      Piston::Svn::Revision.new(self, "HEAD")
    when revision.to_i != 0
      Piston::Svn::Revision.new(self, revision.to_i)
    else
      raise ArgumentError, "Invalid revision argument: #{revision.inspect}"
    end
  end
end

#basenameObject



58
59
60
61
62
63
64
# File 'lib/piston/svn/repository.rb', line 58

def basename
  if self.url =~ /trunk|branches|tags/ then
    self.url.sub(%r{/(?:trunk|branches|tags).*$}, "").split("/").last
  else
    self.url.split("/").last
  end
end

#svn(*args) ⇒ Object



38
39
40
# File 'lib/piston/svn/repository.rb', line 38

def svn(*args)
  self.class.svn(*args)
end