Sha256: c978b94044eb04fe437188d5914ee03c464370b11b3ccb603a8894e13d8bcc5a

Contents?: true

Size: 1.33 KB

Versions: 7

Compression:

Stored size: 1.33 KB

Contents

require 'artoo/delegator'
require 'artoo/robot'

module Artoo
  # Execution context for top-level robots
  # DSL methods executed on main are delegated to this class like Sinatra
  class MainRobot < Artoo::Robot

    # we assume that the first file that requires 'artoo' is the
    # app_file. all other path related options are calculated based
    # on this path by default.
    set :app_file, caller_files.first || $0
    set :start_work, Proc.new { File.expand_path($0) == File.expand_path(app_file) }

    # if run? && ARGV.any?
    #   require 'optparse'
    #   OptionParser.new { |op|
    #     op.on('-p port',   'set the port (default is 4567)')                { |val| set :port, Integer(val) }
    #     op.on('-o addr',   'set the host (default is 0.0.0.0)')             { |val| set :bind, val }
    #     op.on('-e env',    'set the environment (default is development)')  { |val| set :environment, val.to_sym }
    #     op.on('-s server', 'specify rack server/handler (default is thin)') { |val| set :server, val }
    #     op.on('-x',        'turn on the mutex lock (default is off)')       {       set :lock, true }
    #   }.parse!(ARGV.dup)
    # end
  end

  at_exit { MainRobot.work! if $!.nil? && MainRobot.start_work? }
end

# include would include the module in Object
# extend only extends the `main` object
extend Artoo::Delegator

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
artoo-0.4.0 lib/artoo/main.rb
artoo-0.3.0 lib/artoo/main.rb
artoo-0.2.0 lib/artoo/main.rb
artoo-0.1.3 lib/artoo/main.rb
artoo-0.1.2 lib/artoo/main.rb
artoo-0.1.1 lib/artoo/main.rb
artoo-0.1.0 lib/artoo/main.rb