fun_translations 0.0.1.rc1 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/LICENSE.md +1 -1
- data/Rakefile +26 -4
- data/fun_translations.gemspec +6 -1
- data/lib/fun_translations/request.rb +3 -2
- data/lib/fun_translations/translation.rb +5 -3
- data/lib/fun_translations/version.rb +1 -1
- data/lib/fun_translations.rb +1 -0
- metadata +36 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 994d5f1ce5c6cd0ca94cc74f5094798c53edb920af2139812299fd63578730b1
|
4
|
+
data.tar.gz: 39cd9b1094616068c3e713ae0b362842d7e04315c5fd2e890727cec6067d5236
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3ebfd26848a1b1bd1741d0d8e5ae696c98088b3800c0765eaeb93f6d4309e7d5ba3217ba4246512abf275a1e5e70d18a31f3328075ae1a4a704f48f5d097017
|
7
|
+
data.tar.gz: 508deffe255b4726099597899f823efa532e081c3877317285251e0a642e3a1463bf5ee84415702618dd4773f5f6a8a8b0430c8e5d331d143e5df2b33d7df1c9
|
data/CHANGELOG.md
CHANGED
data/LICENSE.md
CHANGED
data/Rakefile
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'rake'
|
4
|
+
require 'rake/clean'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
require 'rubocop/rake_task'
|
4
7
|
|
5
8
|
begin
|
6
9
|
require 'bundler/setup'
|
@@ -9,13 +12,32 @@ rescue LoadError
|
|
9
12
|
puts 'although not required, bundler is recommened for running the tests'
|
10
13
|
end
|
11
14
|
|
12
|
-
task default: :spec
|
13
|
-
|
14
|
-
require 'rspec/core/rake_task'
|
15
15
|
RSpec::Core::RakeTask.new(:spec)
|
16
16
|
|
17
|
-
require 'rubocop/rake_task'
|
18
17
|
RuboCop::RakeTask.new do |task|
|
19
18
|
task.requires << 'rubocop-performance'
|
20
19
|
task.requires << 'rubocop-rspec'
|
21
20
|
end
|
21
|
+
|
22
|
+
namespace :fun_translations do
|
23
|
+
CLOBBER.include(FileList['./*.gem'])
|
24
|
+
|
25
|
+
desc 'Updates RubyGems, installs dependencies'
|
26
|
+
task :install do
|
27
|
+
puts 'Running bundle install'
|
28
|
+
sh 'gem update --system'
|
29
|
+
sh 'bundle'
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'Builds the gem'
|
33
|
+
task :build do
|
34
|
+
puts 'Building'
|
35
|
+
sh 'gem build fun_translations.gemspec'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
task rubospec: %w[rubocop spec]
|
40
|
+
|
41
|
+
task full_build: %w[clobber fun_translations:install fun_translations:build]
|
42
|
+
|
43
|
+
task default: :full_build
|
data/fun_translations.gemspec
CHANGED
@@ -23,17 +23,22 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
25
|
spec.add_dependency 'faraday', '~> 2.6'
|
26
|
+
spec.add_dependency 'json', '~> 2'
|
26
27
|
spec.add_dependency 'zeitwerk', '~> 2.4'
|
27
28
|
spec.add_development_dependency 'codecov', '~> 0.1'
|
28
29
|
spec.add_development_dependency 'rake', '~> 13.0'
|
29
30
|
spec.add_development_dependency 'rspec', '~> 3.6'
|
30
31
|
spec.add_development_dependency 'rubocop', '~> 1.6'
|
31
32
|
spec.add_development_dependency 'rubocop-performance', '~> 1.5'
|
33
|
+
spec.add_development_dependency 'rubocop-rake', '~> 0.6'
|
32
34
|
spec.add_development_dependency 'rubocop-rspec', '~> 2.0'
|
33
35
|
spec.add_development_dependency 'simplecov', '~> 0.16'
|
34
36
|
spec.add_development_dependency 'webmock', '~> 3.14'
|
35
37
|
|
36
38
|
spec.metadata = {
|
37
|
-
'
|
39
|
+
'source_code_uri' => 'https://github.com/bodrovis/fun_translations',
|
40
|
+
'rubygems_mfa_required' => 'true',
|
41
|
+
'changelog_uri' => 'https://github.com/bodrovis/fun_translations/blob/master/CHANGELOG.md',
|
42
|
+
'bug_tracker_uri' => 'https://github.com/bodrovis/fun_translations/issues'
|
38
43
|
}
|
39
44
|
end
|
@@ -20,7 +20,8 @@ module FunTranslations
|
|
20
20
|
# Parses response body using JSON
|
21
21
|
# or raises an error if the status code is not 2xx
|
22
22
|
def respond_with(response)
|
23
|
-
|
23
|
+
raw_body = response.body
|
24
|
+
body = raw_body.empty? ? raw_body : JSON.parse(raw_body)
|
24
25
|
|
25
26
|
respond_with_error(response.status, body['error']) if body.key?('error') || !response.success?
|
26
27
|
|
@@ -28,7 +29,7 @@ module FunTranslations
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def respond_with_error(code, body)
|
31
|
-
raise(FunTranslations::Error
|
32
|
+
raise(FunTranslations::Error.from_response(body)) unless FunTranslations::Error::ERRORS.key? code
|
32
33
|
|
33
34
|
raise FunTranslations::Error::ERRORS[code].from_response(body)
|
34
35
|
end
|
@@ -7,10 +7,12 @@ module FunTranslations
|
|
7
7
|
|
8
8
|
# Initializes a new Translation object
|
9
9
|
def initialize(raw_translation)
|
10
|
-
|
11
|
-
|
10
|
+
translated = raw_translation['translated']
|
11
|
+
|
12
|
+
if translated.respond_to?(:key?) && translated.key?('audio')
|
13
|
+
@audio = translated['audio']
|
12
14
|
else
|
13
|
-
@translated_text =
|
15
|
+
@translated_text = translated
|
14
16
|
end
|
15
17
|
|
16
18
|
@original_text = raw_translation['text']
|
data/lib/fun_translations.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fun_translations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1
|
4
|
+
version: 0.0.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: 2022-
|
11
|
+
date: 2022-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: zeitwerk
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +122,20 @@ dependencies:
|
|
108
122
|
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '1.5'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop-rake
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.6'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.6'
|
111
139
|
- !ruby/object:Gem::Dependency
|
112
140
|
name: rubocop-rspec
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,7 +207,10 @@ homepage: https://github.com/bodrovis/fun_translations
|
|
179
207
|
licenses:
|
180
208
|
- MIT
|
181
209
|
metadata:
|
210
|
+
source_code_uri: https://github.com/bodrovis/fun_translations
|
182
211
|
rubygems_mfa_required: 'true'
|
212
|
+
changelog_uri: https://github.com/bodrovis/fun_translations/blob/master/CHANGELOG.md
|
213
|
+
bug_tracker_uri: https://github.com/bodrovis/fun_translations/issues
|
183
214
|
post_install_message:
|
184
215
|
rdoc_options: []
|
185
216
|
require_paths:
|
@@ -191,11 +222,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
191
222
|
version: 2.7.0
|
192
223
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
224
|
requirements:
|
194
|
-
- - "
|
225
|
+
- - ">="
|
195
226
|
- !ruby/object:Gem::Version
|
196
|
-
version:
|
227
|
+
version: '0'
|
197
228
|
requirements: []
|
198
|
-
rubygems_version: 3.3.
|
229
|
+
rubygems_version: 3.3.26
|
199
230
|
signing_key:
|
200
231
|
specification_version: 4
|
201
232
|
summary: Ruby interface for FunTranslations API.
|