Class: Padrino::Cli::Launcher

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/padrino-core/cli/launcher.rb

Direct Known Subclasses

Base

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean (protected)

Returns:

  • (Boolean)


98
99
100
# File 'lib/padrino-core/cli/launcher.rb', line 98

def self.exit_on_failure?
  true
end

Instance Method Details

#chdir(dir) ⇒ Object (protected)



87
88
89
90
91
92
93
94
95
96
# File 'lib/padrino-core/cli/launcher.rb', line 87

def chdir(dir)
  return unless dir
  begin
    Dir.chdir(dir.to_s)
  rescue Errno::ENOENT
    puts "=> Specified Padrino root '#{dir}' does not appear to exist!"
  rescue Errno::EACCES
    puts "=> Specified Padrino root '#{dir}' cannot be accessed by the current user!"
  end
end

#prepare(task) ⇒ Object (protected)



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/padrino-core/cli/launcher.rb', line 70

def prepare(task)
  if options.help?
    help(task.to_s)
    exit
  end
  if options.environment
    ENV["RACK_ENV"] = options.environment.to_s
  else
    ENV["RACK_ENV"] ||= 'development'
  end
  chdir(options.chdir)
  unless File.exist?('config/boot.rb')
    puts "=> Could not find boot file in: #{options.chdir}/config/boot.rb !!!"
    abort
  end
end

#start(*args) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/padrino-core/cli/launcher.rb', line 22

def start(*args)
  prepare :start
  require File.expand_path("../adapter", __FILE__)
  require File.expand_path('config/boot.rb')

  if options[:server_options]
    puts server_options(options)
  else
    Padrino::Cli::Adapter.start(args.last ? options.merge(:config => args.last).freeze : options)
  end
end

#stopObject



37
38
39
40
41
# File 'lib/padrino-core/cli/launcher.rb', line 37

def stop
  prepare :stop
  require File.expand_path("../adapter", __FILE__)
  Padrino::Cli::Adapter.stop(options)
end