Class: Localeapp::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/localeapp/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



90
91
92
93
94
# File 'lib/localeapp/configuration.rb', line 90

def initialize
  defaults.each do |setting, value|
    send("#{setting}=", value)
  end
end

Instance Attribute Details

#api_keyObject

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

#blacklisted_keys_patternObject

A regular expression that is matched against a translation key. If the key matches, the translation will not be sent to the Locale server via the rails exception handler. default: nil



88
89
90
# File 'lib/localeapp/configuration.rb', line 88

def blacklisted_keys_pattern
  @blacklisted_keys_pattern
end

#cache_missing_translationsObject

Enable or disable the missing translation cache default: false



82
83
84
# File 'lib/localeapp/configuration.rb', line 82

def cache_missing_translations
  @cache_missing_translations
end

#daemon_log_fileObject

The complete path to the log file where we store information about daemon actions default: RAILS_ROOT/log/localeapp_daemon.log



71
72
73
# File 'lib/localeapp/configuration.rb', line 71

def daemon_log_file
  @daemon_log_file
end

#daemon_pid_fileObject

The complete path to the pid file where we store information about daemon default: RAILS_ROOT/tmp/pids/localeapp.pid



67
68
69
# File 'lib/localeapp/configuration.rb', line 67

def daemon_pid_file
  @daemon_pid_file
end

#environment_nameObject

The name of the environment the application is running in



35
36
37
# File 'lib/localeapp/configuration.rb', line 35

def environment_name
  @environment_name
end

#hostObject

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_passwordObject

Returns the value of attribute http_auth_password.



32
33
34
# File 'lib/localeapp/configuration.rb', line 32

def http_auth_password
  @http_auth_password
end

#http_auth_usernameObject

Returns the value of attribute http_auth_username.



31
32
33
# File 'lib/localeapp/configuration.rb', line 31

def http_auth_username
  @http_auth_username
end

#loggerObject

The logger used by Localeapp



54
55
56
# File 'lib/localeapp/configuration.rb', line 54

def logger
  @logger
end

#poll_intervalObject

The number of seconds to wait before asking the service for new translations (defaults to 0 - every request).



58
59
60
# File 'lib/localeapp/configuration.rb', line 58

def poll_interval
  @poll_interval
end

#polling_environmentsObject

The names of environments where updates aren’t pulled (defaults to ‘development’)



51
52
53
# File 'lib/localeapp/configuration.rb', line 51

def polling_environments
  @polling_environments
end

#portObject

The port to connect to if it’s not the default one



29
30
31
# File 'lib/localeapp/configuration.rb', line 29

def port
  @port
end

#project_rootObject

The path to the project in which the translation occurred, such as the RAILS_ROOT



39
40
41
# File 'lib/localeapp/configuration.rb', line 39

def project_root
  @project_root
end

#proxyObject

The proxy to connect via



11
12
13
# File 'lib/localeapp/configuration.rb', line 11

def proxy
  @proxy
end

#raise_on_insecure_yamlObject

Enable or disable the insecure yaml exception default: true



78
79
80
# File 'lib/localeapp/configuration.rb', line 78

def raise_on_insecure_yaml
  @raise_on_insecure_yaml
end

#reloading_environmentsObject

The names of environments where I18n.reload is called for each request (defaults to ‘development’)



47
48
49
# File 'lib/localeapp/configuration.rb', line 47

def reloading_environments
  @reloading_environments
end

#secureObject

Whether to use https or not (defaults to true)



17
18
19
# File 'lib/localeapp/configuration.rb', line 17

def secure
  @secure
end

#sending_environmentsObject

The names of environments where notifications are sent (defaults to ‘development’)



43
44
45
# File 'lib/localeapp/configuration.rb', line 43

def sending_environments
  @sending_environments
end

#ssl_ca_fileObject

Path to local CA certs bundle



23
24
25
# File 'lib/localeapp/configuration.rb', line 23

def ssl_ca_file
  @ssl_ca_file
end

#ssl_verifyObject

Whether to verify ssl server certificates or not (defaults to false, see README)



20
21
22
# File 'lib/localeapp/configuration.rb', line 20

def ssl_verify
  @ssl_verify
end

#ssl_versionObject

SSL version to use in requests (defaults to ‘SSLv23’)



26
27
28
# File 'lib/localeapp/configuration.rb', line 26

def ssl_version
  @ssl_version
end

#synchronization_data_fileObject

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



63
64
65
# File 'lib/localeapp/configuration.rb', line 63

def synchronization_data_file
  @synchronization_data_file
end

#timeoutObject

The request timeout



14
15
16
# File 'lib/localeapp/configuration.rb', line 14

def timeout
  @timeout
end

#translation_data_directoryObject

The complete path to the directory where translations are stored



74
75
76
# File 'lib/localeapp/configuration.rb', line 74

def translation_data_directory
  @translation_data_directory
end

Instance Method Details

#defaultsObject



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/localeapp/configuration.rb', line 96

def defaults
  defaults = {
    :host                       => 'api.localeapp.com',
    :timeout                    => 60,
    :secure                     => true,
    :ssl_verify                 => false,
    :ssl_version                => 'SSLv23',
    :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'),
    :raise_on_insecure_yaml     => true,
  }
  if ENV['DEBUG']
    require 'logger'
    defaults[:logger] = Logger.new(STDOUT)
  end
  defaults
end

#has_api_key?Boolean

Returns:

  • (Boolean)


132
133
134
# File 'lib/localeapp/configuration.rb', line 132

def has_api_key?
  !api_key.nil? && !api_key.empty?
end

#polling_disabled?Boolean

Returns:

  • (Boolean)


120
121
122
# File 'lib/localeapp/configuration.rb', line 120

def polling_disabled?
  !polling_environments.map { |v| v.to_s }.include?(environment_name)
end

#reloading_disabled?Boolean

Returns:

  • (Boolean)


124
125
126
# File 'lib/localeapp/configuration.rb', line 124

def reloading_disabled?
  !reloading_environments.map { |v| v.to_s }.include?(environment_name)
end

#sending_disabled?Boolean

Returns:

  • (Boolean)


128
129
130
# File 'lib/localeapp/configuration.rb', line 128

def sending_disabled?
  !sending_environments.map { |v| v.to_s }.include?(environment_name)
end