class Rsstsvop::Tsvop

Public Class Methods

new( index , yaml_pn ) click to toggle source
Calls superclass method
# File lib/rsstsvop/tsvop.rb, line 6
def initialize( index , yaml_pn )
  yaml_data = load_yaml( yaml_pn )
  super( yaml_data["tsv"][index] )
end

Public Instance Methods

csv_pars_sub(fields , x) click to toggle source
# File lib/rsstsvop/tsvop.rb, line 11
def csv_pars_sub(fields , x)
  if fields.size > @headers.size
    puts "error 1!"
    raise
  elsif fields.size == @headers.size
    if x.size != 0
      puts "error 2!"
      raise
    else
      hash = {}
      0.upto( fields.size - 1 ).each do |x|
        hash[ @headers[x] ] = fields[x]
      end
      @parsed_data << hash
    end
  else
    hash = {}
    0.upto( fields.size - 1 ).each do |x|
      hash[ @headers[x] ] = fields[x]
    end
    
    tail_line = x.pop
    tail_fields = tail_line.split("\t")
    case tail_fields.size
    when 1
      hash[ @headers.last ] = tail_fields[0]
      hash[ @headers[-2] ] = x.join("\n")
    when 2
      hash[ @headers.last ] = tail_fields.last
      x.push( tail_fields[0] )
      hash[ @headers[-2] ] = x.join("\n")
    else
      hash[ @headers.last ] = tail_fields.last
      val , tmp = tail_line.split( "\t#{tail_fields.last}" )
      x.push( val )
      hash[ @headers[-2] ] = x.join("\n")
    end

    @parsed_data << hash
  end
end
csv_parse( array , **options ) click to toggle source
# File lib/rsstsvop/tsvop.rb, line 53
    def csv_parse( array , **options )
      @parsed_data = []
      rows = []
      data_rows = array
      @headers = data_rows.shift.split("\t")

      item_lines = nil
      data_rows.each do |x|
        if x =~ /^[[:digit:]]+\t/
          rows << item_lines if item_lines
          item_lines = []
        else
#          puts x
        end
        if item_lines == nil
          puts x
          puts "error a1"
          raise
        end
        item_lines << x
      end
      rows << item_lines if item_lines.size > 0

      cnt=0
      rows.map{ |x2|
        cnt += 1
        fields = x2.shift.split("\t")
        csv_pars_sub(fields , x2)
      }

      @parsed_data
    end
parse() click to toggle source
# File lib/rsstsvop/tsvop.rb, line 86
    def parse
      # headers of tsv file
      #
      # ticket  summary  component        version        milestone      type owner   status    created    _changetime        _description   _reporter
      @items_by_id = {}
      @items_by_component = {}
      @items_by_version = {}
      @items_by_milestone = {}
      @items_by_type = {}
      @items_by_owner = {}
      @items_by_status = {}
      @items_by_reporter = {}
      
#      @csv_data = CSV.parse( @content , { :headers => true } )
      @csv_data = csv_parse( @content_array , { :headers => true } )

      @csv_data.each do |data|
        @items_by_id[ data['ticket'] ] = data
      end
      
      self
    end
print_by_component( ) click to toggle source
print_by_milestone() click to toggle source
print_by_owner() click to toggle source
print_by_reporter() click to toggle source
print_by_status() click to toggle source
print_by_type() click to toggle source
print_by_version() click to toggle source
print_key() click to toggle source
print_key_values( hash , id_key ) click to toggle source
print_table( dir ) click to toggle source
setup_data( hash , key ) click to toggle source
# File lib/rsstsvop/tsvop.rb, line 109
def setup_data( hash , key )
  if hash.size == 0
    @csv_data.each do |data|
      hash[ data[key] ] ||= []
      hash[ data[key] ] << data
    end
  end
end