dato 0.7.8 → 0.7.9

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: c290af75b0de6f8cd9b187448294b82d731b17d31d4443b1f40b5349fdb9c618
4
- data.tar.gz: c127cf9869c434dce38bb77ba81895bf5ef351bee5a9b0edc9ef2d0fec510753
3
+ metadata.gz: 2faaeda3b7c9f1317aeaa5291274cd1e66f7ec352f45f4513ca3e44747d6d816
4
+ data.tar.gz: 4a8afc49f92605e0c1bcbdd5473d07bbc83f34d7f71e20cf44414489eaa48504
5
5
  SHA512:
6
- metadata.gz: d5552912880af2435a664eed763cb18e858b8653dae00f85f5915b0c7245225454538fe8da7e08e14d6e2fd7e460ed67e4770d1053df78c146060009aee0dfa5
7
- data.tar.gz: 830e413829504a1ae8fc076fc3cb7a9a6b5e60dd9652df2121dca94eaa5a4e3cf68f498796411e09bda3be862ab0515a750c3a97c723a49a0a75422cce6c0c88
6
+ metadata.gz: e64850f3e6bb5d754e1d365d03538d42e37b6798ac177bd6e6eb1297e5431a43f4261c1ad29c05f9d0ecb29d8e7c5200c1d9f4fecb1b4440e3fa37f9b7c7bfc7
7
+ data.tar.gz: cd164fe876d2bd58d23c742ae8b96bffa66e58f896d43f641ac0fe5c2ba736b4d5476aac7b17091c78154ec96a617d210d841039fcd92a34c562a356c4dda053
@@ -1,3 +1,7 @@
1
+ # 0.7.9
2
+
3
+ * Added new attributes to uploads
4
+
1
5
  # 0.7.0
2
6
 
3
7
  * Real-time events are now much more granular and the gem avoids downloading all the content every time a change occurs
@@ -74,19 +74,138 @@ module Dato
74
74
  @upload.copyright
75
75
  end
76
76
 
77
+ def filename
78
+ @upload.filename
79
+ end
80
+
81
+ def basename
82
+ @upload.basename
83
+ end
84
+
77
85
  def alt
78
- default_metadata = @upload.default_field_metadata.deep_stringify_keys.fetch(I18n.locale.to_s, {})
79
- @alt || default_metadata["alt"]
86
+ default_metadata = @upload.default_field_metadata.deep_stringify_keys
87
+ .fetch(I18n.locale.to_s, {})
88
+ @alt || default_metadata['alt']
80
89
  end
81
90
 
82
91
  def title
83
- default_metadata = @upload.default_field_metadata.deep_stringify_keys.fetch(I18n.locale.to_s, {})
84
- @title || default_metadata["title"]
92
+ default_metadata = @upload.default_field_metadata.deep_stringify_keys
93
+ .fetch(I18n.locale.to_s, {})
94
+ @title || default_metadata['title']
85
95
  end
86
96
 
87
97
  def custom_data
88
- default_metadata = @upload.default_field_metadata.deep_stringify_keys.fetch(I18n.locale.to_s, {})
89
- @custom_data.merge(default_metadata.fetch("custom_data", {}))
98
+ default_metadata = @upload.default_field_metadata.deep_stringify_keys
99
+ .fetch(I18n.locale.to_s, {})
100
+ @custom_data.merge(default_metadata.fetch('custom_data', {}))
101
+ end
102
+
103
+ def tags
104
+ @upload.tags
105
+ end
106
+
107
+ def smart_tags
108
+ @upload.smart_tags
109
+ end
110
+
111
+ def is_image
112
+ @upload.is_image
113
+ end
114
+
115
+ def exif_info
116
+ @upload.exif_info
117
+ end
118
+
119
+ def mime_type
120
+ @upload.mime_type
121
+ end
122
+
123
+ def colors
124
+ @upload.colors.map { |color| Color.parse(color, nil) }
125
+ end
126
+
127
+ def blurhash
128
+ @upload.blurhash
129
+ end
130
+
131
+ class VideoAttributes
132
+ def initialize(upload)
133
+ @upload = upload
134
+ end
135
+
136
+ def mux_playback_id
137
+ @upload.mux_playback_id
138
+ end
139
+
140
+ def frame_rate
141
+ @upload.frame_rate
142
+ end
143
+
144
+ def duration
145
+ @upload.duration
146
+ end
147
+
148
+ def streaming_url
149
+ "https://stream.mux.com/#{@upload.mux_playback_id}.m3u8"
150
+ end
151
+
152
+ def thumbnail_url(format = :jpg)
153
+ if format == :gif
154
+ "https://image.mux.com/#{@upload.mux_playback_id}/animated.gif"
155
+ else
156
+ "https://image.mux.com/#{@upload.mux_playback_id}/thumbnail.#{format}"
157
+ end
158
+ end
159
+
160
+ def mp4_url(options = nil)
161
+ @upload.mux_mp4_highest_res or
162
+ return nil
163
+
164
+ if options && options[:exact_res]
165
+ if options[:exact_res] == :low
166
+ raw_mp4_url("low")
167
+ elsif options[:exact_res] == :medium
168
+ if %w[medium high].include?(@upload.mux_mp4_highest_res)
169
+ raw_mp4_url("medium")
170
+ end
171
+ elsif @upload.mux_mp4_highest_res == :high
172
+ raw_mp4_url("high")
173
+ end
174
+ elsif options && options[:res] == :low
175
+ raw_mp4_url("low")
176
+ elsif options && options[:res] == :medium
177
+ if %w[low medium].include?(@upload.mux_mp4_highest_res)
178
+ raw_mp4_url(@upload.mux_mp4_highest_res)
179
+ else
180
+ raw_mp4_url("medium")
181
+ end
182
+ else
183
+ raw_mp4_url(@upload.mux_mp4_highest_res)
184
+ end
185
+ end
186
+
187
+ def to_hash
188
+ {
189
+ mux_playback_id: mux_playback_id,
190
+ frame_rate: frame_rate,
191
+ duration: duration,
192
+ streaming_url: streaming_url,
193
+ thumbnail_url: thumbnail_url,
194
+ mp4_url: mp4_url,
195
+ }
196
+ end
197
+
198
+ private
199
+
200
+ def raw_mp4_url(res)
201
+ "https://stream.mux.com/#{@upload.mux_playback_id}/#{res}.mp4"
202
+ end
203
+ end
204
+
205
+ def video
206
+ if @upload.mux_playback_id
207
+ VideoAttributes.new(@upload)
208
+ end
90
209
  end
91
210
 
92
211
  def file
@@ -111,7 +230,18 @@ module Dato
111
230
  alt: alt,
112
231
  title: title,
113
232
  custom_data: custom_data,
114
- url: url
233
+ url: url,
234
+ copyright: copyright,
235
+ tags: tags,
236
+ smart_tags: smart_tags,
237
+ filename: filename,
238
+ basename: basename,
239
+ is_image: is_image,
240
+ exif_info: exif_info,
241
+ mime_type: mime_type,
242
+ colors: colors.map(&:to_hash),
243
+ blurhash: blurhash,
244
+ video: video && video.to_hash
115
245
  }
116
246
  end
117
247
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dato
4
- VERSION = '0.7.8'
4
+ VERSION = '0.7.9'
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.8
4
+ version: 0.7.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Verna
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-30 00:00:00.000000000 Z
11
+ date: 2019-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler