contentful 2.15.3 → 2.16.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +22 -11
- data/lib/contentful/array_like.rb +11 -2
- data/lib/contentful/asset.rb +4 -0
- data/lib/contentful/base_resource.rb +14 -2
- data/lib/contentful/client.rb +1 -2
- data/lib/contentful/fields_resource.rb +1 -0
- data/lib/contentful/version.rb +1 -1
- metadata +4 -367
- data/.gitignore +0 -7
- data/.rspec +0 -1
- data/.rubocop.yml +0 -31
- data/.rubocop_todo.yml +0 -35
- data/.travis.yml +0 -15
- data/.yardopts +0 -4
- data/Gemfile +0 -9
- data/Gemfile.lock +0 -166
- data/Guardfile +0 -24
- data/RELEASE.md +0 -8
- data/Rakefile +0 -33
- data/contentful.gemspec +0 -44
- data/coverage/.last_run.json +0 -5
- data/coverage/.resultset.json +0 -5086
- data/coverage/.resultset.json.lock +0 -0
- data/coverage/assets/0.10.2/application.css +0 -799
- data/coverage/assets/0.10.2/application.js +0 -1707
- data/coverage/assets/0.10.2/colorbox/border.png +0 -0
- data/coverage/assets/0.10.2/colorbox/controls.png +0 -0
- data/coverage/assets/0.10.2/colorbox/loading.gif +0 -0
- data/coverage/assets/0.10.2/colorbox/loading_background.png +0 -0
- data/coverage/assets/0.10.2/favicon_green.png +0 -0
- data/coverage/assets/0.10.2/favicon_red.png +0 -0
- data/coverage/assets/0.10.2/favicon_yellow.png +0 -0
- data/coverage/assets/0.10.2/loading.gif +0 -0
- data/coverage/assets/0.10.2/magnify.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/index.html +0 -0
- data/doc/Contentful/AccessDenied.html +0 -159
- data/doc/Contentful/Array.html +0 -844
- data/doc/Contentful/ArrayCoercion.html +0 -242
- data/doc/Contentful/ArrayLike.html +0 -624
- data/doc/Contentful/Asset.html +0 -486
- data/doc/Contentful/BadGateway.html +0 -159
- data/doc/Contentful/BadRequest.html +0 -159
- data/doc/Contentful/BaseCoercion.html +0 -445
- data/doc/Contentful/BaseResource.html +0 -598
- data/doc/Contentful/BooleanCoercion.html +0 -242
- data/doc/Contentful/Client.html +0 -1738
- data/doc/Contentful/ContentType.html +0 -617
- data/doc/Contentful/ContentTypeCache.html +0 -428
- data/doc/Contentful/DateCoercion.html +0 -244
- data/doc/Contentful/DeletedAsset.html +0 -156
- data/doc/Contentful/DeletedEntry.html +0 -156
- data/doc/Contentful/EmptyFieldError.html +0 -217
- data/doc/Contentful/Entry.html +0 -334
- data/doc/Contentful/Error.html +0 -407
- data/doc/Contentful/Field.html +0 -935
- data/doc/Contentful/FieldsResource.html +0 -583
- data/doc/Contentful/File.html +0 -218
- data/doc/Contentful/FloatCoercion.html +0 -238
- data/doc/Contentful/IntegerCoercion.html +0 -238
- data/doc/Contentful/Link.html +0 -246
- data/doc/Contentful/LinkCoercion.html +0 -156
- data/doc/Contentful/Locale.html +0 -536
- data/doc/Contentful/Location.html +0 -382
- data/doc/Contentful/LocationCoercion.html +0 -238
- data/doc/Contentful/NotFound.html +0 -159
- data/doc/Contentful/ObjectCoercion.html +0 -238
- data/doc/Contentful/RateLimitExceeded.html +0 -346
- data/doc/Contentful/Request.html +0 -895
- data/doc/Contentful/ResourceBuilder.html +0 -1067
- data/doc/Contentful/ResourceReferences.html +0 -254
- data/doc/Contentful/Response.html +0 -708
- data/doc/Contentful/RichTextCoercion.html +0 -238
- data/doc/Contentful/ServerError.html +0 -159
- data/doc/Contentful/ServiceUnavailable.html +0 -159
- data/doc/Contentful/Space.html +0 -392
- data/doc/Contentful/StringCoercion.html +0 -242
- data/doc/Contentful/StructuredTextCoercion.html +0 -238
- data/doc/Contentful/Support.html +0 -788
- data/doc/Contentful/SymbolCoercion.html +0 -169
- data/doc/Contentful/Sync.html +0 -653
- data/doc/Contentful/SyncPage.html +0 -807
- data/doc/Contentful/TextCoercion.html +0 -169
- data/doc/Contentful/Unauthorized.html +0 -159
- data/doc/Contentful/UnparsableJson.html +0 -159
- data/doc/Contentful/UnparsableResource.html +0 -135
- data/doc/Contentful.html +0 -157
- data/doc/_index.html +0 -563
- data/doc/class_list.html +0 -51
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -58
- data/doc/css/style.css +0 -496
- data/doc/file.CHANGELOG.html +0 -708
- data/doc/file.LICENSE.html +0 -70
- data/doc/file.README.html +0 -758
- data/doc/file_list.html +0 -66
- data/doc/frames.html +0 -17
- data/doc/index.html +0 -758
- data/doc/js/app.js +0 -303
- data/doc/js/full_list.js +0 -216
- data/doc/js/jquery.js +0 -4
- data/doc/method_list.html +0 -1187
- data/doc/top-level-namespace.html +0 -110
- data/examples/custom_classes.rb +0 -39
- data/examples/example_queries.rb +0 -26
- data/examples/raise_errors.rb +0 -20
- data/examples/raw_mode.rb +0 -14
- data/spec/array_spec.rb +0 -167
- data/spec/asset_spec.rb +0 -192
- data/spec/auto_includes_spec.rb +0 -12
- data/spec/client_class_spec.rb +0 -86
- data/spec/client_configuration_spec.rb +0 -377
- data/spec/content_type_spec.rb +0 -49
- data/spec/deleted_asset_spec.rb +0 -38
- data/spec/deleted_entry_spec.rb +0 -38
- data/spec/entry_spec.rb +0 -777
- data/spec/error_class_spec.rb +0 -327
- data/spec/error_requests_spec.rb +0 -87
- data/spec/field_spec.rb +0 -95
- data/spec/file_spec.rb +0 -33
- data/spec/fixtures/json_responses/400_details_errors_object.json +0 -14
- data/spec/fixtures/json_responses/400_details_errors_string.json +0 -12
- data/spec/fixtures/json_responses/400_details_string.json +0 -8
- data/spec/fixtures/json_responses/403_reasons.json +0 -13
- data/spec/fixtures/json_responses/404_details_string.json +0 -8
- data/spec/fixtures/json_responses/404_id.json +0 -11
- data/spec/fixtures/json_responses/404_sys_type.json +0 -12
- data/spec/fixtures/json_responses/404_type.json +0 -10
- data/spec/fixtures/json_responses/content_type.json +0 -83
- data/spec/fixtures/json_responses/default_400.json +0 -7
- data/spec/fixtures/json_responses/default_401.json +0 -7
- data/spec/fixtures/json_responses/default_403.json +0 -7
- data/spec/fixtures/json_responses/default_404.json +0 -7
- data/spec/fixtures/json_responses/default_429.json +0 -7
- data/spec/fixtures/json_responses/default_500.json +0 -7
- data/spec/fixtures/json_responses/default_502.json +0 -7
- data/spec/fixtures/json_responses/default_503.json +0 -7
- data/spec/fixtures/json_responses/includes.json +0 -111
- data/spec/fixtures/json_responses/link_array.json +0 -43
- data/spec/fixtures/json_responses/not_found.json +0 -13
- data/spec/fixtures/json_responses/nyancat.json +0 -48
- data/spec/fixtures/json_responses/other_error.json +0 -9
- data/spec/fixtures/json_responses/other_error_no_details.json +0 -8
- data/spec/fixtures/json_responses/other_error_no_message.json +0 -8
- data/spec/fixtures/json_responses/other_error_no_request_id.json +0 -8
- data/spec/fixtures/json_responses/other_error_nothing.json +0 -6
- data/spec/fixtures/json_responses/self_link.json +0 -82
- data/spec/fixtures/json_responses/unparsable.json +0 -13
- data/spec/fixtures/vcr_cassettes/array/marshal_custom_classes.yml +0 -159
- data/spec/fixtures/vcr_cassettes/array/marshal_unpublished.yml +0 -315
- data/spec/fixtures/vcr_cassettes/array/nested_resources.yml +0 -159
- data/spec/fixtures/vcr_cassettes/array.yml +0 -288
- data/spec/fixtures/vcr_cassettes/arrayField.yml +0 -87
- data/spec/fixtures/vcr_cassettes/array_page_1.yml +0 -106
- data/spec/fixtures/vcr_cassettes/array_page_2.yml +0 -73
- data/spec/fixtures/vcr_cassettes/asset/select_empty_array.yml +0 -104
- data/spec/fixtures/vcr_cassettes/asset/select_no_sys.yml +0 -119
- data/spec/fixtures/vcr_cassettes/asset/select_one_field.yml +0 -97
- data/spec/fixtures/vcr_cassettes/asset/select_only_sys.yml +0 -88
- data/spec/fixtures/vcr_cassettes/asset.yml +0 -96
- data/spec/fixtures/vcr_cassettes/assets/issues_129.yml +0 -90
- data/spec/fixtures/vcr_cassettes/assets/issues_jekyll_46.yml +0 -115
- data/spec/fixtures/vcr_cassettes/bad_request.yml +0 -76
- data/spec/fixtures/vcr_cassettes/content_type.yml +0 -147
- data/spec/fixtures/vcr_cassettes/entries/empty_fields.yml +0 -246
- data/spec/fixtures/vcr_cassettes/entries/issue_117.yml +0 -201
- data/spec/fixtures/vcr_cassettes/entries/issue_125.yml +0 -198
- data/spec/fixtures/vcr_cassettes/entries/rich_text.yml +0 -1707
- data/spec/fixtures/vcr_cassettes/entries/rich_text_hydration_issue.yml +0 -460
- data/spec/fixtures/vcr_cassettes/entries/rich_text_nested_fields.yml +0 -653
- data/spec/fixtures/vcr_cassettes/entries/rich_text_unresolved_relationships.yml +0 -983
- data/spec/fixtures/vcr_cassettes/entries/unresolvable_assets.yml +0 -89
- data/spec/fixtures/vcr_cassettes/entries/unresolvable_filter.yml +0 -159
- data/spec/fixtures/vcr_cassettes/entries/unresolvable_filter_deeply_nested.yml +0 -167
- data/spec/fixtures/vcr_cassettes/entries.yml +0 -561
- data/spec/fixtures/vcr_cassettes/entry/custom_resource.yml +0 -168
- data/spec/fixtures/vcr_cassettes/entry/include_resolution.yml +0 -101
- data/spec/fixtures/vcr_cassettes/entry/include_resolution_uniques.yml +0 -81
- data/spec/fixtures/vcr_cassettes/entry/json_objects.yml +0 -88
- data/spec/fixtures/vcr_cassettes/entry/json_objects_client.yml +0 -86
- data/spec/fixtures/vcr_cassettes/entry/marshal_138.yml +0 -159
- data/spec/fixtures/vcr_cassettes/entry/marshal_unpublished.yml +0 -303
- data/spec/fixtures/vcr_cassettes/entry/marshall.yml +0 -293
- data/spec/fixtures/vcr_cassettes/entry/raw.yml +0 -201
- data/spec/fixtures/vcr_cassettes/entry/search_link_to_asset.yml +0 -81
- data/spec/fixtures/vcr_cassettes/entry/search_link_to_entry.yml +0 -81
- data/spec/fixtures/vcr_cassettes/entry/search_link_to_entry_with_custom_query.yml +0 -115
- data/spec/fixtures/vcr_cassettes/entry/select_empty_array.yml +0 -111
- data/spec/fixtures/vcr_cassettes/entry/select_no_sys.yml +0 -102
- data/spec/fixtures/vcr_cassettes/entry/select_one_field.yml +0 -76
- data/spec/fixtures/vcr_cassettes/entry/select_one_field_proper.yml +0 -114
- data/spec/fixtures/vcr_cassettes/entry/select_only_sys.yml +0 -111
- data/spec/fixtures/vcr_cassettes/entry.yml +0 -102
- data/spec/fixtures/vcr_cassettes/entry_cache.yml +0 -288
- data/spec/fixtures/vcr_cassettes/entry_locales.yml +0 -104
- data/spec/fixtures/vcr_cassettes/field.yml +0 -147
- data/spec/fixtures/vcr_cassettes/human.yml +0 -118
- data/spec/fixtures/vcr_cassettes/linkField.yml +0 -83
- data/spec/fixtures/vcr_cassettes/locale.yml +0 -83
- data/spec/fixtures/vcr_cassettes/locale_from_environment.yml +0 -121
- data/spec/fixtures/vcr_cassettes/location.yml +0 -193
- data/spec/fixtures/vcr_cassettes/multi_locale_array_reference.yml +0 -196
- data/spec/fixtures/vcr_cassettes/multi_locale_reference.yml +0 -214
- data/spec/fixtures/vcr_cassettes/not_found.yml +0 -76
- data/spec/fixtures/vcr_cassettes/nyancat.yml +0 -102
- data/spec/fixtures/vcr_cassettes/query_array_1.yml +0 -89
- data/spec/fixtures/vcr_cassettes/query_array_2.yml +0 -89
- data/spec/fixtures/vcr_cassettes/ratelimit.yml +0 -64
- data/spec/fixtures/vcr_cassettes/ratelimit_retry.yml +0 -294
- data/spec/fixtures/vcr_cassettes/reloaded_entry.yml +0 -102
- data/spec/fixtures/vcr_cassettes/space.yml +0 -83
- data/spec/fixtures/vcr_cassettes/sync_deleted_asset.yml +0 -174
- data/spec/fixtures/vcr_cassettes/sync_deleted_entry.yml +0 -89
- data/spec/fixtures/vcr_cassettes/sync_deletion.yml +0 -191
- data/spec/fixtures/vcr_cassettes/sync_environment.yml +0 -81
- data/spec/fixtures/vcr_cassettes/sync_page.yml +0 -637
- data/spec/fixtures/vcr_cassettes/sync_page_2.yml +0 -71
- data/spec/fixtures/vcr_cassettes/sync_page_short.yml +0 -106
- data/spec/fixtures/vcr_cassettes/unauthorized.yml +0 -64
- data/spec/fixtures/vcr_cassettes/unavailable.yml +0 -76
- data/spec/link_spec.rb +0 -50
- data/spec/locale_spec.rb +0 -37
- data/spec/location_spec.rb +0 -25
- data/spec/request_spec.rb +0 -57
- data/spec/resource_building_spec.rb +0 -31
- data/spec/response_spec.rb +0 -62
- data/spec/space_spec.rb +0 -31
- data/spec/spec_helper.rb +0 -14
- data/spec/support/client.rb +0 -6
- data/spec/support/json_responses.rb +0 -18
- data/spec/support/vcr.rb +0 -16
- data/spec/sync_page_spec.rb +0 -103
- data/spec/sync_spec.rb +0 -180
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c77c841eb951e64584e685f03ce1d0da8534420e162f336330813c877481c12e
|
4
|
+
data.tar.gz: 52b7416520d57ffba83e2f06490714fd620c4553c8f3dd8ede4361f411879c9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a64c6adfc0fabf56f44b87e12b3df902bcfaa43b2282b0e52f04bed468e8137263b8ad67622b16987480a1c7bf95e4a6e6eb94cd2fc6fb653442ac0dcca3769
|
7
|
+
data.tar.gz: 80a5851644694f7967b1e3e38db6e11cf03f06bb4463a4bf9fa23b37dfc6ca80a8bb8152c0332515cfa7b56952b7a6c59434522312814988940864c9e0c304aa
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,27 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 2.16.2
|
6
|
+
### Fixed
|
7
|
+
* Fixed an issue where entry's `raw['fields']` was unexpectedly overwritten by `FieldsResource#raw_with_links` method.
|
8
|
+
|
9
|
+
## 2.16.1
|
10
|
+
* Removed unncessary files from gem release package.
|
11
|
+
|
12
|
+
## 2.16.0
|
13
|
+
|
14
|
+
### Added
|
15
|
+
* Added `Contentful::ArrayLike#to_ary`. [#200](https://github.com/contentful/contentful.rb/issues/200)
|
16
|
+
* Added `_metadata[:tags]` to read metadata tags on `entry` and `asset`.
|
17
|
+
|
18
|
+
## 2.15.4
|
19
|
+
|
20
|
+
### Fixed
|
21
|
+
* Fixed an issue where the `log_level` of `Logger` was changed unintentionally [#222](https://github.com/contentful/contentful.rb/pull/222)
|
22
|
+
* Fixed an issue cause by a `Logger` not being correctly thrown away, causing an exception. [#220](https://github.com/contentful/contentful.rb/pull/220)
|
23
|
+
* Added `title` field to assets to prevent Error raising when the field is empty. [#218](https://github.com/contentful/contentful.rb/pull/218)
|
24
|
+
* Fixed an issue with `ArrayLike` not taking multiple arguments leading to Errors when using it with pagination libraries. [#215](https://github.com/contentful/contentful.rb/pull/215)
|
25
|
+
|
5
26
|
## 2.15.3
|
6
27
|
### Fixed
|
7
28
|
* Fixed a deprecation warning in Ruby 2.7.0 for `URI::escape` and replaced it with a backwards compatible mechanism. [#217](https://github.com/contentful/contentful.rb/issues/217)
|
data/README.md
CHANGED
@@ -10,10 +10,10 @@
|
|
10
10
|
</a>
|
11
11
|
</p>
|
12
12
|
|
13
|
-
# contentful.rb - Contentful Ruby Delivery
|
13
|
+
# contentful.rb - Contentful Ruby Delivery Library
|
14
14
|
[![Gem Version](https://badge.fury.io/rb/contentful.png)](http://badge.fury.io/rb/contentful)
|
15
15
|
|
16
|
-
> Ruby
|
16
|
+
> Ruby library for the Contentful [Content Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/) and [Content Preview API](https://www.contentful.com/developers/docs/references/content-preview-api/). It helps you to easily access your Content stored in Contentful with your Ruby applications.
|
17
17
|
|
18
18
|
<p align="center">
|
19
19
|
<img src="https://img.shields.io/badge/Status-Maintained-green.svg" alt="This repository is actively maintained" />
|
@@ -45,12 +45,12 @@
|
|
45
45
|
|
46
46
|
<!-- TOC -->
|
47
47
|
|
48
|
-
- [contentful.rb - Contentful Ruby Delivery
|
48
|
+
- [contentful.rb - Contentful Ruby Delivery library](#contentfulrb---contentful-ruby-delivery-library)
|
49
49
|
- [Core Features](#core-features)
|
50
50
|
- [Getting started](#getting-started)
|
51
51
|
- [Installation](#installation)
|
52
52
|
- [Your first request](#your-first-request)
|
53
|
-
- [Using this
|
53
|
+
- [Using this library with the Preview API](#using-this-library-with-the-preview-api)
|
54
54
|
- [Authentication](#authentication)
|
55
55
|
- [Documentation & References](#documentation--references)
|
56
56
|
- [Configuration](#configuration)
|
@@ -94,11 +94,11 @@
|
|
94
94
|
|
95
95
|
## Getting started
|
96
96
|
|
97
|
-
In order to get started with the Contentful Ruby
|
97
|
+
In order to get started with the Contentful Ruby library you'll need not only to install it, but also to get credentials which will allow you to have access to your content in Contentful.
|
98
98
|
|
99
99
|
- [Installation](#installation)
|
100
100
|
- [Your first request](#your-first-request)
|
101
|
-
- [Using this
|
101
|
+
- [Using this library with the Preview API](#using-this-library-with-the-preview-api)
|
102
102
|
- [Authentication](#authentication)
|
103
103
|
- [Documentation & References](#documentation--references)
|
104
104
|
|
@@ -118,7 +118,7 @@ gem i contentful
|
|
118
118
|
|
119
119
|
### Your first request
|
120
120
|
|
121
|
-
The following code snippet is the most basic one you can use to get some content from Contentful with this
|
121
|
+
The following code snippet is the most basic one you can use to get some content from Contentful with this library:
|
122
122
|
|
123
123
|
```ruby
|
124
124
|
require 'contentful'
|
@@ -132,9 +132,9 @@ client = Contentful::Client.new(
|
|
132
132
|
entry = client.entry('nyancat')
|
133
133
|
```
|
134
134
|
|
135
|
-
### Using this
|
135
|
+
### Using this library with the Preview API
|
136
136
|
|
137
|
-
This
|
137
|
+
This library can also be used with the Preview API. In order to do so, you need to use the Preview API Access token, available on the same page where you get the Delivery API token, and specify the host of the preview API, such as:
|
138
138
|
|
139
139
|
```ruby
|
140
140
|
require 'contentful'
|
@@ -168,7 +168,7 @@ For more information, check the [Contentful REST API reference on Authentication
|
|
168
168
|
- [Migrating to 2.x](#migrating-to-2x)
|
169
169
|
|
170
170
|
|
171
|
-
To help you get the most out of this
|
171
|
+
To help you get the most out of this library, we've prepared all available client configuration options, reference documentation, tutorials and other examples that will help you learn and understand how to use this library.
|
172
172
|
|
173
173
|
### Configuration
|
174
174
|
|
@@ -287,7 +287,7 @@ client = Contentful::Client.new(
|
|
287
287
|
<td><code>max_include_resolution_depth</code></td>
|
288
288
|
<td><code>20</code></td>
|
289
289
|
<td>
|
290
|
-
Maximum amount of levels to resolve includes for
|
290
|
+
Maximum amount of levels to resolve includes for library entities
|
291
291
|
(this is independent of API-level includes - it represents the maximum depth the include resolution
|
292
292
|
tree is allowed to resolved before falling back to <code>Link</code> objects).
|
293
293
|
This include resolution strategy is in place in order to avoid having infinite circular recursion on resources with circular dependencies.
|
@@ -363,6 +363,8 @@ client = Contentful::Client.new(
|
|
363
363
|
<td>
|
364
364
|
The default severity is set to INFO and logs only the request attributes (headers, parameters and url).
|
365
365
|
Setting it to DEBUG will also log the raw JSON response.
|
366
|
+
WARNING: Setting this will override the level on the logger instance. Leave out this key to preserve
|
367
|
+
the original log_level on the logger, for example when using Rails.logger.
|
366
368
|
</td>
|
367
369
|
</tr>
|
368
370
|
</tbody>
|
@@ -422,6 +424,15 @@ entry.color # 'rainbow'
|
|
422
424
|
entry.birthday # #<DateTime: 2011-04-04T22:00:00+00:00 ((2455656j,79200s,0n),+0s,2299161j)>
|
423
425
|
```
|
424
426
|
|
427
|
+
#### Accessing tags
|
428
|
+
|
429
|
+
Tags can be accessed via the `#_metadata` method.
|
430
|
+
|
431
|
+
```ruby
|
432
|
+
entry = client.entry 'nyancat'
|
433
|
+
entry._metadata[:tags] # => [<Contentful::Link id='tagID'>]
|
434
|
+
```
|
435
|
+
|
425
436
|
#### Dynamic entries
|
426
437
|
|
427
438
|
However, you can (and should) set `:dynamic_entries` to `:auto` in your client configuration.
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Contentful
|
2
4
|
# Useful methods for array-like resources that can be included if an
|
3
5
|
# :items property exists
|
@@ -37,8 +39,8 @@ module Contentful
|
|
37
39
|
# Delegates to items#[]
|
38
40
|
#
|
39
41
|
# @return [Contentful::Entry, Contentful::Asset]
|
40
|
-
def [](
|
41
|
-
items[
|
42
|
+
def [](*args)
|
43
|
+
items[*args]
|
42
44
|
end
|
43
45
|
|
44
46
|
# Delegates to items#last
|
@@ -47,5 +49,12 @@ module Contentful
|
|
47
49
|
def last
|
48
50
|
items.last
|
49
51
|
end
|
52
|
+
|
53
|
+
# Delegates to items#to_ary
|
54
|
+
#
|
55
|
+
# @return [Contentful::Entry, Contentful::Asset]
|
56
|
+
def to_ary
|
57
|
+
items
|
58
|
+
end
|
50
59
|
end
|
51
60
|
end
|
data/lib/contentful/asset.rb
CHANGED
@@ -5,7 +5,7 @@ require_relative 'support'
|
|
5
5
|
module Contentful
|
6
6
|
# Base definition of a Contentful Resource containing Sys properties
|
7
7
|
class BaseResource
|
8
|
-
attr_reader :raw, :default_locale, :sys
|
8
|
+
attr_reader :raw, :default_locale, :sys, :_metadata
|
9
9
|
|
10
10
|
# rubocop:disable Metrics/ParameterLists
|
11
11
|
def initialize(item, configuration = {}, _localized = false, _includes = [], entries = {}, depth = 0, _errors = [])
|
@@ -15,6 +15,7 @@ module Contentful
|
|
15
15
|
@depth = depth
|
16
16
|
@configuration = configuration
|
17
17
|
@sys = hydrate_sys
|
18
|
+
@_metadata = hydrate_metadata
|
18
19
|
|
19
20
|
define_sys_methods!
|
20
21
|
end
|
@@ -36,7 +37,8 @@ module Contentful
|
|
36
37
|
end
|
37
38
|
|
38
39
|
{
|
39
|
-
|
40
|
+
# loggers usually have a file handle that can't be marshalled, so let's not return that
|
41
|
+
configuration: @configuration.merge(entry_mapping: entry_mapping, logger: nil),
|
40
42
|
raw: raw
|
41
43
|
}
|
42
44
|
end
|
@@ -56,6 +58,7 @@ module Contentful
|
|
56
58
|
@configuration = raw_object[:configuration]
|
57
59
|
@default_locale = @configuration[:default_locale]
|
58
60
|
@sys = hydrate_sys
|
61
|
+
@_metadata = hydrate_metadata
|
59
62
|
@depth = 0
|
60
63
|
define_sys_methods!
|
61
64
|
end
|
@@ -92,6 +95,15 @@ module Contentful
|
|
92
95
|
result
|
93
96
|
end
|
94
97
|
|
98
|
+
def hydrate_metadata
|
99
|
+
result = {}
|
100
|
+
raw.fetch('metadata', {}).each do |k, v|
|
101
|
+
v.map! { |tag| build_link(tag) } if k == 'tags'
|
102
|
+
result[Support.snakify(k, @configuration[:use_camel_case]).to_sym] = v
|
103
|
+
end
|
104
|
+
result
|
105
|
+
end
|
106
|
+
|
95
107
|
protected
|
96
108
|
|
97
109
|
def repr_name
|
data/lib/contentful/client.rb
CHANGED
@@ -30,7 +30,6 @@ module Contentful
|
|
30
30
|
raw_mode: false,
|
31
31
|
gzip_encoded: true,
|
32
32
|
logger: false,
|
33
|
-
log_level: Logger::INFO,
|
34
33
|
proxy_host: nil,
|
35
34
|
proxy_username: nil,
|
36
35
|
proxy_password: nil,
|
@@ -105,7 +104,7 @@ module Contentful
|
|
105
104
|
# @private
|
106
105
|
def setup_logger
|
107
106
|
@logger = configuration[:logger]
|
108
|
-
logger.level = configuration[:log_level] if logger
|
107
|
+
logger.level = configuration[:log_level] if logger && configuration.key?(:log_level)
|
109
108
|
end
|
110
109
|
|
111
110
|
# @private
|
@@ -67,6 +67,7 @@ module Contentful
|
|
67
67
|
def raw_with_links
|
68
68
|
links = fields.keys.select { |property| known_link?(property) }
|
69
69
|
processed_raw = raw.clone
|
70
|
+
processed_raw['fields'] = raw['fields'].clone
|
70
71
|
raw['fields'].each do |k, v|
|
71
72
|
links_key = Support.snakify(k, @configuration[:use_camel_case])
|
72
73
|
processed_raw['fields'][k] = links.include?(links_key.to_sym) ? send(links_key) : v
|
data/lib/contentful/version.rb
CHANGED