Class: Dmarcurator::ImportReports
- Inherits:
-
Object
- Object
- Dmarcurator::ImportReports
- Defined in:
- lib/dmarcurator/import_reports.rb
Overview
Import DMARC XML reports into DB
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#reports_path ⇒ Object
readonly
Returns the value of attribute reports_path.
Instance Method Summary collapse
-
#initialize(db_uri:, reports_path:) ⇒ ImportReports
constructor
A new instance of ImportReports.
- #run ⇒ Object
Constructor Details
#initialize(db_uri:, reports_path:) ⇒ ImportReports
Returns a new instance of ImportReports.
9 10 11 12 |
# File 'lib/dmarcurator/import_reports.rb', line 9 def initialize(db_uri:, reports_path:) @db = Sequel.connect(db_uri) @reports_path = reports_path end |
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
7 8 9 |
# File 'lib/dmarcurator/import_reports.rb', line 7 def db @db end |
#reports_path ⇒ Object (readonly)
Returns the value of attribute reports_path.
7 8 9 |
# File 'lib/dmarcurator/import_reports.rb', line 7 def reports_path @reports_path end |
Instance Method Details
#run ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/dmarcurator/import_reports.rb', line 14 def run puts "Importing #{reports_path}" Dir.foreach(reports_path) do |path| next if path == '.' || path == '..' || File.extname(path) != ".xml" puts " #{path}" parsed_report = ::Dmarcurator::Parser::Report.new(xml: "#{reports_path}/#{path}") ::Dmarcurator::Store::Report.import_parsed(db: db, parsed: parsed_report) end puts "Done importing :)" end |