Class: Lucid::CLI::App
Class Method Summary collapse
Instance Method Summary collapse
- #configuration ⇒ Object
-
#initialize(args, stdin = STDIN, out = STDOUT, err = STDERR, kernel = Kernel) ⇒ App
constructor
A new instance of App.
- #start!(existing_runtime = nil) ⇒ Object
Constructor Details
#initialize(args, stdin = STDIN, out = STDOUT, err = STDERR, kernel = Kernel) ⇒ App
Returns a new instance of App.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/lucid/cli/app.rb', line 15 def initialize(args, stdin=STDIN, out=STDOUT, err=STDERR, kernel=Kernel) raise "args can't be nil" unless args raise "out can't be nil" unless out raise "err can't be nil" unless err raise "kernel can't be nil" unless kernel @args = args @out = out @err = err @kernel = kernel @configuration = nil end |
Class Method Details
.start(args) ⇒ Object
11 12 13 |
# File 'lib/lucid/cli/app.rb', line 11 def self.start(args) new(args).start! end |
Instance Method Details
#configuration ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/lucid/cli/app.rb', line 56 def configuration return @configuration if @configuration @configuration = Configuration.new(@out, @err) @configuration.parse(@args) Lucid.logger = @configuration.log log.debug("Configuration: #{@configuration.inspect}") @configuration end |
#start!(existing_runtime = nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/lucid/cli/app.rb', line 27 def start!(existing_runtime = nil) trap_interrupt runtime = if existing_runtime existing_runtime.configure(configuration) existing_runtime else Runtime.new(configuration) end log.debug("Runtime: #{runtime.inspect}") runtime.run runtime.write_testdefs_json failure = runtime.results.failure? || Lucid.wants_to_quit @kernel.exit(failure ? 1 : 0) rescue ProfilesNotDefinedError, YmlLoadError, ProfileNotFound => e @err.puts(e.) rescue SystemExit => e @kernel.exit(e.status) rescue Errno::EACCES, Errno::ENOENT => e @err.puts("#{e.} (#{e.class})") @kernel.exit(1) rescue Exception => e @err.puts("#{e.} (#{e.class})") @err.puts(e.backtrace.join("\n")) @kernel.exit(1) end |