lokalise_manager 2.1.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3a7da094cb7939fd6826c89afbbbc525dff59b553a23fba7b49ed38046e68b9
4
- data.tar.gz: c0a323464c864d12042f126d765a483adc128a4397604d012cdeadee31003fcf
3
+ metadata.gz: 71731c95118ae4f31be9e82b256aa2cc17094a0ab64b5a186b95cb37843fec52
4
+ data.tar.gz: d8cbbfd4d60926f2f62323e0908addacf218425fc7e2b579d2f748d0e9acdf93
5
5
  SHA512:
6
- metadata.gz: 79c0b5a93767b5ffa8cd55dbf6591a90cafbb586043e8e75ca040761b8fa882882971783358e6d342afab96e298d34c67ca5d414d376c909fa564e8ad03d2466
7
- data.tar.gz: ed2ad8e59fb6e15db8ba7c60de48e808c2eab0ff94b8f287c54bb2e618e1c930d5d3244a2483a6e61e69b7094943a05db59ea54ef32fc3596ef344f5956553ee
6
+ metadata.gz: d457a5a7e4f703b80c3780e1a35e75278671c78f9caa0464bb0488352fa2772500e9f4f921446f8a3b51e9240fd229b1935705ba5b86263cb9e20bd27eab274d
7
+ data.tar.gz: 7053cf881bee4814dd67f17238557f7e19a0f6dc96109cf88700845018110c083612477eb15b49643d2459332d7e6abbd705cfe9322d36aa4735d7e73bcf887c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.1.0 (17-Aug-22)
4
+
5
+ * The default format is now `ruby_yaml` (it used to be `yaml`)
6
+
7
+ ## 3.0.0 (11-Mar-22)
8
+
9
+ * **Breaking change**: Require Ruby 2.7 or above
10
+ * **Breaking change (potentially)**: Use ruby-lokalise-api v6. In general, this transition should not affect you if you employ `export!` and `import!` methods only. However, please be aware that ruby-lokalise-api has a few breaking changes [listed in its own changelog](https://lokalise.github.io/ruby-lokalise-api/additional_info/changelog)
11
+ * Use Zeitwerk loader
12
+ * Prettify and update source code
13
+
14
+ ## 2.2.0 (23-Feb-22)
15
+
16
+ * Use ruby-lokalise-api v5
17
+ * Don't use any compression options (compression is now enabled by default)
18
+ * Update tests
19
+
3
20
  ## 2.1.0 (27-Jan-22)
4
21
 
5
22
  * **Breaking change**: `export!` will now return an array of objects responding to the following methods:
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 Lokalise team, Ilya Bodrov
3
+ Copyright (c) 2022 Lokalise team, Ilya Krukowski
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -43,7 +43,7 @@ importer = LokaliseManager.importer api_token: '1234abc', project_id: '123.abc'
43
43
  exporter = LokaliseManager.exporter api_token: '1234abc', project_id: '123.abc'
44
44
  ```
45
45
 
46
- You *must* provide an API token and a project ID (your project ID can be found under Lokalise project settings). [Other options can be customized as well (see below)](https://github.com/bodrovis/lokalise_manager#configuration) but they have sensible defaults.
46
+ You *must* provide an API token and a project ID (your project ID can be found under Lokalise project settings). [Other options can be customized as well (see below)](#configuration) but they have sensible defaults.
47
47
 
48
48
  ### Importing files from Lokalise into your project
49
49
 
@@ -55,7 +55,7 @@ result = importer.import!
55
55
 
56
56
  The `result` will contain a boolean value which says whether the operation was successfull or not.
57
57
 
58
- Please note that upon importing translations any duplicating files inside the `locales` directory (or any other directory that you've specified in the options) will be overwritten! You can enable [safe mode](https://github.com/bodrovis/lokalise_manager#import-config) to check whether the folder is empty or not.
58
+ Please note that upon importing translations any duplicating files inside the `locales` directory (or any other directory that you've specified in the options) **will be overwritten**! You can enable [safe mode](#import-config) to check whether the folder is empty or not.
59
59
 
60
60
  ### Exporting files from your project to Lokalise
61
61
 
@@ -65,19 +65,21 @@ To upload your translation files from a local directory (defaults to `locales/`)
65
65
  processes = exporter.export!
66
66
  ```
67
67
 
68
+ The uploading process is multi-threaded.
69
+
68
70
  `processes` will contain an array of objects responding to the following methods:
69
71
 
70
- * `success` — usually returns `true` (to learn more, check documentation for the `:raise_on_export_fail` option below)
71
- * `process` — returns an object (an instance of the `Lokalise::Resources::QueuedProcess`) representing a [queued background process](https://lokalise.github.io/ruby-lokalise-api/api/queued-processes) as uploading is done in the background on Lokalise.
72
- * `path` — returns an instance of the `Pathname` class which represent the file being uploaded.
72
+ * `#success` — usually returns `true` (to learn more, check documentation for the `:raise_on_export_fail` option below)
73
+ * `#process` — returns an object (an instance of the `RubyLokaliseApi::Resources::QueuedProcess`) representing a [queued background process](https://lokalise.github.io/ruby-lokalise-api/api/queued-processes) as uploading is done in the background on Lokalise.
74
+ * `#path` — returns an instance of the `Pathname` class which represent the file being uploaded.
73
75
 
74
76
  You can perform periodic checks to read the status of the process. Here's a very simple example:
75
77
 
76
78
  ```ruby
77
79
  def uploaded?(process)
78
80
  5.times do # try to check the status 5 times
79
- process = process.reload_data # load new data
80
- return(true) if process.status == 'finished' # return true is the upload has finished
81
+ process = process.reload_data # load new info about this process
82
+ return(true) if process.status == 'finished' # return true if the upload has finished
81
83
  sleep 1 # wait for 1 second, adjust this number with regards to the upload size
82
84
  end
83
85
 
@@ -109,7 +111,7 @@ Please don't forget that Lokalise API has rate limiting and you cannot send more
109
111
 
110
112
  ```ruby
111
113
  {
112
- format: 'yaml',
114
+ format: 'ruby_yaml',
113
115
  placeholder_format: :icu,
114
116
  yaml_include_root: true,
115
117
  original_filenames: true,
@@ -118,7 +120,7 @@ Please don't forget that Lokalise API has rate limiting and you cannot send more
118
120
  }
119
121
  ```
120
122
 
121
- Full list of available import options [can be found in the official API documentation](https://app.lokalise.com/api2docs/curl/#transition-download-files-post).
123
+ Full list of available import options [can be found in the official API documentation](https://developers.lokalise.com/reference/download-files).
122
124
 
123
125
  You can provide additional options, and they will be merged with the default ones. For example:
124
126
 
@@ -133,15 +135,15 @@ In this case the `import_opts` will have `original_filenames` set to `true` and
133
135
  ```ruby
134
136
  importer = LokaliseManager.importer api_token: '1234abc',
135
137
  project_id: '123.abc',
136
- import_opts: {indentation: '4sp}
138
+ import_opts: {indentation: '4sp'}
137
139
  ```
138
140
 
139
141
  * `import_safe_mode` (`boolean`) — default to `false`. When this option is enabled, the import task will check whether the directory set with `locales_path` is empty or not. If it is not empty, you will be prompted to continue.
140
- * `max_retries_import` (`integer`) — this option is introduced to properly handle Lokalise API rate limiting. If the HTTP status code 429 (too many requests) has been received, this gem will apply an exponential backoff mechanism with a very simple formula: `2 ** retries`. If the maximum number of retries has been reached, a `Lokalise::Error::TooManyRequests` exception will be raised and the operation will be halted.
142
+ * `max_retries_import` (`integer`) — this option is introduced to properly handle Lokalise API rate limiting. If the HTTP status code 429 (too many requests) has been received, this gem will apply an exponential backoff mechanism with a very simple formula: `2 ** retries`. If the maximum number of retries has been reached, a `RubyLokaliseApi::Error::TooManyRequests` exception will be raised and the operation will be halted.
141
143
 
142
144
  ### Export config
143
145
 
144
- * `export_opts` (`hash`) — options that will be passed to Lokalise API when uploading translations. Full list of available export options [can be found in the official documentation](https://app.lokalise.com/api2docs/curl/#transition-upload-a-file-post). By default, the following options are provided:
146
+ * `export_opts` (`hash`) — options that will be passed to Lokalise API when uploading translations. Full list of available export options [can be found in the official documentation](https://developers.lokalise.com/reference/upload-a-file). By default, the following options are provided:
145
147
  + `data` (`string`, required) — base64-encoded contents of the translation file.
146
148
  + `filename` (`string`, required) — translation file name. If the file is stored under a subdirectory (for example, `nested/en.yml` inside the `locales/` directory), the whole path acts as a name. Later when importing files with such names, they will be placed into the proper subdirectories.
147
149
  + `lang_iso` (`string`, required) — language ISO code which is determined using the root key inside your YAML file. For example, in this case the `lang_iso` is `en_US`:
@@ -169,7 +171,7 @@ In this case the `export_opts` will have `detect_icu_plurals` set to `true` and
169
171
  c.skip_file_export = ->(file) { f.split[1].to_s.include?('fr') }
170
172
  ```
171
173
 
172
- * `max_retries_export` (`integer`) — this option is introduced to properly handle Lokalise API rate limiting. If the HTTP status code 429 (too many requests) has been received, LokaliseRails will apply an exponential backoff mechanism with a very simple formula: `2 ** retries` (initially `retries` is `0`). If the maximum number of retries has been reached, a `Lokalise::Error::TooManyRequests` exception will be raised and the export operation will be halted. By default, LokaliseManager will make up to `5` retries which potentially means `1 + 2 + 4 + 8 + 16 + 32 = 63` seconds of waiting time. If the `max_retries_export` is less than `1`, LokaliseRails will not perform any retries and give up immediately after receiving error 429.
174
+ * `max_retries_export` (`integer`) — this option is introduced to properly handle Lokalise API rate limiting. If the HTTP status code 429 (too many requests) has been received, LokaliseManager will apply an exponential backoff mechanism with a very simple formula: `2 ** retries` (initially `retries` is `0`). If the maximum number of retries has been reached, a `RubyLokaliseApi::Error::TooManyRequests` exception will be raised and the export operation will be halted. By default, LokaliseManager will make up to `5` retries which potentially means `1 + 2 + 4 + 8 + 16 + 32 = 63` seconds of waiting time. If the `max_retries_export` is less than `1`, LokaliseManager will not perform any retries and give up immediately after receiving error 429.
173
175
  * `raise_on_export_fail` (`boolean`) — default is `true`. When this option is enabled, LokaliseManager will re-raise any exceptions that happened during the file uploading. In other words, if any uploading thread raised an exception, your exporting process will exit with an exception. Suppose, you are uploading 12 translation files; these files will be split in 2 groups with 6 files each, and each group will be uploaded in parallel (using threads). However, suppose some exception happens when uploading the first group. By default this exception will be re-raised for the whole process and the script will never try to upload the second group. If you would like to continue uploading even if an exception happened, set the `raise_on_export_fail` to `false`. In this case the `export!` method will return an array with scheduled processes and with information about processes that were not successfully scheduled. This information is represented as an object with three methods: `path` (contains an instance of the `Pathname` class which says which file could not be uploaded), `error` (the actual exception), and `success` (returns `false`). So, you can use the following snippet to check your processes:
174
176
 
175
177
  ```ruby
@@ -222,7 +224,7 @@ importer = LokaliseManager.importer api_token: '1234abc',
222
224
 
223
225
  These options will be merged with the default ones. Please note that per-client config has the highest priority.
224
226
 
225
- You can also adjust individual options later using the `#config` instance variable (it contains an OpenStruct object):
227
+ You can also adjust individual options later using the `#config` instance variable (it contains a Struct object):
226
228
 
227
229
  ```
228
230
  importer.config.project_id = '678xyz'
@@ -300,4 +302,4 @@ importer.import!
300
302
 
301
303
  ## License
302
304
 
303
- Copyright (c) [Lokalise team](http://lokalise.com), [Ilya Bodrov](http://bodrovis.tech). License type is [MIT](https://github.com/bodrovis/lokalise_manager/blob/master/LICENSE).
305
+ Copyright (c) [Lokalise team](http://lokalise.com), [Ilya Krukowski](http://bodrovis.tech). License type is [MIT](https://github.com/bodrovis/lokalise_manager/blob/master/LICENSE).
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LokaliseManager
4
+ # LokaliseManager error class, subclass of StandardError
4
5
  class Error < StandardError
5
6
  # Initializes a new Error object
6
7
  def initialize(message = '')
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LokaliseManager
4
+ # Global configuration options available for LokaliseManager
4
5
  class GlobalConfig
5
6
  class << self
6
7
  attr_accessor :api_token, :project_id
@@ -64,7 +65,7 @@ module LokaliseManager
64
65
  # Options for import rake task
65
66
  def import_opts
66
67
  @import_opts || {
67
- format: 'yaml',
68
+ format: 'ruby_yaml',
68
69
  placeholder_format: :icu,
69
70
  yaml_include_root: true,
70
71
  original_filenames: true,
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ruby-lokalise-api'
3
+ require 'ruby_lokalise_api'
4
4
  require 'pathname'
5
5
 
6
6
  module LokaliseManager
7
7
  module TaskDefinitions
8
+ # Base class for LokaliseManager task definitions that includes common methods and logic
8
9
  class Base
9
10
  using LokaliseManager::Utils::HashUtils
10
11
 
@@ -33,18 +34,18 @@ module LokaliseManager
33
34
 
34
35
  # Creates a Lokalise API client
35
36
  #
36
- # @return [Lokalise::Client]
37
+ # @return [RubyLokaliseApi::Client]
37
38
  def api_client
38
- client_opts = [config.api_token, {enable_compression: true}.merge(config.timeouts)]
39
- client_method = config.use_oauth2_token ? :oauth_client : :client
39
+ client_opts = [config.api_token, config.timeouts]
40
+ client_method = config.use_oauth2_token ? :oauth2_client : :client
40
41
 
41
- @api_client = ::Lokalise.send(client_method, *client_opts)
42
+ @api_client = ::RubyLokaliseApi.send(client_method, *client_opts)
42
43
  end
43
44
 
44
45
  # Resets API client
45
46
  def reset_api_client!
46
- ::Lokalise.reset_client!
47
- ::Lokalise.reset_oauth_client!
47
+ ::RubyLokaliseApi.reset_client!
48
+ ::RubyLokaliseApi.reset_oauth2_client!
48
49
  @api_client = nil
49
50
  end
50
51
 
@@ -94,7 +95,7 @@ module LokaliseManager
94
95
  retries = 0
95
96
  begin
96
97
  yield
97
- rescue Lokalise::Error::TooManyRequests => e
98
+ rescue RubyLokaliseApi::Error::TooManyRequests => e
98
99
  raise(e.class, "Gave up after #{retries} retries") if retries >= max_retries
99
100
 
100
101
  sleep 2**retries
@@ -4,9 +4,9 @@ require 'base64'
4
4
 
5
5
  module LokaliseManager
6
6
  module TaskDefinitions
7
+ # Exporter class is used when you want to upload translation files from your project to Lokalise
7
8
  class Exporter < Base
8
- using LokaliseManager::Utils::ArrayUtils
9
-
9
+ # Lokalise allows no more than 6 requests per second
10
10
  MAX_THREADS = 6
11
11
 
12
12
  # Performs translation file export to Lokalise and returns an array of queued processes
@@ -17,7 +17,7 @@ module LokaliseManager
17
17
 
18
18
  queued_processes = []
19
19
 
20
- all_files.in_groups_of(MAX_THREADS) do |files_group|
20
+ all_files.each_slice(MAX_THREADS) do |files_group|
21
21
  parallel_upload(files_group).each do |thr|
22
22
  raise_on_fail(thr) if config.raise_on_export_fail
23
23
 
@@ -33,13 +33,15 @@ module LokaliseManager
33
33
  private
34
34
 
35
35
  def parallel_upload(files_group)
36
- files_group.compact.map do |file_data|
36
+ files_group.map do |file_data|
37
37
  do_upload(*file_data)
38
38
  end.map(&:value)
39
39
  end
40
40
 
41
41
  def raise_on_fail(thread)
42
- raise(thread.error.class, "Error while trying to upload #{thread.path}: #{thread.error.message}") unless thread.success
42
+ return if thread.success
43
+
44
+ raise(thread.error.class, "Error while trying to upload #{thread.path}: #{thread.error.message}")
43
45
  end
44
46
 
45
47
  # Performs the actual file uploading to Lokalise. If the API rate limit is exceeed,
@@ -59,18 +61,16 @@ module LokaliseManager
59
61
 
60
62
  # Gets translation files from the specified directory
61
63
  def all_files
62
- files = []
63
64
  loc_path = config.locales_path
64
- Dir["#{loc_path}/**/*"].sort.each do |f|
65
+ Dir["#{loc_path}/**/*"].filter_map do |f|
65
66
  full_path = Pathname.new f
66
67
 
67
68
  next unless file_matches_criteria? full_path
68
69
 
69
70
  relative_path = full_path.relative_path_from Pathname.new(loc_path)
70
71
 
71
- files << [full_path, relative_path]
72
+ [full_path, relative_path]
72
73
  end
73
- files
74
74
  end
75
75
 
76
76
  # Generates export options
@@ -6,6 +6,7 @@ require 'fileutils'
6
6
 
7
7
  module LokaliseManager
8
8
  module TaskDefinitions
9
+ # Importer class is used when you want to download translation files from Lokalise into your project
9
10
  class Importer < Base
10
11
  # Performs translation files import from Lokalise
11
12
  #
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Taken from https://github.com/rails/rails/blob/83217025a171593547d1268651b446d3533e2019/activesupport/lib/active_support/core_ext/hash/deep_merge.rb
4
-
5
3
  module LokaliseManager
6
4
  module Utils
5
+ # Common helper methods for hashes
7
6
  module HashUtils
8
7
  refine Hash do
8
+ # Deeply merges two hashes
9
+ # Taken from https://github.com/rails/rails/blob/83217025a171593547d1268651b446d3533e2019/activesupport/lib/active_support/core_ext/hash/deep_merge.rb
9
10
  def deep_merge(other_hash, &block)
10
11
  dup.deep_merge!(other_hash, &block)
11
12
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LokaliseManager
4
- VERSION = '2.1.0'
4
+ VERSION = '3.1.0'
5
5
  end
@@ -1,17 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'zeitwerk'
3
4
  require 'yaml'
4
5
 
5
- require 'lokalise_manager/utils/hash_utils'
6
- require 'lokalise_manager/utils/array_utils'
7
-
8
- require 'lokalise_manager/version'
9
- require 'lokalise_manager/error'
10
- require 'lokalise_manager/global_config'
11
- require 'lokalise_manager/task_definitions/base'
12
- require 'lokalise_manager/task_definitions/importer'
13
- require 'lokalise_manager/task_definitions/exporter'
6
+ loader = Zeitwerk::Loader.for_gem
7
+ loader.setup
14
8
 
9
+ # LokaliseManager main module that exposes helper methods:
10
+ #
11
+ # importer = LokaliseManager.importer api_token: '1234abc', project_id: '123.abc'
12
+ # exporter = LokaliseManager.exporter api_token: '1234abc', project_id: '123.abc'
13
+ #
14
+ # Use the instantiated objects to import or export your translation files:
15
+ #
16
+ # importer.import!
17
+ # exporter.export!
18
+ #
15
19
  module LokaliseManager
16
20
  class << self
17
21
  # Initializes a new importer client which is used to download
@@ -5,26 +5,26 @@ require File.expand_path('lib/lokalise_manager/version', __dir__)
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'lokalise_manager'
7
7
  spec.version = LokaliseManager::VERSION
8
- spec.authors = ['Ilya Bodrov']
8
+ spec.authors = ['Ilya Krukowski']
9
9
  spec.email = ['golosizpru@gmail.com']
10
10
  spec.summary = 'Lokalise integration for Ruby'
11
11
  spec.description = 'This gem contains a collection of some common tasks for Lokalise. Specifically, it allows to import/export translation files from/to Lokalise TMS.'
12
12
  spec.homepage = 'https://github.com/bodrovis/lokalise_manager'
13
13
  spec.license = 'MIT'
14
14
  spec.platform = Gem::Platform::RUBY
15
- spec.required_ruby_version = '>= 2.5.0'
15
+ spec.required_ruby_version = '>= 2.7'
16
16
 
17
17
  spec.files = Dir['README.md', 'LICENSE',
18
18
  'CHANGELOG.md', 'lib/**/*.rb',
19
19
  'lib/**/*.rake',
20
20
  'lokalise_manager.gemspec', '.github/*.md',
21
21
  'Gemfile', 'Rakefile']
22
- spec.test_files = Dir['spec/**/*.rb']
23
22
  spec.extra_rdoc_files = ['README.md']
24
23
  spec.require_paths = ['lib']
25
24
 
26
- spec.add_dependency 'ruby-lokalise-api', '~> 4.0'
25
+ spec.add_dependency 'ruby-lokalise-api', '~> 6.0'
27
26
  spec.add_dependency 'rubyzip', '~> 2.3'
27
+ spec.add_dependency 'zeitwerk', '~> 2.4'
28
28
 
29
29
  spec.add_development_dependency 'codecov', '~> 0.2'
30
30
  spec.add_development_dependency 'dotenv', '~> 2.5'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lokalise_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - Ilya Bodrov
7
+ - Ilya Krukowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-27 00:00:00.000000000 Z
11
+ date: 2022-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-lokalise-api
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '6.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '4.0'
26
+ version: '6.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rubyzip
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: zeitwerk
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.4'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.4'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: codecov
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -187,21 +201,9 @@ files:
187
201
  - lib/lokalise_manager/task_definitions/base.rb
188
202
  - lib/lokalise_manager/task_definitions/exporter.rb
189
203
  - lib/lokalise_manager/task_definitions/importer.rb
190
- - lib/lokalise_manager/utils/array_utils.rb
191
204
  - lib/lokalise_manager/utils/hash_utils.rb
192
205
  - lib/lokalise_manager/version.rb
193
206
  - lokalise_manager.gemspec
194
- - spec/lib/lokalise_manager/global_config_spec.rb
195
- - spec/lib/lokalise_manager/task_definitions/base_spec.rb
196
- - spec/lib/lokalise_manager/task_definitions/exporter_spec.rb
197
- - spec/lib/lokalise_manager/task_definitions/importer_spec.rb
198
- - spec/lib/lokalise_manager_spec.rb
199
- - spec/lib/utils/array_utils_spec.rb
200
- - spec/lib/utils/hash_utils_spec.rb
201
- - spec/spec_helper.rb
202
- - spec/support/file_manager.rb
203
- - spec/support/spec_addons.rb
204
- - spec/support/vcr.rb
205
207
  homepage: https://github.com/bodrovis/lokalise_manager
206
208
  licenses:
207
209
  - MIT
@@ -215,26 +217,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
215
217
  requirements:
216
218
  - - ">="
217
219
  - !ruby/object:Gem::Version
218
- version: 2.5.0
220
+ version: '2.7'
219
221
  required_rubygems_version: !ruby/object:Gem::Requirement
220
222
  requirements:
221
223
  - - ">="
222
224
  - !ruby/object:Gem::Version
223
225
  version: '0'
224
226
  requirements: []
225
- rubygems_version: 3.3.5
227
+ rubygems_version: 3.3.19
226
228
  signing_key:
227
229
  specification_version: 4
228
230
  summary: Lokalise integration for Ruby
229
- test_files:
230
- - spec/lib/lokalise_manager/global_config_spec.rb
231
- - spec/lib/lokalise_manager/task_definitions/base_spec.rb
232
- - spec/lib/lokalise_manager/task_definitions/exporter_spec.rb
233
- - spec/lib/lokalise_manager/task_definitions/importer_spec.rb
234
- - spec/lib/lokalise_manager_spec.rb
235
- - spec/lib/utils/array_utils_spec.rb
236
- - spec/lib/utils/hash_utils_spec.rb
237
- - spec/spec_helper.rb
238
- - spec/support/file_manager.rb
239
- - spec/support/spec_addons.rb
240
- - spec/support/vcr.rb
231
+ test_files: []
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Taken from https://github.com/rails/rails/blob/6bfc637659248df5d6719a86d2981b52662d9b50/activesupport/lib/active_support/core_ext/array/grouping.rb
4
-
5
- module LokaliseManager
6
- module Utils
7
- module ArrayUtils
8
- refine Array do
9
- def in_groups_of(number, fill_with = nil, &block)
10
- if number.to_i <= 0
11
- raise ArgumentError,
12
- "Group size must be a positive integer, was #{number.inspect}"
13
- end
14
-
15
- if fill_with == false
16
- collection = self
17
- else
18
- padding = (number - (size % number)) % number
19
- collection = dup.concat(Array.new(padding, fill_with))
20
- end
21
-
22
- collection.each_slice(number, &block)
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,114 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe LokaliseManager::GlobalConfig do
4
- let(:fake_class) { class_double(described_class) }
5
-
6
- it 'is possible to provide config' do
7
- described_class.config do |c|
8
- expect(c).to eq(described_class)
9
- end
10
- end
11
-
12
- it 'is possible to set project_id' do
13
- allow(fake_class).to receive(:project_id=).with('123.abc')
14
- fake_class.project_id = '123.abc'
15
- end
16
-
17
- it 'is possible to set raise_on_export_fail' do
18
- allow(fake_class).to receive(:raise_on_export_fail=).with(false)
19
- fake_class.raise_on_export_fail = false
20
- end
21
-
22
- it 'is possible to set silent_mode' do
23
- allow(fake_class).to receive(:silent_mode=).with(true)
24
- fake_class.silent_mode = true
25
- end
26
-
27
- it 'is possible to set use_oauth2_token' do
28
- allow(fake_class).to receive(:use_oauth2_token=).with(true)
29
- fake_class.use_oauth2_token = true
30
- end
31
-
32
- it 'is possible to set file_ext_regexp' do
33
- allow(fake_class).to receive(:file_ext_regexp=).with(Regexp.new('.*'))
34
- fake_class.file_ext_regexp = Regexp.new('.*')
35
- end
36
-
37
- it 'is possible to set import_opts' do
38
- allow(fake_class).to receive(:import_opts=).with(duck_type(:each))
39
- fake_class.import_opts = {
40
- format: 'json',
41
- indentation: '8sp'
42
- }
43
- end
44
-
45
- it 'is possible to set export_opts' do
46
- allow(fake_class).to receive(:export_opts=).with(duck_type(:each))
47
- fake_class.export_opts = {
48
- convert_placeholders: true,
49
- detect_icu_plurals: true
50
- }
51
- end
52
-
53
- it 'is possible to set branch' do
54
- allow(fake_class).to receive(:branch=).with('custom')
55
- fake_class.branch = 'custom'
56
- end
57
-
58
- it 'is possible to set timeouts' do
59
- allow(fake_class).to receive(:timeouts=).with(duck_type(:each))
60
- fake_class.timeouts = {
61
- open_timeout: 100,
62
- timeout: 500
63
- }
64
- end
65
-
66
- it 'is possible to set import_safe_mode' do
67
- allow(fake_class).to receive(:import_safe_mode=).with(true)
68
- fake_class.import_safe_mode = true
69
- end
70
-
71
- it 'is possible to set max_retries_export' do
72
- allow(fake_class).to receive(:max_retries_export=).with(10)
73
- fake_class.max_retries_export = 10
74
- end
75
-
76
- it 'is possible to set max_retries_import' do
77
- allow(fake_class).to receive(:max_retries_import=).with(10)
78
- fake_class.max_retries_import = 10
79
- end
80
-
81
- it 'is possible to set api_token' do
82
- allow(fake_class).to receive(:api_token=).with('abc')
83
- fake_class.api_token = 'abc'
84
- end
85
-
86
- it 'is possible to override locales_path' do
87
- allow(fake_class).to receive(:locales_path=).with('/demo/path')
88
- fake_class.locales_path = '/demo/path'
89
- end
90
-
91
- it 'is possible to set skip_file_export' do
92
- cond = ->(f) { f.nil? }
93
- allow(fake_class).to receive(:skip_file_export=).with(cond)
94
- fake_class.skip_file_export = cond
95
- end
96
-
97
- it 'is possible to set translations_loader' do
98
- runner = ->(f) { f.to_json }
99
- allow(fake_class).to receive(:translations_loader=).with(runner)
100
- fake_class.translations_loader = runner
101
- end
102
-
103
- it 'is possible to set translations_converter' do
104
- runner = ->(f) { f.to_json }
105
- allow(fake_class).to receive(:translations_converter=).with(runner)
106
- fake_class.translations_converter = runner
107
- end
108
-
109
- it 'is possible to set lang_iso_inferer' do
110
- runner = ->(f) { f.to_json }
111
- allow(fake_class).to receive(:lang_iso_inferer=).with(runner)
112
- fake_class.lang_iso_inferer = runner
113
- end
114
- end