Module: MagentWeb

Defined in:
lib/magent_web.rb,
lib/magent_web/app.rb,
lib/magent_web/mongo_helper.rb

Defined Under Namespace

Modules: MongoHelper Classes: App

Class Method Summary collapse

Class Method Details

.appObject



16
17
18
# File 'lib/magent_web.rb', line 16

def self.app
  MagentWeb::App
end

.configObject



41
42
43
# File 'lib/magent_web.rb', line 41

def self.config
  @config ||= YAML.load_file(self.config_path)
end

.config_pathObject



37
38
39
# File 'lib/magent_web.rb', line 37

def self.config_path
  Dir.home+"/.magent_webrc"
end

.connectObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/magent_web.rb', line 20

def self.connect
  ENV["MAGENT_ENV"] ||= ENV["RACK_ENV"] || ENV["RAILS_ENV"]
  if !ENV["MAGENT_ENV"]
    raise ArgumentError, "please define the env var MAGENT_ENV"
  end

  if File.exist?("/etc/magent.yml")
    Magent.setup(YAML.load_file("/etc/magent.yml"), ENV["MAGENT_ENV"], {})
  elsif File.exist?("config/magent.yml")
    Magent.setup(YAML.load_file("config/magent.yml"), ENV["MAGENT_ENV"], {})
  elsif File.exist?("magent.yml")
    Magent.setup(YAML.load_file("magent.yml"), ENV["MAGENT_ENV"], {})
  else
    raise ArgumentError, "/etc/magent.yml, ./config/magent.yml or ./magent.yml were not found"
  end
end