Skip to content

Commit

Permalink
SRUBY-6 Task_id for Translation, code updates (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
bodrovis authored Apr 28, 2021
1 parent 7848311 commit a1bdb6a
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 38 deletions.
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
language: ruby

rvm:
- 2.5.8
- 2.6.6
- 2.7.2
- 3.0.0
- 2.6.7
- 2.7.3
- 3.0.1

install: bundle install --retry=3

Expand Down
6 changes: 6 additions & 0 deletions docs/additional_info/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 4.2.0 (28-Apr-21)

* Added a `task_id` attribute for the `Translation` model
* Drop official support for Ruby 2.5 which has reached the EOL
* Minor code updates

## 4.1.0 (01-Mar-21)

* Added `payment_method` and `dry_run` attributes to `Order`
Expand Down
4 changes: 3 additions & 1 deletion docs/api/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ Starting from July 2020, **background uploading is the only method of importing
## QueuedProcess resource
```

A `QueuedProcess` resource will be returned. This resource contains a status of the import job, process ID to manually check the status, and some other attributes:
To encode your data in Base64, use `Base64.strict_encode64()` method.

After the uploading process is completed, a `QueuedProcess` resource will be returned. This resource contains a status of the import job, process ID to manually check the status, and some other attributes:

```ruby
queued_process = @client.upload_file project_id,
Expand Down
3 changes: 2 additions & 1 deletion lib/ruby-lokalise-api/data/attributes.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@
"is_fuzzy",
"is_reviewed",
"words",
"custom_translation_statuses"
"custom_translation_statuses",
"task_id"
],
"translation_provider": [
"provider_id",
Expand Down
3 changes: 2 additions & 1 deletion lib/ruby-lokalise-api/rest/files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def download_files(project_id, params)
c_r Lokalise::Resources::File, :download, [project_id, 'download'], params
end

# Imports translation file to the given project. File data must base64-encoded
# Imports translation file to the given project. File data must base64-encoded.
# To encode your data in Base64, use `Base64.strict_encode64()` method.
#
# @see https://app.lokalise.com/api2docs/curl/#transition-upload-a-file-post
# @return [Hash]
Expand Down
4 changes: 1 addition & 3 deletions lib/ruby-lokalise-api/utils/attribute_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ def id_key_for(model_class)
#
# @return [Array<String>]
def attributes_for(klass)
@attributes ||= begin
YAML.load_file(File.expand_path('../data/attributes.json', __dir__)).freeze
end
@attributes ||= YAML.load_file(File.expand_path('../data/attributes.json', __dir__)).freeze

name = unify klass.name.snakecase
@attributes[name]
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby-lokalise-api/utils/string_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ def base_class_name
end

def remove_trailing_slash
gsub %r{/\z}, ''
delete_suffix '/'
end
end
2 changes: 1 addition & 1 deletion lib/ruby-lokalise-api/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Lokalise
VERSION = '4.1.0'
VERSION = '4.2.0'
end
39 changes: 22 additions & 17 deletions spec/fixtures/vcr_cassettes/translation.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions spec/lib/ruby-lokalise-api/rest/translations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,27 @@

specify '#translation' do
translation = VCR.use_cassette('translation') do
test_client.translation project_id, translation_id
test_client.translation project_id, 304_581_218
end

expect(translation.translation_id).to eq(translation_id)
expect(translation.key_id).to eq(15_571_975)
expect(translation.language_iso).to eq('en')
expect(translation.modified_at).to eq('2019-03-26 16:41:31 (Etc/UTC)')
expect(translation.modified_at_timestamp).to eq(1_553_618_491)
expect(translation.translation_id).to eq(304_581_218)
expect(translation.key_id).to eq(44_596_059)
expect(translation.language_iso).to eq('ru')
expect(translation.modified_at).to eq('2020-05-15 10:44:42 (Etc/UTC)')
expect(translation.modified_at_timestamp).to eq(1_589_539_482)
expect(translation.modified_by).to eq(20_181)
expect(translation.modified_by_email).to eq('[email protected]')
expect(translation.translation).to eq('RSpec is a testing suite')
expect(translation.translation).to eq('Сообщение')
expect(translation.is_fuzzy).to eq(false)
expect(translation.is_reviewed).to eq(false)
expect(translation.words).to eq(5)
expect(translation.words).to eq(1)
expect(translation.custom_translation_statuses).to eq([])
expect(translation.task_id).to be_nil
end

specify '#reload_data' do
translation = VCR.use_cassette('translation') do
test_client.translation project_id, translation_id
test_client.translation project_id, 304_581_218
end

reloaded_translation = VCR.use_cassette('translation') do
Expand Down

0 comments on commit a1bdb6a

Please sign in to comment.