Class: I18n::Migrations::Backends::CrowdTranslateClient
- Inherits:
-
Object
- Object
- I18n::Migrations::Backends::CrowdTranslateClient
- Defined in:
- lib/i18n/migrations/backends/crowd_translate_client.rb
Instance Method Summary collapse
- #get_locale_file(locale_code) ⇒ Object
- #get_migration_versions ⇒ Object
-
#initialize ⇒ CrowdTranslateClient
constructor
A new instance of CrowdTranslateClient.
- #put_locale(locale_code, name:, yaml_file:, yaml_metadata_file:) ⇒ Object
- #put_migration(version:, ruby_file:) ⇒ Object
Constructor Details
#initialize ⇒ CrowdTranslateClient
Returns a new instance of CrowdTranslateClient.
11 12 13 14 15 16 17 |
# File 'lib/i18n/migrations/backends/crowd_translate_client.rb', line 11 def initialize token = ENV['CROWD_TRANSLATE_API_TOKEN'] raise("You must define CROWD_TRANSLATE_API_TOKEN in order to talk to Crowd Translate") unless token.present? @server = ENV['CROWD_TRANSLATE_SERVER'] || 'https://crowd-translate.herokuapp.com' @faraday = Faraday.new(url: base_url, headers: { 'X-CrowdTranslateApiToken' => token }) end |
Instance Method Details
#get_locale_file(locale_code) ⇒ Object
19 20 21 |
# File 'lib/i18n/migrations/backends/crowd_translate_client.rb', line 19 def get_locale_file(locale_code) get("locales/#{locale_code}.yml") end |
#get_migration_versions ⇒ Object
23 24 25 |
# File 'lib/i18n/migrations/backends/crowd_translate_client.rb', line 23 def get_migration_versions JSON.parse(get('migrations.json')) end |
#put_locale(locale_code, name:, yaml_file:, yaml_metadata_file:) ⇒ Object
31 32 33 34 |
# File 'lib/i18n/migrations/backends/crowd_translate_client.rb', line 31 def put_locale(locale_code, name:, yaml_file:, yaml_metadata_file:) put("locales/#{locale_code}", locale: { name: name, yaml_file: yaml_file, yaml_metadata_file: }) end |
#put_migration(version:, ruby_file:) ⇒ Object
27 28 29 |
# File 'lib/i18n/migrations/backends/crowd_translate_client.rb', line 27 def put_migration(version:, ruby_file:) put("migrations/#{version}.json", migration: { ruby_file: ruby_file }) end |