contentful 2.14.0 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1930a37ca31d693b4cb4ff55f065b85cc3271696ae3dd96b063093a2f9c24be
4
- data.tar.gz: 5299cd8d71d9200873fcbc527d41bedd717ed216a323b0a537d9148d1b0a664d
3
+ metadata.gz: '09f8c373dc24453c4566564a0ac34244df2af9bb9eaf123daa91b514f6a0bf14'
4
+ data.tar.gz: a99d41fd2698f8dec1536822198fc661a248bc6eacd04c2f7dde555a22dd647d
5
5
  SHA512:
6
- metadata.gz: 1b3f75e991ce3eecde93a3109acafb20f400e349df4f369463d2adfea36c863772cdc84d1353b7e24018342fbc4eb0cbf6ee9d884b445877817f4821ef26b3ef
7
- data.tar.gz: 2bf465ba3e6a9e8129fe7648212d75454332866a478f2aebfb2effb8679a56338cf2890bcd0718a4815f20ca42292f496427aedda571f9b7ab4b5ac5470c0523
6
+ metadata.gz: bfe5899e858df982b9d1eeb475729503513d1b18e7315c3f93d35167c19512c301047f3bba4d0cabc37223bc1b06c64c34c70e7720a64ad4283e19616759cfcf
7
+ data.tar.gz: f06391fb774add42ea406736f5115d1e0ebf1a08b3ed1c4454640f5b4b240c9a919132170448d0449058b3d11f3d8ab161338d3801385b7e408c30d3e702e1ba
@@ -21,6 +21,9 @@ AllCops:
21
21
  Metrics/ClassLength:
22
22
  Max: 280
23
23
 
24
+ Metrics/ParameterLists:
25
+ Max: 6
26
+
24
27
  Style/MutableConstant:
25
28
  Enabled: false
26
29
 
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 2.15.0
6
+ ### Added
7
+ * Added the capability for `Array#next_page` to support carry-over of query parameters.
8
+
5
9
  ## 2.14.0
6
10
  ### Added
7
11
  * Allow user defined methods to override properties created by the SDK, if you want to access overriden fields or sys properties use `#fields[]` or `#sys[]` as accessors. [#210](https://github.com/contentful/contentful.rb/pull/210)
@@ -26,7 +26,7 @@ Gem::Specification.new do |gem|
26
26
 
27
27
  gem.add_dependency 'multi_json', '~> 1'
28
28
 
29
- gem.add_development_dependency 'bundler', '~> 1.5'
29
+ gem.add_development_dependency 'bundler'
30
30
  gem.add_development_dependency 'rake', '< 11.0'
31
31
  gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
32
32
 
@@ -11,13 +11,15 @@ module Contentful
11
11
 
12
12
  include Contentful::ArrayLike
13
13
 
14
- attr_reader :total, :limit, :skip, :items, :endpoint
14
+ attr_reader :total, :limit, :skip, :items, :endpoint, :query
15
15
 
16
16
  def initialize(item = nil,
17
17
  configuration = {
18
18
  default_locale: Contentful::Client::DEFAULT_CONFIGURATION[:default_locale]
19
19
  },
20
- endpoint = '', *)
20
+ endpoint = '',
21
+ query = {},
22
+ *)
21
23
  super(item, configuration)
22
24
 
23
25
  @endpoint = endpoint
@@ -25,11 +27,12 @@ module Contentful
25
27
  @limit = item.fetch('limit', nil)
26
28
  @skip = item.fetch('skip', nil)
27
29
  @items = item.fetch('items', [])
30
+ @query = query
28
31
  end
29
32
 
30
33
  # @private
31
34
  def marshal_dump
32
- super.merge(endpoint: endpoint)
35
+ super.merge(endpoint: endpoint, query: query)
33
36
  end
34
37
 
35
38
  # @private
@@ -39,6 +42,7 @@ module Contentful
39
42
  @total = raw.fetch('total', nil)
40
43
  @limit = raw.fetch('limit', nil)
41
44
  @skip = raw.fetch('skip', nil)
45
+ @query = raw_object[:query]
42
46
  @items = raw.fetch('items', []).map do |item|
43
47
  require_relative 'resource_builder'
44
48
  ResourceBuilder.new(
@@ -72,7 +76,8 @@ module Contentful
72
76
  'Asset' => 'assets',
73
77
  'Locale' => 'locales'
74
78
  }
75
- client.public_send(plurals[items.first.type], limit: limit, skip: new_skip)
79
+
80
+ client.public_send(plurals[items.first.type], query.merge(limit: limit, skip: new_skip))
76
81
  end
77
82
  end
78
83
  end
@@ -386,7 +386,9 @@ module Contentful
386
386
  response.object,
387
387
  configuration.merge(endpoint: response.request.endpoint),
388
388
  (response.request.query || {}).fetch(:locale, nil) == '*',
389
- 0
389
+ 0,
390
+ [],
391
+ response.request.query || {}
390
392
  ).run
391
393
  end
392
394
 
@@ -32,9 +32,9 @@ module Contentful
32
32
  # Buildable Resources
33
33
  BUILDABLES = %w[Entry Asset ContentType Space DeletedEntry DeletedAsset Locale].freeze
34
34
 
35
- attr_reader :json, :default_locale, :endpoint, :depth, :localized, :resource_mapping, :entry_mapping, :resource
35
+ attr_reader :json, :default_locale, :endpoint, :depth, :localized, :resource_mapping, :entry_mapping, :resource, :query
36
36
 
37
- def initialize(json, configuration = {}, localized = false, depth = 0, errors = [])
37
+ def initialize(json, configuration = {}, localized = false, depth = 0, errors = [], query = {})
38
38
  @json = json
39
39
  @default_locale = configuration.fetch(:default_locale, ::Contentful::Client::DEFAULT_CONFIGURATION[:default_locale])
40
40
  @resource_mapping = default_resource_mapping.merge(configuration.fetch(:resource_mapping, {}))
@@ -46,6 +46,7 @@ module Contentful
46
46
  @configuration = configuration
47
47
  @resource_cache = configuration[:_entries_cache] || {}
48
48
  @errors = errors
49
+ @query = query
49
50
  end
50
51
 
51
52
  # Starts the parsing process.
@@ -69,7 +70,7 @@ module Contentful
69
70
  build_item(item, includes, errors)
70
71
  end
71
72
  array_class = fetch_array_class
72
- array_class.new(json.merge('items' => result), @configuration, endpoint)
73
+ array_class.new(json.merge('items' => result), @configuration, endpoint, query)
73
74
  end
74
75
 
75
76
  def build_single
@@ -1,5 +1,5 @@
1
1
  # Contentful Namespace
2
2
  module Contentful
3
3
  # Gem Version
4
- VERSION = '2.14.0'
4
+ VERSION = '2.15.0'
5
5
  end
@@ -63,6 +63,25 @@ describe Contentful::Array do
63
63
  it 'will return false if #request not available' do
64
64
  expect(Contentful::Array.new({}).reload).to be_falsey
65
65
  end
66
+
67
+ it 'respects query parameters' do
68
+ array_page_1 = vcr('query_array_1') { client.entries(content_type: 'cat', limit: 1) }
69
+ array_page_2 = vcr('query_array_2') { array_page_1.next_page(client) }
70
+
71
+ expect(array_page_1).to be_a Contentful::Array
72
+ expect(array_page_2).to be_a Contentful::Array
73
+
74
+ expect(array_page_1.query).to include(content_type: 'cat')
75
+ expect(array_page_2.query).to include(content_type: 'cat')
76
+
77
+ expect(array_page_1.size).to eq 1
78
+ expect(array_page_2.size).to eq 1
79
+
80
+ expect(array_page_1[0].content_type.id).to eq 'cat'
81
+ expect(array_page_2[0].content_type.id).to eq 'cat'
82
+
83
+ expect(array_page_1[0].id).not_to eq array_page_2[0].id
84
+ end
66
85
  end
67
86
 
68
87
  describe 'marshalling' do
@@ -28,7 +28,7 @@ describe Contentful::Client do
28
28
  end
29
29
 
30
30
  it 'uses Request#query' do
31
- expect(request).to receive(:query).twice.and_call_original
31
+ expect(request).to receive(:query).thrice.and_call_original
32
32
  vcr('content_type') { client.get(request) }
33
33
  end
34
34
 
@@ -0,0 +1,89 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/entries?content_type=cat&limit=1
6
+ body:
7
+ encoding: UTF-8
8
+ string: ''
9
+ headers:
10
+ X-Contentful-User-Agent:
11
+ - sdk contentful.rb/2.14.0; platform ruby/2.6.3; os macOS/18;
12
+ Authorization:
13
+ - Bearer b4c0n73n7fu1
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/4.1.1
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ Connection:
30
+ - close
31
+ Content-Length:
32
+ - '1083'
33
+ Access-Control-Allow-Headers:
34
+ - 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
35
+ Access-Control-Allow-Methods:
36
+ - GET,HEAD,OPTIONS
37
+ Access-Control-Allow-Origin:
38
+ - "*"
39
+ Access-Control-Expose-Headers:
40
+ - Etag
41
+ Access-Control-Max-Age:
42
+ - '86400'
43
+ Cf-Environment-Id:
44
+ - master
45
+ Cf-Environment-Uuid:
46
+ - b0e55a5c-6ee0-4c81-b32a-3bd22a568e43
47
+ Cf-Organization-Id:
48
+ - 7BLDDu2FYCNoN4QIWys1BR
49
+ Cf-Space-Id:
50
+ - cfexampleapi
51
+ Content-Encoding:
52
+ - gzip
53
+ Content-Type:
54
+ - application/vnd.contentful.delivery.v1+json
55
+ Contentful-Api:
56
+ - cda_cached
57
+ Etag:
58
+ - W/"10877546587147223532"
59
+ Server:
60
+ - Contentful
61
+ X-Content-Type-Options:
62
+ - nosniff
63
+ X-Contentful-Region:
64
+ - us-east-1
65
+ Accept-Ranges:
66
+ - bytes
67
+ Date:
68
+ - Fri, 15 Nov 2019 09:46:36 GMT
69
+ Via:
70
+ - 1.1 varnish
71
+ Age:
72
+ - '0'
73
+ X-Served-By:
74
+ - cache-bma1646-BMA
75
+ X-Cache:
76
+ - MISS
77
+ X-Cache-Hits:
78
+ - '0'
79
+ Vary:
80
+ - Accept-Encoding
81
+ X-Contentful-Request-Id:
82
+ - 1cdde516-8e6a-465f-bdb1-efe27b1dfb07
83
+ body:
84
+ encoding: ASCII-8BIT
85
+ string: !binary |-
86
+ H4sIAAAAAAAAA92YS2/jNhCA7/kVga6tJZKSrMfNCLZogHZRIF4USFEEtETZjPWqRCfrXeS/L0k9TMmU7Wbdw1YwbJHUkDPDmU9Df725vTXqfW2Et1/5LW+wfUl4y1hUFd4bvO/tZ/EMKxhOeb8tW/WWlrwBZCOlGWW8BWWLMpKJ6f6S0zWTjtaQ69QljsRC3RNNp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MIcify4uFAOHXx3roELfW3z3bRw1uWc4cXrn85d9rDeZf8gsv2UWUGMQRTDwJ77Hlz5sYdsxyZ+4GIA4jmEllDniR/cnpALys9PScVTzizzd4ADIg0BmnQ84uAQHK78R2gKHFyxd4PjUuu0DBFeUE89U3UI73+7ebv5BiVHfZkVEwAA
87
+ http_version:
88
+ recorded_at: Fri, 15 Nov 2019 09:46:36 GMT
89
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,89 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://cdn.contentful.com/spaces/cfexampleapi/environments/master/entries?content_type=cat&limit=1&skip=1
6
+ body:
7
+ encoding: UTF-8
8
+ string: ''
9
+ headers:
10
+ X-Contentful-User-Agent:
11
+ - sdk contentful.rb/2.14.0; platform ruby/2.6.3; os macOS/18;
12
+ Authorization:
13
+ - Bearer b4c0n73n7fu1
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/4.1.1
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ Connection:
30
+ - close
31
+ Content-Length:
32
+ - '400'
33
+ Access-Control-Allow-Headers:
34
+ - 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
35
+ Access-Control-Allow-Methods:
36
+ - GET,HEAD,OPTIONS
37
+ Access-Control-Allow-Origin:
38
+ - "*"
39
+ Access-Control-Expose-Headers:
40
+ - Etag
41
+ Access-Control-Max-Age:
42
+ - '86400'
43
+ Cf-Environment-Id:
44
+ - master
45
+ Cf-Environment-Uuid:
46
+ - b0e55a5c-6ee0-4c81-b32a-3bd22a568e43
47
+ Cf-Organization-Id:
48
+ - 7BLDDu2FYCNoN4QIWys1BR
49
+ Cf-Space-Id:
50
+ - cfexampleapi
51
+ Content-Encoding:
52
+ - gzip
53
+ Content-Type:
54
+ - application/vnd.contentful.delivery.v1+json
55
+ Contentful-Api:
56
+ - cda_cached
57
+ Etag:
58
+ - W/"12211725640257057039"
59
+ Server:
60
+ - Contentful
61
+ X-Content-Type-Options:
62
+ - nosniff
63
+ X-Contentful-Region:
64
+ - us-east-1
65
+ Accept-Ranges:
66
+ - bytes
67
+ Date:
68
+ - Fri, 15 Nov 2019 09:46:47 GMT
69
+ Via:
70
+ - 1.1 varnish
71
+ Age:
72
+ - '0'
73
+ X-Served-By:
74
+ - cache-bma1624-BMA
75
+ X-Cache:
76
+ - MISS
77
+ X-Cache-Hits:
78
+ - '0'
79
+ Vary:
80
+ - Accept-Encoding
81
+ X-Contentful-Request-Id:
82
+ - 74c9dc83-4a97-4ac3-8780-8c3d2540f815
83
+ body:
84
+ encoding: ASCII-8BIT
85
+ string: !binary |-
86
+ H4sIAAAAAAAAA41TTW/CMAy98ytQrhtTGiagvaEJ7bIb7LKJg9cGZjVNqzSgVYj/viT9ChVSySGKndjv2X65TKZTUlYliaYXczSGrgpuLLJWCipifNdn+0bnGoTxz51VplgYI3CGwAx1Z6HmmU337dLVSQcYDqcsILZA7Yva6TGxDudsGX2gTIlF7JfBlumuYbx1GQcPMLHFxAf+B1khOBRoa2rXtTu7KutF6pgjqANykXgZOyobqVXlX8SKg+bJ2vaBMBrMZ3QxY8sdY9HrImL0ZcWCLz/gVCTDgJUNCGhEw4guX0IW3gRweUaVy4xLizHetbqIDErN1bApj3Z042GOdk3xM5aYS8OOec2Mc6kN52ZI47wf5fbm5b0/c9DjoxZ5DMLpncvZ57YN6NRAnAT672EVQiRkLuT9jkIEpryXfyMoASUcJfR09jcNErmy6XIF8ugLmPyg0r+J+YbmNgiXoRVVsNqxeUSNTOiT231VCTw4dHkSwoMQeHbusBliLXu77yfXyT+v5gceBAQAAA==
87
+ http_version:
88
+ recorded_at: Fri, 15 Nov 2019 09:46:47 GMT
89
+ recorded_with: VCR 5.0.0
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: 2.14.0
4
+ version: 2.15.0
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: 2019-10-22 00:00:00.000000000 Z
13
+ date: 2019-11-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: http
@@ -50,16 +50,16 @@ dependencies:
50
50
  name: bundler
51
51
  requirement: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - "~>"
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: '1.5'
55
+ version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
58
  version_requirements: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - "~>"
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: '1.5'
62
+ version: '0'
63
63
  - !ruby/object:Gem::Dependency
64
64
  name: rake
65
65
  requirement: !ruby/object:Gem::Requirement
@@ -487,6 +487,8 @@ files:
487
487
  - spec/fixtures/vcr_cassettes/multi_locale_reference.yml
488
488
  - spec/fixtures/vcr_cassettes/not_found.yml
489
489
  - spec/fixtures/vcr_cassettes/nyancat.yml
490
+ - spec/fixtures/vcr_cassettes/query_array_1.yml
491
+ - spec/fixtures/vcr_cassettes/query_array_2.yml
490
492
  - spec/fixtures/vcr_cassettes/ratelimit.yml
491
493
  - spec/fixtures/vcr_cassettes/ratelimit_retry.yml
492
494
  - spec/fixtures/vcr_cassettes/reloaded_entry.yml
@@ -634,6 +636,8 @@ test_files:
634
636
  - spec/fixtures/vcr_cassettes/multi_locale_reference.yml
635
637
  - spec/fixtures/vcr_cassettes/not_found.yml
636
638
  - spec/fixtures/vcr_cassettes/nyancat.yml
639
+ - spec/fixtures/vcr_cassettes/query_array_1.yml
640
+ - spec/fixtures/vcr_cassettes/query_array_2.yml
637
641
  - spec/fixtures/vcr_cassettes/ratelimit.yml
638
642
  - spec/fixtures/vcr_cassettes/ratelimit_retry.yml
639
643
  - spec/fixtures/vcr_cassettes/reloaded_entry.yml