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
1313 end
1414
1515 def version(version = nil, &block)
16− return @version if version.nil?
16+ return @version unless block_given?
1717
1818 klass = Class.new(self)
1919 klass.class_exec(&block)
@@ -48,7 +48,7 @@ module Docs · 28 unmodified lines
4848
4949 def slug
5050 slug = @slug || name.try(:downcase)
51− version? ? "#{slug}~#{version}" : slug
51+ version? ? "#{slug}~#{version.downcase.gsub(/[^a-z0-9\_\.]/, '_')}" : slug
5252 end
5353
5454 def path
@@ -66,7 +66,7 @@ module Docs · 11 unmodified lines
6666 def as_json
6767 json = { name: name, slug: slug, type: type }
6868 json[:links] = links if links.present?
69− json[:version] = version if version.present?
69+ json[:version] = version if version.present? || defined?(@version)
7070 json[:release] = release if release.present?
7171 json
7272 end