Class: Padrino::Cli::Base
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Launcher
#chdir, exit_on_failure?, #prepare, #start, #stop
Class Method Details
.banner(task = nil, *args) ⇒ Object
89
90
91
|
# File 'lib/padrino-core/cli/base.rb', line 89
def self.banner(task = nil, *args)
"padrino #{task.name}"
end
|
Instance Method Details
#capture(stream) ⇒ Object
Also known as:
silence
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/padrino-core/cli/base.rb', line 93
def capture(stream)
begin
stream = stream.to_s
eval "$#{stream} = StringIO.new"
yield
result = eval("$#{stream}").string
ensure
eval("$#{stream} = #{stream.upcase}")
end
result
end
|
#console(*args) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/padrino-core/cli/base.rb', line 28
def console(*args)
prepare :console
require File.expand_path('../version', __dir__)
require File.expand_path('config/boot.rb')
puts "=> Loading #{Padrino.env} console (Padrino v.#{Padrino.version})"
require File.expand_path('console', __dir__)
ARGV.clear
if defined? Pry
Pry.start
else
require 'irb'
begin
require 'irb/completion'
rescue LoadError
end
IRB.start
end
end
|
#generate(*args) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/padrino-core/cli/base.rb', line 50
def generate(*args)
padrino_gen_path = File.expand_path('../../../../padrino-gen/lib', __dir__)
$LOAD_PATH.unshift(padrino_gen_path) if File.directory?(padrino_gen_path) && !$LOAD_PATH.include?(padrino_gen_path)
require 'padrino-core/command'
require 'padrino-gen/command'
ARGV.shift
ARGV << 'help' if ARGV.empty?
Padrino.bin_gen(*ARGV)
rescue StandardError
puts '<= You need padrino-gen! Run: gem install padrino-gen'
end
|
#rake(*args) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/padrino-core/cli/base.rb', line 10
def rake(*args)
prepare :rake
args << '-T' if options[:list]
args << options[:list] unless options[:list].nil? || options[:list].to_s == 'list'
args << '--trace' if options[:trace]
args << '--verbose' if options[:verbose]
ARGV.clear
ARGV.concat(args)
puts "=> Executing Rake #{ARGV.join(' ')} ..."
load File.expand_path('rake.rb', __dir__)
Rake.application.init
Rake.application.instance_variable_set(:@rakefile, __FILE__)
load File.expand_path('Rakefile')
Rake.application.top_level
end
|
#runner(*args) ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/padrino-core/cli/base.rb', line 72
def runner(*args)
prepare :runner
code_or_file = args.shift
abort 'Please specify code or file' if code_or_file.nil?
require File.expand_path('config/boot.rb')
if File.exist?(code_or_file)
eval(File.read(code_or_file), nil, code_or_file)
else
eval(code_or_file)
end
end
|
#version ⇒ Object
65
66
67
68
|
# File 'lib/padrino-core/cli/base.rb', line 65
def version
require 'padrino-core/version'
puts "Padrino v. #{Padrino.version}"
end
|