Class: AppConfig
- Inherits:
-
Settingslogic
- Object
- Settingslogic
- AppConfig
- Defined in:
- app/models/app_config.rb
Class Method Summary (collapse)
- + (Object) [](key)
- + (Object) []=(key, value)
- + (Boolean) config_file_is_old_style?
- + (Boolean) have_old_config_file?
- + (Object) load!
- + (Boolean) no_cert_file_in_prod?
- + (Boolean) no_config_file?
- + (Object) normalize_admins
- + (Object) normalize_pod_url
- + (Object) pod_uri
- + (Object) source_file_name
- + (Boolean) travis?
Class Method Details
+ (Object) [](key)
103 104 105 106 |
# File 'app/models/app_config.rb', line 103 def self.[] (key) return self.pod_uri if key == :pod_uri super end |
+ (Object) []=(key, value)
108 109 110 111 112 113 114 |
# File 'app/models/app_config.rb', line 108 def self.[]= (key, value) super if key.to_sym == :pod_url @@pod_uri = nil normalize_pod_url end end |
+ (Boolean) config_file_is_old_style?
71 72 73 |
# File 'app/models/app_config.rb', line 71 def self.config_file_is_old_style? !(File.read(@source) =~ /^defaults: &defaults/) end |
+ (Boolean) have_old_config_file?
83 84 85 |
# File 'app/models/app_config.rb', line 83 def self.have_old_config_file? File.exists?(File.join(Rails.root, "config", "app.yml")) || (File.exists?(File.join(Rails.root, "config", "app_config.yml"))) end |
+ (Object) load!
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/models/app_config.rb', line 21 def self.load! if no_config_file? && !have_old_config_file? && !travis? $stderr.puts "******** You haven't set up your Diaspora settings file. **********\nPlease do the following:\n1. Copy config/application.yml.example to config/application.yml.\n2. Have a look at the settings in that file. It has sensible defaults for development, which (we hope)\nwork without modification. However, it's always good to know what's available to change later.\n3. Restart Diaspora!\n******** Thanks for being an alpha tester! **********\n" Process.exit(1) end if (no_config_file? && have_old_config_file?) || config_file_is_old_style? $stderr.puts "******** The Diaspora configuration file format has changed. **********\nPlease do the following:\n1. Copy config/application.yml.example to config/application.yml.\n2. Make any changes in config/application.yml that you previously made in config/app.yml or config/app_config.yml.\n3. Delete config/app.yml and config/app_config.yml. Don't worry if they don't exist, though.\n4. Restart Diaspora!\n******** Thanks for being an alpha tester! **********\n" Process.exit(1) end super if no_cert_file_in_prod? $stderr.puts "******** Diaspora does not know where your SSL-CA-Certificates file is. **********\nPlease add the root certificate bundle (this is operating system specific) to application.yml. Defaults:\nCentOS: '/etc/pki/tls/certs/ca-bundle.crt'\nDebian: '/etc/ssl/certs/ca-certificates.crt'\n\nExample:\nca_file: '/etc/ssl/certs/ca-certificates.crt'\n******** Thanks for being secure! **********\n" Process.exit(1) end normalize_pod_url normalize_admins end |
+ (Boolean) no_cert_file_in_prod?
79 80 81 |
# File 'app/models/app_config.rb', line 79 def self.no_cert_file_in_prod? (Rails.env == "production") && self[:ca_file] && !File.exists?(self[:ca_file]) end |
+ (Boolean) no_config_file?
75 76 77 |
# File 'app/models/app_config.rb', line 75 def self.no_config_file? !File.exists?(@source) end |
+ (Object) normalize_admins
96 97 98 99 |
# File 'app/models/app_config.rb', line 96 def self.normalize_admins self[:admins] ||= [] self[:admins].collect! { |username| username.downcase } end |
+ (Object) normalize_pod_url
87 88 89 90 91 92 93 94 |
# File 'app/models/app_config.rb', line 87 def self.normalize_pod_url unless self[:pod_url] =~ /^(https?:\/\/)/ # starts with http:// or https:// self[:pod_url] = "http://#{self[:pod_url]}" end unless self[:pod_url] =~ /\/$/ # ends with slash self[:pod_url] = "#{self[:pod_url]}/" end end |
+ (Object) pod_uri
118 119 120 121 122 123 124 125 126 127 |
# File 'app/models/app_config.rb', line 118 def self.pod_uri if @@pod_uri.nil? begin @@pod_uri = URI.parse(self.pod_url) rescue puts "WARNING: pod url " + self.pod_url + " is not a legal URI" end end return @@pod_uri end |
+ (Object) source_file_name
12 13 14 15 16 |
# File 'app/models/app_config.rb', line 12 def self.source_file_name file_name = "application.yml" file_name << ".example" if travis? File.join(Rails.root, "config", file_name) end |
+ (Boolean) travis?
8 9 10 |
# File 'app/models/app_config.rb', line 8 def self.travis? ENV["TRAVIS"] end |