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.



92
93
94
95
96
# File 'lib/localeapp/configuration.rb', line 92

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



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

def blacklisted_keys_pattern
  @blacklisted_keys_pattern
end

#cache_missing_translationsObject

Enable or disable the missing translation cache default: false



84
85
86
# File 'lib/localeapp/configuration.rb', line 84

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



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

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



69
70
71
# File 'lib/localeapp/configuration.rb', line 69

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



56
57
58
# File 'lib/localeapp/configuration.rb', line 56

def logger
  @logger
end

#poll_intervalObject

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



60
61
62
# File 'lib/localeapp/configuration.rb', line 60

def poll_interval
  @poll_interval
end

#polling_environmentsObject

The names of environments where localeapp will poll for translations from Localeapp API (to check for new translations there) on every page request to your app’s website. (defaults to ‘development’)



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

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



80
81
82
# File 'lib/localeapp/configuration.rb', line 80

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 missing translations are sent from (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



65
66
67
# File 'lib/localeapp/configuration.rb', line 65

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



76
77
78
# File 'lib/localeapp/configuration.rb', line 76

def translation_data_directory
  @translation_data_directory
end

Instance Method Details

#defaultsObject



98
99
100
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 98

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)


134
135
136
# File 'lib/localeapp/configuration.rb', line 134

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

#polling_disabled?Boolean

Returns:

  • (Boolean)


122
123
124
# File 'lib/localeapp/configuration.rb', line 122

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

#reloading_disabled?Boolean

Returns:

  • (Boolean)


126
127
128
# File 'lib/localeapp/configuration.rb', line 126

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

#sending_disabled?Boolean

Returns:

  • (Boolean)


130
131
132
# File 'lib/localeapp/configuration.rb', line 130

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