Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions lib/docs/core/doc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,6 @@ def as_json
json
end

def as_json_extra(store)
json = self.as_json
if options[:attribution].is_a?(String)
json[:attribution] = options[:attribution].strip
end
json[:db_size] = store.size(self.db_path) if store.exist?(self.db_path)
json[:mtime] = store.mtime(self.meta_path).to_i if store.exist?(self.meta_path)
json
end

def store_page(store, id)
index = EntryIndex.new
pages = PageDb.new
Expand Down
6 changes: 5 additions & 1 deletion lib/docs/core/manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ def store
def as_json
@docs.each_with_object [] do |doc, result|
next unless @store.exist?(doc.meta_path)
result << doc.as_json_extra(@store)
json = JSON.parse(@store.read(doc.meta_path))
if doc.options[:attribution].is_a?(String)
json[:attribution] = doc.options[:attribution].strip
end
result << json
end
end

Expand Down
4 changes: 2 additions & 2 deletions test/lib/docs/core/manifest_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ class ManifestTest < MiniTest::Spec

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

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

Expand Down