Skip to content

Commit

Permalink
Crowdin delivery
Browse files Browse the repository at this point in the history
  • Loading branch information
keshandrr committed Feb 14, 2022
1 parent 92a8f14 commit dafc90f
Show file tree
Hide file tree
Showing 30 changed files with 1,941 additions and 131 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Ignore Ruby logs
.ruby-version
.idea

# Ignore MacOS logs
.DS_Store

# Ignore versioning file
# Ignore versioning files
Gemfile.lock
.ruby-version

# Ignore tests coverage folder
coverage
51 changes: 27 additions & 24 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2022-01-05 07:49:15 UTC using RuboCop version 1.23.0.
# on 2022-02-14 06:05:44 UTC using RuboCop version 1.23.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
Expand Down Expand Up @@ -50,24 +50,26 @@ Metrics/AbcSize:
Metrics/BlockLength:
Max: 54

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

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

# Offense count: 1
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
# Offense count: 2
# Configuration parameters: CountKeywordArgs.
Metrics/ParameterLists:
MaxOptionalParameters: 4
Max: 6

# Offense count: 1
# Offense count: 2
Naming/AccessorMethodName:
Exclude:
- 'lib/crowdin-api/api-resources/users.rb'
- 'lib/crowdin-api/core/request.rb'

# Offense count: 3
Expand Down Expand Up @@ -109,25 +111,10 @@ Style/CollectionCompact:
Exclude:
- 'lib/crowdin-api/core/request.rb'

# Offense count: 13
# Offense count: 22
# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'lib/crowdin-api/api-resources/languages.rb'
- 'lib/crowdin-api/api-resources/projects.rb'
- 'lib/crowdin-api/api-resources/source_files.rb'
- 'lib/crowdin-api/api-resources/source_strings.rb'
- 'lib/crowdin-api/api-resources/storages.rb'
- 'lib/crowdin-api/api-resources/translation_status.rb'
- 'lib/crowdin-api/api-resources/translations.rb'
- 'lib/crowdin-api/api-resources/workflows.rb'
- 'lib/crowdin-api/client/configuration.rb'
- 'lib/crowdin-api/core/api_errors_raiser.rb'
- 'lib/crowdin-api/core/clc_errors_raiser.rb'
- 'lib/crowdin-api/core/client_errors_raiser.rb'
- 'lib/crowdin-api/core/request.rb'
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Expand All @@ -141,3 +128,19 @@ Style/FrozenStringLiteralComment:
Style/MixinUsage:
Exclude:
- 'bin/crowdin-console'

# Offense count: 2
# Cop supports --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'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 122
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,20 @@ projects = crowdin.list_projects(offset: 10, limit: 20)
# Get specified project
project = crowdin.get_project(your_project_id)

# Edit project
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'))
# or you can specify only path to file
# or you can specify only absolute path to file
storage = crowdin.add_storage('YourFilename.extension')

# Download file
file = crowdin.download_file(your_file_id, your_destination, your_project_id)
# your_destination - filename or absolute path to file, optional
# Without destination option method will save file to current directory with a default filename
# Without destination option file will be saved to the current directory with a default filename
# project_id is optional, as it can be initialized with a Crowdin Client

# File revisions
Expand Down
5 changes: 2 additions & 3 deletions bin/crowdin-console
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ require 'optparse'
# bundle exec crowdin-console --enterprise --api-token YOUR_ENTERPRISE_API_TOKEN --organization-domain YOUR_DOMAIN
#

require 'crowdin-api/core/clc_errors_raiser'
include Crowdin::Errors::ClcErrorsRaiser

options = {}
Expand All @@ -40,8 +39,8 @@ if options[:enterprise]
@crowdin = Crowdin::Client.new do |config|
config.api_token = options[:api_token]
config.organization_domain = options[:organization_domain]
config.enable_logger = options[:enable_logger] || false
config.project_id = options[:project_id] || nil
config.enable_logger = options[:enable_logger] || false
config.project_id = options[:project_id] || nil
end
else
@crowdin = Crowdin::Client.new do |config|
Expand Down
27 changes: 21 additions & 6 deletions lib/crowdin-api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,34 @@

# Core modules
require 'crowdin-api/core/errors'
require 'crowdin-api/core/api_errors_raiser'
require 'crowdin-api/core/client_errors_raiser'
require 'crowdin-api/core/errors_raisers'
require 'crowdin-api/core/request'
require 'crowdin-api/core/utils'

# Api modules
# 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/storages'
require 'crowdin-api/api-resources/translation_status'
require 'crowdin-api/api-resources/translations'
require 'crowdin-api/api-resources/workflows'
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'

# Client modules
require 'crowdin-api/client/version'
Expand Down
34 changes: 34 additions & 0 deletions lib/crowdin-api/api-resources/dictionaries.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true

module Crowdin
module ApiResources
module Dictionaries
def list_dictionaries(query = {}, project_id = config.project_id)
project_id || raise_project_id_is_required_error

request = Web::Request.new(
self,
:get,
"/projects/#{project_id}/dictionaries",
query
)

request.perform
end

def edit_dictionary(language_id = nil, query = {}, project_id = config.project_id)
language_id || raise_parameter_is_required_error(:language_id)
project_id || raise_project_id_is_required_error

request = Web::Request.new(
self,
:patch,
"/projects/#{project_id}/dictionaries/#{language_id}",
query
)

request.perform
end
end
end
end
99 changes: 99 additions & 0 deletions lib/crowdin-api/api-resources/distributions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# frozen_string_literal: true

module Crowdin
module ApiResources
module Distributions
def list_distributions(query = {}, project_id = config.project_id)
project_id || raise_project_id_is_required_error

request = Web::Request.new(
self,
:get,
"/projects/#{project_id}/distributions",
query
)

request.perform
end

def add_distribution(query = {}, project_id = config.project_id)
project_id || raise_project_id_is_required_error

request = Web::Request.new(
self,
:post,
"/projects/#{project_id}/distributions",
query
)

request.perform
end

def get_distribution(hash = nil, project_id = config.project_id)
hash || raise_parameter_is_required_error(:hash)
project_id || raise_project_id_is_required_error

request = Web::Request.new(
self,
:get,
"/projects/#{project_id}/distributions/#{hash}"
)

request.perform
end

def delete_distribution(hash = nil, project_id = config.project_id)
hash || raise_parameter_is_required_error(:hash)
project_id || raise_project_id_is_required_error

request = Web::Request.new(
self,
:delete,
"/projects/#{project_id}/distributions/#{hash}"
)

request.perform
end

def edit_distribution(hash = nil, query = {}, project_id = config.project_id)
hash || raise_parameter_is_required_error(:hash)
project_id || raise_project_id_is_required_error

request = Web::Request.new(
self,
:patch,
"/projects/#{project_id}/distributions/#{hash}",
query
)

request.perform
end

def get_destribution_release(hash = nil, project_id = config.project_id)
hash || raise_parameter_is_required_error(:hash)
project_id || raise_project_id_is_required_error

request = Web::Request.new(
self,
:get,
"/projects/#{project_id}/distributions/#{hash}/release"
)

request.perform
end

def release_distribution(hash = nil, project_id = config.project_id)
hash || raise_parameter_is_required_error(:hash)
project_id || raise_project_id_is_required_error

request = Web::Request.new(
self,
:post,
"/projects/#{project_id}/distributions/#{hash}/release"
)

request.perform
end
end
end
end
Loading

0 comments on commit dafc90f

Please sign in to comment.