contentful-management 0.3.1 → 0.4.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 078f6456feff75c1b9b229796ce894c38fb75f67
|
4
|
+
data.tar.gz: 1d2374e3fb60e05ad5a12f9d2dcaabfde8a2453b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3df2feede3f7a11508ebc6d284e01e0696f3111263bfc3eb3efa137ba5e847bc061137a4ebb077edca5bdebf7bd20e982b46daa5c9a40461cc26c83e357619b
|
7
|
+
data.tar.gz: bf49926589bd2e50a5ddfe5218a19e3eb12b167f569bca930cc446daa094702938cc33bc5825b1414d50b84e83ee6dea23f90aae86948d16c3bf3b8bb43388c1
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# Change Log
|
2
|
-
##
|
2
|
+
## 0.4.0
|
3
3
|
### Fixed
|
4
4
|
* Return Keep attribute if it's already a hash [#33](https://github.com/contentful/contentful-management.rb/pull/33)
|
5
5
|
* Typo in header [#34](https://github.com/contentful/contentful-management.rb/pull/34)
|
6
6
|
* Items are nil when creating an array field for a content type [#35](https://github.com/contentful/contentful-management.rb/issues/35)
|
7
|
+
### Added
|
8
|
+
* `raise_errors` can be enabled, disabled by default [#38](https://github.com/contentful/contentful-management.rb/pull/38)
|
7
9
|
|
8
10
|
## 0.3.1
|
9
11
|
### Added
|
data/README.md
CHANGED
@@ -542,6 +542,14 @@ Logger.new('logfile.log')
|
|
542
542
|
|
543
543
|
The default severity is set to INFO and logs only the request attributes (headers, parameters and url). Setting it to DEBUG will also log the raw JSON response.
|
544
544
|
|
545
|
+
## Raise Errors
|
546
|
+
|
547
|
+
If ```:raise_errors``` is set to true, an Exception will be raised in case of an error. The default is false, in this case a ```Contentful::Management::Error``` object will be returned.
|
548
|
+
|
549
|
+
```ruby
|
550
|
+
client = Contentful::Management::Client.new('access_token', raise_errors: true)
|
551
|
+
```
|
552
|
+
|
545
553
|
## Contributing
|
546
554
|
|
547
555
|
1. Fork it ( https://github.com/[my-github-username]/contentful-management/fork )
|
@@ -25,7 +25,8 @@ module Contentful
|
|
25
25
|
default_locale: 'en-US',
|
26
26
|
gzip_encoded: false,
|
27
27
|
logger: false,
|
28
|
-
log_level: Logger::INFO
|
28
|
+
log_level: Logger::INFO,
|
29
|
+
raise_errors: false
|
29
30
|
}
|
30
31
|
|
31
32
|
def initialize(access_token = nil, configuration = {})
|
@@ -83,11 +84,13 @@ module Contentful
|
|
83
84
|
def execute_request(request)
|
84
85
|
request_url = request.url
|
85
86
|
url = request.absolute? ? request_url : base_url + request_url
|
86
|
-
logger.info(request: {url: url, query: request.query
|
87
|
+
logger.info(request: {url: url, query: request.query, header: request_headers}) if logger
|
87
88
|
raw_response = yield(url)
|
88
89
|
logger.debug(response: raw_response) if logger
|
89
90
|
clear_headers
|
90
|
-
Response.new(raw_response, request)
|
91
|
+
result = Response.new(raw_response, request)
|
92
|
+
fail result.object if result.object.is_a?(Error) && configuration[:raise_errors]
|
93
|
+
result
|
91
94
|
end
|
92
95
|
|
93
96
|
def clear_headers
|
@@ -74,6 +74,15 @@ module Contentful
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
+
describe '.raise_error' do
|
78
|
+
it 'raise error set to true' do
|
79
|
+
expect(subject.configuration[:raise_errors]).to be_falsey
|
80
|
+
end
|
81
|
+
it 'raise error set to false' do
|
82
|
+
client = Client.new('token', raise_errors: true)
|
83
|
+
expect(client.configuration[:raise_errors]).to be_truthy
|
84
|
+
end
|
85
|
+
end
|
77
86
|
end
|
78
87
|
end
|
79
88
|
end
|
@@ -55,6 +55,14 @@ module Contentful
|
|
55
55
|
expect(result).to be_kind_of Contentful::Management::NotFound
|
56
56
|
end
|
57
57
|
end
|
58
|
+
context 'raise_error when space not found' do
|
59
|
+
let!(:client) { Client.new(token, raise_errors: true) }
|
60
|
+
it 'returns an error when entry does not exists' do
|
61
|
+
expect_vcr('entry/find_not_found') do
|
62
|
+
subject.find(space_id, 'not_exist')
|
63
|
+
end.to raise_error Contentful::Management::NotFound
|
64
|
+
end
|
65
|
+
end
|
58
66
|
|
59
67
|
it 'returns an error when service is unavailable' do
|
60
68
|
vcr('entry/service_unavailable') do
|
@@ -268,9 +276,9 @@ module Contentful
|
|
268
276
|
vcr('entry/create_with_entries') do
|
269
277
|
entry_att = Entry.find(space_id, '1d1QDYzeiyWmgqQYysae8u')
|
270
278
|
new_entry = subject.create(content_type,
|
271
|
-
|
272
|
-
|
273
|
-
|
279
|
+
name: 'EntryWithEntries',
|
280
|
+
age: 20,
|
281
|
+
entries: [entry_att, entry_att, entry_att])
|
274
282
|
expect(new_entry.name).to eq 'EntryWithEntries'
|
275
283
|
expect(new_entry.age).to eq 20
|
276
284
|
end
|
@@ -572,18 +580,18 @@ module Contentful
|
|
572
580
|
# entry_att = Entry.find('ene4qtp2sh7u', '60zYC7nY9GcKGiCYwAs4wm')
|
573
581
|
|
574
582
|
attributes = {
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
583
|
+
name: 'Test name',
|
584
|
+
number: 30,
|
585
|
+
float1: 1.1,
|
586
|
+
boolean: true, date: '2000-07-12T11:11:00+02:00',
|
587
|
+
time: '2000-07-12T11:11:00+02:00',
|
588
|
+
location: location,
|
589
|
+
image: Asset.new,
|
590
|
+
images: [Asset.new, Asset.new],
|
591
|
+
array: %w(PL USD XX),
|
592
|
+
entry: Entry.new,
|
593
|
+
entries: [Entry.new, Entry.new],
|
594
|
+
object_json: {'test' => {'@type' => 'Codequest'}}
|
587
595
|
}
|
588
596
|
|
589
597
|
parsed_attributes = Entry.new.fields_from_attributes(attributes)
|
@@ -606,7 +614,7 @@ module Contentful
|
|
606
614
|
|
607
615
|
it 'keepd hashes in attributes' do
|
608
616
|
attributes = {
|
609
|
-
|
617
|
+
entries: [{sys: {type: 'Link', linkType: 'Entry', id: nil}}, {sys: {type: 'Link', linkType: 'Entry', id: nil}}]
|
610
618
|
}
|
611
619
|
|
612
620
|
parsed_attributes = Entry.new.fields_from_attributes(attributes)
|
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: 0.
|
4
|
+
version: 0.4.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: 2014-
|
13
|
+
date: 2014-11-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: http
|