Class: MVCLI::App

Inherits:
Object
  • Object
show all
Defined in:
lib/mvcli/app.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ App

Returns a new instance of App.



12
13
14
15
16
17
18
19
20
# File 'lib/mvcli/app.rb', line 12

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

Class Attribute Details

.root ⇒ Object

Returns the value of attribute root.



35
36
37
# File 'lib/mvcli/app.rb', line 35

def root
  @root
end

Class Method Details

.main(*args) ⇒ Object



42
43
44
# File 'lib/mvcli/app.rb', line 42

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

Instance Method Details

#call(command) ⇒ Object



22
23
24
# File 'lib/mvcli/app.rb', line 22

def call(command)
  @middleware.call command
end

#main(argv = ARGV.dup, input = $stdin, output = $stdout, log = $stderr, env = ENV.dup) ⇒ Object



38
39
40
# File 'lib/mvcli/app.rb', line 38

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

#root ⇒ Object



26
27
28
# File 'lib/mvcli/app.rb', line 26

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

#route_file ⇒ Object



30
31
32
# File 'lib/mvcli/app.rb', line 30

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