lib/revepast/parser.rb in revepast-0.0.2 vs lib/revepast/parser.rb in revepast-0.0.3
- old
+ new
@@ -1,21 +1,28 @@
module Revepast
module Parser
+ require "revepast/parser/eft"
+ require "revepast/parser/cargo_scan"
class Utils
def sanitize(str)
- return str.gsub /^$\n/, ''
+ result = []
+ str.each_line do |line|
+ line = line.chomp.gsub /^$\n/, ''
+ unless line.nil? || line == ""
+ result << line
+ end
+ end
+ return result
end
def regex_match_lines(regex, lines)
matches = Array.new
bad_lines = Array.new
lines.each do |line|
if line.match(regex)
- # p "--#{line.chomp}"
a = line.match(regex)
matches.push(a.captures)
- # p matches
else
bad_lines.push(line.chomp)
end
end
return matches, bad_lines
@@ -32,10 +39,10 @@
matches, bad_lines = regex_match_lines(listing_re, lines)
matches2, bad_lines2 = regex_match_lines(listing_re2, bad_lines)
matches3, bad_lines3 = regex_match_lines(listing_re3, bad_lines2)
items = Hash.new { |h, k| h[k] = 0 }
- matches.each do |name, count|
+ matches.each do |count, name|
items[name.strip] += count.to_i
end
matches2.each do |name, count|
items[name.strip] += count.to_i
end
\ No newline at end of file