Class: MVCLI::App

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

Instance Attribute Summary

Attributes inherited from Core

#name, #namespace, #path

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Core

<<, #activate!, all, drain, each, #exists?, inherited, #initialize, #read, #version

Constructor Details

This class inherits a constructor from MVCLI::Core

Class Method Details

.main(*args) ⇒ Object



40
41
42
# File 'lib/mvcli/app.rb', line 40

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

Instance Method Details

#bootstrap(command) ⇒ Object



18
19
20
# File 'lib/mvcli/app.rb', line 18

def bootstrap(command)
  Map command: command, app: self, cortex: cortex, loader: loader, actions: Action
end

#call(command) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/mvcli/app.rb', line 10

def call(command)
  Scope.new(bootstrap command) do
    cortex.activate!
    action = router[command]
    return action.call command
  end
end

#cortexObject



22
23
24
25
26
27
28
# File 'lib/mvcli/app.rb', line 22

def cortex
  @cortex ||= Cortex.new do |cortex|
    Core.drain do |cls|
      cortex << cls.new if cls.path
    end
  end
end

#loaderObject



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

def loader
  #TODO: use generic extension mechanism
  require "mvcli/std/extensions/erb_extension"
  MVCLI::Loader.new :template => MVCLI::ERBExtension.new
end

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



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

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