Class: Localeapp::Configuration
- Inherits:
-
Object
- Object
- Localeapp::Configuration
- Defined in:
- lib/localeapp/configuration.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
The API key for your project, found on the project edit form.
-
#daemon_log_file ⇒ Object
The complete path to the log file where we store information about daemon actions default: RAILS_ROOT/log/localeapp_daemon.log.
-
#daemon_pid_file ⇒ Object
The complete path to the pid file where we store information about daemon default: RAILS_ROOT/tmp/pids/localeapp.pid.
-
#disabled_polling_environments ⇒ Object
deprecated
Deprecated.
Use #polling_environments instead. This is safer but make sure to reverse your logic if you’ve changed the defaults
-
#disabled_reloading_environments ⇒ Object
deprecated
Deprecated.
Use #reloading_environments instead. This is safer but make sure to reverse your logic if you’ve changed the defaults
-
#disabled_sending_environments ⇒ Object
deprecated
Deprecated.
Use #sending_environments instead. This is safer but make sure to reverse your logic if you’ve changed the defaults
-
#environment_name ⇒ Object
The name of the environment the application is running in.
-
#host ⇒ Object
The host to connect to (defaults to api.localeapp.com).
-
#http_auth_password ⇒ Object
Returns the value of attribute http_auth_password.
-
#http_auth_username ⇒ Object
Returns the value of attribute http_auth_username.
-
#logger ⇒ Object
The logger used by Localeapp.
-
#poll_interval ⇒ Object
The number of seconds to wait before asking the service for new translations (defaults to 0 - every request).
-
#polling_environments ⇒ Object
The names of environments where updates aren’t pulled (defaults to ‘development’).
-
#port ⇒ Object
The port to connect to if it’s not the default one.
-
#project_root ⇒ Object
The path to the project in which the translation occurred, such as the RAILS_ROOT.
-
#proxy ⇒ Object
The proxy to connect via.
-
#reloading_environments ⇒ Object
The names of environments where I18n.reload is called for each request (defaults to ‘development’).
-
#secure ⇒ Object
Whether to use https or not (defaults to true).
-
#sending_environments ⇒ Object
The names of environments where notifications are sent (defaults to ‘development’).
-
#ssl_ca_file ⇒ Object
Path to local CA certs bundle.
-
#ssl_verify ⇒ Object
Whether to verify ssl server certificates or not (defaults to false, see README).
-
#synchronization_data_file ⇒ Object
The complete path to the data file where we store synchronization information (defaults to ./localeapp.yml) local_app/rails overwrites this to RAILS_ROOT/log/localeapp.yml.
-
#translation_data_directory ⇒ Object
The complete path to the directory where translations are stored.
Instance Method Summary collapse
- #deprecated_environment_config_used? ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #polling_disabled? ⇒ Boolean
- #reloading_disabled? ⇒ Boolean
- #sending_disabled? ⇒ Boolean
- #write_initial(path) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/localeapp/configuration.rb', line 101 def initialize @host = 'api.localeapp.com' @secure = true @ssl_verify = false @disabled_sending_environments = %w(test cucumber production) @disabled_reloading_environments = %w(test cucumber production) @disabled_polling_environments = %w(test cucumber production) @sending_environments = %w(development) @reloading_environments = %w(development) @polling_environments = %w(development) @poll_interval = 0 @synchronization_data_file = File.join('log', 'localeapp.yml') @daemon_pid_file = File.join('tmp', 'pids', 'localeapp.pid') @daemon_log_file = File.join('log', 'localeapp_daemon.log') @translation_data_directory = File.join('config', 'locales') if ENV['DEBUG'] require 'logger' @logger = Logger.new(STDOUT) end end |
Instance Attribute Details
#api_key ⇒ Object
The API key for your project, found on the project edit form
5 6 7 |
# File 'lib/localeapp/configuration.rb', line 5 def api_key @api_key end |
#daemon_log_file ⇒ Object
The complete path to the log file where we store information about daemon actions default: RAILS_ROOT/log/localeapp_daemon.log
92 93 94 |
# File 'lib/localeapp/configuration.rb', line 92 def daemon_log_file @daemon_log_file end |
#daemon_pid_file ⇒ Object
The complete path to the pid file where we store information about daemon default: RAILS_ROOT/tmp/pids/localeapp.pid
88 89 90 |
# File 'lib/localeapp/configuration.rb', line 88 def daemon_pid_file @daemon_pid_file end |
#disabled_polling_environments ⇒ Object
Use #polling_environments instead. This is safer but make sure to reverse your logic if you’ve changed the defaults
The names of environments where updates aren’t pulled (defaults to ‘test’, ‘cucumber’, ‘production’)
68 69 70 |
# File 'lib/localeapp/configuration.rb', line 68 def disabled_polling_environments @disabled_polling_environments end |
#disabled_reloading_environments ⇒ Object
Use #reloading_environments instead. This is safer but make sure to reverse your logic if you’ve changed the defaults
The names of environments where I18n.reload isn’t called for each request (defaults to ‘test’, ‘cucumber’, ‘production’)
59 60 61 |
# File 'lib/localeapp/configuration.rb', line 59 def disabled_reloading_environments @disabled_reloading_environments end |
#disabled_sending_environments ⇒ Object
Use #sending_environments instead. This is safer but make sure to reverse your logic if you’ve changed the defaults
The names of environments where notifications aren’t sent (defaults to ‘test’, ‘cucumber’, ‘production’)
50 51 52 |
# File 'lib/localeapp/configuration.rb', line 50 def disabled_sending_environments @disabled_sending_environments end |
#environment_name ⇒ Object
The name of the environment the application is running in
29 30 31 |
# File 'lib/localeapp/configuration.rb', line 29 def environment_name @environment_name end |
#host ⇒ Object
The host to connect to (defaults to api.localeapp.com)
8 9 10 |
# File 'lib/localeapp/configuration.rb', line 8 def host @host end |
#http_auth_password ⇒ Object
Returns the value of attribute http_auth_password.
26 27 28 |
# File 'lib/localeapp/configuration.rb', line 26 def http_auth_password @http_auth_password end |
#http_auth_username ⇒ Object
Returns the value of attribute http_auth_username.
25 26 27 |
# File 'lib/localeapp/configuration.rb', line 25 def http_auth_username @http_auth_username end |
#logger ⇒ Object
The logger used by Localeapp
75 76 77 |
# File 'lib/localeapp/configuration.rb', line 75 def logger @logger end |
#poll_interval ⇒ Object
The number of seconds to wait before asking the service for new translations (defaults to 0 - every request).
79 80 81 |
# File 'lib/localeapp/configuration.rb', line 79 def poll_interval @poll_interval end |
#polling_environments ⇒ Object
The names of environments where updates aren’t pulled (defaults to ‘development’)
45 46 47 |
# File 'lib/localeapp/configuration.rb', line 45 def polling_environments @polling_environments end |
#port ⇒ Object
The port to connect to if it’s not the default one
23 24 25 |
# File 'lib/localeapp/configuration.rb', line 23 def port @port end |
#project_root ⇒ Object
The path to the project in which the translation occurred, such as the RAILS_ROOT
33 34 35 |
# File 'lib/localeapp/configuration.rb', line 33 def project_root @project_root end |
#proxy ⇒ Object
The proxy to connect via
11 12 13 |
# File 'lib/localeapp/configuration.rb', line 11 def proxy @proxy end |
#reloading_environments ⇒ Object
The names of environments where I18n.reload is called for each request (defaults to ‘development’)
41 42 43 |
# File 'lib/localeapp/configuration.rb', line 41 def reloading_environments @reloading_environments end |
#secure ⇒ Object
Whether to use https or not (defaults to true)
14 15 16 |
# File 'lib/localeapp/configuration.rb', line 14 def secure @secure end |
#sending_environments ⇒ Object
The names of environments where notifications are sent (defaults to ‘development’)
37 38 39 |
# File 'lib/localeapp/configuration.rb', line 37 def sending_environments @sending_environments end |
#ssl_ca_file ⇒ Object
Path to local CA certs bundle
20 21 22 |
# File 'lib/localeapp/configuration.rb', line 20 def ssl_ca_file @ssl_ca_file end |
#ssl_verify ⇒ Object
Whether to verify ssl server certificates or not (defaults to false, see README)
17 18 19 |
# File 'lib/localeapp/configuration.rb', line 17 def ssl_verify @ssl_verify end |
#synchronization_data_file ⇒ Object
The complete path to the data file where we store synchronization information (defaults to ./localeapp.yml) local_app/rails overwrites this to RAILS_ROOT/log/localeapp.yml
84 85 86 |
# File 'lib/localeapp/configuration.rb', line 84 def synchronization_data_file @synchronization_data_file end |
#translation_data_directory ⇒ Object
The complete path to the directory where translations are stored
95 96 97 |
# File 'lib/localeapp/configuration.rb', line 95 def translation_data_directory @translation_data_directory end |
Instance Method Details
#deprecated_environment_config_used? ⇒ Boolean
97 98 99 |
# File 'lib/localeapp/configuration.rb', line 97 def deprecated_environment_config_used? @deprecated_environment_config_used end |
#polling_disabled? ⇒ Boolean
122 123 124 125 126 127 128 129 |
# File 'lib/localeapp/configuration.rb', line 122 def polling_disabled? if deprecated_environment_config_used? ::Localeapp.log "DEPRECATION: disabled_polling_environments is deprecated and will be removed. Use polling_environments instead and reverse the logic if you've changed the defaults" disabled_polling_environments.map { |v| v.to_s }.include?(environment_name) else !polling_environments.map { |v| v.to_s }.include?(environment_name) end end |
#reloading_disabled? ⇒ Boolean
131 132 133 134 135 136 137 138 |
# File 'lib/localeapp/configuration.rb', line 131 def reloading_disabled? if deprecated_environment_config_used? ::Localeapp.log "DEPRECATION: disabled_reloading_environments is deprecated and will be removed. Use reloading_environments instead and reverse the logic if you've changed the defaults" disabled_reloading_environments.map { |v| v.to_s }.include?(environment_name) else !reloading_environments.map { |v| v.to_s }.include?(environment_name) end end |
#sending_disabled? ⇒ Boolean
140 141 142 143 144 145 146 147 |
# File 'lib/localeapp/configuration.rb', line 140 def sending_disabled? if deprecated_environment_config_used? ::Localeapp.log "DEPRECATION: disabled_sending_environments is deprecated and will be removed. Use sending_environments instead and reverse the logic if you've changed the defaults" disabled_sending_environments.map { |v| v.to_s }.include?(environment_name) else !sending_environments.map { |v| v.to_s }.include?(environment_name) end end |
#write_initial(path) ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/localeapp/configuration.rb', line 149 def write_initial(path) dir = File.dirname(path) FileUtils.mkdir_p(dir) File.open(path, 'w+') do |file| file.write "require 'localeapp/rails'\n\nLocaleapp.configure do |config|\n config.api_key = '\#{@api_key}'\nend\n" end end |