Skip to content

Commit

Permalink
Merge pull request #19 from crowdin/client-updates
Browse files Browse the repository at this point in the history
Release '1.3.0'
  • Loading branch information
andrii-bodnar authored May 13, 2022
2 parents d89eddd + 503bd55 commit 56a277e
Show file tree
Hide file tree
Showing 72 changed files with 3,160 additions and 1,921 deletions.
127 changes: 96 additions & 31 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2022-02-14 06:05:44 UTC using RuboCop version 1.23.0.
# on 2022-05-09 23:17:26 UTC using RuboCop version 1.26.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Cop supports --auto-correct.
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: Include.
# Include: **/*.gemspec
Gemspec/RequireMFA:
Expand All @@ -21,8 +21,19 @@ Gemspec/RequiredRubyVersion:
Exclude:
- 'crowdin-api.gemspec'

# Offense count: 18
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
Layout/ExtraSpacing:
Exclude:
- 'lib/crowdin-api/api_resources/machine_translation_engines.rb'
- 'lib/crowdin-api/api_resources/reports.rb'
- 'lib/crowdin-api/api_resources/teams.rb'
- 'lib/crowdin-api/api_resources/users.rb'
- 'lib/crowdin-api/api_resources/workflows.rb'

# Offense count: 4
# Cop supports --auto-correct.
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
# SupportedHashRocketStyles: key, separator, table
# SupportedColonStyles: key, separator, table
Expand All @@ -31,36 +42,68 @@ Layout/HashAlignment:
Exclude:
- 'lib/crowdin-api/client/configuration.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Offense count: 13
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: normal, indented_internal_methods
Layout/IndentationConsistency:
Exclude:
- 'lib/crowdin-api/client/client.rb'
- 'lib/crowdin-api/core/request.rb'
- 'lib/crowdin-api/core/send_request.rb'

# Offense count: 13
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: Width, IgnoredPatterns.
Layout/IndentationWidth:
Exclude:
- 'lib/crowdin-api/client/client.rb'
- 'lib/crowdin-api/core/request.rb'
- 'lib/crowdin-api/core/send_request.rb'

# Offense count: 22
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
# SupportedStylesForExponentOperator: space, no_space
Layout/SpaceAroundOperators:
Exclude:
- 'crowdin-api.gemspec'
- 'lib/crowdin-api/api_resources/machine_translation_engines.rb'
- 'lib/crowdin-api/api_resources/reports.rb'
- 'lib/crowdin-api/api_resources/teams.rb'
- 'lib/crowdin-api/api_resources/users.rb'
- 'lib/crowdin-api/api_resources/workflows.rb'
- 'spec/api_resources/projects_spec.rb'

# Offense count: 1
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
Lint/UnusedMethodArgument:
Exclude:
- 'lib/crowdin-api/core/send_request.rb'

# Offense count: 2
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 23

# Offense count: 1
# Offense count: 4
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
# IgnoredMethods: refine
Metrics/BlockLength:
Max: 54
Max: 171

# Offense count: 12
# Offense count: 13
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
Metrics/MethodLength:
Max: 18

# Offense count: 8
# Offense count: 9
# Configuration parameters: CountComments, CountAsOne.
Metrics/ModuleLength:
Max: 199

# Offense count: 2
# Offense count: 3
# Configuration parameters: CountKeywordArgs.
Metrics/ParameterLists:
MaxOptionalParameters: 4
Expand All @@ -69,55 +112,62 @@ Metrics/ParameterLists:
# Offense count: 2
Naming/AccessorMethodName:
Exclude:
- 'lib/crowdin-api/api-resources/users.rb'
- 'lib/crowdin-api/core/request.rb'
- 'lib/crowdin-api/api_resources/users.rb'
- 'lib/crowdin-api/core/send_request.rb'

# Offense count: 3
# Offense count: 1
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Naming/FileName:
Exclude:
- 'lib/crowdin-api.rb'
- 'spec/client/client-instance_spec.rb'
- 'spec/client/configuration-instance_spec.rb'

# Offense count: 3
# Offense count: 2
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
Naming/MemoizedInstanceVariableName:
Exclude:
- 'lib/crowdin-api/client/client.rb'

# Offense count: 3
# Cop supports --auto-correct.
# Offense count: 6
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: PreferredName.
Naming/RescuedExceptionsVariableName:
Exclude:
- 'lib/crowdin-api/core/request.rb'
- 'lib/crowdin-api/core/send_request.rb'

# Offense count: 8
# Cop supports --auto-correct.
# Offense count: 7
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: separated, grouped
Style/AccessorGrouping:
Exclude:
- 'lib/crowdin-api/client/client.rb'
- 'lib/crowdin-api/client/configuration.rb'
- 'lib/crowdin-api/core/request.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Offense count: 4
# This cop supports unsafe auto-correction (--auto-correct-all).
Style/CollectionCompact:
Exclude:
- 'lib/crowdin-api/core/request.rb'
- 'lib/crowdin-api/core/send_request.rb'

# Offense count: 22
# Offense count: 24
# Configuration parameters: AllowedConstants.
Style/Documentation:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: allowed_in_returns, forbidden
Style/DoubleNegation:
Exclude:
- 'lib/crowdin-api/client/configuration.rb'

# Offense count: 1
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Expand All @@ -130,17 +180,32 @@ Style/MixinUsage:
- 'bin/crowdin-console'

# Offense count: 2
# Cop supports --auto-correct.
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: implicit, explicit
Style/RescueStandardError:
Exclude:
- 'lib/crowdin-api/api-resources/labels.rb'
- 'lib/crowdin-api/api-resources/string_translations.rb'
- 'lib/crowdin-api/api_resources/labels.rb'
- 'lib/crowdin-api/api_resources/string_translations.rb'

# Offense count: 1
# This cop supports unsafe auto-correction (--auto-correct-all).
# Configuration parameters: Mode.
Style/StringConcatenation:
Exclude:
- 'lib/crowdin-api/api_resources/projects.rb'

# Offense count: 8
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Exclude:
- 'spec/api_resources/projects_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 122
Max: 121
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ For more about Crowdin API v2 see the documentation:
Add this line to your application's Gemfile:

```gemfile
gem 'crowdin-api', '~> 1.2.1'
gem 'crowdin-api', '~> 1.3.0'
```

And then execute:
Expand Down Expand Up @@ -74,15 +74,15 @@ crowdin = Crowdin::Client.new do |config|
config.api_token = 'YourApiToken'
end

# Or you can intialize Enterprise Client instance by specifying your
# Or you can initialize Enterprise Client instance by specifying your
# organization_domain in config options
crowdin = Crowdin::Client.new do |config|
config.api_token = 'YourEnterpriseApiToken'
config.organization_domain = 'YourOrganizationDomain'
end
# Note: we use full specified organization domain if that includes '.com'
# config.organization_domain = your_domain -> https://your_domain.api.crowdin.com
# config.organization_domain = your_domain.com -> your_domain.com
# config.organization_domain = your_domain.com -> https://your_domain.com

# All supported Crowdin Client config options now:
crowdin = Crowdin::Client.new do |config|
Expand Down Expand Up @@ -121,9 +121,9 @@ projects = crowdin.list_projects(offset: 10, limit: 20)
project = crowdin.get_project(your_project_id)

# Edit project
project = crowdin.edit_project(project_id, [{op: 'replace',
path: '/name',
value: 'your_new_project_name'}])
project = crowdin.edit_project(project_id, [{ op: 'replace',
path: '/name',
value: 'your_new_project_name' }])

# Add Storage
storage = crowdin.add_storage(File.open('YourFilename.extension', 'r'))
Expand All @@ -141,6 +141,8 @@ file = crowdin.download_file(your_file_id, your_destination, your_project_id)
file_revisions = crowdin.list_file_revisions(your_file_id, limit: 10)
# or you can specify your project_id
file_revisions = crowdin.list_file_revisions(your_file_id, { limit: 10 }, your_project_id)

# Note: more examples you can find in spec folder
```

### Command-Line Client
Expand Down
2 changes: 1 addition & 1 deletion bin/crowdin-console
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require 'optparse'
#
# bundle exec crowdin-console --enable-logger --api-token YOUR_API_TOKEN --project-id YOUR_PROJECT_ID
#
# or Enterpise API:
# or Enterprise API:
#
# bundle exec crowdin-console --enterprise --api-token YOUR_ENTERPRISE_API_TOKEN --organization-domain YOUR_DOMAIN
#
Expand Down
6 changes: 0 additions & 6 deletions bin/setup

This file was deleted.

3 changes: 1 addition & 2 deletions crowdin-api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Gem::Specification.new do |gem|
gem.license = 'MIT'

gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
gem.require_paths = ['lib']
gem.bindir = 'bin'
gem.executables << 'crowdin-console'
Expand All @@ -25,9 +24,9 @@ Gem::Specification.new do |gem|

gem.add_development_dependency 'bundler', '~> 2.2', '>= 2.2.32'
gem.add_development_dependency 'codecov', '~> 0.6.0'
gem.add_development_dependency 'pry', '~> 0.14.1'
gem.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
gem.add_development_dependency 'rspec', '~> 3.10'
gem.add_development_dependency 'rubocop', '~> 1.23'
gem.add_development_dependency 'sinatra', '~> 2.1'
gem.add_development_dependency 'webmock', '~> 3.14'
end
41 changes: 17 additions & 24 deletions lib/crowdin-api.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# frozen_string_literal: true

module Crowdin
# API Resources modules
API_RESOURCES_MODULES = %i[Storages Languages Projects Workflows SourceFiles Translations SourceStrings
StringTranslations StringComments Screenshots Glossaries TranslationMemory
MachineTranslationEngines Reports Tasks Users Teams Vendors Webhooks
Dictionaries Distributions Labels TranslationStatus].freeze

# Error Raisers modules
ERROR_RAISERS_MODULES = %i[ApiErrorsRaiser ClientErrorsRaiser].freeze
end

# Libs
require 'json'
require 'open-uri'
Expand All @@ -9,32 +20,14 @@
require 'crowdin-api/core/errors'
require 'crowdin-api/core/errors_raisers'
require 'crowdin-api/core/request'
require 'crowdin-api/core/utils'
require 'crowdin-api/core/send_request'

# API modules
require 'crowdin-api/api-resources/storages'
require 'crowdin-api/api-resources/languages'
require 'crowdin-api/api-resources/projects'
require 'crowdin-api/api-resources/workflows'
require 'crowdin-api/api-resources/source_files'
require 'crowdin-api/api-resources/translations'
require 'crowdin-api/api-resources/source_strings'
require 'crowdin-api/api-resources/string_translations'
require 'crowdin-api/api-resources/string_comments'
require 'crowdin-api/api-resources/screenshots'
require 'crowdin-api/api-resources/glossaries'
require 'crowdin-api/api-resources/translation_memory'
require 'crowdin-api/api-resources/machine_translation_engines'
require 'crowdin-api/api-resources/reports'
require 'crowdin-api/api-resources/tasks'
require 'crowdin-api/api-resources/users'
require 'crowdin-api/api-resources/teams'
require 'crowdin-api/api-resources/vendors'
require 'crowdin-api/api-resources/webhooks'
require 'crowdin-api/api-resources/dictionaries'
require 'crowdin-api/api-resources/distributions'
require 'crowdin-api/api-resources/labels'
require 'crowdin-api/api-resources/translation_status'
Crowdin::API_RESOURCES_MODULES.each do |api_resource|
require "crowdin-api/api_resources/#{api_resource.to_s.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase}"
rescue LoadError
# Ignored
end

# Client modules
require 'crowdin-api/client/version'
Expand Down
Loading

0 comments on commit 56a277e

Please sign in to comment.