Class: Aardi::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/aardi/renderer.rb

Overview

:reek:TooManyInstanceVariables

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(html_files: nil, content_hashes: nil, sitemap: nil) ⇒ Renderer

:reek:ControlParameter



9
10
11
12
13
14
15
16
# File 'lib/aardi/renderer.rb', line 9

def initialize(html_files: nil, content_hashes: nil, sitemap: nil)
  @html_files = html_files || Dir.glob('./**/*.html').to_set
  @content_hashes = content_hashes || ContentHashes.new(Config[:content_hashes_path])
  @sitemap = sitemap || Sitemap.new
  @template = Template.new(Config[:template_path])
  @custom_renderer = CustomRenderer.new
  @markup_renderer = Redcarpet::Markdown.new(@custom_renderer, markup_options)
end

Instance Attribute Details

#content_hashesObject (readonly)

Returns the value of attribute content_hashes.



6
7
8
# File 'lib/aardi/renderer.rb', line 6

def content_hashes
  @content_hashes
end

#html_filesObject (readonly)

Returns the value of attribute html_files.



6
7
8
# File 'lib/aardi/renderer.rb', line 6

def html_files
  @html_files
end

#sitemapObject (readonly)

Returns the value of attribute sitemap.



6
7
8
# File 'lib/aardi/renderer.rb', line 6

def sitemap
  @sitemap
end

Instance Method Details

#finalize(result) ⇒ Object



18
19
20
21
# File 'lib/aardi/renderer.rb', line 18

def finalize(result)
  content_hashes.save(result)
  Orphanage.new.report(html_files, result.keys)
end

#markup(content) ⇒ Object



23
24
25
26
# File 'lib/aardi/renderer.rb', line 23

def markup(content)
  @custom_renderer.reset
  @markup_renderer.render(content)
end

#markup_feed_snippet(content) ⇒ Object



28
29
30
# File 'lib/aardi/renderer.rb', line 28

def markup_feed_snippet(content)
  markup(content.sub(/\A(### .*\n)?\n+/, '')).strip
end

#render(src) ⇒ Object



32
33
34
# File 'lib/aardi/renderer.rb', line 32

def render(src)
  @template.render(src)
end