Module: Application::Defaults

Included in:
Application
Defined in:
lib/ruby-app/application_defaults.rb

Instance Method Summary collapse

Instance Method Details

#bundler_groupObject



62
63
# File 'lib/ruby-app/application_defaults.rb', line 62

def bundler_group
end

#configObject



46
47
48
# File 'lib/ruby-app/application_defaults.rb', line 46

def config
  CommonConfig
end

#envObject Also known as: environment



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ruby-app/application_defaults.rb', line 15

def env
  @gem_env ||= begin
    env = ENV['APP_ENV'] || ENV['RAILS_ENV']

    # if not specify env, try find file with env config/environment.current
    # which created this file by a capistrano, by example
    unless env
      path = File.join(root, %w{ config environment.current })
      if File.exists?(path)
        env = File.read(path)
        env.strip!
      end
    end

    env = 'development' unless env

    env
  end
end

#error_mailerObject



69
70
71
# File 'lib/ruby-app/application_defaults.rb', line 69

def error_mailer
  ErrorMailer
end

#hostnameObject



77
78
79
# File 'lib/ruby-app/application_defaults.rb', line 77

def hostname
  @_hostname ||= `hostname`.chop
end

#identifierObject



50
51
52
# File 'lib/ruby-app/application_defaults.rb', line 50

def identifier
  "ruby-app"
end

#initializer_pathsObject



58
59
60
# File 'lib/ruby-app/application_defaults.rb', line 58

def initializer_paths
  @gem_initializer_paths ||= []
end

#loggerObject



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

def logger
  @gem_logger ||= begin
    file = env.to_s['test'] ? File.open(File.join(logger_dir, "#{name rescue 'ruby-app'}.log"), "a") : STDERR
    LocalLogger.new(file).tap do |l|
      l.level = App.config.log_level
    end
  end
end

#logger_dirObject



11
12
13
# File 'lib/ruby-app/application_defaults.rb', line 11

def logger_dir
  @gem_logger_dir ||= File.join(root, %w{log})
end

#rake_pathsObject



54
55
56
# File 'lib/ruby-app/application_defaults.rb', line 54

def rake_paths
  @gem_rake_paths ||= []
end

#revisionObject



73
74
75
# File 'lib/ruby-app/application_defaults.rb', line 73

def revision
  @_revision ||= File.read(File.join(root, %w[REVISION]))[0..5] rescue nil
end

#started_atObject



65
66
67
# File 'lib/ruby-app/application_defaults.rb', line 65

def started_at
  $app_started_at
end

#tmp_dirObject



7
8
9
# File 'lib/ruby-app/application_defaults.rb', line 7

def tmp_dir
  @gem_tmp_dir ||= File.join(root, %w{tmp})
end