contentful-management 1.4.0 → 1.5.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/contentful-management.gemspec +2 -1
- data/lib/contentful/management/asset.rb +5 -0
- data/lib/contentful/management/entry.rb +5 -0
- data/lib/contentful/management/resource.rb +5 -0
- data/lib/contentful/management/resource_requester.rb +1 -0
- data/lib/contentful/management/support.rb +11 -0
- data/lib/contentful/management/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/asset/select_operator.yml +137 -0
- data/spec/fixtures/vcr_cassettes/entry/select_operator.yml +144 -0
- data/spec/lib/contentful/management/asset_spec.rb +6 -0
- data/spec/lib/contentful/management/entry_spec.rb +6 -0
- metadata +24 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5375f7ca984d57cac6d910e9499a7fee451f57f
|
4
|
+
data.tar.gz: 7d847b47c7cb3f9af9dae098f869fb99b4cd04dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 648da2fcb41cb3007f9201e606f460f20b72104b03c6dd57ee5df680d7fca13162b9bfc08018cf4e779d0ff858bc7536d06c8d3a2010239fecab4ff776e93304
|
7
|
+
data.tar.gz: 194e585093ea3025e1b582aa60a96b3d4871afd2030cd9b3cbd5b8b8f29879819d5a7bc56987bfd66adeed95febdd3cb6f188717cb65b920b1b875532f72e53a
|
data/CHANGELOG.md
CHANGED
@@ -22,7 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency 'json', '~> 1.8'
|
23
23
|
|
24
24
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
25
|
-
spec.add_development_dependency 'rake'
|
25
|
+
spec.add_development_dependency 'rake', '< 11.0'
|
26
|
+
spec.add_development_dependency 'public_suffix', '< 1.5'
|
26
27
|
|
27
28
|
spec.add_development_dependency 'rspec', '~> 3'
|
28
29
|
spec.add_development_dependency 'rspec-its'
|
@@ -17,6 +17,17 @@ module Contentful
|
|
17
17
|
oldval.class.to_s == 'Hash' && newval.class.to_s == 'Hash' ? deep_hash_merge(oldval, newval) : newval
|
18
18
|
end
|
19
19
|
end
|
20
|
+
|
21
|
+
def normalize_select!(parameters)
|
22
|
+
return parameters unless parameters.key?(:select)
|
23
|
+
|
24
|
+
parameters[:select] = parameters[:select].split(',').map(&:strip) if parameters[:select].is_a? String
|
25
|
+
parameters[:select] = parameters[:select].reject { |p| p.start_with?('sys.') }
|
26
|
+
parameters[:select] << 'sys' unless parameters[:select].include?('sys')
|
27
|
+
parameters[:select] = parameters[:select].join(',')
|
28
|
+
|
29
|
+
parameters
|
30
|
+
end
|
20
31
|
end
|
21
32
|
end
|
22
33
|
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.contentful.com/spaces/cfexampleapi/assets?select=fields.title,sys&sys.id=nyancat
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- RubyContentfulManagementGem/1.4.0
|
12
|
+
Authorization:
|
13
|
+
- Bearer <ACCESS_TOKEN>
|
14
|
+
Content-Type:
|
15
|
+
- application/vnd.contentful.management.v1+json
|
16
|
+
Connection:
|
17
|
+
- close
|
18
|
+
Host:
|
19
|
+
- api.contentful.com
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Access-Control-Allow-Headers:
|
26
|
+
- 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
|
27
|
+
Access-Control-Allow-Methods:
|
28
|
+
- DELETE,GET,HEAD,POST,PUT,OPTIONS
|
29
|
+
Access-Control-Allow-Origin:
|
30
|
+
- "*"
|
31
|
+
Access-Control-Expose-Headers:
|
32
|
+
- Etag
|
33
|
+
Access-Control-Max-Age:
|
34
|
+
- '1728000'
|
35
|
+
Cf-Space-Id:
|
36
|
+
- cfexampleapi
|
37
|
+
Content-Type:
|
38
|
+
- application/vnd.contentful.management.v1+json
|
39
|
+
Date:
|
40
|
+
- Fri, 16 Dec 2016 17:57:18 GMT
|
41
|
+
Etag:
|
42
|
+
- '"b1e04275d327bd92a0b7708469e61e54"'
|
43
|
+
Server:
|
44
|
+
- Contentful
|
45
|
+
Strict-Transport-Security:
|
46
|
+
- max-age=15768000
|
47
|
+
X-Content-Type-Options:
|
48
|
+
- nosniff
|
49
|
+
X-Contentful-Ratelimit-Hour-Limit:
|
50
|
+
- '18000'
|
51
|
+
X-Contentful-Ratelimit-Hour-Remaining:
|
52
|
+
- '17860'
|
53
|
+
X-Contentful-Ratelimit-Reset:
|
54
|
+
- '0'
|
55
|
+
X-Contentful-Ratelimit-Second-Limit:
|
56
|
+
- '10'
|
57
|
+
X-Contentful-Ratelimit-Second-Remaining:
|
58
|
+
- '9'
|
59
|
+
X-Contentful-Request-Id:
|
60
|
+
- fccc4fc0c16dcbc89993ba46ef11722a
|
61
|
+
Content-Length:
|
62
|
+
- '1220'
|
63
|
+
Connection:
|
64
|
+
- Close
|
65
|
+
Set-Cookie:
|
66
|
+
- incap_ses_472_673446=0RSRWi7W0hlhIMcXnuGMBv0qVFgAAAAArAVpzrhH2sNu9g8/gS4xGQ==;
|
67
|
+
path=/; Domain=.contentful.com
|
68
|
+
- nlbi_673446=p9epGdYA1RrEr+hV6lKYhQAAAAAZNLPwoIBxQLcTIy81I+Jj; path=/; Domain=.contentful.com
|
69
|
+
- visid_incap_673446=TKmNQo+PRJamIXAbX/aRVv0qVFgAAAAAQUIPAAAAAABwhsCdHN7togOQgjwxEmlG;
|
70
|
+
expires=Sat, 16 Dec 2017 11:10:55 GMT; path=/; Domain=.contentful.com
|
71
|
+
X-Iinfo:
|
72
|
+
- 8-39954889-39954903 NNNN CT(101 101 0) RT(1481911034611 70) q(0 0 2 -1) r(30
|
73
|
+
30) U5
|
74
|
+
X-Cdn:
|
75
|
+
- Incapsula
|
76
|
+
body:
|
77
|
+
encoding: ASCII-8BIT
|
78
|
+
string: |
|
79
|
+
{
|
80
|
+
"sys": {
|
81
|
+
"type": "Array"
|
82
|
+
},
|
83
|
+
"total": 1,
|
84
|
+
"skip": 0,
|
85
|
+
"limit": 100,
|
86
|
+
"items": [
|
87
|
+
{
|
88
|
+
"fields": {
|
89
|
+
"title": {
|
90
|
+
"en-US": "Nyan Cat"
|
91
|
+
}
|
92
|
+
},
|
93
|
+
"sys": {
|
94
|
+
"space": {
|
95
|
+
"sys": {
|
96
|
+
"type": "Link",
|
97
|
+
"linkType": "Space",
|
98
|
+
"id": "cfexampleapi"
|
99
|
+
}
|
100
|
+
},
|
101
|
+
"id": "nyancat",
|
102
|
+
"type": "Asset",
|
103
|
+
"createdAt": "2013-09-02T14:54:17.868Z",
|
104
|
+
"updatedAt": "2013-09-02T14:56:34.264Z",
|
105
|
+
"createdBy": {
|
106
|
+
"sys": {
|
107
|
+
"type": "Link",
|
108
|
+
"linkType": "User",
|
109
|
+
"id": "7BslKh9TdKGOK41VmLDjFZ"
|
110
|
+
}
|
111
|
+
},
|
112
|
+
"updatedBy": {
|
113
|
+
"sys": {
|
114
|
+
"type": "Link",
|
115
|
+
"linkType": "User",
|
116
|
+
"id": "7BslKh9TdKGOK41VmLDjFZ"
|
117
|
+
}
|
118
|
+
},
|
119
|
+
"publishedCounter": 1,
|
120
|
+
"version": 2,
|
121
|
+
"publishedBy": {
|
122
|
+
"sys": {
|
123
|
+
"type": "Link",
|
124
|
+
"linkType": "User",
|
125
|
+
"id": "7BslKh9TdKGOK41VmLDjFZ"
|
126
|
+
}
|
127
|
+
},
|
128
|
+
"publishedVersion": 1,
|
129
|
+
"firstPublishedAt": "2013-09-02T14:56:34.240Z",
|
130
|
+
"publishedAt": "2013-09-02T14:56:34.240Z"
|
131
|
+
}
|
132
|
+
}
|
133
|
+
]
|
134
|
+
}
|
135
|
+
http_version:
|
136
|
+
recorded_at: Fri, 16 Dec 2016 17:57:18 GMT
|
137
|
+
recorded_with: VCR 3.0.3
|
@@ -0,0 +1,144 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.contentful.com/spaces/cfexampleapi/entries?content_type=cat&select=fields.lives,sys&sys.id=nyancat
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- RubyContentfulManagementGem/1.4.0
|
12
|
+
Authorization:
|
13
|
+
- Bearer <ACCESS_TOKEN>
|
14
|
+
Content-Type:
|
15
|
+
- application/vnd.contentful.management.v1+json
|
16
|
+
Connection:
|
17
|
+
- close
|
18
|
+
Host:
|
19
|
+
- api.contentful.com
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Access-Control-Allow-Headers:
|
26
|
+
- 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
|
27
|
+
Access-Control-Allow-Methods:
|
28
|
+
- DELETE,GET,HEAD,POST,PUT,OPTIONS
|
29
|
+
Access-Control-Allow-Origin:
|
30
|
+
- "*"
|
31
|
+
Access-Control-Expose-Headers:
|
32
|
+
- Etag
|
33
|
+
Access-Control-Max-Age:
|
34
|
+
- '1728000'
|
35
|
+
Cf-Space-Id:
|
36
|
+
- cfexampleapi
|
37
|
+
Content-Type:
|
38
|
+
- application/vnd.contentful.management.v1+json
|
39
|
+
Date:
|
40
|
+
- Fri, 16 Dec 2016 18:00:04 GMT
|
41
|
+
Etag:
|
42
|
+
- '"ed0826e81d22bcd08b35f94f4bc82d1e"'
|
43
|
+
Server:
|
44
|
+
- Contentful
|
45
|
+
Strict-Transport-Security:
|
46
|
+
- max-age=15768000
|
47
|
+
X-Content-Type-Options:
|
48
|
+
- nosniff
|
49
|
+
X-Contentful-Ratelimit-Hour-Limit:
|
50
|
+
- '18000'
|
51
|
+
X-Contentful-Ratelimit-Hour-Remaining:
|
52
|
+
- '17883'
|
53
|
+
X-Contentful-Ratelimit-Reset:
|
54
|
+
- '0'
|
55
|
+
X-Contentful-Ratelimit-Second-Limit:
|
56
|
+
- '10'
|
57
|
+
X-Contentful-Ratelimit-Second-Remaining:
|
58
|
+
- '9'
|
59
|
+
X-Contentful-Request-Id:
|
60
|
+
- 28a7082823b538951d9a099bac40c527
|
61
|
+
Content-Length:
|
62
|
+
- '1374'
|
63
|
+
Connection:
|
64
|
+
- Close
|
65
|
+
Set-Cookie:
|
66
|
+
- incap_ses_472_673446=IJw9TuV0ZGKtUsgXnuGMBqMrVFgAAAAAi4iCWS8V/VnXGKNdm/wKyg==;
|
67
|
+
path=/; Domain=.contentful.com
|
68
|
+
- nlbi_673446=ktbvABNwb38Nw5Mv6lKYhQAAAAC4U8Sqbk2yWH0JO+36N3dB; path=/; Domain=.contentful.com
|
69
|
+
- visid_incap_673446=s+iXCCDpTkmJETU1n9MwnqMrVFgAAAAAQUIPAAAAAABRit5PDIa8+j0nzfJqL/e8;
|
70
|
+
expires=Sat, 16 Dec 2017 11:10:55 GMT; path=/; Domain=.contentful.com
|
71
|
+
X-Iinfo:
|
72
|
+
- 8-39995933-39995956 NNNN CT(92 188 0) RT(1481911203237 69) q(0 0 2 -1) r(5
|
73
|
+
5) U5
|
74
|
+
X-Cdn:
|
75
|
+
- Incapsula
|
76
|
+
body:
|
77
|
+
encoding: ASCII-8BIT
|
78
|
+
string: |
|
79
|
+
{
|
80
|
+
"sys": {
|
81
|
+
"type": "Array"
|
82
|
+
},
|
83
|
+
"total": 1,
|
84
|
+
"skip": 0,
|
85
|
+
"limit": 100,
|
86
|
+
"items": [
|
87
|
+
{
|
88
|
+
"fields": {
|
89
|
+
"lives": {
|
90
|
+
"en-US": 1337
|
91
|
+
}
|
92
|
+
},
|
93
|
+
"sys": {
|
94
|
+
"space": {
|
95
|
+
"sys": {
|
96
|
+
"type": "Link",
|
97
|
+
"linkType": "Space",
|
98
|
+
"id": "cfexampleapi"
|
99
|
+
}
|
100
|
+
},
|
101
|
+
"id": "nyancat",
|
102
|
+
"type": "Entry",
|
103
|
+
"createdAt": "2013-06-27T22:46:15.910Z",
|
104
|
+
"updatedAt": "2016-05-19T11:40:57.752Z",
|
105
|
+
"createdBy": {
|
106
|
+
"sys": {
|
107
|
+
"type": "Link",
|
108
|
+
"linkType": "User",
|
109
|
+
"id": "7BslKh9TdKGOK41VmLDjFZ"
|
110
|
+
}
|
111
|
+
},
|
112
|
+
"updatedBy": {
|
113
|
+
"sys": {
|
114
|
+
"type": "Link",
|
115
|
+
"linkType": "User",
|
116
|
+
"id": "5NItczv8FWvPn5UTJpTOMM"
|
117
|
+
}
|
118
|
+
},
|
119
|
+
"publishedCounter": 5,
|
120
|
+
"version": 15,
|
121
|
+
"publishedBy": {
|
122
|
+
"sys": {
|
123
|
+
"type": "Link",
|
124
|
+
"linkType": "User",
|
125
|
+
"id": "7BslKh9TdKGOK41VmLDjFZ"
|
126
|
+
}
|
127
|
+
},
|
128
|
+
"publishedVersion": 10,
|
129
|
+
"firstPublishedAt": "2013-06-27T22:46:19.513Z",
|
130
|
+
"publishedAt": "2013-09-04T09:19:39.027Z",
|
131
|
+
"contentType": {
|
132
|
+
"sys": {
|
133
|
+
"type": "Link",
|
134
|
+
"linkType": "ContentType",
|
135
|
+
"id": "cat"
|
136
|
+
}
|
137
|
+
}
|
138
|
+
}
|
139
|
+
}
|
140
|
+
]
|
141
|
+
}
|
142
|
+
http_version:
|
143
|
+
recorded_at: Fri, 16 Dec 2016 18:00:04 GMT
|
144
|
+
recorded_with: VCR 3.0.3
|
@@ -34,6 +34,12 @@ module Contentful
|
|
34
34
|
assets.next_page
|
35
35
|
end
|
36
36
|
end
|
37
|
+
it 'supports select operator' do
|
38
|
+
vcr('asset/select_operator') do
|
39
|
+
nyancat = subject.all('cfexampleapi', 'sys.id' => 'nyancat', select: 'fields.title').first
|
40
|
+
expect(nyancat.fields).to eq({ title: 'Nyan Cat' })
|
41
|
+
end
|
42
|
+
end
|
37
43
|
end
|
38
44
|
|
39
45
|
describe '.all_published' do
|
@@ -53,6 +53,12 @@ module Contentful
|
|
53
53
|
entries.next_page
|
54
54
|
end
|
55
55
|
end
|
56
|
+
it 'supports select operator' do
|
57
|
+
vcr('entry/select_operator') do
|
58
|
+
nyancat = subject.all('cfexampleapi', 'sys.id' => 'nyancat', content_type: 'cat', select: 'fields.lives').first
|
59
|
+
expect(nyancat.fields).to eq({lives: 1337})
|
60
|
+
end
|
61
|
+
end
|
56
62
|
end
|
57
63
|
|
58
64
|
describe '.all_published' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contentful-management
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Protas
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-12-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: http
|
@@ -72,16 +72,30 @@ dependencies:
|
|
72
72
|
name: rake
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
|
-
- - "
|
75
|
+
- - "<"
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
77
|
+
version: '11.0'
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
|
-
- - "
|
82
|
+
- - "<"
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version: '0'
|
84
|
+
version: '11.0'
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: public_suffix
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "<"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '1.5'
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - "<"
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '1.5'
|
85
99
|
- !ruby/object:Gem::Dependency
|
86
100
|
name: rspec
|
87
101
|
requirement: !ruby/object:Gem::Requirement
|
@@ -305,6 +319,7 @@ files:
|
|
305
319
|
- spec/fixtures/vcr_cassettes/asset/reload.yml
|
306
320
|
- spec/fixtures/vcr_cassettes/asset/reload_with_fields.yml
|
307
321
|
- spec/fixtures/vcr_cassettes/asset/save_update.yml
|
322
|
+
- spec/fixtures/vcr_cassettes/asset/select_operator.yml
|
308
323
|
- spec/fixtures/vcr_cassettes/asset/set_locale.yml
|
309
324
|
- spec/fixtures/vcr_cassettes/asset/unarchive.yml
|
310
325
|
- spec/fixtures/vcr_cassettes/asset/unarchive_already_unarchive.yml
|
@@ -443,6 +458,7 @@ files:
|
|
443
458
|
- spec/fixtures/vcr_cassettes/entry/search_filter/range_operators_greater_than_or_equal.yml
|
444
459
|
- spec/fixtures/vcr_cassettes/entry/search_filter/range_operators_less.yml
|
445
460
|
- spec/fixtures/vcr_cassettes/entry/search_filter/reverse_order_sys_updatedAt.yml
|
461
|
+
- spec/fixtures/vcr_cassettes/entry/select_operator.yml
|
446
462
|
- spec/fixtures/vcr_cassettes/entry/service_unavailable.yml
|
447
463
|
- spec/fixtures/vcr_cassettes/entry/too_many_requests.yml
|
448
464
|
- spec/fixtures/vcr_cassettes/entry/too_many_requests_retry.yml
|
@@ -599,6 +615,7 @@ test_files:
|
|
599
615
|
- spec/fixtures/vcr_cassettes/asset/reload.yml
|
600
616
|
- spec/fixtures/vcr_cassettes/asset/reload_with_fields.yml
|
601
617
|
- spec/fixtures/vcr_cassettes/asset/save_update.yml
|
618
|
+
- spec/fixtures/vcr_cassettes/asset/select_operator.yml
|
602
619
|
- spec/fixtures/vcr_cassettes/asset/set_locale.yml
|
603
620
|
- spec/fixtures/vcr_cassettes/asset/unarchive.yml
|
604
621
|
- spec/fixtures/vcr_cassettes/asset/unarchive_already_unarchive.yml
|
@@ -737,6 +754,7 @@ test_files:
|
|
737
754
|
- spec/fixtures/vcr_cassettes/entry/search_filter/range_operators_greater_than_or_equal.yml
|
738
755
|
- spec/fixtures/vcr_cassettes/entry/search_filter/range_operators_less.yml
|
739
756
|
- spec/fixtures/vcr_cassettes/entry/search_filter/reverse_order_sys_updatedAt.yml
|
757
|
+
- spec/fixtures/vcr_cassettes/entry/select_operator.yml
|
740
758
|
- spec/fixtures/vcr_cassettes/entry/service_unavailable.yml
|
741
759
|
- spec/fixtures/vcr_cassettes/entry/too_many_requests.yml
|
742
760
|
- spec/fixtures/vcr_cassettes/entry/too_many_requests_retry.yml
|