Module: App
- Defined in:
- lib/vex/base/app.rb,
lib/vex/base/argv.rb
Defined Under Namespace
Modules: Etest
Class Method Summary collapse
- .argv ⇒ Object
- .development? ⇒ Boolean
- .env ⇒ Object
- .local_conf ⇒ Object
- .logger ⇒ Object
- .production? ⇒ Boolean
- .rails? ⇒ Boolean
- .revision ⇒ Object
- .root ⇒ Object
-
.subdir(path, *parts) ⇒ Object
make a sub dir.
- .test? ⇒ Boolean
- .tmpdir ⇒ Object
Class Method Details
.argv ⇒ Object
55 56 57 |
# File 'lib/vex/base/argv.rb', line 55 def self.argv @argv ||= Argv.new ARGV end |
.development? ⇒ Boolean
24 25 26 |
# File 'lib/vex/base/app.rb', line 24 def self.development? env == "development" end |
.env ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/vex/base/app.rb', line 14 def self.env if rails? RAILS_ENV elsif defined?(APP_ENV) APP_ENV else "production" end end |
.local_conf ⇒ Object
99 100 101 102 |
# File 'lib/vex/base/app.rb', line 99 def self.local_conf @local_conf = nil if App.env == "development" @local_conf ||= LocalConf.new("local.yml") end |
.logger ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/vex/base/app.rb', line 51 def self.logger if rails? RAILS_DEFAULT_LOGGER else require "logger" logdir = "#{root}/log" FileUtils.mkdir_p logdir Logger.new "#{logdir}/#{env}.log" end end |
.production? ⇒ Boolean
28 29 30 |
# File 'lib/vex/base/app.rb', line 28 def self.production? env == "production" end |
.rails? ⇒ Boolean
2 3 4 |
# File 'lib/vex/base/app.rb', line 2 def self.rails? defined?(RAILS_ROOT) end |
.revision ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/vex/base/app.rb', line 6 def self.revision @revision ||= begin "r#{File.read("#{root}/REVISION")}" rescue Errno::ENOENT "" end end |
.root ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/vex/base/app.rb', line 36 def self.root @root ||= begin if defined?(RAILS_ROOT) RAILS_ROOT elsif defined?(APP_ROOT) APP_ROOT elsif defined?($0) File. File.dirname($0) else raise "Cannot determine application root" end end end |
.subdir(path, *parts) ⇒ Object
make a sub dir
80 81 82 83 84 |
# File 'lib/vex/base/app.rb', line 80 def self.subdir(path, *parts) path = "#{root}/#{path}/#{parts.join("/")}" mkdir_and_verify path path end |
.test? ⇒ Boolean
32 33 34 |
# File 'lib/vex/base/app.rb', line 32 def self.test? env == "test" end |
.tmpdir ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/vex/base/app.rb', line 63 def self.tmpdir @tmpdir ||= begin tmpdir = if rails? "#{root}/tmp" else ENV["TMPDIR"] || "/tmp" end tmpdir = tmpdir.gsub(/\/$/, "") raise "Cannot determine tmpdir setting" if tmpdir.blank? tmpdir end end |