module Magis
Constants
- VERSION
Public Class Methods
application()
click to toggle source
# File lib/magis/base.rb, line 38 def self.application Api end
db()
click to toggle source
# File lib/magis/base.rb, line 75 def self.db @@db end
env()
click to toggle source
# File lib/magis/base.rb, line 42 def self.env @@environment ||= ENV['RACK_ENV'] setup ||= @@environment == "setup" production ||= @@environment == "production" development ||= @@environment == "development" test ||= @@environment == "test" @environments ||= OpenStruct.new({ setup?: setup, production?: production, development?: development, test?: test }) @environments end
file(filename)
click to toggle source
# File lib/magis/base.rb, line 21 def self.file(filename) local_path = self.framework_path project_path = File.expand_path(self.home_folder) file_contents = nil full_file_name = project_path + filename if File.file?(full_file_name) file_contents = File.new(full_file_name).readlines elsif File.file?(local_path + filename) full_file_name = local_path + filename file_contents = File.new(full_file_name).readlines end file_contents end
framework_path()
click to toggle source
# File lib/magis/base.rb, line 18 def self.framework_path @@local_path ||= File.expand_path("../../", File.dirname(__FILE__)) end
home_folder()
click to toggle source
# File lib/magis/base.rb, line 57 def self.home_folder Dir.pwd end
load_collection(file)
click to toggle source
# File lib/magis/base.rb, line 79 def self.load_collection(file) if File.exist?(home_folder + "/collections/" + file + ".yml") YAML.load_file(home_folder + "/collections/" + file + ".yml") else Hash.new end end
load_configuration(file)
click to toggle source
# File lib/magis/base.rb, line 87 def self.load_configuration(file) @@files ||= Hash.new if File.exist?(home_folder + "/config/" + file + ".yml") @@files[file] ||= YAML.load_file(home_folder + "/config/" + file + ".yml") else Hash.new end end
omni_auth_config(type)
click to toggle source
# File lib/magis/base.rb, line 96 def self.omni_auth_config(type) configuration = self.load_configuration(type) configuration[:id] ||= nil configuration[:secret] ||= nil configuration end
set_db()
click to toggle source
# File lib/magis/base.rb, line 61 def self.set_db uri = ENV["DB_URI"] || Magis.load_configuration("database")["uri"] if uri client = MongoClient.from_uri(uri) else client = MongoClient.new end db_name = ENV["DB_NAME"] || Magis.load_configuration("database")["name"] @@db = client[db_name] end
start()
click to toggle source
# File lib/magis/base.rb, line 104 def self.start Dir["/api/*.rb"].each {|file| require file } self.set_db end