lib/fdoc/presenters/meta_service_presenter.rb in fdoc-0.3.0 vs lib/fdoc/presenters/meta_service_presenter.rb in fdoc-0.3.1
- old
+ new
@@ -1,18 +1,29 @@
-# HtmlPresenter for Fdoc::MetaService
-class Fdoc::MetaServicePresenter < Fdoc::HtmlPresenter
+# BasePresenter for Fdoc::MetaService
+class Fdoc::MetaServicePresenter < Fdoc::BasePresenter
attr_reader :meta_service
+ extend Forwardable
+ def_delegators :meta_service, :name, :meta_service_dir
+
def initialize(meta_service, options = {})
super(options)
@meta_service = meta_service
end
+ def name
+ meta_service.name
+ end
+
def to_html
render_erb('meta_service.html.erb')
end
+ def to_markdown
+ render_erb('meta_service.md.erb')
+ end
+
def services
@services ||= meta_service.services.
sort_by(&:name).
map do |service|
Fdoc::ServicePresenter.new(service, options)
@@ -36,15 +47,23 @@
end
@endpoints
end
- def description
- render_markdown(meta_service.description)
+ def description(options = {:render => true})
+ options[:render] ? render_markdown(meta_service.description) : meta_service.description
end
- def discussion
- render_markdown(meta_service.discussion)
+ def discussion(options = {:render => true})
+ options[:render] ? render_markdown(meta_service.discussion) : meta_service.discussion
+ end
+
+ def relative_service_path(service_presenter, file_name = nil)
+ service_path = service_presenter.slug_name
+ if file_name
+ service_path = File.join(service_path, file_name)
+ end
+ service_path
end
private
def ungrouped_endpoints