lib/docparser/output.rb in docparser-0.2.3 vs lib/docparser/output.rb in docparser-0.3.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
module DocParser
# The Output base class.
# All Output classes inherit from this one.
class Output
attr_reader :rowcount, :filename
@@ -22,14 +24,15 @@
def initialize(filename: nil, uniq: false)
@rowcount = 0
@filename = filename
@uniq = uniq
@uniqarr = []
- fail ArgumentError, 'Please specify a filename' if filename.empty?
+ raise ArgumentError, 'Please specify a filename' if filename.empty?
+
@file = open filename, 'w'
- classname = self.class.name.split('::').last
- @logger = Log4r::Logger.new("docparser::output::#{classname}")
+ @logger = Logger.new(STDERR)
+ @logger.level = Logger::INFO
open_file
end
# Stores the header
def header=(row)
@@ -38,10 +41,11 @@
end
# Adds a row
def add_row(row)
return if @uniq && @uniqarr.include?(row.hash)
+
@rowcount += 1
write_row row
@uniqarr << row.hash
end
@@ -64,15 +68,14 @@
# do nothing
end
# Called when a row is added
def write_row(_row)
- fail NotImplementedError, 'No row writer defined'
+ raise NotImplementedError, 'No row writer defined'
end
# Called before closing the file
- def footer
- end
+ def footer; end
end
# MissingHeaderException gets thrown if a required header is missing.
class MissingHeaderException < StandardError; end
end