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.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/localeapp/configuration.rb', line 50

def initialize
  @host                            = 'api.localeapp.com'
  @port                            = 80
  @disabled_sending_environments   = %w(test cucumber production)
  @disabled_reloading_environments = %w(test cucumber production)
  @disabled_polling_environments   = %w(test cucumber production)
  @poll_interval                   = 0
  @synchronization_data_file       = File.join('log', 'localeapp.yml')
  @translation_data_directory      = File.join('config', 'locales')
  if ENV['DEBUG']
    require 'logger'
    @logger = Logger.new(STDOUT)
  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

#disabled_polling_environmentsObject

The names of environments where updates aren’t pulled (defaults to ‘test’, ‘cucumber’, ‘production’)



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

def disabled_polling_environments
  @disabled_polling_environments
end

#disabled_reloading_environmentsObject

The names of environments where I18n.reload isn’t called for each request (defaults to ‘test’, ‘cucumber’, ‘production’)



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

def disabled_reloading_environments
  @disabled_reloading_environments
end

#disabled_sending_environmentsObject

The names of environments where notifications aren’t sent (defaults to ‘test’, ‘cucumber’, ‘production’)



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

def disabled_sending_environments
  @disabled_sending_environments
end

#environment_nameObject

The name of the environment the application is running in



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

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.



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

def http_auth_password
  @http_auth_password
end

#http_auth_usernameObject

Returns the value of attribute http_auth_username.



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

def http_auth_username
  @http_auth_username
end

#loggerObject

The logger used by Localeapp



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

def logger
  @logger
end

#poll_intervalObject

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



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

def poll_interval
  @poll_interval
end

#portObject

The port to connect to (defaults to 80)



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

def port
  @port
end

#project_rootObject

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



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

def project_root
  @project_root
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



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

def synchronization_data_file
  @synchronization_data_file
end

#translation_data_directoryObject

The complete path to the directory where translations are stored



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

def translation_data_directory
  @translation_data_directory
end

Instance Method Details

#polling_disabled?Boolean

Returns:

  • (Boolean)


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

def polling_disabled?
  disabled_polling_environments.include?(environment_name)
end

#reloading_disabled?Boolean

Returns:

  • (Boolean)


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

def reloading_disabled?
  disabled_reloading_environments.include?(environment_name)
end

#sending_disabled?Boolean

Returns:

  • (Boolean)


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

def sending_disabled?
  disabled_sending_environments.include?(environment_name)
end

#write_initial(path) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/localeapp/configuration.rb', line 77

def write_initial(path)
  dir = File.dirname(path)
  FileUtils.mkdir_p(dir)
  File.open(path, 'w+') do |file|
    file.write <<-CONTENT
require 'localeapp/rails'

Localeapp.configure do |config|
  config.api_key = '#{@api_key}'
  config.host = '#{@host}'
  config.port = #{@port}
end
CONTENT
  end
end