lib/fdoc/presenters/service_presenter.rb in fdoc-0.3.0 vs lib/fdoc/presenters/service_presenter.rb in fdoc-0.3.1

- old
+ new

@@ -1,18 +1,27 @@ -# An HtmlPresenter for Fdoc::Service -class Fdoc::ServicePresenter < Fdoc::HtmlPresenter +# An BasePresenter for Fdoc::Service +class Fdoc::ServicePresenter < Fdoc::BasePresenter attr_reader :service + extend Forwardable + + def_delegators :service, :name, :service_dir, :meta_service + + def initialize(service, options = {}) super(options) @service = service end def to_html render_erb('service.html.erb') end + def to_markdown + render_erb('service.md.erb') + end + def name_as_link(options = {}) path = service.meta_service ? index_path(slug_name) : index_path '<a href="%s">%s %s</a>' % [ path, options[:prefix], service.name ] end @@ -44,13 +53,23 @@ end @endpoints end - def description - render_markdown(service.description) + def description(options = {:render => true}) + options[:render] ? render_markdown(service.description) : service.description end - def discussion - render_markdown(service.discussion) + def discussion(options = {:render => true}) + options[:render] ? render_markdown(service.discussion) : service.discussion end + + def relative_meta_service_path(file_name = nil) + service_path = service_dir.gsub(meta_service.meta_service_dir, "") + service_path = service_path.count("/").times.map { "../" }.join + if file_name + service_path = File.join(service_path, file_name) + end + service_path + end + end