class Docset::IndexDB
Public Class Methods
new(file)
click to toggle source
# File lib/docset/index_db.rb, line 5 def initialize(file) @db = SQLite3::Database.new(file) @db.busy_timeout(5000) end
Public Instance Methods
add_index(name, type, path)
click to toggle source
# File lib/docset/index_db.rb, line 18 def add_index(name, type, path) @db.prepare("INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES (?, ?, ?);") do |stmt| stmt.execute([name, type, path]) end end
init()
click to toggle source
# File lib/docset/index_db.rb, line 10 def init @db.execute_batch(<<~SQL) DROP TABLE IF EXISTS searchIndex; CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT); CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path); SQL end