Module: App
- Extended by:
- Appetizer::Events
- Defined in:
- lib/appetizer/setup.rb
Class Method Summary collapse
- .development? ⇒ Boolean
- .env ⇒ Object
- .init! ⇒ Object
- .load(file) ⇒ Object
- .log ⇒ Object
- .production? ⇒ Boolean
- .require(file) ⇒ Object
- .test? ⇒ Boolean
Methods included from Appetizer::Events
Class Method Details
.development? ⇒ Boolean
21 22 23 |
# File 'lib/appetizer/setup.rb', line 21 def self.development? :development == env end |
.env ⇒ Object
17 18 19 |
# File 'lib/appetizer/setup.rb', line 17 def self.env (ENV["RACK_ENV"] || ENV["RAILS_ENV"] || "development").intern end |
.init! ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/appetizer/setup.rb', line 25 def self.init! return true if defined?(@initialized) && @initialized load "config/init.rb" if File.exists? "config/init.rb" fire :initializing Dir["config/init/**/*.rb"].sort.each { |f| load f } # If the app has an app/models directory, autorequire 'em. if File.directory? "app/models" $:.unshift File. "app/models" Dir["app/models/**/*.rb"].sort.each { |f| require f[11..-4] } end fire :initialized @initialized = true end |
.load(file) ⇒ Object
46 47 48 49 50 |
# File 'lib/appetizer/setup.rb', line 46 def self.load file now = Time.now.to_f if ENV["TRACE"] Kernel.load file p :load => { file => (Time.now.to_f - now) } if ENV["TRACE"] end |
.log ⇒ Object
52 53 54 |
# File 'lib/appetizer/setup.rb', line 52 def self.log @log ||= Logger.new test? ? "tmp/test.log" : $stdout end |
.production? ⇒ Boolean
56 57 58 |
# File 'lib/appetizer/setup.rb', line 56 def self.production? :production == env end |
.require(file) ⇒ Object
60 61 62 63 64 |
# File 'lib/appetizer/setup.rb', line 60 def self.require file now = Time.now.to_f if ENV["TRACE"] Kernel.require file p :require => { file => (Time.now.to_f - now) } if ENV["TRACE"] end |
.test? ⇒ Boolean
66 67 68 |
# File 'lib/appetizer/setup.rb', line 66 def self.test? :test == env end |