Fix manifest db_size
Unified · Split
| @@ -86,16 +86,6 @@ module Docs · 85 unmodified lines | ||
| 86 | 86 | json |
| 87 | 87 | end |
| 88 | 88 | |
| 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 | − | |
| 99 | 89 | def store_page(store, id) |
| 100 | 90 | index = EntryIndex.new |
| 101 | 91 | pages = PageDb.new |
| @@ -16,7 +16,11 @@ module Docs · 15 unmodified lines | ||
| 16 | 16 | def as_json |
| 17 | 17 | @docs.each_with_object [] do |doc, result| |
| 18 | 18 | 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 | |
| 20 | 24 | end |
| 21 | 25 | end |
| 22 | 26 | |
| @@ -57,14 +57,14 @@ class ManifestTest < MiniTest::Spec · 56 unmodified lines | ||
| 57 | 57 | |
| 58 | 58 | context "when the doc has a meta file" do |
| 59 | 59 | before do |
| 60 | − stub(store).exist?("testdoc/db.json") { false } | |
| 61 | 60 | stub(store).exist?(meta_path) { true } |
| 61 | + stub(store).read(meta_path) { '{"name":"Test", "db_size": 776533}' } | |
| 62 | 62 | end |
| 63 | 63 | |
| 64 | 64 | it "includes the doc's meta representation" do |
| 65 | 65 | json = manifest.as_json |
| 66 | 66 | 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 | |
| 68 | 68 | end |
| 69 | 69 | end |
| 70 | 70 | |