Class: Markup::Preview::Command::Runner

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/markup-preview-command.rb

Constant Summary collapse

TMPDIR =
File.join(Dir.tmpdir, 'markup-preview')
TMPFILE =
File.join(TMPDIR, $$.to_s) + '.html'

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util

#browser_command, #command_exist?

Constructor Details

#initialize(argv) ⇒ Runner

Returns a new instance of Runner.



20
21
22
# File 'lib/markup-preview-command.rb', line 20

def initialize(argv)
  @opts = Options.new(argv)
end

Class Method Details

.run(argv) ⇒ Object



24
25
26
# File 'lib/markup-preview-command.rb', line 24

def self.run(argv)
  self.new(argv).run
end

Instance Method Details

#runObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/markup-preview-command.rb', line 28

def run
  create_html
  if @opts.browser
    open_browser
    exit($?.exitstatus || 0)
  else
    puts File.read(TMPFILE)
    exit 0
  end
end