Class: Insight::Parser
- Inherits:
-
Object
- Object
- Insight::Parser
- Defined in:
- lib/insight.rb
Instance Method Summary collapse
- #initdb(db) ⇒ Object
-
#initialize(config, db) ⇒ Parser
constructor
A new instance of Parser.
- #parse(file) ⇒ Object
Constructor Details
Instance Method Details
#initdb(db) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/insight.rb', line 64 def initdb(db) begin @db = SQLite3::Database.new db rescue SQLite3::Exception => e puts "Exception opening #{db}" puts e end end |
#parse(file) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/insight.rb', line 82 def parse(file) @db.execute "BEGIN TRANSACTION;" @rulesToApply = [] @rules.each{|rule| if(rule.applies?(file)) @rulesToApply.push(rule) end } File.open(file, 'r+') do |file| file.each_line { |line| @rulesToApply.each{|rule| rule.line(line) } } end @db.execute("COMMIT TRANSACTION;") end |