History

Add support for blank and non-number version names

Ref #25.

Thibaut Courouble committed 10 years ago

Commit 3df9cff1 parent 16ddcb14 files · +14 −8Browse files

Showing the changes to lib/docs (1 of 4 files). Show all

Unified · Split

lib/docs/core/doc.rb+3−3
@@ -13,7 +13,7 @@ module Docs · 12 unmodified lines
13 end13 end
14 14
15 def version(version = nil, &block)15 def version(version = nil, &block)
16 return @version if version.nil?16 return @version unless block_given?
17 17
18 klass = Class.new(self)18 klass = Class.new(self)
19 klass.class_exec(&block)19 klass.class_exec(&block)
@@ -48,7 +48,7 @@ module Docs · 28 unmodified lines
48 48
49 def slug49 def slug
50 slug = @slug || name.try(:downcase)50 slug = @slug || name.try(:downcase)
51 version? ? "#{slug}~#{version}" : slug51 version? ? "#{slug}~#{version.downcase.gsub(/[^a-z0-9\_\.]/, '_')}" : slug
52 end52 end
53 53
54 def path54 def path
@@ -66,7 +66,7 @@ module Docs · 11 unmodified lines
66 def as_json66 def as_json
67 json = { name: name, slug: slug, type: type }67 json = { name: name, slug: slug, type: type }
68 json[:links] = links if links.present?68 json[:links] = links if links.present?
69 json[:version] = version if version.present?69 json[:version] = version if version.present? || defined?(@version)
70 json[:release] = release if release.present?70 json[:release] = release if release.present?
71 json71 json
72 end72 end