Class: Markyboot::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/markyboot/cli.rb

Instance Method Summary collapse

Instance Method Details

#preview(file = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/markyboot/cli.rb', line 8

def preview(file = nil)
  raise "No file specified" if file.nil?

  content = File.read(file)
  html = Markyboot::Document.new(content).render

  begin
    preview = File.new('/tmp/preview.html', 'w')
    preview.write html
    system %Q{open #{preview.path}}
    puts "#{preview.path} opened in browser."
  ensure
    preview.close
  end
end