Class: Docset::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/docset/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Base

Returns a new instance of Base.



7
8
9
10
11
12
# File 'lib/docset/base.rb', line 7

def initialize(path)
  @path = path
  FileUtils.mkdir_p(documents_path)
  @db = IndexDB.new(docset_index_db_path)
  @db.init
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/docset/base.rb', line 5

def path
  @path
end

Instance Method Details

#add_content(from, to = '') ⇒ Object



14
15
16
17
18
# File 'lib/docset/base.rb', line 14

def add_content(from, to = '')
  dest_path = File.join(contents_path, to)
  FileUtils.mkdir_p(File.dirname(dest_path))
  FileUtils.cp_r(from, dest_path)
end

#add_document(from, to = '') ⇒ Object



20
21
22
23
24
# File 'lib/docset/base.rb', line 20

def add_document(from, to = '')
  dest_path = File.join(documents_path, to)
  FileUtils.mkdir_p(File.dirname(dest_path))
  FileUtils.cp_r(from, dest_path)
end

#add_index(name, type, path) ⇒ Object



26
27
28
# File 'lib/docset/base.rb', line 26

def add_index(name, type, path)
  @db.add_index(name, type, path)
end

#add_plist(plist) ⇒ Object



30
31
32
# File 'lib/docset/base.rb', line 30

def add_plist(plist)
  File.write(plist_path, plist.to_s)
end

#write_content(to, content) ⇒ Object



34
35
36
37
38
# File 'lib/docset/base.rb', line 34

def write_content(to, content)
  dest_path = File.join(contents_path, to)
  FileUtils.mkdir_p(File.dirname(dest_path))
  File.write(dest_path, content)
end

#write_document(to, document) ⇒ Object



40
41
42
43
44
# File 'lib/docset/base.rb', line 40

def write_document(to, document)
  dest_path = File.join(documents_path, to)
  FileUtils.mkdir_p(File.dirname(dest_path))
  File.write(dest_path, document)
end