You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
devdocs/lib/docs/core/manifest.rb

33 lines
675 B

11 years ago
require 'yajl/json_gem'
module Docs
class Manifest
FILENAME = 'docs.json'
2 months ago
def initialize(store, docs)
11 years ago
@store = store
@docs = docs
end
def store
@store.write FILENAME, to_json
end
def as_json
@docs.each_with_object [] do |doc, result|
next unless @store.exist?(doc.meta_path)
json = JSON.parse(@store.read(doc.meta_path))
if doc.options[:attribution].is_a?(String)
json[:attribution] = doc.options[:attribution].strip
end
2 months ago
json[:alias] = Docs.aliases[doc.slug]
result << json
11 years ago
end
end
def to_json
JSON.pretty_generate(as_json)
11 years ago
end
end
end