dato 0.3.2 → 0.3.3

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
  SHA1:
3
- metadata.gz: b22dc599e5529754089542cb6ce568607eb59e86
4
- data.tar.gz: fd19980cc06613e5a4dd4d26874eefbe3148226f
3
+ metadata.gz: b9ddbcaa4cd09253d0a43f0f05169498d22e125e
4
+ data.tar.gz: 16f0cf8243fd0f9519f78bc49fceb1a41cb6c85a
5
5
  SHA512:
6
- metadata.gz: 28b6e5b8a8cde330ad75c386b97a85746d3985ef9188a88daa78bea84224fad5dcfcb4ab96e3b592c4a5920dfc817ad47b78c5d5b6e072d1ffd3c3498de5c381
7
- data.tar.gz: 09c7c0f716d9552054faec5f306b293f072d8c217d34f911ce722f1eae3df9eba4ad2a21743f9612f4f4170d8565d760b39bd09345576ced1ffb6a07603b2bf8
6
+ metadata.gz: 53899624f929cdc34a587426ab3fc21a18e5096b6b1f87ffe5cf959087d2c8a42bf2ef27baf775acf81aa6e0203774f9667767994e6421723a2ecc60d9b53f9e
7
+ data.tar.gz: 7363a20c682292080b81a2f55a47d7ed0a7924d2e998dfd6e22c3c2f8b604627319153a7960e8eba65075ccf3d840b3eb36a6b7c6d2d371aa682d841c1c142cd
@@ -4,7 +4,7 @@ module Dato
4
4
  module FieldType
5
5
  class Date
6
6
  def self.parse(value, _repo)
7
- ::Date.parse(value)
7
+ value && ::Date.parse(value)
8
8
  end
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ module Dato
4
4
  module FieldType
5
5
  class DateTime
6
6
  def self.parse(value, _repo)
7
- ::Time.parse(value).utc
7
+ value && ::Time.parse(value).utc
8
8
  end
9
9
  end
10
10
  end
@@ -8,7 +8,7 @@ module Dato
8
8
  attr_reader :path, :format, :size
9
9
 
10
10
  def self.parse(value, _repo)
11
- new(
11
+ value && new(
12
12
  value[:path],
13
13
  value[:format],
14
14
  value[:size]
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ require 'dato/local/field_type/file'
3
+
4
+ module Dato
5
+ module Local
6
+ module FieldType
7
+ class Gallery < Array
8
+ def self.parse(value, repo)
9
+ images = if value
10
+ value.map { |image| FieldType::Image.parse(image, repo) }
11
+ else
12
+ []
13
+ end
14
+ new(images)
15
+ end
16
+
17
+ def to_hash
18
+ map(&:to_hash)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -11,7 +11,7 @@ module Dato
11
11
  attr_reader :facebook_page_url
12
12
 
13
13
  def self.parse(value, _repo)
14
- new(
14
+ value && new(
15
15
  value[:site_name],
16
16
  value[:title_suffix],
17
17
  value[:twitter_account],
@@ -5,22 +5,26 @@ module Dato
5
5
  module Local
6
6
  module FieldType
7
7
  class Image < Dato::Local::FieldType::File
8
- attr_reader :width, :height
8
+ attr_reader :width, :height, :title, :alt
9
9
 
10
10
  def self.parse(value, _repo)
11
- new(
11
+ value && new(
12
12
  value[:path],
13
13
  value[:format],
14
14
  value[:size],
15
15
  value[:width],
16
- value[:height]
16
+ value[:height],
17
+ value[:alt],
18
+ value[:title]
17
19
  )
18
20
  end
19
21
 
20
- def initialize(path, format, size, width, height)
22
+ def initialize(path, format, size, width, height, alt, title)
21
23
  super(path, format, size)
22
24
  @width = width
23
25
  @height = height
26
+ @alt = alt
27
+ @title = title
24
28
  end
25
29
 
26
30
  alias raw_file file
@@ -32,7 +36,9 @@ module Dato
32
36
  def to_hash
33
37
  super.merge(
34
38
  width: width,
35
- height: height
39
+ height: height,
40
+ alt: alt,
41
+ title: title
36
42
  )
37
43
  end
38
44
  end
@@ -6,7 +6,7 @@ module Dato
6
6
  attr_reader :latitude, :longitude
7
7
 
8
8
  def self.parse(value, _repo)
9
- new(value[:latitude], value[:longitude])
9
+ value && new(value[:latitude], value[:longitude])
10
10
  end
11
11
 
12
12
  def initialize(latitude, longitude)
@@ -4,7 +4,7 @@ module Dato
4
4
  module FieldType
5
5
  class Link
6
6
  def self.parse(value, repo)
7
- repo.find(value)
7
+ value && repo.find(value)
8
8
  end
9
9
  end
10
10
  end
@@ -4,7 +4,12 @@ module Dato
4
4
  module FieldType
5
5
  class Links < Array
6
6
  def self.parse(ids, repo)
7
- new(ids.map { |id| repo.find(id) })
7
+ items = if ids
8
+ ids.map { |id| repo.find(id) }
9
+ else
10
+ []
11
+ end
12
+ new(items)
8
13
  end
9
14
 
10
15
  def to_hash
@@ -6,7 +6,7 @@ module Dato
6
6
  attr_reader :title, :description
7
7
 
8
8
  def self.parse(value, _repo)
9
- new(value[:title], value[:description], value[:image])
9
+ value && new(value[:title], value[:description], value[:image])
10
10
  end
11
11
 
12
12
  def initialize(title, description, image)
@@ -16,7 +16,7 @@ module Dato
16
16
  attr_reader :provider_uid
17
17
 
18
18
  def self.parse(value, _repo)
19
- new(
19
+ value && new(
20
20
  value[:url],
21
21
  value[:thumbnail_url],
22
22
  value[:title],
@@ -124,7 +124,7 @@ module Dato
124
124
  end
125
125
 
126
126
  if type_klass
127
- value && type_klass.parse(value, @items_repo)
127
+ type_klass.parse(value, @items_repo)
128
128
  else
129
129
  warning = [
130
130
  "Warning: unrecognized field of type `#{field_type}`",
@@ -126,9 +126,10 @@ module Dato
126
126
  def build_singletons_by_type!
127
127
  item_types.each do |item_type|
128
128
  method = item_type_methods[item_type]
129
- if item_type.singleton
130
- @collections_by_type[method] = @items_by_id[item_type.singleton_item.id]
131
- end
129
+ next unless item_type.singleton
130
+ @collections_by_type[method] = @items_by_id[
131
+ item_type.singleton_item.id
132
+ ]
132
133
  end
133
134
  end
134
135
 
@@ -58,7 +58,7 @@ module Dato
58
58
  entity.send(method)
59
59
  end
60
60
 
61
- value && type_klass.parse(value, @items_repo)
61
+ type_klass.parse(value, @items_repo)
62
62
  end
63
63
  end
64
64
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Dato
3
- VERSION = '0.3.2'
3
+ VERSION = '0.3.3'
4
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'pusher-client'
2
3
 
3
4
  module Dato
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.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Verna
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-17 00:00:00.000000000 Z
11
+ date: 2016-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -402,6 +402,7 @@ files:
402
402
  - lib/dato/local/field_type/date_time.rb
403
403
  - lib/dato/local/field_type/file.rb
404
404
  - lib/dato/local/field_type/float.rb
405
+ - lib/dato/local/field_type/gallery.rb
405
406
  - lib/dato/local/field_type/global_seo.rb
406
407
  - lib/dato/local/field_type/image.rb
407
408
  - lib/dato/local/field_type/integer.rb