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/cli/add.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/i18n_shim.rb,
lib/localeapp/api_caller.rb,
lib/localeapp/cli/daemon.rb,
lib/localeapp/cli/remove.rb,
lib/localeapp/cli/rename.rb,
lib/localeapp/cli/update.rb,
lib/localeapp/cli/command.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, LocaleappError, MissingTranslationRecord, MissingTranslations, Poller, PotentiallyInsecureYaml, Sender, Updater
Constant Summary collapse
- API_VERSION =
"1"
- LOG_PREFIX =
"** [Localeapp] "
- VERSION =
"0.6.9"
- I18nMissingTranslationException =
I18n::MissingTranslationData
Class Attribute Summary collapse
-
.configuration ⇒ Object
An Localeapp configuration object.
-
.missing_translations ⇒ Object
readonly
The missing_translations object is responsible for keeping track of missing translations that will be sent to the backend.
-
.poller ⇒ Object
The poller object is responsible for retrieving data for the Localeapp server.
-
.sender ⇒ Object
The sender object is responsible for delivering formatted data to the Localeapp server.
-
.updater ⇒ Object
The updater object is responsible for merging translations into the i18n backend.
Class Method Summary collapse
-
.configure {|configuration| ... } ⇒ Object
Localeapp.configure do |config| config.api_key = ‘1234567890abcdef’ end.
- .debug(message) ⇒ Object
- .default_config_file_paths ⇒ Object
- .has_config_file? ⇒ Boolean
- .load_yaml(contents) ⇒ Object
- .load_yaml_file(filename) ⇒ Object
-
.log(message) ⇒ Object
Writes out the given message to the #logger.
- .log_with_time(message) ⇒ Object
-
.logger ⇒ Object
Look for the Rails logger currently defined.
Class Attribute Details
.configuration ⇒ Object
An Localeapp configuration object.
62 63 64 |
# File 'lib/localeapp.rb', line 62 def configuration @configuration end |
.missing_translations ⇒ Object (readonly)
The missing_translations object is responsible for keeping track of missing translations that will be sent to the backend
75 76 77 |
# File 'lib/localeapp.rb', line 75 def missing_translations @missing_translations end |
.poller ⇒ Object
The poller object is responsible for retrieving data for the Localeapp server
68 69 70 |
# File 'lib/localeapp.rb', line 68 def poller @poller end |
.sender ⇒ Object
The sender object is responsible for delivering formatted data to the Localeapp server.
65 66 67 |
# File 'lib/localeapp.rb', line 65 def sender @sender end |
.updater ⇒ Object
The updater object is responsible for merging translations into the i18n backend
71 72 73 |
# File 'lib/localeapp.rb', line 71 def updater @updater end |
Class Method Details
.configure {|configuration| ... } ⇒ Object
Localeapp.configure do |config|
config.api_key = '1234567890abcdef'
end
100 101 102 103 104 105 106 107 |
# File 'lib/localeapp.rb', line 100 def configure self.configuration ||= Configuration.new yield(configuration) if block_given? self.sender = Sender.new self.poller = Poller.new self.updater = Updater.new @missing_translations = MissingTranslations.new end |
.debug(message) ⇒ Object
87 88 89 |
# File 'lib/localeapp.rb', line 87 def debug() logger.debug(LOG_PREFIX + ) if logger end |
.default_config_file_paths ⇒ Object
113 114 115 116 117 118 |
# File 'lib/localeapp.rb', line 113 def default_config_file_paths [ File.join(Dir.pwd, '.localeapp', 'config.rb'), File.join(Dir.pwd, 'config', 'initializers', 'localeapp.rb') ] end |
.has_config_file? ⇒ Boolean
109 110 111 |
# File 'lib/localeapp.rb', line 109 def has_config_file? default_config_file_paths.any? { |path| File.exists?(path) } end |
.load_yaml(contents) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/localeapp.rb', line 120 def load_yaml(contents) if Localeapp.configuration.raise_on_insecure_yaml raise Localeapp::PotentiallyInsecureYaml if contents =~ /!ruby\// end if defined?(Psych) && defined?(Psych::VERSION) Psych.load(contents) else normalize_results(YAML.load(contents)) end end |
.load_yaml_file(filename) ⇒ Object
132 133 134 |
# File 'lib/localeapp.rb', line 132 def load_yaml_file(filename) load_yaml(File.read(filename)) end |
.log(message) ⇒ Object
Writes out the given message to the #logger
79 80 81 |
# File 'lib/localeapp.rb', line 79 def log() logger.info LOG_PREFIX + if logger end |
.log_with_time(message) ⇒ Object
83 84 85 |
# File 'lib/localeapp.rb', line 83 def log_with_time() log [Time.now.to_i, ].join(' - ') end |
.logger ⇒ Object
Look for the Rails logger currently defined
92 93 94 |
# File 'lib/localeapp.rb', line 92 def logger self.configuration && self.configuration.logger end |