Module: App

Defined in:
lib/vex/base/app.rb

Defined Under Namespace

Modules: Etest

Class Method Summary collapse

Class Method Details

.development?Boolean

Returns:

  • (Boolean)

24
25
26
# File 'lib/vex/base/app.rb', line 24

def self.development?
  env == "development"
end

.envObject


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_confObject


73
74
75
76
# File 'lib/vex/base/app.rb', line 73

def self.local_conf
  @local_conf = nil if App.env == "development"
  @local_conf ||= LocalConf.new("local.yml")
end

.loggerObject


46
47
48
49
50
51
52
53
54
55
56
# File 'lib/vex/base/app.rb', line 46

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

Returns:

  • (Boolean)

28
29
30
# File 'lib/vex/base/app.rb', line 28

def self.production?
  env == "production"
end

.rails?Boolean

Returns:

  • (Boolean)

2
3
4
# File 'lib/vex/base/app.rb', line 2

def self.rails?
  defined?(RAILS_ROOT)
end

.revisionObject


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

.rootObject


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

def self.root
  if defined?(RAILS_ROOT)
    RAILS_ROOT
  elsif defined?(APP_ROOT)
    APP_ROOT
  else
    raise "Cannot determine application root"
  end
end

.test?Boolean

Returns:

  • (Boolean)

32
33
34
# File 'lib/vex/base/app.rb', line 32

def self.test?
  env == "test"
end

.tmpdirObject


58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/vex/base/app.rb', line 58

def self.tmpdir
  @tmpdir ||= begin
    tmpdir = if rails?
      "#{root}/tmp"
    else
      ENV["TMPDIR"]
    end

    tmpdir = tmpdir.gsub(/\/$/, "")

    raise "Cannot determine tmpdir setting" if tmpdir.blank?
    tmpdir
  end
end