lib/platform/config.rb in platform-3.1.2 vs lib/platform/config.rb in platform-3.1.3
- old
+ new
@@ -87,21 +87,15 @@
puts ">> Resetting #{cls.name}..."
cls.delete_all
end
init_default_categories
- init_default_applications
puts "Done."
end
def self.system_user
- if user_class_name == "Platform::PlatformUser"
- @system_user ||= Platform::PlatformUser.first || Platform::PlatformUser.create(:name => "System User")
- return @system_user
- end
-
return nil unless site_info[:system_user_id]
@system_user ||= user_class_name.constantize.find_by_id(site_info[:system_user_id])
end
def self.system_developer
@@ -114,20 +108,12 @@
puts "Cannot initialize default application because system user id is not specified in the config."
return
end
default_applications.each do |keyword, description|
- category_keywords = description.delete("category_keywords")
- icon_path = description.delete("icon_path")
- logo_path = description.delete("logo_path")
-
app = Platform::Application.create(description.merge(:developer => system_developer))
- app.store_icon(File.new("#{root}/#{icon_path}", "r")) if icon_path
- app.store_logo(File.new("#{root}/#{logo_path}", "r")) if logo_path
-
puts "Initialized #{app.name}."
- app.approve!
end
end
def self.init_default_categories
puts "Initializing default categories..."
@@ -156,12 +142,13 @@
def self.env
Rails.env
end
def self.load_yml(file_path, for_env = env)
- yml = YAML.load_file("#{root}#{file_path}")
- yml = yml[for_env] unless for_env.nil?
+ yml_path = "#{root}#{file_path}"
+ yml = YAML.load_file(yml_path)
+ yml = yml['defaults'].rmerge(yml[for_env] || {}) unless for_env.nil?
HashWithIndifferentAccess.new(yml)
end
def self.config
@config ||= load_yml("/config/platform/config.yml")
@@ -189,10 +176,14 @@
def self.enable_developer_agreement?
config[:enable_developer_agreement]
end
+ def self.developer_agreement_path
+ config[:developer_agreement_path]
+ end
+
def self.enable_app_statistics?
config[:enable_app_statistics]
end
def self.enable_api_verification?
@@ -600,9 +591,14 @@
def self.api_explorer_app_id
config[:api_explorer_app_id]
end
+ def self.api_explorer_app
+ return if api_explorer_app_id.blank?
+ @api_explorer_app ||= Platform::Application.find_by_id(api_explorer_app_id)
+ end
+
def self.api_explorer_app?
!api_explorer_app_id.blank?
end
def self.api_proxies_path