Class: RubyApp::Application
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
method_missing
#configuration
Constructor Details
#initialize(options) ⇒ Application
Returns a new instance of Application.
21
22
23
24
|
# File 'lib/ruby_app/application.rb', line 21
def initialize(options)
@options = options
@environment = {}
end
|
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
19
20
21
|
# File 'lib/ruby_app/application.rb', line 19
def environment
@environment
end
|
#options ⇒ Object
Returns the value of attribute options.
19
20
21
|
# File 'lib/ruby_app/application.rb', line 19
def options
@options
end
|
Class Method Details
.create!(options = {}) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/ruby_app/application.rb', line 30
def self.create!(options = {})
_options = { :application_class => RubyApp::Application,
:session_class => RubyApp::Session,
:log_path => File.join(RubyApp::ROOT, %w[process log application.log]),
:configuration_paths => [],
:default_language => :en,
:translations_paths => [] }.merge(options)
_options[:configuration_paths] = [File.join(RubyApp::ROOT, %w[config.yml])] + ( _options[:configuration_paths].is_a?(Array) ? _options[:configuration_paths] : [_options[:configuration_paths]] )
_options[:translations_paths] = [File.join(RubyApp::ROOT, %w[translations])] + ( _options[:translations_paths].is_a?(Array) ? _options[:translations_paths] : [_options[:translations_paths]] )
RubyApp::Log.open!(_options[:log_path])
RubyApp::Configuration.load!(_options[:configuration_paths])
@@_application = _options.application_class.new(_options)
end
|
.create_cache(path, root) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/ruby_app/application.rb', line 50
def self.create_cache(path, root)
RubyApp::Application.create!
begin
Dir.glob(File.join(path, %w[** *.rb])).each do |element_file|
RubyApp::Request.create!
begin
require element_file
element_class = element_file.gsub(root, '')
element_class = element_class.gsub(/^\//, '')
element_class = element_class.gsub(/\.rb$/, '')
element_class = RubyApp::Application.upcode(element_class)
begin
element_class = eval(element_class)
[:css, :js].each do |format|
begin
element_class.render(format, true)
rescue Exception => exception
puts "#{element_class}.render(#{format.inspect}) exception=#{exception.message}"
end
end
rescue Exception => exception
puts exception.message
end
ensure
RubyApp::Request.destroy!
end
end
ensure
RubyApp::Application.destroy!
end
end
|
.destroy_cache(path) ⇒ Object
82
83
84
85
86
|
# File 'lib/ruby_app/application.rb', line 82
def self.destroy_cache(path)
Dir.glob(File.join(path, %w[** .cache])).each do |directory|
FileUtils.rm_r(directory)
end
end
|
.get ⇒ Object
26
27
28
|
# File 'lib/ruby_app/application.rb', line 26
def self.get
@@_application ||= nil
end
|
.upcode(value) ⇒ Object
88
89
90
91
|
# File 'lib/ruby_app/application.rb', line 88
def self.upcode(value)
value = value.gsub(/\/(.?)/) { "::#{$1.upcase}" }
value.gsub(/(?:^|_)(.)/) { $1.upcase }
end
|