contentful 1.1.0 → 1.1.1
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/contentful/asset.rb +1 -0
- data/lib/contentful/entry.rb +2 -1
- data/lib/contentful/version.rb +1 -1
- data/spec/entry_spec.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58f25fa3b3309c03b128ee16d9703f4b462c9921
|
4
|
+
data.tar.gz: 87ee174d7e0a063e1f93818063b993805b878690
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b60a5aea8f56ca5cd84e1739cf044abe6f175ccadbba288d9bf89bf0af4ce256d135533e0b552ed102a975b5e4b836cbe001b013f1e952fddc60f394271e3104
|
7
|
+
data.tar.gz: db7212eb5ce1eafa4ea0fd32f4ad63b5dbf9a697d6913f63963b822f84685c6f8260ee520fa3214301f98e502a9a9964406c65c835b11caa58586b32e93e3fd5
|
data/CHANGELOG.md
CHANGED
data/lib/contentful/asset.rb
CHANGED
@@ -19,6 +19,7 @@ module Contentful
|
|
19
19
|
@properties = extract_from_object(raw_object, :property, self.class.property_coercions.keys)
|
20
20
|
@sys = raw_object.key?('sys') ? extract_from_object(raw_object['sys'], :sys) : {}
|
21
21
|
initialize_fields_for_localized_resource(raw_object)
|
22
|
+
@raw = raw_object
|
22
23
|
end
|
23
24
|
|
24
25
|
# Generates a URL for the Contentful Image API
|
data/lib/contentful/entry.rb
CHANGED
@@ -19,12 +19,13 @@ module Contentful
|
|
19
19
|
@properties = extract_from_object(raw_object, :property, self.class.property_coercions.keys)
|
20
20
|
@sys = raw_object.key?('sys') ? extract_from_object(raw_object['sys'], :sys) : {}
|
21
21
|
extract_fields_from_object!(raw_object)
|
22
|
+
@raw = raw_object
|
22
23
|
end
|
23
24
|
|
24
25
|
# @private
|
25
26
|
def raw_with_links
|
26
27
|
links = properties.keys.select { |property| known_link?(property) }
|
27
|
-
processed_raw =
|
28
|
+
processed_raw = raw.clone
|
28
29
|
raw['fields'].each do |k, v|
|
29
30
|
processed_raw['fields'][k] = links.include?(k.to_sym) ? send(snakify(k)) : v
|
30
31
|
end
|
data/lib/contentful/version.rb
CHANGED
data/spec/entry_spec.rb
CHANGED
@@ -176,6 +176,7 @@ describe Contentful::Entry do
|
|
176
176
|
property :lives
|
177
177
|
property :bestFriend, Cat
|
178
178
|
property :catPack
|
179
|
+
property :image, Contentful::Asset
|
179
180
|
end
|
180
181
|
|
181
182
|
def test_dump(nyancat)
|
@@ -209,6 +210,8 @@ describe Contentful::Entry do
|
|
209
210
|
expect(new_cat.cat_pack.first.name).to eq "Happy Cat"
|
210
211
|
expect(new_cat.cat_pack.first.cat_pack[0].name).to eq "Nyan Cat"
|
211
212
|
expect(new_cat.cat_pack.first.cat_pack[1].name).to eq "Worried Cat"
|
213
|
+
|
214
|
+
expect(new_cat.image.file.url).to eq "//images.contentful.com/cfexampleapi/4gp6taAwW4CmSgumq2ekUm/9da0cd1936871b8d72343e895a00d611/Nyan_cat_250px_frame.png"
|
212
215
|
end
|
213
216
|
|
214
217
|
it 'using entry_mapping' do
|
@@ -230,6 +233,20 @@ describe Contentful::Entry do
|
|
230
233
|
}
|
231
234
|
end
|
232
235
|
|
236
|
+
it 'can remarshall an unmarshalled object' do
|
237
|
+
vcr('entry/marshall') {
|
238
|
+
nyancat = create_client(resource_mapping: {
|
239
|
+
'Entry' => ->(_json_object) do
|
240
|
+
return Cat if _json_object.fetch('sys', {}).fetch('contentType', {}).fetch('sys', {}).fetch('id', nil) == 'cat'
|
241
|
+
Contentful::Entry
|
242
|
+
end
|
243
|
+
}).entries(include: 2, 'sys.id' => 'nyancat').first
|
244
|
+
|
245
|
+
# The double load/dump is on purpose
|
246
|
+
test_dump(Marshal.load(Marshal.dump(nyancat)))
|
247
|
+
}
|
248
|
+
end
|
249
|
+
|
233
250
|
it 'newly created custom resources have property mappings' do
|
234
251
|
entry = Cat.new
|
235
252
|
|
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: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Contentful GmbH (Jan Lelis)
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-12-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: http
|