Class: Svnlog2csv::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/svnlog2csv/reader.rb

Overview

Classe di utilità che sfrutta nokogiri per leggere dati xml

Constant Summary collapse

NODE_TYPE =
Nokogiri::XML::Reader::TYPE_ELEMENT

Instance Method Summary collapse

Constructor Details

#initialize(string_or_io) ⇒ Reader

Returns a new instance of Reader.



8
9
10
# File 'lib/svnlog2csv/reader.rb', line 8

def initialize string_or_io
  @reader = Nokogiri::XML::Reader(string_or_io) 
end

Instance Method Details

#authorsObject

Estrae dall’xml tutti gli autori dei commit.



21
22
23
24
25
26
27
28
29
30
# File 'lib/svnlog2csv/reader.rb', line 21

def authors
  list = []
  each("author") do |node|
    author = node.inner_xml
    unless list.include?(author)
      list << author
    end
  end
  list
end

#each(node_name = nil) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/svnlog2csv/reader.rb', line 12

def each node_name = nil
  @reader.each do |node|
    if node_name.nil? || (node.name == node_name && node.node_type == NODE_TYPE)
      yield node
    end
  end
end