Class: Svnx::Status::Entry

Inherits:
Base::Entry show all
Includes:
Comparable
Defined in:
lib/svnx/status/entry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base::Entry

#attribute_value, #element_text, #set_attr_var, #set_attr_vars, #set_elmt_var, #set_elmt_vars, #set_var

Constructor Details

#initialize(xmlelement, rootpath: nil) ⇒ Entry

Returns a new instance of Entry.



23
24
25
26
27
28
# File 'lib/svnx/status/entry.rb', line 23

def initialize xmlelement, rootpath: nil
  @rootpath = rootpath
  super xmlelement
  # @status is an Svnx::Action
  @action = @status
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



19
20
21
# File 'lib/svnx/status/entry.rb', line 19

def action
  @action
end

#commit_revisionObject (readonly)

Returns the value of attribute commit_revision.



20
21
22
# File 'lib/svnx/status/entry.rb', line 20

def commit_revision
  @commit_revision
end

#nameObject (readonly)

Returns the value of attribute name.



21
22
23
# File 'lib/svnx/status/entry.rb', line 21

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



17
18
19
# File 'lib/svnx/status/entry.rb', line 17

def path
  @path
end

#statusObject (readonly)

Returns the value of attribute status.



16
17
18
# File 'lib/svnx/status/entry.rb', line 16

def status
  @status
end

#status_revisionObject (readonly)

Returns the value of attribute status_revision.



18
19
20
# File 'lib/svnx/status/entry.rb', line 18

def status_revision
  @status_revision
end

Instance Method Details

#<=>(other) ⇒ Object



51
52
53
# File 'lib/svnx/status/entry.rb', line 51

def <=> other
  path <=> other.path
end

#set_from_element(elmt) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/svnx/status/entry.rb', line 30

def set_from_element elmt
  set_attr_var elmt, 'path'

  wcstatus = elmt.elements['wc-status']
  @status = Svnx::Action.new(wcstatus.attributes['item'])
  set_attr_var wcstatus, 'status_revision', 'revision'
  
  commit = wcstatus.elements['commit']
  set_attr_var commit, 'commit_revision', 'revision'
  @name = @path.dup

  if @rootpath
    # name is prefixed with directory unless '.' is used as the argument
    @name.sub! Regexp.new('^' + @rootpath), ''
  end
end

#to_sObject



47
48
49
# File 'lib/svnx/status/entry.rb', line 47

def to_s
  "path: #{@path}; status: #{@status}"
end