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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf533a202661dbb21a1407db9ce750ce065e4b65
4
- data.tar.gz: ab9be792f8c764a9a3d193b2b48a4023e5d67f7a
3
+ metadata.gz: 58f25fa3b3309c03b128ee16d9703f4b462c9921
4
+ data.tar.gz: 87ee174d7e0a063e1f93818063b993805b878690
5
5
  SHA512:
6
- metadata.gz: 20c2571a350ee58c2b3bb9022067f286b11e853c140d4469ca12b501d0659f1188c9efcf6754d261b334ce387f776b2c8db389261ad909a78fcdcf2eaf8d2c13
7
- data.tar.gz: 63b528128d85440107f71f696d0e9278aa94b0e0cae82e6e19a3d007269a04f9468e9ad05e298939df78020c864e263cd0b35c19ca7e68a4228ce09debf86577
6
+ metadata.gz: b60a5aea8f56ca5cd84e1739cf044abe6f175ccadbba288d9bf89bf0af4ce256d135533e0b552ed102a975b5e4b836cbe001b013f1e952fddc60f394271e3104
7
+ data.tar.gz: db7212eb5ce1eafa4ea0fd32f4ad63b5dbf9a697d6913f63963b822f84685c6f8260ee520fa3214301f98e502a9a9964406c65c835b11caa58586b32e93e3fd5
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 1.1.1
6
+ ### Fixed
7
+ * Fix Re-Marshalling of already Un-Marshalled objects
8
+
5
9
  ## 1.1.0
6
10
  ### Added
7
11
  * Add support for `select` operator in `#entries` and `#assets` call
@@ -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
@@ -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 = Marshal.load(Marshal.dump(raw)) # Deep Copy
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
@@ -1,5 +1,5 @@
1
1
  # Contentful Namespace
2
2
  module Contentful
3
3
  # Gem Version
4
- VERSION = '1.1.0'
4
+ VERSION = '1.1.1'
5
5
  end
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.0
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-10-18 00:00:00.000000000 Z
13
+ date: 2016-12-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: http