Improve Doc#name and Doc#slug

pull/602/head
Thibaut Courouble 8 years ago
parent b36f3f8095
commit c1ebb7a0b9

@ -44,14 +44,11 @@ module Docs
end
def name
@name || super.try(:demodulize)
@name || super.demodulize
end
def slug
slug = @slug || (
raise "Slug must be set explicitly when name (#{name}) consists of anything else than [\\w\\.%]" if /[^\w\.%]/ =~ name
name.try(:downcase)
)
slug = @slug || default_slug || raise('slug is required')
version? ? "#{slug}~#{version_slug}" : slug
end
@ -119,6 +116,11 @@ module Docs
private
def default_slug
return if name =~ /[^A-Za-z0-9_]/
name.downcase
end
def store_page?(page)
page[:entries].present?
end

@ -3,7 +3,9 @@ require 'docs'
class ManifestTest < MiniTest::Spec
let :doc do
Class.new Docs::Doc
doc = Class.new Docs::Doc
doc.name = 'TestDoc'
doc
end
let :store do

Loading…
Cancel
Save