Module: Jobim::Application

Defined in:
lib/jobim/application.rb

Overview

Application container for initialization and execution of Jobim’s resources. Generates a new ‘Jobim::CLI` instance, and then passes it off to a `Jobim::Server`. Good chance this will change in the future.

Class Method Summary collapse

Class Method Details

.run(*args, &block) ⇒ Object

Initializes and runs the CLI and Server

Parameters:

  • args (Array<String>)

    list of args passed to the application

  • block (Block)

    dummy block object (Not used)



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/jobim/application.rb', line 9

def self.run(*args, &block)
  cli = Jobim::CLI.new
  begin
    cli.parse(args)

    exit if cli.exit

    Jobim::Server.start!(cli.settings)
  rescue OptionParser::InvalidOption => invalid_option
    $stderr.puts ">>> Error: #{invalid_option}"
    $stderr.puts cli.help

  rescue RuntimeError => runtime_error
    $stderr.puts '>>> Failed to start server'
    $stderr.puts ">> #{runtime_error}"
  end
end