contentful_middleman 3.0.0 → 3.0.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.
Files changed (34) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +4 -0
  3. data/lib/contentful_middleman/import_task.rb +10 -3
  4. data/lib/contentful_middleman/mappers/base.rb +12 -5
  5. data/lib/contentful_middleman/version.rb +1 -1
  6. data/lib/contentful_middleman/version_hash.rb +3 -2
  7. data/spec/contentful_middleman/import_task_spec.rb +3 -2
  8. data/spec/contentful_middleman/mappers/base_spec.rb +31 -0
  9. data/spec/fixtures/backup_fixtures/.tmp/backups/.gitkeep +0 -0
  10. data/spec/fixtures/vcr_fixtures/client.yml +1 -1
  11. data/spec/fixtures/vcr_fixtures/entries/localized_references.yml +2 -2
  12. data/spec/fixtures/vcr_fixtures/entries/localized_references_localized_assets.yml +2 -2
  13. data/spec/fixtures/vcr_fixtures/entries/locations.yml +2 -2
  14. data/spec/fixtures/vcr_fixtures/entries/map_with_camel_case.yml +244 -0
  15. data/spec/fixtures/vcr_fixtures/entries/nil_file.yml +2 -2
  16. data/spec/fixtures/vcr_fixtures/entries/repeated_entry.yml +2 -2
  17. data/spec/fixtures/vcr_fixtures/helpers/preview.yml +2 -2
  18. data/spec/fixtures/vcr_fixtures/instance/entries_1.yml +1 -1
  19. data/spec/fixtures/vcr_fixtures/instance/entries_2.yml +3 -3
  20. data/spec/fixtures/vcr_fixtures/instance/entries_3.yml +3 -3
  21. data/spec/fixtures/vcr_fixtures/instance/include_resolution_1.yml +2 -2
  22. data/spec/fixtures/vcr_fixtures/mappers/entries.yml +2 -2
  23. data/spec/fixtures/vcr_fixtures/mappers/entries_localized.yml +2 -2
  24. data/spec/fixtures/vcr_fixtures/tools/preview_helper.yml +1 -1
  25. data/spec/fixtures/vcr_fixtures/tools/preview_helper/asset.yml +1 -1
  26. data/spec/fixtures/vcr_fixtures/tools/preview_helper/asset_2.yml +1 -1
  27. data/spec/fixtures/vcr_fixtures/tools/preview_helper/assets.yml +1 -1
  28. data/spec/fixtures/vcr_fixtures/tools/preview_helper/assets_2.yml +1 -1
  29. data/spec/fixtures/vcr_fixtures/tools/preview_helper/entries.yml +1 -1
  30. data/spec/fixtures/vcr_fixtures/tools/preview_helper/entries_2.yml +1 -1
  31. data/spec/fixtures/vcr_fixtures/tools/preview_helper/entry.yml +1 -1
  32. data/spec/fixtures/vcr_fixtures/tools/preview_helper/entry_2.yml +1 -1
  33. data/spec/spec_helper.rb +10 -7
  34. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1f2caf1c451b4d1c5775bd1febbf4132438a02c2
4
- data.tar.gz: 36e15755edb936f0736c165d035584f12f9b1bb1
2
+ SHA256:
3
+ metadata.gz: e9ffdf90b11369b5a8889218f9b961c1fb32273b2acf2eae06785e944a27a539
4
+ data.tar.gz: 47679bc6168d7cfd968a1e226fc01ce25ea4e4e44bcd9ef2a5e128c873bb00c6
5
5
  SHA512:
6
- metadata.gz: f3a1a10b30f596340df8fc0fc83993a82372f084984266289d682020a072919dec93adf1563de3251bbb7829b1d2c011642192283e6f8e1098a50302818d5332
7
- data.tar.gz: 4bd32921dc5d64ffb4254f0d0d5898bdf47105ff8eb5776c546249599a165d628eea2ed8b2cef4a1d93f0f1417277d9ea7822889f0c9e4013f8f15023f8a018c
6
+ metadata.gz: 275ea6a5292da0585fe3ae0f9cf3b7c23ebf3dcd05eb23966a5b0fedc9078508ea6586f90a7b41d704b69b90aa603c6a6cb10631ddeb818ed3f7d3b0a5ccaf54
7
+ data.tar.gz: 659f627c6a8b70cce3b29f27ee90c0dc840f34a67834c3c89d888b816646d613548e75536f302f4f71ff95002ae9a606a9c97e59805103ec605a0bb53d5cb284
@@ -1,6 +1,10 @@
1
1
  # Change Log
2
2
  ## Unreleased
3
3
 
4
+ ## 3.0.1
5
+ ### Fixed
6
+ * Allow usage of `use_camel_case` in client options.
7
+
4
8
  ## 3.0.0
5
9
 
6
10
  This is an atificial version bump, no new features have been added and no breaking change introduced.
@@ -6,6 +6,7 @@ module ContentfulMiddleman
6
6
  @content_type_mappers = content_type_mappers
7
7
  @changed_local_data = false
8
8
  @contentful = contentful
9
+ @use_camel_case = @contentful.options.client_options.fetch(:use_camel_case, false)
9
10
  end
10
11
 
11
12
  def run
@@ -13,7 +14,7 @@ module ContentfulMiddleman
13
14
 
14
15
  LocalData::Store.new(local_data_files, @space_name).write
15
16
 
16
- new_version_hash = ContentfulMiddleman::VersionHash.write_for_space_with_entries(@space_name, entries)
17
+ new_version_hash = ContentfulMiddleman::VersionHash.write_for_space_with_entries(@space_name, entries, @use_camel_case)
17
18
 
18
19
  @changed_local_data = new_version_hash != old_version_hash
19
20
  end
@@ -33,12 +34,18 @@ module ContentfulMiddleman
33
34
 
34
35
  private
35
36
  def local_data_files
37
+ content_type_key = if @use_camel_case
38
+ :contentType
39
+ else
40
+ :content_type
41
+ end
42
+
36
43
  entries.map do |entry|
37
- content_type_mapper_class = @content_type_mappers.fetch(entry.sys[:content_type].id, nil)
44
+ content_type_mapper_class = @content_type_mappers.fetch(entry.sys[content_type_key].id, nil)
38
45
 
39
46
  next unless content_type_mapper_class
40
47
 
41
- content_type_name = @content_type_names.fetch(entry.sys[:content_type].id).to_s
48
+ content_type_name = @content_type_names.fetch(entry.sys[content_type_key].id).to_s
42
49
  context = ContentfulMiddleman::Context.new
43
50
 
44
51
  content_type_mapper = content_type_mapper_class.new(entries, @contentful.options)
@@ -9,6 +9,9 @@ module ContentfulMiddleman
9
9
  @entries = entries
10
10
  @options = options
11
11
  @children = {}
12
+ @created_at_key = using_camel_case? ? :createdAt : :created_at
13
+ @updated_at_key = using_camel_case? ? :updatedAt : :updated_at
14
+ @content_type_key = using_camel_case? ? :contentType : :content_type
12
15
  end
13
16
 
14
17
  def map(context, entry)
@@ -25,6 +28,10 @@ module ContentfulMiddleman
25
28
 
26
29
  private
27
30
 
31
+ def using_camel_case?
32
+ @options.client_options.fetch(:use_camel_case, false)
33
+ end
34
+
28
35
  def has_multiple_locales?
29
36
  @options.cda_query.fetch(:locale, nil) == '*'
30
37
  end
@@ -61,8 +68,8 @@ module ContentfulMiddleman
61
68
 
62
69
  def map_asset_metadata(asset)
63
70
  context = Context.new
64
- context.updated_at = asset.sys[:updated_at].iso8601 unless asset.sys[:updated_at].nil?
65
- context.created_at = asset.sys[:created_at].iso8601 unless asset.sys[:created_at].nil?
71
+ context.updated_at = asset.sys[@updated_at_key].iso8601 unless asset.sys[@updated_at_key].nil?
72
+ context.created_at = asset.sys[@created_at_key].iso8601 unless asset.sys[@created_at_key].nil?
66
73
  context.id = asset.sys[:id]
67
74
 
68
75
  context
@@ -87,9 +94,9 @@ module ContentfulMiddleman
87
94
 
88
95
  def map_entry_metadata(entry)
89
96
  context = Context.new
90
- context.content_type_id = entry.sys[:content_type].id unless entry.sys[:content_type].nil?
91
- context.updated_at = entry.sys[:updated_at].iso8601 unless entry.sys[:updated_at].nil?
92
- context.created_at = entry.sys[:created_at].iso8601 unless entry.sys[:created_at].nil?
97
+ context.content_type_id = entry.sys[@content_type_key].id unless entry.sys[@content_type_key].nil?
98
+ context.updated_at = entry.sys[@updated_at_key].iso8601 unless entry.sys[@updated_at_key].nil?
99
+ context.created_at = entry.sys[@created_at_key].iso8601 unless entry.sys[@created_at_key].nil?
93
100
  context.id = entry.sys[:id]
94
101
 
95
102
  context
@@ -1,3 +1,3 @@
1
1
  module ContentfulMiddleman
2
- VERSION = "3.0.0"
2
+ VERSION = "3.0.1"
3
3
  end
@@ -10,9 +10,10 @@ module ContentfulMiddleman
10
10
  ::File.read(hashfilename_for_space) if File.exist? hashfilename_for_space
11
11
  end
12
12
 
13
- def write_for_space_with_entries(space_name, entries)
13
+ def write_for_space_with_entries(space_name, entries, use_camel_case = false)
14
+ updated_at_key = use_camel_case ? :updatedAt : :updated_at
14
15
  sorted_entries = entries.sort {|a, b| a.id <=> b.id}
15
- ids_and_revisions_string = sorted_entries.map {|e| "#{e.id}#{e.updated_at}"}.join
16
+ ids_and_revisions_string = sorted_entries.map {|e| "#{e.id}#{e.public_send(updated_at_key)}"}.join
16
17
  entries_hash = Digest::SHA1.hexdigest( ids_and_revisions_string )
17
18
 
18
19
  File.open(hashfilename(space_name), 'w') { |file| file.write(entries_hash) }
@@ -4,9 +4,10 @@ class ClientDouble
4
4
  def entries
5
5
  []
6
6
  end
7
- end
8
7
 
9
- class EntryDouble
8
+ def options
9
+ OptionsDouble.new
10
+ end
10
11
  end
11
12
 
12
13
  describe ContentfulMiddleman::ImportTask do
@@ -160,6 +160,37 @@ describe ContentfulMiddleman::Mapper::Base do
160
160
  }
161
161
  end
162
162
 
163
+ it 'maps properly when using camel case option' do
164
+ vcr('entries/map_with_camel_case') {
165
+ subject = described_class.new entries, OptionsDouble.new(client_options: { use_camel_case: true })
166
+ expect(context.hashize).to eq ({})
167
+
168
+ expected = {
169
+ :_meta => {
170
+ :content_type_id=>"test",
171
+ :updated_at=>"2018-06-14T13:13:17+00:00",
172
+ :created_at=>"2018-06-14T13:13:17+00:00",
173
+ :id=>"5xkCBpVmHmS2WwqOW8OSwK"
174
+ },
175
+ id: "5xkCBpVmHmS2WwqOW8OSwK",
176
+ someField: "foobar"
177
+ }
178
+
179
+ client = Contentful::Client.new(
180
+ space: 'ycz65dz7s75m',
181
+ access_token: '7790b343268100301696628b99678de6a552c967ded5c448bf9f2cba3de806ca',
182
+ dynamic_entries: :auto,
183
+ use_camel_case: true
184
+ )
185
+
186
+ entry = client.entries.first
187
+
188
+ subject.map(context, entry)
189
+
190
+ expect(context.hashize).to eq(expected)
191
+ }
192
+ end
193
+
163
194
  it 'maps entries with multiple locales with nested resources that are also localized' do
164
195
  vcr('entries/localized_references_localized_assets') {
165
196
  subject = described_class.new entries, OptionsDouble.new(cda_query: {locale: '*'})
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://cdn.contentful.com/spaces/cfexampleapi/content_types?limit=1000
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/content_types?limit=1000
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://cdn.contentful.com/spaces/1sjfpsn7l90g/content_types?limit=1000
5
+ uri: https://cdn.contentful.com/spaces/1sjfpsn7l90g/environments/master/content_types?limit=1000
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -117,7 +117,7 @@ http_interactions:
117
117
  recorded_at: Thu, 29 Sep 2016 22:30:25 GMT
118
118
  - request:
119
119
  method: get
120
- uri: https://cdn.contentful.com/spaces/1sjfpsn7l90g/entries?locale=*
120
+ uri: https://cdn.contentful.com/spaces/1sjfpsn7l90g/environments/master/entries?locale=*
121
121
  body:
122
122
  encoding: US-ASCII
123
123
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://cdn.contentful.com/spaces/bht13amj0fva/content_types?limit=1000
5
+ uri: https://cdn.contentful.com/spaces/bht13amj0fva/environments/master/content_types?limit=1000
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -119,7 +119,7 @@ http_interactions:
119
119
  recorded_at: Wed, 05 Oct 2016 14:33:01 GMT
120
120
  - request:
121
121
  method: get
122
- uri: https://cdn.contentful.com/spaces/bht13amj0fva/entries?locale=*
122
+ uri: https://cdn.contentful.com/spaces/bht13amj0fva/environments/master/entries?locale=*
123
123
  body:
124
124
  encoding: US-ASCII
125
125
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://cdn.contentful.com/spaces/v0h47qlgo3zl/content_types?limit=1000
5
+ uri: https://cdn.contentful.com/spaces/v0h47qlgo3zl/environments/master/content_types?limit=1000
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -80,7 +80,7 @@ http_interactions:
80
80
  recorded_at: Mon, 21 Aug 2017 21:10:22 GMT
81
81
  - request:
82
82
  method: get
83
- uri: https://cdn.contentful.com/spaces/v0h47qlgo3zl/entries?content_type=destination&select=fields.name,fields.coordinates,sys&sys.id=4ik8UErhRmIwomiQs8EUkI
83
+ uri: https://cdn.contentful.com/spaces/v0h47qlgo3zl/environments/master/entries?content_type=destination&select=fields.name,fields.coordinates,sys&sys.id=4ik8UErhRmIwomiQs8EUkI
84
84
  body:
85
85
  encoding: US-ASCII
86
86
  string: ''
@@ -0,0 +1,244 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://cdn.contentful.com/spaces/ycz65dz7s75m/environments/master/content_types?limit=1000
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ X-Contentful-User-Agent:
11
+ - sdk contentful.rb/2.2.1; platform ruby/2.5.1; os macOS/16;
12
+ Authorization:
13
+ - Bearer 7790b343268100301696628b99678de6a552c967ded5c448bf9f2cba3de806ca
14
+ Content-Type:
15
+ - application/vnd.contentful.delivery.v1+json
16
+ Accept-Encoding:
17
+ - gzip
18
+ Connection:
19
+ - close
20
+ Host:
21
+ - cdn.contentful.com
22
+ User-Agent:
23
+ - http.rb/2.2.2
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ Access-Control-Allow-Headers:
30
+ - Accept,Accept-Language,Authorization,Cache-Control,Content-Length,Content-Range,Content-Type,DNT,Destination,Expires,If-Match,If-Modified-Since,If-None-Match,Keep-Alive,Last-Modified,Origin,Pragma,Range,User-Agent,X-Http-Method-Override,X-Mx-ReqToken,X-Requested-With,X-Contentful-Version,X-Contentful-Content-Type,X-Contentful-Organization,X-Contentful-Skip-Transformation,X-Contentful-User-Agent,X-Contentful-Enable-Alpha-Feature
31
+ Access-Control-Allow-Methods:
32
+ - GET,HEAD,OPTIONS
33
+ Access-Control-Allow-Origin:
34
+ - "*"
35
+ Access-Control-Expose-Headers:
36
+ - Etag
37
+ Access-Control-Max-Age:
38
+ - '86400'
39
+ Cache-Control:
40
+ - max-age=0
41
+ Content-Type:
42
+ - application/vnd.contentful.delivery.v1+json
43
+ Etag:
44
+ - '"a802c9553879adaad0097a8beedb5ecc"'
45
+ Server:
46
+ - Contentful
47
+ X-Content-Type-Options:
48
+ - nosniff
49
+ X-Contentful-Request-Id:
50
+ - b86f4e978f9a1bfee6bc90007bbe9e41
51
+ Content-Length:
52
+ - '957'
53
+ Accept-Ranges:
54
+ - bytes
55
+ Date:
56
+ - Thu, 14 Jun 2018 13:16:11 GMT
57
+ Via:
58
+ - 1.1 varnish
59
+ Age:
60
+ - '0'
61
+ Connection:
62
+ - close
63
+ X-Served-By:
64
+ - cache-hhn1532-HHN
65
+ X-Cache:
66
+ - MISS
67
+ X-Cache-Hits:
68
+ - '0'
69
+ X-Timer:
70
+ - S1528982171.382086,VS0,VE270
71
+ Vary:
72
+ - Accept-Encoding
73
+ body:
74
+ encoding: ASCII-8BIT
75
+ string: |
76
+ {
77
+ "sys": {
78
+ "type": "Array"
79
+ },
80
+ "total": 1,
81
+ "skip": 0,
82
+ "limit": 1000,
83
+ "items": [
84
+ {
85
+ "sys": {
86
+ "space": {
87
+ "sys": {
88
+ "type": "Link",
89
+ "linkType": "Space",
90
+ "id": "ycz65dz7s75m"
91
+ }
92
+ },
93
+ "id": "test",
94
+ "type": "ContentType",
95
+ "createdAt": "2018-06-14T13:13:07.886Z",
96
+ "updatedAt": "2018-06-14T13:13:07.886Z",
97
+ "environment": {
98
+ "sys": {
99
+ "id": "master",
100
+ "type": "Link",
101
+ "linkType": "Environment"
102
+ }
103
+ },
104
+ "revision": 1
105
+ },
106
+ "displayField": "someField",
107
+ "name": "Test",
108
+ "description": "",
109
+ "fields": [
110
+ {
111
+ "id": "someField",
112
+ "name": "someField",
113
+ "type": "Symbol",
114
+ "localized": false,
115
+ "required": false,
116
+ "disabled": false,
117
+ "omitted": false
118
+ }
119
+ ]
120
+ }
121
+ ]
122
+ }
123
+ http_version:
124
+ recorded_at: Thu, 14 Jun 2018 13:16:11 GMT
125
+ - request:
126
+ method: get
127
+ uri: https://cdn.contentful.com/spaces/ycz65dz7s75m/environments/master/entries
128
+ body:
129
+ encoding: US-ASCII
130
+ string: ''
131
+ headers:
132
+ X-Contentful-User-Agent:
133
+ - sdk contentful.rb/2.2.1; platform ruby/2.5.1; os macOS/16;
134
+ Authorization:
135
+ - Bearer 7790b343268100301696628b99678de6a552c967ded5c448bf9f2cba3de806ca
136
+ Content-Type:
137
+ - application/vnd.contentful.delivery.v1+json
138
+ Accept-Encoding:
139
+ - gzip
140
+ Connection:
141
+ - close
142
+ Host:
143
+ - cdn.contentful.com
144
+ User-Agent:
145
+ - http.rb/2.2.2
146
+ response:
147
+ status:
148
+ code: 200
149
+ message: OK
150
+ headers:
151
+ Access-Control-Allow-Headers:
152
+ - Accept,Accept-Language,Authorization,Cache-Control,Content-Length,Content-Range,Content-Type,DNT,Destination,Expires,If-Match,If-Modified-Since,If-None-Match,Keep-Alive,Last-Modified,Origin,Pragma,Range,User-Agent,X-Http-Method-Override,X-Mx-ReqToken,X-Requested-With,X-Contentful-Version,X-Contentful-Content-Type,X-Contentful-Organization,X-Contentful-Skip-Transformation,X-Contentful-User-Agent,X-Contentful-Enable-Alpha-Feature
153
+ Access-Control-Allow-Methods:
154
+ - GET,HEAD,OPTIONS
155
+ Access-Control-Allow-Origin:
156
+ - "*"
157
+ Access-Control-Expose-Headers:
158
+ - Etag
159
+ Access-Control-Max-Age:
160
+ - '86400'
161
+ Cache-Control:
162
+ - max-age=0
163
+ Content-Type:
164
+ - application/vnd.contentful.delivery.v1+json
165
+ Etag:
166
+ - '"376db3c86ef859e48397c6520bfcf235"'
167
+ Server:
168
+ - Contentful
169
+ X-Content-Type-Options:
170
+ - nosniff
171
+ X-Contentful-Request-Id:
172
+ - 6644c1c7f9d2b797077967aa07c407b8
173
+ Content-Length:
174
+ - '879'
175
+ Accept-Ranges:
176
+ - bytes
177
+ Date:
178
+ - Thu, 14 Jun 2018 13:16:12 GMT
179
+ Via:
180
+ - 1.1 varnish
181
+ Age:
182
+ - '0'
183
+ Connection:
184
+ - close
185
+ X-Served-By:
186
+ - cache-hhn1526-HHN
187
+ X-Cache:
188
+ - MISS
189
+ X-Cache-Hits:
190
+ - '0'
191
+ X-Timer:
192
+ - S1528982172.794017,VS0,VE278
193
+ Vary:
194
+ - Accept-Encoding
195
+ body:
196
+ encoding: ASCII-8BIT
197
+ string: |
198
+ {
199
+ "sys": {
200
+ "type": "Array"
201
+ },
202
+ "total": 1,
203
+ "skip": 0,
204
+ "limit": 100,
205
+ "items": [
206
+ {
207
+ "sys": {
208
+ "space": {
209
+ "sys": {
210
+ "type": "Link",
211
+ "linkType": "Space",
212
+ "id": "ycz65dz7s75m"
213
+ }
214
+ },
215
+ "id": "5xkCBpVmHmS2WwqOW8OSwK",
216
+ "type": "Entry",
217
+ "createdAt": "2018-06-14T13:13:17.377Z",
218
+ "updatedAt": "2018-06-14T13:13:17.377Z",
219
+ "environment": {
220
+ "sys": {
221
+ "id": "master",
222
+ "type": "Link",
223
+ "linkType": "Environment"
224
+ }
225
+ },
226
+ "revision": 1,
227
+ "contentType": {
228
+ "sys": {
229
+ "type": "Link",
230
+ "linkType": "ContentType",
231
+ "id": "test"
232
+ }
233
+ },
234
+ "locale": "en-US"
235
+ },
236
+ "fields": {
237
+ "someField": "foobar"
238
+ }
239
+ }
240
+ ]
241
+ }
242
+ http_version:
243
+ recorded_at: Thu, 14 Jun 2018 13:16:12 GMT
244
+ recorded_with: VCR 3.0.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://preview.contentful.com/spaces/7f19o1co4hn7/content_types?limit=1000
5
+ uri: https://preview.contentful.com/spaces/7f19o1co4hn7/environments/master/content_types?limit=1000
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -79,7 +79,7 @@ http_interactions:
79
79
  recorded_at: Tue, 19 Jul 2016 13:49:05 GMT
80
80
  - request:
81
81
  method: get
82
- uri: https://preview.contentful.com/spaces/7f19o1co4hn7/entries?sys.id=6C4T3KAZUWaysA6ooQOWiE
82
+ uri: https://preview.contentful.com/spaces/7f19o1co4hn7/environments/master/entries?sys.id=6C4T3KAZUWaysA6ooQOWiE
83
83
  body:
84
84
  encoding: US-ASCII
85
85
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://cdn.contentful.com/spaces/a80guayqr8ut/content_types?limit=1000
5
+ uri: https://cdn.contentful.com/spaces/a80guayqr8ut/environments/master/content_types?limit=1000
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -90,7 +90,7 @@ http_interactions:
90
90
  recorded_at: Tue, 13 Dec 2016 12:56:31 GMT
91
91
  - request:
92
92
  method: get
93
- uri: https://cdn.contentful.com/spaces/a80guayqr8ut/entries?sys.id=DT1yQgZABwuWeY842sGYY
93
+ uri: https://cdn.contentful.com/spaces/a80guayqr8ut/environments/master/entries?sys.id=DT1yQgZABwuWeY842sGYY
94
94
  body:
95
95
  encoding: US-ASCII
96
96
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://preview.contentful.com/spaces/cfexampleapi/content_types?limit=1000
5
+ uri: https://preview.contentful.com/spaces/cfexampleapi/environments/master/content_types?limit=1000
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -92,7 +92,7 @@ http_interactions:
92
92
  recorded_at: Thu, 10 Dec 2015 19:42:11 GMT
93
93
  - request:
94
94
  method: get
95
- uri: https://preview.contentful.com/spaces/cfexampleapi/entries
95
+ uri: https://preview.contentful.com/spaces/cfexampleapi/environments/master/entries
96
96
  body:
97
97
  encoding: US-ASCII
98
98
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://cdn.contentful.com/spaces/cfexampleapi/content_types?limit=1000
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/content_types?limit=1000
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://cdn.contentful.com/spaces/cfexampleapi/content_types?limit=1000
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/content_types?limit=1000
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -92,7 +92,7 @@ http_interactions:
92
92
  recorded_at: Thu, 26 Nov 2015 14:05:49 GMT
93
93
  - request:
94
94
  method: get
95
- uri: https://cdn.contentful.com/spaces/cfexampleapi/entries?limit=1
95
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/entries?limit=1
96
96
  body:
97
97
  encoding: US-ASCII
98
98
  string: ''
@@ -176,7 +176,7 @@ http_interactions:
176
176
  recorded_at: Thu, 26 Nov 2015 14:05:49 GMT
177
177
  - request:
178
178
  method: get
179
- uri: https://cdn.contentful.com/spaces/cfexampleapi/entries?limit=1000&order=sys.createdAt&skip=0
179
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/entries?limit=1000&order=sys.createdAt&skip=0
180
180
  body:
181
181
  encoding: US-ASCII
182
182
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://cdn.contentful.com/spaces/cfexampleapi/content_types?limit=1000
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/content_types?limit=1000
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -98,7 +98,7 @@ http_interactions:
98
98
  recorded_at: Wed, 07 Sep 2016 22:51:13 GMT
99
99
  - request:
100
100
  method: get
101
- uri: https://cdn.contentful.com/spaces/cfexampleapi/entries?limit=1
101
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/entries?limit=1
102
102
  body:
103
103
  encoding: US-ASCII
104
104
  string: ''
@@ -213,7 +213,7 @@ http_interactions:
213
213
  recorded_at: Wed, 07 Sep 2016 22:51:13 GMT
214
214
  - request:
215
215
  method: get
216
- uri: https://cdn.contentful.com/spaces/cfexampleapi/entries?limit=100&order=sys.createdAt&skip=0
216
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/entries?limit=100&order=sys.createdAt&skip=0
217
217
  body:
218
218
  encoding: US-ASCII
219
219
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://cdn.contentful.com/spaces/cfexampleapi/content_types?limit=1000
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/content_types?limit=1000
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -97,7 +97,7 @@ http_interactions:
97
97
  recorded_at: Thu, 27 Apr 2017 13:45:07 GMT
98
98
  - request:
99
99
  method: get
100
- uri: https://cdn.contentful.com/spaces/cfexampleapi/entries?sys.id=nyancat
100
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/entries?sys.id=nyancat
101
101
  body:
102
102
  encoding: US-ASCII
103
103
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://cdn.contentful.com/spaces/cfexampleapi/content_types?limit=1000
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/content_types?limit=1000
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -321,7 +321,7 @@ http_interactions:
321
321
  recorded_at: Wed, 02 Dec 2015 18:20:27 GMT
322
322
  - request:
323
323
  method: get
324
- uri: https://cdn.contentful.com/spaces/cfexampleapi/entries
324
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/entries
325
325
  body:
326
326
  encoding: US-ASCII
327
327
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://cdn.contentful.com/spaces/cfexampleapi/content_types?limit=1000
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/content_types?limit=1000
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -321,7 +321,7 @@ http_interactions:
321
321
  recorded_at: Wed, 02 Dec 2015 18:20:29 GMT
322
322
  - request:
323
323
  method: get
324
- uri: https://cdn.contentful.com/spaces/cfexampleapi/entries?include=1&locale=*
324
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/entries?include=1&locale=*
325
325
  body:
326
326
  encoding: US-ASCII
327
327
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://cdn.contentful.com/spaces/cfexampleapi/content_types?limit=1000
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/content_types?limit=1000
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://cdn.contentful.com/spaces/cfexampleapi/assets/nyancat
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/assets/nyancat
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://cdn.contentful.com/spaces/cfexampleapi/assets/happycat
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/assets/happycat
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://cdn.contentful.com/spaces/cfexampleapi/assets
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/assets
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://cdn.contentful.com/spaces/cfexampleapi/assets?order=sys.createdAt
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/assets?order=sys.createdAt
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://cdn.contentful.com/spaces/cfexampleapi/entries
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/entries
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://cdn.contentful.com/spaces/cfexampleapi/entries?content_type=cat
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/entries?content_type=cat
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://cdn.contentful.com/spaces/cfexampleapi/entries?sys.id=garfield
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/entries?sys.id=garfield
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://cdn.contentful.com/spaces/cfexampleapi/entries?sys.id=happycat
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/entries?sys.id=happycat
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -85,13 +85,20 @@ end
85
85
  class EntryDouble
86
86
  attr_reader :id, :sys, :fields
87
87
 
88
- def initialize(id, sys_data = {}, fields = {}, updated_at = nil)
88
+ def initialize(id, sys_data = {}, fields = {}, updated_at = nil, camel_case = false)
89
89
  @id = id
90
90
  sys_data[:id] = id
91
- sys_data[:updated_at] = updated_at
92
- sys_data[:content_type] = ContentTypeDouble.new("#{id}_ct")
91
+ sys_data[camel_case ? :updatedAt : :updated_at] = updated_at
92
+ sys_data[camel_case ? :contentType : :content_type] = ContentTypeDouble.new("#{id}_ct")
93
93
  @sys = sys_data
94
94
  @fields = fields
95
+ @camel_case = camel_case
96
+
97
+ sys_data.each do |k, v|
98
+ define_singleton_method k do
99
+ v
100
+ end
101
+ end
95
102
 
96
103
  unless fields.nil?
97
104
  fields.each do |k, v|
@@ -101,8 +108,4 @@ class EntryDouble
101
108
  end
102
109
  end
103
110
  end
104
-
105
- def updated_at
106
- sys[:updated_at]
107
- end
108
111
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contentful_middleman
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sascha Konietzke
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-11-13 00:00:00.000000000 Z
12
+ date: 2018-06-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: middleman-core
@@ -259,6 +259,7 @@ files:
259
259
  - spec/fixtures/vcr_fixtures/entries/localized_references.yml
260
260
  - spec/fixtures/vcr_fixtures/entries/localized_references_localized_assets.yml
261
261
  - spec/fixtures/vcr_fixtures/entries/locations.yml
262
+ - spec/fixtures/vcr_fixtures/entries/map_with_camel_case.yml
262
263
  - spec/fixtures/vcr_fixtures/entries/nil_file.yml
263
264
  - spec/fixtures/vcr_fixtures/entries/repeated_entry.yml
264
265
  - spec/fixtures/vcr_fixtures/helpers/preview.yml
@@ -298,7 +299,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
298
299
  version: '0'
299
300
  requirements: []
300
301
  rubyforge_project:
301
- rubygems_version: 2.6.14
302
+ rubygems_version: 2.7.6
302
303
  signing_key:
303
304
  specification_version: 4
304
305
  summary: Include mangablable content from the Contentful CMS and API into your Middleman
@@ -326,6 +327,7 @@ test_files:
326
327
  - spec/fixtures/vcr_fixtures/entries/localized_references.yml
327
328
  - spec/fixtures/vcr_fixtures/entries/localized_references_localized_assets.yml
328
329
  - spec/fixtures/vcr_fixtures/entries/locations.yml
330
+ - spec/fixtures/vcr_fixtures/entries/map_with_camel_case.yml
329
331
  - spec/fixtures/vcr_fixtures/entries/nil_file.yml
330
332
  - spec/fixtures/vcr_fixtures/entries/repeated_entry.yml
331
333
  - spec/fixtures/vcr_fixtures/helpers/preview.yml