dato 0.7.16 → 0.7.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5497d73f33b5f38e2f931d32bba7fa6362d5069d0b8fa5cf3b85326f339ab0ba
4
- data.tar.gz: b085c940d24c1f3a2bea211ad0fef22cf0455bbb958c85c0932fa4659c9a362c
3
+ metadata.gz: fe8a9078fb6f9d6b37f6d9e371dbfcd417b2be9d2108395ad742a37b1f361262
4
+ data.tar.gz: 3466ff70f311f4c7208ff37ce20c2b2753cfd9eac05ac912cc42412748be3244
5
5
  SHA512:
6
- metadata.gz: ce46783a3fe8719de2400ea08b94bde2b7c64856c889129cd22580c97e727931c8025f97740dd8c5124997d973178aff3b284f103967bee91ff4a857151afc6f
7
- data.tar.gz: dce4329c9bf0a556a0044b7e17c21e4e091a51da35466734fd03987dd59206a5f00d57b7496f0c46451cba4ebaf446628664bac89d0454f824488108825d23e4
6
+ metadata.gz: 23adcec27891f974552ee201cddc28b982579f849ffbaaaf88c4fad678460ce10effec7a52a65a4cd548253f79bfbe22c98b6f78caf8c95fb6dba3005b4eab3d
7
+ data.tar.gz: 32aea1391ce6f54ab64af0de2ec95619b7a3ece9644dfa98ed0b6bcefa819de797ea3b6b87741235b561a73aab952643cb9ecf47e7fae97cc9d323700f60360e
@@ -38,40 +38,40 @@ Find more info [on the documentation](https://www.datocms.com/docs/content-manag
38
38
 
39
39
  # 0.7.11 (not released)
40
40
 
41
- - Updated specs cassettes after `appeareance -> appearance` typo fix
42
- - Some style changes
41
+ * Updated specs cassettes after `appeareance -> appearance` typo fix
42
+ * Some style changes
43
43
 
44
44
  # 0.7.10
45
45
 
46
- - Fixed SEO title retrieval. Now it fallbacks to default SEO title is item title is blank
46
+ * Fixed SEO title retrieval. Now it fallbacks to default SEO title is item title is blank
47
47
 
48
48
  # 0.7.9
49
49
 
50
- - Added new attributes to uploads
50
+ * Added new attributes to uploads
51
51
 
52
52
  # 0.7.0
53
53
 
54
- - Real-time events are now much more granular and the gem avoids downloading all the content every time a change occurs
54
+ * Real-time events are now much more granular and the gem avoids downloading all the content every time a change occurs
55
55
 
56
56
  # 0.6.18
57
57
 
58
- - Fixed regression where you could no longer access items' item type
58
+ * Fixed regression where you could no longer access items' item type
59
59
 
60
60
  # 0.6.15
61
61
 
62
- - Handle `429 Too Many Requests` responses from API
62
+ * Handle `429 Too Many Requests` responses from API
63
63
 
64
64
  # 0.6.12
65
65
 
66
- - Allow empty responses from server
66
+ * Allow empty responses from server
67
67
 
68
68
  # 0.6.10
69
69
 
70
- - Introduced `.meta` on `Dato::Local::Item` to fetch all meta information about the records
70
+ * Introduced `.meta` on `Dato::Local::Item` to fetch all meta information about the records
71
71
 
72
72
  # 0.6.5
73
73
 
74
- - The `.seo_meta_tags` method now generates fallback titles based on the model field title
74
+ * The `.seo_meta_tags` method now generates fallback titles based on the model field title
75
75
 
76
76
  # v0.6.2
77
77
 
@@ -79,7 +79,7 @@ Moved `json_schema` as runtime dependency
79
79
 
80
80
  # v0.6.1
81
81
 
82
- The big change is that the methods the client makes available are generated at runtime based on the [JSON Schema of our CMA](https://www.datocms.com/content-management-api/). This means any new API endpoint — or changes to existing ones — will instantly be reflected to the client, without the need to upgrade to the latest client version.
82
+ The big change is that the methods the client makes available are generated at runtime based on the [JSON Schema of our CMA](https://www.datocms.com/content-management-api/). This means any new API endpoint — or changes to existing ones — will instantly be reflected to the client, without the need to upgrade to the latest client version.
83
83
 
84
84
  We also added a new `deserialize_response` option to every call, that you can use if you want to retrieve the exact payload the DatoCMS returns:
85
85
 
@@ -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.16'
4
+ VERSION = '0.7.17'
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.16
4
+ version: 0.7.17
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-30 00:00:00.000000000 Z
11
+ date: 2020-10-07 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,8 +479,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
479
479
  - !ruby/object:Gem::Version
480
480
  version: '0'
481
481
  requirements: []
482
- rubygems_version: 3.0.3
483
- signing_key:
482
+ rubyforge_project:
483
+ rubygems_version: 2.7.6
484
+ signing_key:
484
485
  specification_version: 4
485
486
  summary: Ruby client for DatoCMS API
486
487
  test_files: []