class OmahPluginSqlite
Public Class Methods
new(settings: {}, variables: {}, debug: false)
click to toggle source
# File lib/omah-plugin-sqlite.rb, line 13 def initialize(settings: {}, variables: {}, debug: false) dbfile = settings[:dbfile] sqlite = dbfile =~ /^sqlite:\/\// ? DRbSQLite : SQLite3::Database if FileX.exists? dbfile then @db = sqlite.new dbfile else @db = sqlite.new dbfile # Create a database rows = @db.execute <<-SQL create table headers ( id integer primary key autoincrement, from_x varchar(50), to_x varchar(50), subject varchar(140), date timestamp, filepath varchar(70) ); SQL end end
Public Instance Methods
on_newmessage(h)
click to toggle source
# File lib/omah-plugin-sqlite.rb, line 45 def on_newmessage(h) @db.execute("INSERT INTO headers (from_x, to_x, subject, date, filepath) VALUES (?, ?, ?, ?, ?)", %i(from to subject date html_filepath)\ .map{|x| h[x]} ) end