Class: Esvien::Repo

Inherits:
Object
  • Object
show all
Defined in:
lib/esvien/repo.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ Repo

Returns a new instance of Repo.



6
7
8
9
# File 'lib/esvien/repo.rb', line 6

def initialize(uri)
  @uri = uri
  get_repository_info
end

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



3
4
5
# File 'lib/esvien/repo.rb', line 3

def uri
  @uri
end

#uuidObject (readonly)

Returns the value of attribute uuid.



4
5
6
# File 'lib/esvien/repo.rb', line 4

def uuid
  @uuid
end

Instance Method Details

#==(other) ⇒ Object



28
29
30
# File 'lib/esvien/repo.rb', line 28

def ==(other)
  uuid == other.uuid
end

#commits(range = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/esvien/repo.rb', line 11

def commits(range=nil)
  return [] if @revision == 0

  doc = svnxml(:log, '-r', svn_range_string(range) || '1:HEAD', uri)
  elems = doc.search('/log/logentry')
  elems.map do |elem|
    commit = Commit.new(elem.attributes['revision'].to_i, self)
    commit.author = elem.children_of_type('author').first.inner_text
    commit.date = Time.parse(elem.children_of_type('date').first.inner_text)
    commit
  end
end

#headObject



24
25
26
# File 'lib/esvien/repo.rb', line 24

def head
  commits('HEAD').first
end

#pretty_print(pp) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/esvien/repo.rb', line 32

def pretty_print(pp)
  pp.group(1, %{#<#{self.class}}, %{>}) do
    pp.breakable
    pp.seplist(%w[uri uuid], lambda { pp.comma_breakable }) do |attr|
      pp.text(attr)
      pp.text("=")
      pp.pp(send(attr))
    end
  end
end