lib/retter/stationery/previewer.rb in retter-0.0.0 vs lib/retter/stationery/previewer.rb in retter-0.0.1
- old
+ new
@@ -2,11 +2,15 @@
module Retter::Stationery
class Previewer
attr_reader :config
- def initialize(date, config)
+ extend Forwardable
+
+ def_delegators :@config, *Retter::Config.delegatables
+
+ def initialize(config, date)
@config, @date = config, date
@body, @entry = *nil
load_retter_file
load_wip_entry_if_needed
@@ -15,15 +19,15 @@
def file_path
config.retter_home.join '.preview.html'
end
def renderer
- Haml::Engine.new(config.layout_file.read, ugly: true)
+ Haml::Engine.new(layout_file.read, ugly: true)
end
def entry_renderer
- Haml::Engine.new(config.entry_layout_file.read, ugly: true)
+ Haml::Engine.new(entry_layout_file.read, ugly: true)
end
def print
build_entry
print_html
@@ -40,20 +44,20 @@
file.puts View::Helper.fix_path(html, './')
end
end
def build_entry
- @entry = Retter::Entry.new(date: @date, body: Retter::Stationery.parser.render(@body))
+ @entry = Retter::Entry.new(date: @date, body: Retter::Stationery.markupper.render(@body))
end
def load_retter_file
- retter_file = config.retter_file(@date, '.md')
+ retter_file = retter_file(@date)
@body = retter_file.exist? ? retter_file.read : ''
end
def load_wip_entry_if_needed
- if @date == Date.today && config.wip_file.exist?
- @body = [@body, config.wip_file.read].join("\n")
+ if @date == Date.today && wip_file.exist?
+ @body = [@body, wip_file.read].join("\n")
end
end
end
end