dato 0.3.6 → 0.3.7

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: 2483e2bce179699cf4d9adf4a8e05f25f66ee40b
4
- data.tar.gz: bc8e25b3b03a40fe8d6d68663612e62ff669d93b
3
+ metadata.gz: b565e0c69439a1ff651c792a9f667afdeed71d12
4
+ data.tar.gz: a545f329291e9778ff30d97c9489449df39804b7
5
5
  SHA512:
6
- metadata.gz: b8cacae14beebb7b76b163480f16dfb25d621d7a1e10b1af18791bf1285c8a96d0ef50489edfb5a6164fe2dcb3b52a0c8e625866aeb3c9ccdddf5a30df0cad15
7
- data.tar.gz: d152ae64a4158d6eece5b73d1f2d8a5e876e6d63b4745fd677837cd47b829205f8589c50427485d6bbde5e5ababe46babaca13a15857ca3833eefbff252b6db4
6
+ metadata.gz: 8183e81004df27ca2a3c373a32bb472b7851d4a9307891d3a10826a48031e3b36578b2d237455262bbef086b40f45e08e4a0ab3d99245fecba044b915275ae13
7
+ data.tar.gz: 8f72ca7d25556fa52e4c5cacc890144a2f7756b71ed401975bfb74cfb1213d3a55c71d25276fb403c3c9a41c803e61afbd0a16222b8fee66483a4703c431b36d
data/README.md CHANGED
@@ -16,7 +16,7 @@ Ruby client for the DatoCMS API.
16
16
  This gem can be used in different ways, so the documentation is split up in different files:
17
17
 
18
18
  * [I want to use the content of a DatoCMS site in my static website (Hugo, Jekyll, etc.)](https://github.com/datocms/ruby-datocms-client/blob/master/docs/dato-cli.md);
19
- * [I want to edit the contents of an existing DatoCMS site programmatically](https://github.com/datocms/ruby-datocms-client/blob/master/docs/site-api-client.md);
19
+ * [I want to edit the content of an existing DatoCMS site programmatically](https://github.com/datocms/ruby-datocms-client/blob/master/docs/site-api-client.md);
20
20
  * [I want to create new DatoCMS sites programmatically](https://github.com/datocms/ruby-datocms-client/blob/master/docs/account-api-client.md).
21
21
 
22
22
  ## Development
data/docs/dato-cli.md CHANGED
@@ -41,7 +41,7 @@ If everything worked correctly, you should now run `bundle exec dato` and see so
41
41
  ```
42
42
  $ bundle exec dato
43
43
  DatoCMS commands:
44
- dato dump --token=TOKEN # dumps DatoCMS contents into local files
44
+ dato dump --token=TOKEN # dumps DatoCMS content into local files
45
45
  dato help [COMMAND] # Describe available commands or one specific command
46
46
  ```
47
47
 
@@ -1,4 +1,4 @@
1
- # Edit the contents of an existing DatoCMS site
1
+ # Edit the content of an existing DatoCMS site
2
2
 
3
3
  With this gem, you can easily create, edit and destroy any object within a DatoCMS site:
4
4
 
data/lib/dato/cli.rb CHANGED
@@ -8,7 +8,7 @@ module Dato
8
8
  class Cli < Thor
9
9
  package_name 'DatoCMS'
10
10
 
11
- desc 'dump', 'dumps DatoCMS contents into local files'
11
+ desc 'dump', 'dumps DatoCMS content into local files'
12
12
  option :config, default: 'dato.config.rb'
13
13
  option :token, default: ENV['DATO_API_TOKEN'], required: true
14
14
  def dump
@@ -21,31 +21,25 @@ module Dato
21
21
  @size = size
22
22
  end
23
23
 
24
- def file(host = default_host)
24
+ def file
25
25
  Imgix::Client.new(
26
- host: host,
26
+ host: 'dato-images.imgix.net',
27
27
  secure: true,
28
28
  include_library_param: false
29
29
  ).path(path)
30
30
  end
31
31
 
32
- def url(host: default_host, **opts)
33
- file(host).to_url(opts)
32
+ def url(opts)
33
+ file.to_url(opts)
34
34
  end
35
35
 
36
- def to_hash
36
+ def to_hash(*args)
37
37
  {
38
38
  format: format,
39
39
  size: size,
40
40
  url: url
41
41
  }
42
42
  end
43
-
44
- private
45
-
46
- def default_host
47
- 'dato-images.imgix.net'
48
- end
49
43
  end
50
44
  end
51
45
  end
@@ -14,8 +14,8 @@ module Dato
14
14
  new(images)
15
15
  end
16
16
 
17
- def to_hash
18
- map(&:to_hash)
17
+ def to_hash(max_depth = 3, current_depth = 0)
18
+ map { |item| item.to_hash(max_depth, current_depth) }
19
19
  end
20
20
  end
21
21
  end
@@ -38,13 +38,13 @@ module Dato
38
38
  @fallback_seo && Seo.parse(@fallback_seo, nil)
39
39
  end
40
40
 
41
- def to_hash
41
+ def to_hash(*args)
42
42
  {
43
43
  site_name: site_name,
44
44
  title_suffix: title_suffix,
45
45
  twitter_account: twitter_account,
46
46
  facebook_page_url: facebook_page_url,
47
- fallback_seo: fallback_seo && fallback_seo.to_hash
47
+ fallback_seo: fallback_seo && fallback_seo.to_hash(*args)
48
48
  }
49
49
  end
50
50
  end
@@ -29,11 +29,11 @@ module Dato
29
29
 
30
30
  alias raw_file file
31
31
 
32
- def file(host = default_host)
32
+ def file
33
33
  super.ch('DPR', 'Width').auto('format')
34
34
  end
35
35
 
36
- def to_hash
36
+ def to_hash(*args)
37
37
  super.merge(
38
38
  width: width,
39
39
  height: height,
@@ -18,7 +18,7 @@ module Dato
18
18
  [latitude, longitude]
19
19
  end
20
20
 
21
- def to_hash
21
+ def to_hash(*args)
22
22
  {
23
23
  latitude: latitude,
24
24
  longitude: longitude
@@ -12,8 +12,8 @@ module Dato
12
12
  new(items)
13
13
  end
14
14
 
15
- def to_hash
16
- map(&:to_hash)
15
+ def to_hash(max_depth = 3, current_depth = 0)
16
+ map { |item| item.to_hash(max_depth, current_depth) }
17
17
  end
18
18
  end
19
19
  end
@@ -12,8 +12,8 @@ module Dato
12
12
  new(items)
13
13
  end
14
14
 
15
- def to_hash
16
- map(&:to_hash)
15
+ def to_hash(max_depth = 3, current_depth = 0)
16
+ map { |item| item.to_hash(max_depth, current_depth) }
17
17
  end
18
18
  end
19
19
  end
@@ -19,11 +19,11 @@ module Dato
19
19
  @image && Image.parse(@image, nil)
20
20
  end
21
21
 
22
- def to_hash
22
+ def to_hash(*args)
23
23
  {
24
24
  title: title,
25
25
  description: description,
26
- image: image && image.to_hash
26
+ image: image && image.to_hash(*args)
27
27
  }
28
28
  end
29
29
  end
@@ -52,7 +52,7 @@ module Dato
52
52
  VideoEmbed.embed(url, { width: width, height: height }.compact)
53
53
  end
54
54
 
55
- def to_hash
55
+ def to_hash(*args)
56
56
  {
57
57
  url: url,
58
58
  thumbnail_url: thumbnail_url,
@@ -59,11 +59,11 @@ module Dato
59
59
  def singleton?
60
60
  item_type.singleton
61
61
  end
62
+ alias single_instance? singleton?
62
63
 
63
64
  def item_type
64
65
  @item_type ||= entity.item_type
65
66
  end
66
- alias content_type item_type
67
67
 
68
68
  def fields
69
69
  @fields ||= item_type.fields.sort_by(&:position)
@@ -91,7 +91,11 @@ module Dato
91
91
  end
92
92
  alias inspect to_s
93
93
 
94
- def to_hash
94
+ def to_hash(max_depth = 3, current_depth = 0)
95
+ if current_depth >= max_depth
96
+ return id
97
+ end
98
+
95
99
  base = {
96
100
  id: id,
97
101
  item_type: item_type.api_key,
@@ -104,7 +108,10 @@ module Dato
104
108
  value = send(field.api_key)
105
109
 
106
110
  result[field.api_key.to_sym] = if value.respond_to?(:to_hash)
107
- value.to_hash
111
+ value.to_hash(
112
+ max_depth,
113
+ current_depth + 1
114
+ )
108
115
  else
109
116
  value
110
117
  end
@@ -18,7 +18,7 @@ module Dato
18
18
  end
19
19
 
20
20
  def find(id)
21
- @items_by_id[id]
21
+ @items_by_id[id.to_s]
22
22
  end
23
23
 
24
24
  def respond_to_missing?(method, include_private = false)
@@ -10,7 +10,7 @@ module Dato
10
10
 
11
11
  attr_reader :entity
12
12
  def_delegators :entity, :id, :name, :locales, :theme_hue, :domain,
13
- :internal_domain, :no_index
13
+ :internal_domain, :no_index, :frontend_url
14
14
 
15
15
  def initialize(entity)
16
16
  @entity = entity
@@ -36,7 +36,7 @@ module Dato
36
36
  def to_hash
37
37
  attributes = [
38
38
  :id, :name, :locales, :theme_hue, :domain, :internal_domain,
39
- :no_index, :global_seo, :favicon
39
+ :no_index, :global_seo, :favicon, :frontend_url
40
40
  ]
41
41
 
42
42
  attributes.each_with_object({}) do |attribute, result|
@@ -6,7 +6,7 @@ module Dato
6
6
  module MetaTags
7
7
  class OgSiteName < Base
8
8
  def build
9
- card_tag('og:site_name', site_name) if site_name
9
+ og_tag('og:site_name', site_name) if site_name
10
10
  end
11
11
 
12
12
  def site_name
data/lib/dato/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Dato
3
- VERSION = '0.3.6'
3
+ VERSION = '0.3.7'
4
4
  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.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Verna
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-08 00:00:00.000000000 Z
11
+ date: 2017-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler