Class: Docs::Manifest

Inherits:
Object
  • Object
show all
Defined in:
lib/docs/core/manifest.rb

Constant Summary collapse

FILENAME =
'docs.json'

Instance Method Summary collapse

Constructor Details

#initialize(store, docs) ⇒ Manifest

Returns a new instance of Manifest


7
8
9
10
# File 'lib/docs/core/manifest.rb', line 7

def initialize(store, docs)
  @store = store
  @docs = docs
end

Instance Method Details

#as_jsonObject


16
17
18
19
20
21
# File 'lib/docs/core/manifest.rb', line 16

def as_json
  indexed_docs.map(&:as_json).each do |json|
    json[:mtime] = doc_mtime(json)
    json[:db_size] = doc_db_size(json)
  end
end

#storeObject


12
13
14
# File 'lib/docs/core/manifest.rb', line 12

def store
  @store.write FILENAME, to_json
end

#to_jsonObject


23
24
25
# File 'lib/docs/core/manifest.rb', line 23

def to_json
  JSON.generate(as_json)
end