Class: CleanDB

Inherits:
Object
  • Object
show all
Defined in:
lib/hikiutils/cleandb.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ CleanDB

Returns a new instance of CleanDB.



3
4
5
6
7
8
# File 'lib/hikiutils/cleandb.rb', line 3

def initialize(file_path)
  @db = Hash.new
  file = File.read(File.join(file_path,"info.db"))
  @db = TMarshal::load(file)
  @text_dir = Dir::entries(File.join(file_path,"text"))[3..-1]
end

Instance Attribute Details

#dbObject

Returns the value of attribute db.



2
3
4
# File 'lib/hikiutils/cleandb.rb', line 2

def db
  @db
end

#file_pathObject

Returns the value of attribute file_path.



2
3
4
# File 'lib/hikiutils/cleandb.rb', line 2

def file_path
  @file_path
end

#text_dirObject

Returns the value of attribute text_dir.



2
3
4
# File 'lib/hikiutils/cleandb.rb', line 2

def text_dir
  @text_dir
end

Instance Method Details

#show_inconsistObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/hikiutils/cleandb.rb', line 10

def show_inconsist
  cont = ""
  @text_dir.each { |ent|
    if @db[ent]==nil then
      cont << "in text_dir but not in db:#{ent}\n"
      next
    end
    #  newdb.store(ent,db[ent])
  }

  @db.each { |ent|
    name = ent[0]
    if !(@text_dir.member? (name)) then
      cont <<  "in db but not in text_dir:#{name}\n"
    end
  }
  return cont
end