Class: Lucie::App

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

Overview

App responsible for configuring and launch the application based on Lucie application framework.

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, root, pwd = nil) ⇒ App

Returns a new instance of App.



37
38
39
40
41
42
43
44
# File 'lib/lucie/app.rb', line 37

def initialize(command, root, pwd = nil)
  @root = root
  @command = CommandLineParser.new(command)
  @exit_value ||= 0
  @task = nil
  @pwd = pwd || ENV["PWD"]
  Dir.chdir(@pwd)
end

Class Attribute Details

.log_levelObject

Returns the value of attribute log_level.



11
12
13
# File 'lib/lucie/app.rb', line 11

def log_level
  @log_level
end

.raise_exceptionObject

Returns the value of attribute raise_exception.



10
11
12
# File 'lib/lucie/app.rb', line 10

def raise_exception
  @raise_exception
end

.rootObject

Returns the value of attribute root.



12
13
14
# File 'lib/lucie/app.rb', line 12

def root
  @root
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



17
18
19
# File 'lib/lucie/app.rb', line 17

def command
  @command
end

#pwdObject (readonly)

Returns the value of attribute pwd.



19
20
21
# File 'lib/lucie/app.rb', line 19

def pwd
  @pwd
end

#rootObject (readonly)

Returns the value of attribute root.



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

def root
  @root
end

Class Method Details

.init(command = ARGV, root = nil, pwd = nil) ⇒ Object



27
28
29
30
# File 'lib/lucie/app.rb', line 27

def self.init(command = ARGV, root = nil, pwd = nil)
  root ||= File.expand_path("..", File.dirname(Kernel.caller[0]))
  self.new(command, root, pwd)
end

.run(command = ARGV, root = nil, pwd = nil) ⇒ Object



21
22
23
24
25
# File 'lib/lucie/app.rb', line 21

def self.run(command = ARGV, root = nil, pwd = nil)
  root ||= File.expand_path("..", File.dirname(Kernel.caller[0]))
  instance = self.init(command, root, pwd)
  self.start(instance)
end

.start(instance) ⇒ Object



32
33
34
35
# File 'lib/lucie/app.rb', line 32

def self.start(instance)
  instance.start
  instance.exit_value
end

Instance Method Details

#envObject



54
55
56
# File 'lib/lucie/app.rb', line 54

def env
  ENV
end

#exit_valueObject



50
51
52
# File 'lib/lucie/app.rb', line 50

def exit_value
  @exit_value
end

#startObject



46
47
48
# File 'lib/lucie/app.rb', line 46

def start
  help? ? call_help : call_method_invoking_process
end