contentful 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -0
- data/README.md +1 -1
- data/contentful.gemspec +4 -2
- data/lib/contentful/dynamic_entry.rb +1 -1
- data/lib/contentful/resource.rb +4 -4
- data/lib/contentful/resource/asset_fields.rb +1 -1
- data/lib/contentful/resource/fields.rb +3 -3
- data/lib/contentful/resource_builder.rb +2 -1
- data/lib/contentful/version.rb +1 -1
- data/spec/coercions_spec.rb +13 -0
- data/spec/entry_spec.rb +1 -1
- data/spec/spec_helper.rb +5 -0
- metadata +36 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ba77ca80d0071ad28546271729538c6a701616d
|
4
|
+
data.tar.gz: 65a9ee25b3709bb641deed8345862914480068e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51c966da267b2dc62c189a57dd69200ec9a83f81cba5bccd4695c5ef756babdc6aeccbb53a7c98bde97325fbfff86c68eac08912871192d035d36188828de389
|
7
|
+
data.tar.gz: d5c14ff5244ef3463bfec9cac959be1de527f45ca0f48e8885101ea473dc5f53f1b8d471a2479b668504cc8ee003ccb23ea4be549a3e5aee1135929f03039c91
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -89,7 +89,7 @@ However, you can (and should) set `:dynamic_entries` to `:auto` in your client c
|
|
89
89
|
client = Contentful::Client.new(
|
90
90
|
access_token: 'b4c0n73n7fu1',
|
91
91
|
space: 'cfexampleapi',
|
92
|
-
dynamic_entries: :auto
|
92
|
+
dynamic_entries: :auto
|
93
93
|
)
|
94
94
|
|
95
95
|
entry = client.entry 'nyancat' # => #<Contentful::DynamicEntry[cat]: ...>
|
data/contentful.gemspec
CHANGED
@@ -15,8 +15,9 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.test_files = gem.files.grep(%r{^spec/})
|
16
16
|
gem.require_paths = ['lib']
|
17
17
|
|
18
|
-
gem.add_dependency 'http', '~> 0
|
18
|
+
gem.add_dependency 'http', '~> 1.0'
|
19
19
|
gem.add_dependency 'multi_json', '~> 1'
|
20
|
+
gem.add_dependency 'json', '~> 1.8'
|
20
21
|
|
21
22
|
gem.add_development_dependency 'bundler', '~> 1.5'
|
22
23
|
gem.add_development_dependency 'rake', '~> 10'
|
@@ -26,9 +27,10 @@ Gem::Specification.new do |gem|
|
|
26
27
|
gem.add_development_dependency 'guard-rspec'
|
27
28
|
gem.add_development_dependency 'guard-rubocop'
|
28
29
|
gem.add_development_dependency 'guard-yard'
|
29
|
-
gem.add_development_dependency 'rubocop'
|
30
|
+
gem.add_development_dependency 'rubocop', '~> 0.41.0'
|
30
31
|
gem.add_development_dependency 'rspec', '~> 2'
|
31
32
|
gem.add_development_dependency 'rr'
|
32
33
|
gem.add_development_dependency 'vcr'
|
33
34
|
gem.add_development_dependency 'webmock', '~> 1', '>= 1.17.3'
|
35
|
+
gem.add_development_dependency 'tins', '~> 1.6.0'
|
34
36
|
end
|
@@ -31,7 +31,7 @@ module Contentful
|
|
31
31
|
|
32
32
|
Class.new DynamicEntry do
|
33
33
|
content_type.fields.each do |f|
|
34
|
-
define_method Support.snakify(f.id).to_sym do |wanted_locale =
|
34
|
+
define_method Support.snakify(f.id).to_sym do |wanted_locale = nil|
|
35
35
|
fields(wanted_locale)[f.id.to_sym]
|
36
36
|
end
|
37
37
|
end
|
data/lib/contentful/resource.rb
CHANGED
@@ -174,9 +174,7 @@ module Contentful
|
|
174
174
|
end
|
175
175
|
|
176
176
|
def coerce_value_or_array(value, what = nil)
|
177
|
-
if value.
|
178
|
-
nil
|
179
|
-
elsif value.is_a? ::Array
|
177
|
+
if value.is_a? ::Array
|
180
178
|
value.map { |v| coerce_or_create_class(v, what) }
|
181
179
|
elsif should_coerce_hash?(value)
|
182
180
|
::Hash[value.map do |k, v|
|
@@ -214,8 +212,10 @@ module Contentful
|
|
214
212
|
case what
|
215
213
|
when Symbol
|
216
214
|
COERCIONS[what] ? COERCIONS[what][value] : value
|
215
|
+
when Proc
|
216
|
+
what[value]
|
217
217
|
when Class
|
218
|
-
what.new(value, client)
|
218
|
+
what.new(value, client) if value
|
219
219
|
else
|
220
220
|
value
|
221
221
|
end
|
@@ -10,9 +10,9 @@ module Contentful
|
|
10
10
|
# Returns all fields of the asset
|
11
11
|
#
|
12
12
|
# @return [Hash] fields for Resource on selected locale
|
13
|
-
def fields(wanted_locale =
|
14
|
-
wanted_locale = wanted_locale.
|
15
|
-
@fields
|
13
|
+
def fields(wanted_locale = nil)
|
14
|
+
wanted_locale = (locale || default_locale) if wanted_locale.nil?
|
15
|
+
@fields[wanted_locale.to_s] || {}
|
16
16
|
end
|
17
17
|
|
18
18
|
# Returns all fields of the asset with locales nested by field
|
@@ -69,9 +69,10 @@ module Contentful
|
|
69
69
|
|
70
70
|
unless @included_resources.empty?
|
71
71
|
replace_links_in_included_resources_with_known_resources
|
72
|
-
replace_links_with_known_resources @resource
|
73
72
|
end
|
74
73
|
|
74
|
+
replace_links_with_known_resources @resource
|
75
|
+
|
75
76
|
@resource
|
76
77
|
rescue UnparsableResource => error
|
77
78
|
error
|
data/lib/contentful/version.rb
CHANGED
data/spec/coercions_spec.rb
CHANGED
@@ -7,4 +7,17 @@ describe 'Coercion Examples' do
|
|
7
7
|
expect(entry.created_at).to be_a DateTime
|
8
8
|
expect(entry.created_at.day).to eq 27
|
9
9
|
end
|
10
|
+
|
11
|
+
describe 'custom coercion' do
|
12
|
+
class TestCar
|
13
|
+
include Contentful::Resource
|
14
|
+
|
15
|
+
property :parts, ->(v) { Array(v) unless v }
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'can use proc' do
|
19
|
+
car = TestCar.new("parts" => nil)
|
20
|
+
expect(car.parts).to be_empty
|
21
|
+
end
|
22
|
+
end
|
10
23
|
end
|
data/spec/entry_spec.rb
CHANGED
@@ -121,7 +121,7 @@ describe Contentful::Entry do
|
|
121
121
|
expect(entry).to be_a Kategorie
|
122
122
|
expect(entry.title).to eq "Some Title"
|
123
123
|
expect(entry.slug).to eq "/asda.html"
|
124
|
-
expect(entry.featured_articles.first.is_a?(Contentful::
|
124
|
+
expect(entry.featured_articles.first.is_a?(Contentful::Entry)).to be_truthy
|
125
125
|
expect(entry.top).to be_truthy
|
126
126
|
}
|
127
127
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contentful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Contentful GmbH (Jan Lelis)
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-08-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: http
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '0
|
20
|
+
version: '1.0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '0
|
27
|
+
version: '1.0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: multi_json
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,6 +39,20 @@ dependencies:
|
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '1'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: json
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.8'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.8'
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: bundler
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -141,16 +155,16 @@ dependencies:
|
|
141
155
|
name: rubocop
|
142
156
|
requirement: !ruby/object:Gem::Requirement
|
143
157
|
requirements:
|
144
|
-
- - "
|
158
|
+
- - "~>"
|
145
159
|
- !ruby/object:Gem::Version
|
146
|
-
version:
|
160
|
+
version: 0.41.0
|
147
161
|
type: :development
|
148
162
|
prerelease: false
|
149
163
|
version_requirements: !ruby/object:Gem::Requirement
|
150
164
|
requirements:
|
151
|
-
- - "
|
165
|
+
- - "~>"
|
152
166
|
- !ruby/object:Gem::Version
|
153
|
-
version:
|
167
|
+
version: 0.41.0
|
154
168
|
- !ruby/object:Gem::Dependency
|
155
169
|
name: rspec
|
156
170
|
requirement: !ruby/object:Gem::Requirement
|
@@ -213,6 +227,20 @@ dependencies:
|
|
213
227
|
- - ">="
|
214
228
|
- !ruby/object:Gem::Version
|
215
229
|
version: 1.17.3
|
230
|
+
- !ruby/object:Gem::Dependency
|
231
|
+
name: tins
|
232
|
+
requirement: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - "~>"
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: 1.6.0
|
237
|
+
type: :development
|
238
|
+
prerelease: false
|
239
|
+
version_requirements: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - "~>"
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: 1.6.0
|
216
244
|
description: Ruby client for the https://www.contentful.com Content Delivery API
|
217
245
|
email: rubygems@contentful.com
|
218
246
|
executables: []
|