Class: Useless::Doc::UI::Godel

Inherits:
Object
  • Object
show all
Includes:
Useless::Doc::UI
Defined in:
lib/useless/doc/ui/godel.rb

Defined Under Namespace

Classes: API, Domain, Request, Resource, Response, Stage

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(router) ⇒ Godel

Returns a new instance of Godel.



33
34
35
# File 'lib/useless/doc/ui/godel.rb', line 33

def initialize(router)
  @router = router
end

Class Method Details

.asset_pathObject



16
17
18
# File 'lib/useless/doc/ui/godel.rb', line 16

def self.asset_path
  File.dirname(__FILE__) + '/godel'
end

.markdownObject



20
21
22
23
24
25
26
# File 'lib/useless/doc/ui/godel.rb', line 20

def self.markdown
  @markdown ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML,
    :no_intra_emphasis => true, :tables => true,
    :fenced_code_blocks => true,:autolink => true,
    :space_after_headers => true, :lax_spacing => true,
    :superscript => true)
end

.strip_heredoc(string) ⇒ Object



28
29
30
31
# File 'lib/useless/doc/ui/godel.rb', line 28

def self.strip_heredoc(string)
  indent = string.scan(/^[ \t]*(?=\S)/).min.size
  string.gsub(/^[ \t]{#{indent}}/, '')
end

Instance Method Details

#css(entity = nil) ⇒ Object



49
50
51
# File 'lib/useless/doc/ui/godel.rb', line 49

def css(entity = nil)
  File.read(Godel.asset_path + '/stylesheet.css')
end

#html(entity) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/useless/doc/ui/godel.rb', line 37

def html(entity)
  view = case entity
  when Core::Domain   then Godel::Domain
  when Core::API      then Godel::API
  when Core::Resource then Godel::Resource
  end

  if view
    view.new(entity, @router).render
  end
end