Add version to doc manifest

Ref #25.
pull/308/merge
Thibaut Courouble 9 years ago
parent 621ac0a350
commit b67a02ed35

@ -1,10 +1,10 @@
class app.models.Doc extends app.Model class app.models.Doc extends app.Model
# Attributes: name, slug, type, release, db_size, mtime, links # Attributes: name, slug, type, version, release, db_size, mtime, links
constructor: -> constructor: ->
super super
@reset @ @reset @
[@slug_without_version, @version] = @slug.split('~v') @slug_without_version = @slug.split('~v')[0]
@fullName = "#{@name}" + if @version then " #{@version}" else '' @fullName = "#{@name}" + if @version then " #{@version}" else ''
@icon = @slug_without_version @icon = @slug_without_version
@text = @toEntry().text @text = @toEntry().text

@ -66,6 +66,7 @@ module Docs
def as_json def as_json
json = { name: name, slug: slug, type: type } json = { name: name, slug: slug, type: type }
json[:links] = links if links.present? json[:links] = links if links.present?
json[:version] = version if version.present?
json[:release] = release if release.present? json[:release] = release if release.present?
json json
end end

@ -133,10 +133,10 @@ class DocsDocTest < MiniTest::Spec
assert_instance_of Hash, doc.as_json assert_instance_of Hash, doc.as_json
end end
it "includes the doc's name, slug, type, and release" do it "includes the doc's name, slug, type, version, and release" do
assert_equal %i(name slug type), doc.as_json.keys assert_equal %i(name slug type), doc.as_json.keys
%w(name slug type release links).each do |attribute| %w(name slug type version release links).each do |attribute|
eval "stub(doc).#{attribute} { attribute }" eval "stub(doc).#{attribute} { attribute }"
assert_equal attribute, doc.as_json[attribute.to_sym] assert_equal attribute, doc.as_json[attribute.to_sym]
end end

Loading…
Cancel
Save