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.



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

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

#cache_missing_translationsObject

Enable or disable the missing translation cache default: false



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

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



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

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



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

def daemon_pid_file
  @daemon_pid_file
end

#environment_nameObject

The name of the environment the application is running in



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

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.



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

def http_auth_password
  @http_auth_password
end

#http_auth_usernameObject

Returns the value of attribute http_auth_username.



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

def http_auth_username
  @http_auth_username
end

#loggerObject

The logger used by Localeapp



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

def logger
  @logger
end

#poll_intervalObject

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



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

def poll_interval
  @poll_interval
end

#polling_environmentsObject

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



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

def polling_environments
  @polling_environments
end

#portObject

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



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

def port
  @port
end

#project_rootObject

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



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

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



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

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’)



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

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’)



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

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

#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



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

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



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

def translation_data_directory
  @translation_data_directory
end

Instance Method Details

#defaultsObject



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/localeapp/configuration.rb', line 87

def defaults
  defaults = {
    :host                       => 'api.localeapp.com',
    :timeout                    => 60,
    :secure                     => true,
    :ssl_verify                 => false,
    :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)


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

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

#polling_disabled?Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/localeapp/configuration.rb', line 110

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

#reloading_disabled?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/localeapp/configuration.rb', line 114

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

#sending_disabled?Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/localeapp/configuration.rb', line 118

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