Class: Findex::Indexer

Inherits:
Object
  • Object
show all
Defined in:
lib/findex/indexer.rb

Overview

Class used for indexing files

Constant Summary collapse

DB_FLAGS =
Xapian::DB_CREATE_OR_OPEN

Instance Method Summary collapse

Constructor Details

#initialize(root_path) ⇒ Indexer



11
12
13
14
15
# File 'lib/findex/indexer.rb', line 11

def initialize(root_path)
  @root_path = Pathname.new(root_path)
  @findex_path = @root_path + '.findex'
  setup
end

Instance Method Details

#startObject



17
18
19
20
21
22
23
24
25
# File 'lib/findex/indexer.rb', line 17

def start
  @db.begin_transaction
  existing = refresh_existing
  files.each do |file|
    next if existing.include?(file)
    insert(file)
  end
  @db.commit_transaction
end