Ref #25.
Showing the changes to lib/docs (1 of 4 files). Show all
Unified · Split
| @@ -13,7 +13,7 @@ module Docs · 12 unmodified lines | ||
| 13 | 13 | end |
| 14 | 14 | |
| 15 | 15 | def version(version = nil, &block) |
| 16 | − return @version if version.nil? | |
| 16 | + return @version unless block_given? | |
| 17 | 17 | |
| 18 | 18 | klass = Class.new(self) |
| 19 | 19 | klass.class_exec(&block) |
| @@ -48,7 +48,7 @@ module Docs · 28 unmodified lines | ||
| 48 | 48 | |
| 49 | 49 | def slug |
| 50 | 50 | slug = @slug || name.try(:downcase) |
| 51 | − version? ? "#{slug}~#{version}" : slug | |
| 51 | + version? ? "#{slug}~#{version.downcase.gsub(/[^a-z0-9\_\.]/, '_')}" : slug | |
| 52 | 52 | end |
| 53 | 53 | |
| 54 | 54 | def path |
| @@ -66,7 +66,7 @@ module Docs · 11 unmodified lines | ||
| 66 | 66 | def as_json |
| 67 | 67 | json = { name: name, slug: slug, type: type } |
| 68 | 68 | json[:links] = links if links.present? |
| 69 | − json[:version] = version if version.present? | |
| 69 | + json[:version] = version if version.present? || defined?(@version) | |
| 70 | 70 | json[:release] = release if release.present? |
| 71 | 71 | json |
| 72 | 72 | end |