Class: RevealCK::Builders::CreateIndexHtml

Inherits:
CreationTask show all
Defined in:
lib/reveal-ck/builders/create_index_html.rb

Overview

Given a slides.html, a Rake application, a template for building out a reveal.js index.html, and a place where the resulting index.html file should end up, this class knows how to work with Rake and create the index.html.

Instance Attribute Summary collapse

Attributes inherited from CreationTask

#application, #things_to_create

Instance Method Summary collapse

Methods inherited from CreationTask

#name, #prepare

Methods included from RakeAware

#copy_file, #create_directory, #task

Methods included from Retrieve

included, #retrieve

Constructor Details

#initialize(args) ⇒ CreateIndexHtml

Returns a new instance of CreateIndexHtml.



12
13
14
15
16
17
18
# File 'lib/reveal-ck/builders/create_index_html.rb', line 12

def initialize(args)
  @slides_html = retrieve(:slides_html, args)
  @template = retrieve(:template, args)
  @output_dir = retrieve(:output_dir, args)
  @config = retrieve(:config, args)
  super
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



10
11
12
# File 'lib/reveal-ck/builders/create_index_html.rb', line 10

def config
  @config
end

#output_dirObject (readonly)

Returns the value of attribute output_dir.



10
11
12
# File 'lib/reveal-ck/builders/create_index_html.rb', line 10

def output_dir
  @output_dir
end

#slides_htmlObject (readonly)

Returns the value of attribute slides_html.



10
11
12
# File 'lib/reveal-ck/builders/create_index_html.rb', line 10

def slides_html
  @slides_html
end

#templateObject (readonly)

Returns the value of attribute template.



10
11
12
# File 'lib/reveal-ck/builders/create_index_html.rb', line 10

def template
  @template
end

Instance Method Details

#setupObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/reveal-ck/builders/create_index_html.rb', line 20

def setup
  index_html_file = "#{output_dir}/index.html"
  task(index_html_file => slides_html) do
    content = IndexHtml.new(slides_html: slides_html,
                            template: template,
                            config: config).render
    File.open(index_html_file, 'w') do |index_html|
      index_html.puts(content)
    end
  end
  things_to_create.add(index_html_file)
end