Sha256: 38ebfe69cb00e7eb0b7d5aaf54d05a74d14758ce9077defa15cd902ea05a8ac9

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require "mvcli"
require_relative "middleware"
require_relative "command"
require_relative "actions"
require_relative "router"
require_relative "provisioning"

module MVCLI
  class App
    def initialize
      @router = Router.new Actions.new root
      @router.instance_eval route_file.read, route_file.to_s, 1
      ActiveSupport::Dependencies.autoload_paths << root.join('app/providers')
      ActiveSupport::Dependencies.autoload_paths << root.join('app/controllers')
      @middleware = Middleware.new
      @middleware << Provisioning::Middleware.new
      @middleware << @router
    end

    def call(command)
      @middleware.call command
    end

    def root
      self.class.root or fail "Invalid App: undefined application root directory"
    end

    def route_file
      root.join 'app/routes.rb'
    end

    class << self
      attr_accessor :root
    end

    def main(argv = ARGV.dup, input = $stdin, output = $stdout, log = $stderr, env = ENV.dup)
      call Command.new(argv, input, output, log, env)
    end

    def self.main(*args)
      new.main *args
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mvcli-0.0.4 lib/mvcli/app.rb