Class: Lando::Generator::Command::Preview

Inherits:
Object
  • Object
show all
Extended by:
Lando::Generator::CommandHelper
Defined in:
lib/lando/generator/command/preview.rb

Class Method Summary collapse

Methods included from Lando::Generator::CommandHelper

assert_template_exists, require_nonblank, templates_path

Class Method Details

.execute(template = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/lando/generator/command/preview.rb', line 11

def execute(template = nil)
  require_nonblank('template', template)
  preview_path = File.join self.templates_path, template, 'example.html'
  
  assert_template_exists(template)

  if /darwin/ =~ RUBY_PLATFORM
    system "open #{preview_path}"
  elsif /mswin|mingw|cygwin/ =~ RUBY_PLATFORM
    system "start #{preview_path}"
  elsif /linux|bsd/ =~ RUBY_PLATFORM
    system "xdg-open #{preview_path}"
  else
    STDERR.puts "Sorry, 'preview' is not implemented yet on this platform: #{RUBY_PLATFORM}".red
    return
  end            
end