Skip to content

Commit

Permalink
Version 8.0.0.rc1 (#28)
Browse files Browse the repository at this point in the history
* v8, first draft

* docs for v8

* v8.0.0.rc1 is ready
  • Loading branch information
bodrovis authored Jul 20, 2023
1 parent 2525015 commit e90eead
Show file tree
Hide file tree
Showing 646 changed files with 16,326 additions and 16,647 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,25 @@ jobs:
matrix:
os: [ubuntu-latest]
ruby:
- 2.7
- '3.0'
- 3.1
- 3.2
runs-on: ${{ matrix.os }}
env:
LOKALISE_API_TOKEN: 123abc
LOKALISE_PROJECT_ID: 672198945b7d72fc048021.15940510
OAUTH2_CLIENT_ID: fake
OAUTH2_CLIENT_SECRET: fake
OAUTH2_TOKEN: fake
OAUTH2_REFRESH_TOKEN: fake
OAUTH2_CODE: fake
OAUTH2_TOKEN_REFRESHED: fake
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake spec
- run: bundle exec rake spec
- name: Coveralls
uses: coverallsapp/github-action@v2
49 changes: 18 additions & 31 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ AllCops:
TargetRubyVersion: 2.7
NewCops: enable

Layout/SpaceInsideHashLiteralBraces:
EnforcedStyle: no_space

Metrics/BlockLength:
Max: 36
Exclude:
- spec/**/*.rb

Metrics/BlockNesting:
Max: 2

Layout/LineLength:
AllowURI: true
Exclude:
Expand All @@ -27,35 +24,15 @@ Metrics/MethodLength:
CountComments: false
Max: 10

Metrics/ModuleLength:
Max: 150

Metrics/ClassLength:
Max: 150

Metrics/ParameterLists:
Max: 5
Max: 4
CountKeywordArgs: true

Style/CollectionMethods:
Enabled: true
PreferredMethods:
collect: 'map'
collect!: 'map!'
inject: 'reduce'
find: 'detect'
find_all: 'select'
delete: 'gsub'

Style/Documentation:
Enabled: false
Exclude:
- ./lib/ruby_lokalise_api/rest/segments.rb

Layout/DotPosition:
EnforcedStyle: trailing

Layout/AccessModifierIndentation:
Enabled: false

Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: 'no_comma'

Expand All @@ -68,11 +45,21 @@ RSpec/MultipleExpectations:
RSpec/ExampleLength:
Max: 35

RSpec/FilePath:
Style/Documentation:
Enabled: false

RSpec/MessageSpies:
EnforcedStyle: receive
RSpec/FilePath:
CustomTransform:
OAuth2: oauth2
OAuth2Client: oauth2_client
OAuth2Token: oauth2_token
OAuth2RefreshedToken: oauth2_refreshed_token

Gemspec/DevelopmentDependencies:
EnforcedStyle: gemspec
Exclude:
- ./docs/Gemfile

RSpec/MultipleMemoizedHelpers:
Max: 10
Exclude:
- ./spec/lib/ruby_lokalise_api/resources/project_spec.rb
2 changes: 1 addition & 1 deletion docs/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ gem 'minima', '~> 2.0'

# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
gem 'github-pages', '~> 227', group: :jekyll_plugins
gem 'github-pages', '~> 228', group: :jekyll_plugins

# If you have any plugins, put them here!
group :jekyll_plugins do
Expand Down
4 changes: 2 additions & 2 deletions docs/_data/api_items.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
- title: JWT
path: jwt
sub_paths:
- title: Get OTA JWT
path: get-ota-jwt
- title: Create JWT
path: create-jwt
- title: Translation keys
path: keys
sub_paths:
Expand Down
71 changes: 71 additions & 0 deletions docs/additional_info/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,76 @@
# Changelog

## 8.0.0

In this version **SDK has been fully rewritten** to make it more robust, better tested, and even more comfortable to work with. While most of the methods have similar signatures, there are a few major changes.

Breaking changes:

* Method `translation_statuses` has been renamed to `custom_translation_statuses`
* Method `translation_status` has been renamed to `custom_translation_status`
* Method `create_translation_status` has been renamed to `create_custom_translation_status`
* Method `update_translation_status` has been renamed to `update_custom_translation_status`
* Method `destroy_translation_status` has been renamed to `destroy_custom_translation_status`
* Method `translation_status_colors` has been renamed to `custom_translation_status_colors`
* Method `language` has been renamed to `project_language`
* Method `create_languages` has been renamed to `create_project_languages`
* Method `update_language` has been renamed to `update_project_language`
* Method `destroy_language` has been renamed to `destroy_project_language`
* Method `destroy_all` has been removed from `Keys` collection
* Method `jwt` has been renamed to `create_jwt`:

```ruby
token = @client.create_jwt project_id, service: :ota

token.jwt # => '123abcd'
```

* `raw_data` method has been removed. All resources respond to the methods named after the corresponding attributes and also support `[]` notation. Therefore both versions should work:

```ruby
branch = @client.branch project_id, branch_id

branch.name # => 'my-branch'
branch[:name] # => 'my-branch'
```

Updates:

* Added many new instance methods like `update`, `destroy`, and `reload_data`.

```ruby
params = {
lang_name: 'Updated custom language',
plural_forms: %w[one many]
}

language = @client.project_language project_id, language_id

updated_language = language.update params

updated_language.lang_name # => 'Updated custom language'
```

* Individual projects now respond to many new methods like `merge_branch`, `restore_snapshot`, and so on. Please browse documentation for a specific endpoint to learn about new features.

```ruby
project = @client.project project_id

restored_project = project.restore_snapshot snapshot_id

restored_project.name # => 'Project copy'
```

* Methods like `destroy` now return objects, not hashes. However, these objects also respond to the `[]` method to preserve backwards compatibility.

```ruby
response = @client.destroy_screenshot project_id, screen_id
response.screenshot_deleted # => true
response[:screenshot_deleted] # => true
```

* Test only with Ruby 3+ (though the SDK should still work with version 2.7+). Next major version will require Ruby 3+.

## 7.2.0 (11-Jan-2023)

* Updated the `jwt` method. It is now mandatory to provide the project ID to request JWT for:
Expand Down
4 changes: 1 addition & 3 deletions docs/additional_info/exception_handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,4 @@ The gem may raise the following custom exceptions:

## API Rate Limits

[Access to all endpoints is limited](https://developers.lokalise.com/reference/api-rate-limits) to 6 requests per second from 14 September, 2021. This limit is applied per API token and per IP address. If you exceed the limit, a 429 HTTP status code will be returned and the corresponding exception will be raised that you should handle properly. To handle such errors, we recommend an exponential backoff mechanism with a limited number of retries. You can use [lokalise_rails backoff mechanism](https://github.com/bodrovis/lokalise_rails/blob/master/lib/lokalise_rails/task_definition/base.rb#L63) as an example.

Only one concurrent request per token is allowed.
[Access to all endpoints is limited](https://developers.lokalise.com/reference/api-rate-limits) to 6 requests per second from 14 September, 2021. This limit is applied per API token and per IP address. If you exceed the limit, a 429 HTTP status code will be returned and the corresponding exception will be raised that you should handle properly. To handle such errors, we recommend an exponential backoff mechanism with a limited number of retries. You can use [lokalise_rails backoff mechanism](https://github.com/bodrovis/lokalise_rails/blob/master/lib/lokalise_rails/task_definition/base.rb#L63) as an example.
8 changes: 6 additions & 2 deletions docs/additional_info/oauth2.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The `auth` method returns a URL looking like this:
https://app.lokalise.com/oauth2/auth?client_id=12345&scope=read_projects
```

Your customers have to visit this URL and allow access to proceed. After allowing access, the customer will be presented with a secret code that has to be used in the following step.
**Your customers have to visit this URL and allow access to proceed**. After allowing access, the customer will be presented with a secret code that has to be used in the following step.

## Generating OAuth 2 token

Expand Down Expand Up @@ -80,4 +80,8 @@ require 'ruby_lokalise_api'

This is because with OAuth2 tokens, a different authorization header must be sent.

Now you can send requests on the user's behalf!
Now you can send requests on the user's behalf!

```ruby
projects = @client.projects page: 2, limit: 3
```
Loading

0 comments on commit e90eead

Please sign in to comment.