Class: WebStat::Configure

Inherits:
Object
  • Object
show all
Defined in:
lib/web_stat/configure.rb

Constant Summary collapse

DEFAULT_CONFIG_FILE_PATH =
'config/web_stat.yml'

Class Method Summary collapse

Class Method Details

.getObject

Get yaml



8
9
10
11
12
13
14
# File 'lib/web_stat/configure.rb', line 8

def get
  if defined? Rails
    Psych.safe_load(ERB.new(File.read(get_configure_path)).result, aliases: true)[Rails.env]
  else
    Psych::safe_load(ERB.new(File.read(get_configure_path)).result, aliases: true)[ENV["ENV"] || "production"]
  end
end

.get_configure_pathObject

Get configure path



17
18
19
20
21
22
23
# File 'lib/web_stat/configure.rb', line 17

def get_configure_path
  if File.exist?(get_custom_configure_path)
    get_custom_configure_path
  else
    get_default_configure_path
  end
end

.get_custom_configure_pathObject

Get custom configure path



31
32
33
34
35
36
37
# File 'lib/web_stat/configure.rb', line 31

def get_custom_configure_path
  if defined? Rails
   File.join(Rails.root, DEFAULT_CONFIG_FILE_PATH)
  else
    File.join(Bundler.root, DEFAULT_CONFIG_FILE_PATH)
  end
end

.get_default_configure_pathObject

Get default configure path



26
27
28
# File 'lib/web_stat/configure.rb', line 26

def get_default_configure_path
  File.join(File.expand_path("../", __FILE__), DEFAULT_CONFIG_FILE_PATH)
end