lokalise_manager 5.0.0 → 5.1.1

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: 31b3524b3186c5fa2f6ff2f915cf45dc2cc26f69c615ff6d44fffd6581286222
4
- data.tar.gz: 324ce28075eb3d6cacfda2076ac5b0d9b18a0750026e464e99ebb8b9aafa70d5
3
+ metadata.gz: 82874b49ae901318d91845641a40e1c0b085764e53179799dffb54f84e205fc0
4
+ data.tar.gz: 5c8035fed54faf4dbd82eba23acaf172af60bf0d0cd4f4b0705bace632b1049a
5
5
  SHA512:
6
- metadata.gz: 207900d1455053cc5246892f53ceed6027d2335ced167702e8f9c2eb977b0ce037f089cf447d8b4941bcd49d940de9d66a88c078df147c7ad23cad30e001b230
7
- data.tar.gz: 14cc73a9f1a2fe3cad5716e9fe11bb68ad991eb239fc0d2aac45322b3237faf7644b7da403b2124733107e7f29a3e78cba3c510c77993d8f8339753112cd2b16
6
+ metadata.gz: 473fc616ce635982fe180396a3f2be51c974fd05bbca4e5f1a4780cdda9f10951a0763ce1c366abccae96ba618a20f7d9d94b150c4f9423ba72d678dec2f53cf
7
+ data.tar.gz: 24b1bd4791c79ef2ff0e6f1fc096b23a50a63878f55c66c10b0830d4ac614e76890a7b50d376cef649dae6970ded2215088ca95b9c96ee3124574b7594eda086
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.1.1
4
+
5
+ * Update documentation, minor code fixes
6
+
7
+ ## 5.1.0 (09-Feb-2024)
8
+
9
+ * Handle rare case when the server returns HTML instead of JSON which happens when too many requests are sent
10
+
3
11
  ## 5.0.0 (09-Nov-2023)
4
12
 
5
13
  * **Breaking change**: require Ruby 3+. Version 2.7 has reached end-of-life and thus we are not planning to support it anymore. If you need support for Ruby 2.7, please stay on 4.0.0.
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Ilya Krukowski
3
+ Copyright (c) 2024 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
@@ -6,17 +6,22 @@
6
6
  [![Maintainability](https://api.codeclimate.com/v1/badges/9b682367a274ee3dcdee/maintainability)](https://codeclimate.com/github/bodrovis/lokalise_manager/maintainability)
7
7
  ![Downloads total](https://img.shields.io/gem/dt/lokalise_manager)
8
8
 
9
- This gem provides [Lokalise](http://lokalise.com) integration for Ruby and allows to exchange translation files between your project and TMS easily. It relies on [ruby-lokalise-api](https://lokalise.github.io/ruby-lokalise-api) to send APIv2 requests.
9
+ The LokaliseManager gem provides seamless integration with [Lokalise](http://lokalise.com), enabling easy exchange of translation files between your Ruby project and the Lokalise translation management system (TMS). It leverages the [ruby-lokalise-api](https://lokalise.github.io/ruby-lokalise-api) to send and manage APIv2 requests.
10
10
 
11
- If you are looking for a Rails integration, please check [lokalise_rails](https://github.com/bodrovis/lokalise_rails) which provides a set of Rake tasks for importing/exporting.
11
+ For integration directly with Rails applications, refer to [lokalise_rails](https://github.com/bodrovis/lokalise_rails), which offers a suite of Rake tasks specifically designed for importing and exporting translation files.
12
12
 
13
- ## Getting started
13
+ ## Getting Started
14
14
 
15
15
  ### Requirements
16
16
 
17
- This gem requires Ruby 2.5+. You will also need to [setup a Lokalise account](https://app.lokalise.com/signup) and create a [translation project](https://docs.lokalise.com/en/articles/1400460-projects). Finally, you will need to generate a [read/write API token](https://docs.lokalise.com/en/articles/1929556-api-tokens) at your Lokalise profile.
17
+ - **Ruby version**: Ruby 3.0 or higher is required.
18
+ - **Lokalise account**: You must have an active [Lokalise account](https://app.lokalise.com/signup).
19
+ - **Project setup**: Create a [translation project](https://docs.lokalise.com/en/articles/1400460-projects) within your Lokalise account.
20
+ - **API token**: Obtain a read/write [API token](https://docs.lokalise.com/en/articles/1929556-api-tokens) from your Lokalise profile.
18
21
 
19
- Alternatively, you can utilize a token obtained via OAuth 2 flow. When using such a token, you'll have to set `:use_oauth2_token` option to `true` (see below).
22
+ ### Optional
23
+
24
+ - **OAuth 2 token**: If you prefer using an OAuth 2 token instead of a standard API token, set the `:use_oauth2_token` option to `true` in your configuration settings.
20
25
 
21
26
  ### Installation
22
27
 
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LokaliseManager
4
- # LokaliseManager error class, subclass of StandardError
4
+ # The Error class provides a custom exception type for the LokaliseManager,
5
+ # allowing the library to raise specific errors that can be easily identified
6
+ # and handled separately from other StandardError exceptions in Ruby.
5
7
  class Error < StandardError
6
8
  # Initializes a new Error object
7
9
  def initialize(message = '')
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LokaliseManager
4
- # Global configuration options available for LokaliseManager
4
+ # GlobalConfig provides a central place to manage configuration settings for LokaliseManager.
5
+ # It allows setting various operational parameters such as API tokens, paths, and behavior modifiers.
5
6
  class GlobalConfig
6
7
  class << self
7
8
  attr_accessor :api_token, :project_id
@@ -11,58 +12,57 @@ module LokaliseManager
11
12
  :max_retries_export, :max_retries_import, :use_oauth2_token, :silent_mode,
12
13
  :raise_on_export_fail
13
14
 
14
- # Main interface to provide configuration options
15
+ # Yield self to block for configuration
15
16
  def config
16
17
  yield self
17
18
  end
18
19
 
19
- # When enabled, will re-raise any exception that happens during file exporting
20
+ # Return whether to raise on export failure
20
21
  def raise_on_export_fail
21
- @raise_on_export_fail || true
22
+ @raise_on_export_fail.nil? ? true : @raise_on_export_fail
22
23
  end
23
24
 
24
- # When enabled, won't print any debugging info to $stdout
25
+ # Return whether debugging information is suppressed
25
26
  def silent_mode
26
27
  @silent_mode || false
27
28
  end
28
29
 
29
- # When enabled, will use OAuth 2 Lokalise client and will require to provide a token obtained via OAuth 2 flow
30
- # rather than via Lokalise profile
30
+ # Return whether to use OAuth2 tokens instead of regular API tokens
31
31
  def use_oauth2_token
32
32
  @use_oauth2_token || false
33
33
  end
34
34
 
35
- # Full path to directory with translation files
35
+ # Return the path to locales
36
36
  def locales_path
37
37
  @locales_path || "#{Dir.getwd}/locales"
38
38
  end
39
39
 
40
- # Project branch to use
40
+ # Return the project branch
41
41
  def branch
42
42
  @branch || ''
43
43
  end
44
44
 
45
- # Set request timeouts for the Lokalise API client
45
+ # Return API request timeouts
46
46
  def timeouts
47
47
  @timeouts || {}
48
48
  end
49
49
 
50
- # Maximum number of retries for file exporting
50
+ # Return the max retries for export
51
51
  def max_retries_export
52
52
  @max_retries_export || 5
53
53
  end
54
54
 
55
- # Maximum number of retries for file importing
55
+ # Return the max retries for import
56
56
  def max_retries_import
57
57
  @max_retries_import || 5
58
58
  end
59
59
 
60
- # Regular expression used to select translation files with proper extensions
60
+ # Return the regex for file extensions
61
61
  def file_ext_regexp
62
62
  @file_ext_regexp || /\.ya?ml\z/i
63
63
  end
64
64
 
65
- # Options for import rake task
65
+ # Return import options with defaults
66
66
  def import_opts
67
67
  @import_opts || {
68
68
  format: 'ruby_yaml',
@@ -74,33 +74,32 @@ module LokaliseManager
74
74
  }
75
75
  end
76
76
 
77
- # Options for export rake task
77
+ # Return export options
78
78
  def export_opts
79
79
  @export_opts || {}
80
80
  end
81
81
 
82
- # Enables safe mode for import. When enabled, will check whether the target folder is empty or not
82
+ # Return whether import should check if target is empty
83
83
  def import_safe_mode
84
84
  @import_safe_mode.nil? ? false : @import_safe_mode
85
85
  end
86
86
 
87
- # Additional file skip criteria to apply when performing export
87
+ # Return whether to skip file export based on a lambda condition
88
88
  def skip_file_export
89
89
  @skip_file_export || ->(_) { false }
90
90
  end
91
91
 
92
+ # Load translations from raw data
92
93
  def translations_loader
93
- @translations_loader || ->(raw_data) { YAML.safe_load raw_data }
94
+ @translations_loader || ->(raw_data) { YAML.safe_load(raw_data) }
94
95
  end
95
96
 
96
- # Converts translations data to the proper format
97
+ # Convert raw translation data to YAML format
97
98
  def translations_converter
98
99
  @translations_converter || ->(raw_data) { YAML.dump(raw_data).gsub('\\\\n', '\n') }
99
100
  end
100
101
 
101
- # Infers lang ISO for the given translation file
102
- # The lambda expects to accept the raw contents of the translation file
103
- # and the full path to the file (instance of the `Pathname` class)
102
+ # Infer language ISO code from translation file
104
103
  def lang_iso_inferer
105
104
  @lang_iso_inferer || ->(data, _path) { YAML.safe_load(data)&.keys&.first }
106
105
  end
@@ -5,17 +5,18 @@ 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
+ # Base class for LokaliseManager task definitions, including common methods and logic.
9
+ # This class serves as the foundation for importer and exporter classes, handling API
10
+ # client interactions and configuration merging.
9
11
  class Base
10
12
  using LokaliseManager::Utils::HashUtils
11
13
 
12
14
  attr_accessor :config
13
15
 
14
- # Creates a new importer or exporter. It accepts custom config and merges it
15
- # with the global config (custom config take precendence)
16
+ # Initializes a new task object by merging custom and global configurations.
16
17
  #
17
- # @param custom_opts [Hash]
18
- # @param global_config [Object]
18
+ # @param custom_opts [Hash] Custom configurations for specific tasks.
19
+ # @param global_config [Object] Reference to the global configuration.
19
20
  def initialize(custom_opts = {}, global_config = LokaliseManager::GlobalConfig)
20
21
  primary_opts = global_config
21
22
  .singleton_methods
@@ -32,10 +33,12 @@ module LokaliseManager
32
33
  @config = config_klass.new all_opts
33
34
  end
34
35
 
35
- # Creates a Lokalise API client
36
+ # Creates or retrieves a Lokalise API client based on configuration.
36
37
  #
37
- # @return [RubyLokaliseApi::Client]
38
+ # @return [RubyLokaliseApi::Client] Lokalise API client.
38
39
  def api_client
40
+ return @api_client if @api_client
41
+
39
42
  client_opts = [config.api_token, config.timeouts]
40
43
  client_method = config.use_oauth2_token ? :oauth2_client : :client
41
44
 
@@ -51,51 +54,51 @@ module LokaliseManager
51
54
 
52
55
  private
53
56
 
54
- # Checks task options
55
- #
56
- # @return Array
57
+ # Checks and validates task options, raising errors if configurations are missing.
57
58
  def check_options_errors!
58
59
  errors = []
59
60
  errors << 'Project ID is not set!' if config.project_id.nil? || config.project_id.empty?
60
61
  errors << 'Lokalise API token is not set!' if config.api_token.nil? || config.api_token.empty?
61
-
62
- raise(LokaliseManager::Error, errors.join(' ')) if errors.any?
62
+ raise LokaliseManager::Error, errors.join(' ') if errors.any?
63
63
  end
64
64
 
65
- # Checks whether the provided file has a proper extension as dictated by the `file_ext_regexp` option
65
+ # Determines if the file has the correct extension based on the configuration.
66
66
  #
67
- # @return Boolean
68
- # @param raw_path [String, Pathname]
67
+ # @param raw_path [String, Pathname] Path to check.
68
+ # @return [Boolean] True if the extension matches, false otherwise.
69
69
  def proper_ext?(raw_path)
70
70
  path = raw_path.is_a?(Pathname) ? raw_path : Pathname.new(raw_path)
71
71
  config.file_ext_regexp.match? path.extname
72
72
  end
73
73
 
74
- # Returns directory and filename for the given entry
74
+ # Extracts the directory and filename from a given path.
75
75
  #
76
- # @return Array
77
- # @param entry [String]
76
+ # @param entry [String] The file path.
77
+ # @return [Array] Contains [Pathname, Pathname] representing the directory and filename.
78
78
  def subdir_and_filename_for(entry)
79
79
  Pathname.new(entry).split
80
80
  end
81
81
 
82
- # Returns Lokalise project ID and branch, semicolumn separated
82
+ # Constructs a project identifier string that may include a branch.
83
83
  #
84
- # @return [String]
84
+ # @return [String] Project identifier potentially including the branch.
85
85
  def project_id_with_branch
86
- return config.project_id.to_s if config.branch.to_s.strip.empty?
87
-
88
- "#{config.project_id}:#{config.branch}"
86
+ config.branch.to_s.strip.empty? ? config.project_id.to_s : "#{config.project_id}:#{config.branch}"
89
87
  end
90
88
 
91
- # Sends request with exponential backoff mechanism
89
+ # In rare cases the server might return HTML instead of JSON.
90
+ # It happens when too many requests are being sent.
91
+ # Until this is fixed, we revert to this quick'n'dirty solution.
92
+ EXCEPTIONS = [JSON::ParserError, RubyLokaliseApi::Error::TooManyRequests].freeze
93
+
94
+ # Implements an exponential backoff strategy for handling retries after failures.
92
95
  def with_exp_backoff(max_retries)
93
96
  return unless block_given?
94
97
 
95
98
  retries = 0
96
99
  begin
97
100
  yield
98
- rescue RubyLokaliseApi::Error::TooManyRequests => e
101
+ rescue *EXCEPTIONS => e
99
102
  raise(e.class, "Gave up after #{retries} retries") if retries >= max_retries
100
103
 
101
104
  sleep 2**retries
@@ -4,14 +4,14 @@ 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
+ # Class to handle exporting translation files from a local project to Lokalise.
8
8
  class Exporter < Base
9
- # Lokalise allows no more than 6 requests per second
9
+ # Maximum number of concurrent uploads to avoid exceeding Lokalise API rate limits.
10
10
  MAX_THREADS = 6
11
11
 
12
- # Performs translation file export to Lokalise and returns an array of queued processes
12
+ # Exports translation files to Lokalise and handles any necessary concurrency and error checking.
13
13
  #
14
- # @return [Array]
14
+ # @return [Array] An array of process statuses for each file uploaded.
15
15
  def export!
16
16
  check_options_errors!
17
17
 
@@ -25,16 +25,21 @@ module LokaliseManager
25
25
  end
26
26
  end
27
27
 
28
- $stdout.print('Task complete!') unless config.silent_mode
28
+ print_completion_message unless config.silent_mode
29
29
 
30
30
  queued_processes
31
31
  end
32
32
 
33
33
  private
34
34
 
35
+ # Handles parallel uploads of a group of files, utilizing threading.
36
+ #
37
+ # @param files_group [Array] Group of files to be uploaded.
38
+ # @return [Array] Array of threads handling the file uploads.
39
+
35
40
  def parallel_upload(files_group)
36
41
  files_group.map do |file_data|
37
- do_upload(*file_data)
42
+ Thread.new { do_upload(*file_data) }
38
43
  end.map(&:value)
39
44
  end
40
45
 
@@ -44,21 +49,28 @@ module LokaliseManager
44
49
  raise(thread.error.class, "Error while trying to upload #{thread.path}: #{thread.error.message}")
45
50
  end
46
51
 
47
- # Performs the actual file uploading to Lokalise. If the API rate limit is exceeed,
48
- # applies exponential backoff
52
+ # Performs the actual upload of a file to Lokalise.
53
+ #
54
+ # @param f_path [Pathname] Full path to the file.
55
+ # @param r_path [Pathname] Relative path of the file within the project.
56
+ # @return [Struct] A struct with the success status, process details, and any error information.
49
57
  def do_upload(f_path, r_path)
50
58
  proc_klass = Struct.new(:success, :process, :path, :error, keyword_init: true)
51
-
52
- Thread.new do
59
+ begin
53
60
  process = with_exp_backoff(config.max_retries_export) do
54
- api_client.upload_file project_id_with_branch, opts(f_path, r_path)
61
+ api_client.upload_file(project_id_with_branch, opts(f_path, r_path))
55
62
  end
56
- proc_klass.new success: true, process: process, path: f_path
63
+ proc_klass.new(success: true, process: process, path: f_path)
57
64
  rescue StandardError => e
58
- proc_klass.new success: false, path: f_path, error: e
65
+ proc_klass.new(success: false, path: f_path, error: e)
59
66
  end
60
67
  end
61
68
 
69
+ # Prints a completion message to standard output.
70
+ def print_completion_message
71
+ $stdout.print('Task complete!')
72
+ end
73
+
62
74
  # Gets translation files from the specified directory
63
75
  def all_files
64
76
  loc_path = config.locales_path
@@ -6,11 +6,14 @@ 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
+ # The Importer class is responsible for downloading translation files from Lokalise
10
+ # and importing them into the specified project directory. This class extends the Base class,
11
+ # which provides shared functionality and configuration management.
10
12
  class Importer < Base
11
- # Performs translation files import from Lokalise
13
+ # Initiates the import process by checking configuration, ensuring safe mode conditions,
14
+ # downloading files, and processing them. Outputs task completion status.
12
15
  #
13
- # @return [Boolean]
16
+ # @return [Boolean] Returns true if the import completes successfully, false if cancelled.
14
17
  def import!
15
18
  check_options_errors!
16
19
 
@@ -27,10 +30,9 @@ module LokaliseManager
27
30
 
28
31
  private
29
32
 
30
- # Downloads files from Lokalise using the specified config.
31
- # Utilizes exponential backoff if "too many requests" error is received
33
+ # Downloads translation files from Lokalise, handling retries and errors using exponential backoff.
32
34
  #
33
- # @return [Hash]
35
+ # @return [Hash] Returns the response from Lokalise API containing download details.
34
36
  def download_files
35
37
  with_exp_backoff(config.max_retries_import) do
36
38
  api_client.download_files project_id_with_branch, config.import_opts
@@ -39,45 +41,40 @@ module LokaliseManager
39
41
  raise e.class, "There was an error when trying to download files: #{e.message}"
40
42
  end
41
43
 
42
- # Opens ZIP archive (local or remote) with translations and processes its entries
44
+ # Opens a ZIP archive from a given path and processes each entry if it matches the required file extension.
43
45
  #
44
- # @param path [String]
46
+ # @param path [String] The URL or local path to the ZIP archive.
45
47
  def open_and_process_zip(path)
46
48
  Zip::File.open_buffer(open_file_or_remote(path)) do |zip|
47
- fetch_zip_entries(zip) { |entry| process!(entry) }
48
- end
49
- rescue StandardError => e
50
- raise(e.class, "There was an error when trying to process the downloaded files: #{e.message}")
51
- end
52
-
53
- # Iterates over ZIP entries. Each entry may be a file or folder.
54
- def fetch_zip_entries(zip)
55
- return unless block_given?
56
-
57
- zip.each do |entry|
58
- next unless proper_ext? entry.name
49
+ zip.each do |entry|
50
+ next unless proper_ext?(entry.name)
59
51
 
60
- yield entry
52
+ process_entry(entry)
53
+ end
61
54
  end
55
+ rescue StandardError => e
56
+ raise e.class, "Error processing ZIP file: #{e.message}"
62
57
  end
63
58
 
64
- # Processes ZIP entry by reading its contents and creating the corresponding translation file
65
- def process!(zip_entry)
66
- data = data_from zip_entry
67
- subdir, filename = subdir_and_filename_for zip_entry.name
68
- full_path = "#{config.locales_path}/#{subdir}"
59
+ # Processes a single ZIP entry by extracting data, determining the correct directory structure,
60
+ # and writing the data to the appropriate file.
61
+ #
62
+ # @param zip_entry [Zip::Entry] The ZIP entry to process.
63
+ def process_entry(zip_entry)
64
+ data = data_from(zip_entry)
65
+ subdir, filename = subdir_and_filename_for(zip_entry.name)
66
+ full_path = File.join(config.locales_path, subdir)
69
67
  FileUtils.mkdir_p full_path
70
68
 
71
- File.open(File.join(full_path, filename), 'w+:UTF-8') do |f|
72
- f.write config.translations_converter.call(data)
73
- end
69
+ File.write(File.join(full_path, filename), config.translations_converter.call(data), mode: 'w+:UTF-8')
74
70
  rescue StandardError => e
75
- raise e.class, "Error when trying to process #{zip_entry&.name}: #{e.message}"
71
+ raise e.class, "Error processing entry #{zip_entry.name}: #{e.message}"
76
72
  end
77
73
 
78
- # Checks whether the user wishes to proceed when safe mode is enabled and the target directory is not empty
74
+ # Determines if the import should proceed based on the safe mode setting and the content of the target directory.
75
+ # In safe mode, the directory must be empty, or the user must confirm continuation.
79
76
  #
80
- # @return [Boolean]
77
+ # @return [Boolean] Returns true if the import should proceed, false otherwise.
81
78
  def proceed_when_safe_mode?
82
79
  return true unless config.import_safe_mode && !Dir.empty?(config.locales_path.to_s)
83
80
 
@@ -87,9 +84,10 @@ module LokaliseManager
87
84
  answer.to_s.strip == 'Y'
88
85
  end
89
86
 
90
- # Opens a local file or a remote URL using the provided patf
87
+ # Opens a local file or a remote URL using the provided path, safely handling different path schemes.
91
88
  #
92
- # @return [String]
89
+ # @param path [String] The path to the file, either a local path or a URL.
90
+ # @return [IO] Returns an IO object for the file.
93
91
  def open_file_or_remote(path)
94
92
  parsed_path = URI.parse(path)
95
93
 
@@ -100,6 +98,9 @@ module LokaliseManager
100
98
  end
101
99
  end
102
100
 
101
+ # Loads translations from the ZIP file.
102
+ #
103
+ # @param zip_entry [Zip::Entry] The ZIP entry to process.
103
104
  def data_from(zip_entry)
104
105
  config.translations_loader.call zip_entry.get_input_stream.read
105
106
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LokaliseManager
4
- VERSION = '5.0.0'
4
+ VERSION = '5.1.1'
5
5
  end
@@ -6,34 +6,34 @@ require 'yaml'
6
6
  loader = Zeitwerk::Loader.for_gem
7
7
  loader.setup
8
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:
9
+ # The LokaliseManager module provides functionalities to import and export translation
10
+ # files to and from the Lokalise TMS. It simplifies interactions with the Lokalise API
11
+ # by providing a straightforward interface to instantiate importers and exporters.
15
12
  #
13
+ # Example:
14
+ # importer = LokaliseManager.importer(api_token: '1234abc', project_id: '123.abc')
15
+ # exporter = LokaliseManager.exporter(api_token: '1234abc', project_id: '123.abc')
16
16
  # importer.import!
17
17
  # exporter.export!
18
18
  #
19
19
  module LokaliseManager
20
20
  class << self
21
- # Initializes a new importer client which is used to download
22
- # translation files from Lokalise to the current project
21
+ # Creates an importer object for downloading translation files from Lokalise.
22
+ #
23
+ # @param custom_opts [Hash] Custom options for the importer (e.g., API token and project ID).
24
+ # @param global_config [Object] Global configuration settings, defaults to LokaliseManager::GlobalConfig.
25
+ # @return [LokaliseManager::TaskDefinitions::Importer] An instance of the importer.
23
26
  #
24
- # @return [LokaliseManager::TaskDefinitions::Importer]
25
- # @param custom_opts [Hash]
26
- # @param global_config [Object]
27
27
  def importer(custom_opts = {}, global_config = LokaliseManager::GlobalConfig)
28
28
  LokaliseManager::TaskDefinitions::Importer.new custom_opts, global_config
29
29
  end
30
30
 
31
- # Initializes a new exporter client which is used to upload
32
- # translation files from the current project to Lokalise
31
+ # Creates an exporter object for uploading translation files to Lokalise.
32
+ #
33
+ # @param custom_opts [Hash] Custom options for the exporter (e.g., API token and project ID).
34
+ # @param global_config [Object] Global configuration settings, defaults to LokaliseManager::GlobalConfig.
35
+ # @return [LokaliseManager::TaskDefinitions::Exporter] An instance of the exporter.
33
36
  #
34
- # @return [LokaliseManager::TaskDefinitions::Exporter]
35
- # @param custom_opts [Hash]
36
- # @param global_config [Object]
37
37
  def exporter(custom_opts = {}, global_config = LokaliseManager::GlobalConfig)
38
38
  LokaliseManager::TaskDefinitions::Exporter.new custom_opts, global_config
39
39
  end
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency 'rubyzip', '~> 2.3'
28
28
  spec.add_dependency 'zeitwerk', '~> 2.4'
29
29
 
30
- spec.add_development_dependency 'dotenv', '~> 2.5'
30
+ spec.add_development_dependency 'dotenv', '~> 3.0'
31
31
  spec.add_development_dependency 'rake', '~> 13.0'
32
32
  spec.add_development_dependency 'rspec', '~> 3.6'
33
33
  spec.add_development_dependency 'rubocop', '~> 1.0'
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: 5.0.0
4
+ version: 5.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Krukowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-09 00:00:00.000000000 Z
11
+ date: 2024-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-lokalise-api
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '2.5'
61
+ version: '3.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '2.5'
68
+ version: '3.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -238,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
238
238
  - !ruby/object:Gem::Version
239
239
  version: '0'
240
240
  requirements: []
241
- rubygems_version: 3.4.21
241
+ rubygems_version: 3.5.10
242
242
  signing_key:
243
243
  specification_version: 4
244
244
  summary: Lokalise integration for Ruby