abbyy-cloud 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2c718870d311c032c56d09eaefe85358d8053c6
4
- data.tar.gz: 6b5236b37d7d2362cdb46f390a99cc4ed4d84675
3
+ metadata.gz: b2bb5a00bd968d42ffd282e36baad493f4b12d40
4
+ data.tar.gz: 3fa49d803793d4a754d9de5b8ecffe383a25da96
5
5
  SHA512:
6
- metadata.gz: e18b7be8f087be2564513df127d8676f7a0047cf807fc7ad8b12332505c69cad972c9c3ef76dcd74687ad3f57521bde7d1b27aad0f83b24729f6958d0fe87b4f
7
- data.tar.gz: 7db9109e79a27f3100ad6e198b5e4f967e61662d181da6cb351c8e3ee5bb298f4e69a0fe60c038fdcb89699c800cce344e994fb6787d64a36510abb331803083
6
+ metadata.gz: 4c29312f49b5b07f0a1dde5facbbdb52513bed58582524c5459532a9ae8479a6d09f67aa4679720abb6260a10f7362f6caa57a178caaf0a3a2d32f36fe20cb88
7
+ data.tar.gz: bedf9412d5be453309dda444096eb314301f6f90471b7028956e8a3edb70c2fef22e3ea0e4351818eaae484ede6993585ad7dc90d7ef8315744d31921222cfa6
@@ -1,6 +1,10 @@
1
- # Master (to be released)
1
+ # [v0.0.10 2016-10-11](https://github.com/nepalez/abbyy-cloud/tree/v0.0.10)
2
2
 
3
- [Compare v0.0.9...HEAD](https://github.com/nepalez/abbyy-cloud/compare/v0.0.9...HEAD)
3
+ ### Internal
4
+
5
+ * Switched to `dry-initializer` gem v0.9.2+ (nepalez)
6
+
7
+ [Compare v0.0.9...v0.0.10](https://github.com/nepalez/abbyy-cloud/compare/v0.0.9...v0.0.10)
4
8
 
5
9
  # [v0.0.9 2016-10-11](https://github.com/nepalez/abbyy-cloud/tree/v0.0.9)
6
10
 
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = "abbyy-cloud"
6
- gem.version = "0.0.9"
6
+ gem.version = "0.0.10"
7
7
  gem.authors = ["Andrew Kozin"]
8
8
  gem.email = ["andrew.kozin@gmail.com"]
9
9
  gem.summary = "HTTP client to ABBYY Cloud API"
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
 
18
18
  gem.required_ruby_version = ">= 2.3.0"
19
19
 
20
- gem.add_runtime_dependency "dry-initializer", "~> 0.6"
20
+ gem.add_runtime_dependency "dry-initializer", "~> 0.9.2"
21
21
  gem.add_runtime_dependency "dry-types", "~> 0.9.0"
22
22
  gem.add_runtime_dependency "hashie", "~> 3.4"
23
23
  gem.add_runtime_dependency "multipart_body", "~> 0.2"
@@ -7,8 +7,13 @@ class ABBYY::Cloud
7
7
  def initialize(response)
8
8
  @status = response.code.to_i
9
9
  @data = Models::Error[parse_response(response)] unless @status == 500
10
+ super
11
+ end
12
+
13
+ private
10
14
 
11
- super <<-MESSAGE.gsub(/ +\|/, "")
15
+ def message
16
+ <<-MESSAGE.gsub(/ +\|/, "")
12
17
  |ABBYY Cloud API responded to the request #{data&.request_id} with a status #{status}
13
18
  | error: #{data&.error}
14
19
  | description: #{data&.error_description}
@@ -16,8 +21,6 @@ class ABBYY::Cloud
16
21
  MESSAGE
17
22
  end
18
23
 
19
- private
20
-
21
24
  def parse_response(response)
22
25
  JSON.parse(response.body)
23
26
  rescue
@@ -8,35 +8,44 @@
8
8
  #
9
9
  class ABBYY::Cloud
10
10
  class Model
11
- class << self
12
- include Dry::Initializer::Mixin
13
- alias_method :attribute, :option
14
- alias_method :param, :option
11
+ extend Dry::Initializer::Mixin
15
12
 
13
+ class << self
16
14
  def new(value)
17
15
  return value if value.is_a? self
18
16
  value = value.to_h.each_with_object({}) do |(key, val), obj|
19
17
  obj[key.to_sym] = val
20
18
  end
19
+
21
20
  super value
22
21
  end
23
22
  alias_method :call, :new
24
23
  alias_method :[], :new
25
- end
26
24
 
27
- tolerant_to_unknown_options
25
+ def attributes
26
+ @attributes ||= []
27
+ end
28
+
29
+ def option(name, type = nil, as: nil, **opts)
30
+ super.tap { attributes << (as || name).to_sym }
31
+ end
32
+ alias_method :attribute, :option
33
+ alias_method :param, :option
34
+
35
+ private
36
+
37
+ def inherited(klass)
38
+ super
39
+ klass.instance_variable_set :@attributes, attributes.dup
40
+ end
41
+ end
28
42
 
29
43
  def ==(other)
30
- return false unless other.respond_to? :to_h
31
- to_h == other.to_h
44
+ other.respond_to?(:to_h) ? to_h == other.to_h : false
32
45
  end
33
46
 
34
47
  def to_h
35
- attributes = method(:initialize)
36
- .parameters
37
- .map { |item| item[1] unless item[0] == :keyrest }.compact
38
-
39
- attributes.each_with_object({}) do |key, hash|
48
+ self.class.attributes.each_with_object({}) do |key, hash|
40
49
  val = send(key)
41
50
  hash[key] = hashify(val) unless val == Dry::Initializer::UNDEFINED
42
51
  end
@@ -4,10 +4,9 @@ require_relative "direction"
4
4
  class ABBYY::Cloud
5
5
  module Models
6
6
  class Engine < Model
7
- attribute :name, type: Types::Strict::String
8
- attribute :languages, type: Types::Array.member(Types::Locale)
9
- attribute :translation_directions,
10
- type: Types::Array.member(Types::Direction)
7
+ attribute :name, Types::Strict::String
8
+ attribute :languages, Types::Array.member(Types::Locale)
9
+ attribute :translation_directions, Types::Array.member(Types::Direction)
11
10
  end
12
11
 
13
12
  # Registers type Types::Engine
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abbyy-cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kozin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-11 00:00:00.000000000 Z
11
+ date: 2016-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-initializer
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.6'
19
+ version: 0.9.2
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: '0.6'
26
+ version: 0.9.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: dry-types
29
29
  requirement: !ruby/object:Gem::Requirement