Class: Rpub::Commands::Preview

Inherits:
Base
  • Object
show all
Includes:
Rpub::CompilationHelpers
Defined in:
lib/rpub/commands/preview.rb

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods included from Rpub::CompilationHelpers

#config, #create_book, #layout, #markdown_files, #styles

Methods inherited from Base

#help

Methods included from SubclassTracker

#each, #identifier, #inherited, #matching

Constructor Details

#initialize(*args) ⇒ Preview

Returns a new instance of Preview.



8
9
10
11
# File 'lib/rpub/commands/preview.rb', line 8

def initialize(*args)
  super
  @filename = 'preview.html'
end

Instance Method Details

#invokeObject



13
14
15
16
17
18
19
20
# File 'lib/rpub/commands/preview.rb', line 13

def invoke
  super
  return unless markdown_files.any?
  concatenation = markdown_files.join("\n")
  File.open(@filename, 'w') do |f|
    f.write move_styles_inline(Kramdown::Document.new(concatenation, KRAMDOWN_OPTIONS.merge(:template => layout)).to_html)
  end
end