Module: Localeapp

Defined in:
lib/localeapp.rb,
lib/localeapp/rails.rb,
lib/localeapp/poller.rb,
lib/localeapp/routes.rb,
lib/localeapp/sender.rb,
lib/localeapp/updater.rb,
lib/localeapp/version.rb,
lib/localeapp/api_call.rb,
lib/localeapp/cli/pull.rb,
lib/localeapp/cli/push.rb,
lib/localeapp/api_caller.rb,
lib/localeapp/cli/update.rb,
lib/localeapp/cli/install.rb,
lib/localeapp/key_checker.rb,
lib/localeapp/configuration.rb,
lib/localeapp/rails/controller.rb,
lib/localeapp/exception_handler.rb,
lib/localeapp/missing_translations.rb

Defined Under Namespace

Modules: ApiCall, CLI, Rails, Routes, TranslationHelperMonkeyPatch Classes: ApiCaller, Configuration, ExceptionHandler, KeyChecker, MissingTranslationRecord, MissingTranslations, Poller, Sender, Updater

Constant Summary collapse

API_VERSION =
"1"
LOG_PREFIX =
"** [Localeapp] "
VERSION =
"0.0.10"
I18nMissingTranslationException =
I18n::MissingTranslationData

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject

An Localeapp configuration object.



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

def configuration
  @configuration
end

.missing_translationsObject (readonly)

The missing_translations object is responsible for keeping track of missing translations that will be sent to the backend



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

def missing_translations
  @missing_translations
end

.pollerObject

The poller object is responsible for retrieving data for the Localeapp server



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

def poller
  @poller
end

.senderObject

The sender object is responsible for delivering formatted data to the Localeapp server.



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

def sender
  @sender
end

.updaterObject

The updater object is responsible for merging translations into the i18n backend



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

def updater
  @updater
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Localeapp.configure do |config|

config.api_key = '1234567890abcdef'

end

Examples:

Configuration

Yields:



87
88
89
90
91
92
93
94
# File 'lib/localeapp.rb', line 87

def configure
  self.configuration ||= Configuration.new
  yield(configuration)
  self.sender  = Sender.new
  self.poller  = Poller.new
  self.updater = Updater.new
  @missing_translations = MissingTranslations.new
end

.debug(message) ⇒ Object



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

def debug(message)
  logger.debug(LOG_PREFIX + message) if logger
end

.include_config_file(file_path = nil) ⇒ Object

requires the Localeapp configuration



97
98
99
100
101
102
103
104
105
# File 'lib/localeapp.rb', line 97

def include_config_file(file_path=nil)
  file_path ||= File.join(Dir.pwd, 'config', 'initializers', 'localeapp')
  begin
    require file_path
    true
  rescue
    false
  end
end

.log(message) ⇒ Object

Writes out the given message to the #logger



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

def log(message)
  logger.info LOG_PREFIX + message if logger
end

.loggerObject

Look for the Rails logger currently defined



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

def logger
  self.configuration && self.configuration.logger
end