Skip to content

Commit ce248ce

Browse files
committed
Fix manifest db_size
1 parent da5430a commit ce248ce

3 files changed

Lines changed: 7 additions & 13 deletions

File tree

lib/docs/core/doc.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,6 @@ def as_json
8686
json
8787
end
8888

89-
def as_json_extra(store)
90-
json = self.as_json
91-
if options[:attribution].is_a?(String)
92-
json[:attribution] = options[:attribution].strip
93-
end
94-
json[:db_size] = store.size(self.db_path) if store.exist?(self.db_path)
95-
json[:mtime] = store.mtime(self.meta_path).to_i if store.exist?(self.meta_path)
96-
json
97-
end
98-
9989
def store_page(store, id)
10090
index = EntryIndex.new
10191
pages = PageDb.new

lib/docs/core/manifest.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ def store
1616
def as_json
1717
@docs.each_with_object [] do |doc, result|
1818
next unless @store.exist?(doc.meta_path)
19-
result << doc.as_json_extra(@store)
19+
json = JSON.parse(@store.read(doc.meta_path))
20+
if doc.options[:attribution].is_a?(String)
21+
json[:attribution] = doc.options[:attribution].strip
22+
end
23+
result << json
2024
end
2125
end
2226

test/lib/docs/core/manifest_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ class ManifestTest < MiniTest::Spec
5757

5858
context "when the doc has a meta file" do
5959
before do
60-
stub(store).exist?("testdoc/db.json") { false }
6160
stub(store).exist?(meta_path) { true }
61+
stub(store).read(meta_path) { '{"name":"Test", "db_size": 776533}' }
6262
end
6363

6464
it "includes the doc's meta representation" do
6565
json = manifest.as_json
6666
assert_equal 1, json.length
67-
assert_equal "{:name=>\"TestDoc\", :slug=>\"testdoc\", :type=>nil, :attribution=>\"foo\", :mtime=>0}", json[0].to_s
67+
assert_equal "{\"name\"=>\"Test\", \"db_size\"=>776533, :attribution=>\"foo\"}", json[0].to_s
6868
end
6969
end
7070

0 commit comments

Comments
 (0)