class Moonrope::DocContext
Attributes
vars[R]
Public Class Methods
new(generator, options = {})
click to toggle source
# File lib/moonrope/doc_context.rb, line 6 def initialize(generator, options = {}) @generator = generator @vars = options.delete(:vars) || {} @options = options end
Public Instance Methods
asset_path(file)
click to toggle source
# File lib/moonrope/doc_context.rb, line 49 def asset_path(file) path("assets/" + file) end
base()
click to toggle source
# File lib/moonrope/doc_context.rb, line 20 def base @generator.base end
friendly_type(type)
click to toggle source
# File lib/moonrope/doc_context.rb, line 81 def friendly_type(type) if type.is_a?(Symbol) type.to_s.capitalize else type.to_s end end
full_prefix()
click to toggle source
# File lib/moonrope/doc_context.rb, line 53 def full_prefix "#{host}/#{prefix}/#{version}" end
git_version()
click to toggle source
# File lib/moonrope/doc_context.rb, line 44 def git_version ENV["VDT_VERSION"] || (`git rev-parse HEAD`.strip rescue nil) end
host()
click to toggle source
# File lib/moonrope/doc_context.rb, line 24 def host @generator.host end
humanize(string)
click to toggle source
# File lib/moonrope/doc_context.rb, line 89 def humanize(string) string.to_s.gsub(/\_/, ' ') end
method_missing(name)
click to toggle source
Calls superclass method
# File lib/moonrope/doc_context.rb, line 36 def method_missing(name) if @vars.has_key?(name.to_sym) @vars[name.to_sym] else super end end
partial(name, attributes = {})
click to toggle source
# File lib/moonrope/doc_context.rb, line 76 def partial(name, attributes = {}) erb = self.class.new(@generator, @options.merge(:vars => attributes)) erb.render(File.join(@generator.template_root_path, "_#{name}.erb")) end
path(file)
click to toggle source
# File lib/moonrope/doc_context.rb, line 57 def path(file) depth = ((@options[:output_file] || '').split('/').size - 1).times.map { "../" }.join if file == :root file = depth + (@options[:welcome_file] || "welcome") else file = depth + file end if @options[:html_extensions] && !(file =~ /\.[a-z]+\z/) file = "#{file}.html" end file end
prefix()
click to toggle source
# File lib/moonrope/doc_context.rb, line 28 def prefix @generator.prefix end
render(template_file)
click to toggle source
# File lib/moonrope/doc_context.rb, line 72 def render(template_file) ERB.new(File.read(template_file), nil, '-').result(binding) end
set_page_title(title)
click to toggle source
# File lib/moonrope/doc_context.rb, line 12 def set_page_title(title) @vars[:page_title] = title end
version()
click to toggle source
# File lib/moonrope/doc_context.rb, line 32 def version @generator.version end