dato 0.7.14 → 0.7.15

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
  SHA256:
3
- metadata.gz: ffe0429654722ca0165930dc29c1a0350bb386cd73b6c824d2d43cc0af8bb13f
4
- data.tar.gz: fc124f52acef1d95d507dce6a9c45fa7556b9c5a018b9f630fbd688282015eb7
3
+ metadata.gz: 7779edc00921c84e0f98aee2008bb8fd3f89d893c02107d965db12d1f5bc7882
4
+ data.tar.gz: 25ba5f84f8a6236c40d2846ef976987501f4977d481c9c445e298b666bc6b1ec
5
5
  SHA512:
6
- metadata.gz: 7981652ff2a86c8f6081bbb3b7c4fa3d148ba2b159009e5528df476f3ee0517f95c98f7bb8f035c0d09e694f562b06d50a3df44910930a478df3676940508f77
7
- data.tar.gz: 396828391163788c25f77da2d01c576d6c4cbad8993dda40d97b7700cb1896c7426897613dc9cc40c99177d7cdc8846a382d8ca9e2f37f0152abf3ff82636efe
6
+ metadata.gz: 955b67a6fadad2fb96e1342ec2e8907f5084085e0f18737655ebac56a4a8661e5d670ff9e662b3afc21381636139480f86ae48d47f268b571a21fcfa470de8c2
7
+ data.tar.gz: 479fe2e231a44cdf9518961c98bfddbd67ac06d4cd511e37a7369d668e5f0fa4eeca195d8af09bd981277a5c195f01d5f368f6b134562ebdd8f43df0c47a8c91
@@ -100,10 +100,11 @@ module Dato
100
100
  sleep(1)
101
101
  request(*args)
102
102
  else
103
+ # puts body.inspect
104
+ # puts '===='
105
+ # puts error.message
106
+ # puts '===='
103
107
  error = ApiError.new(e.response)
104
- puts '===='
105
- puts error.message
106
- puts '===='
107
108
  raise error
108
109
  end
109
110
  end
@@ -23,8 +23,10 @@ module Dato
23
23
  data[:type] = type
24
24
  data[:attributes] = serialized_attributes(resource)
25
25
 
26
- if relationships.any?
27
- data[:relationships] = serialized_relationships(resource)
26
+ serialized_relationships = serialized_relationships(resource)
27
+
28
+ if serialized_relationships
29
+ data[:relationships] = serialized_relationships
28
30
  end
29
31
 
30
32
  { data: data }
@@ -82,7 +84,7 @@ module Dato
82
84
  end
83
85
  end
84
86
 
85
- result
87
+ result.empty? ? nil : result
86
88
  end
87
89
 
88
90
  def attributes(resource)
@@ -110,7 +112,11 @@ module Dato
110
112
  end
111
113
 
112
114
  def required_relationships
113
- (link_relationships.required || []).map(&:to_sym)
115
+ if link.schema.properties['data'].required.include?("relationships")
116
+ (link_relationships.required || []).map(&:to_sym)
117
+ else
118
+ []
119
+ end
114
120
  end
115
121
 
116
122
  def link_attributes
@@ -18,6 +18,7 @@ module Dato
18
18
  v[:alt],
19
19
  v[:title],
20
20
  v[:custom_data],
21
+ v[:focal_point],
21
22
  repo.site.entity.imgix_host
22
23
  )
23
24
  end
@@ -29,12 +30,14 @@ module Dato
29
30
  alt,
30
31
  title,
31
32
  custom_data,
33
+ focal_point,
32
34
  imgix_host
33
35
  )
34
36
  @upload = upload
35
37
  @alt = alt
36
38
  @title = title
37
39
  @custom_data = custom_data
40
+ @focal_point = focal_point
38
41
  @imgix_host = imgix_host
39
42
  end
40
43
 
@@ -100,6 +103,12 @@ module Dato
100
103
  @custom_data.merge(default_metadata.fetch('custom_data', {}))
101
104
  end
102
105
 
106
+ def focal_point
107
+ default_metadata = @upload.default_field_metadata.deep_stringify_keys
108
+ .fetch(I18n.locale.to_s, {})
109
+ @focal_point || default_metadata['focal_point']
110
+ end
111
+
103
112
  def tags
104
113
  @upload.tags
105
114
  end
@@ -216,8 +225,25 @@ module Dato
216
225
  ).path(path)
217
226
  end
218
227
 
219
- def url(opts = {})
220
- file.to_url(opts)
228
+ def url(query = {})
229
+ query.deep_stringify_keys!
230
+
231
+ if focal_point &&
232
+ query["fit"] == "crop" &&
233
+ (query["h"] || query["height"]) &&
234
+ (query["w"] || query["width"]) &&
235
+ [nil, "focalpoint"].include?(query["crop"]) &&
236
+ query["fp-x"].nil? &&
237
+ query["fp-y"].nil?
238
+
239
+ query.merge!(
240
+ "crop" => "focalpoint",
241
+ "fp-x" => focal_point[:x],
242
+ "fp-y" => focal_point[:y],
243
+ )
244
+ end
245
+
246
+ file.to_url(query)
221
247
  end
222
248
 
223
249
  def lqip_data_url(opts = {})
@@ -241,6 +267,7 @@ module Dato
241
267
  alt: alt,
242
268
  title: title,
243
269
  custom_data: custom_data,
270
+ focal_point: focal_point,
244
271
  url: url,
245
272
  copyright: copyright,
246
273
  tags: tags,
@@ -72,7 +72,7 @@ module Dato
72
72
  end
73
73
  connection.get(url).body
74
74
  rescue Faraday::Error => e
75
- puts "Error during uploading #{url}"
75
+ puts "Error during upload of #{url}: #{e.message}"
76
76
  raise e
77
77
  end
78
78
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dato
4
- VERSION = '0.7.14'
4
+ VERSION = '0.7.15'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.14
4
+ version: 0.7.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Verna
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-07 00:00:00.000000000 Z
11
+ date: 2020-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -464,7 +464,7 @@ homepage: https://github.com/datocms/ruby-datocms-client
464
464
  licenses:
465
465
  - MIT
466
466
  metadata: {}
467
- post_install_message:
467
+ post_install_message:
468
468
  rdoc_options: []
469
469
  require_paths:
470
470
  - lib
@@ -479,9 +479,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
479
479
  - !ruby/object:Gem::Version
480
480
  version: '0'
481
481
  requirements: []
482
- rubyforge_project:
482
+ rubyforge_project:
483
483
  rubygems_version: 2.7.6
484
- signing_key:
484
+ signing_key:
485
485
  specification_version: 4
486
486
  summary: Ruby client for DatoCMS API
487
487
  test_files: []