contentful 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/TAGS CHANGED
@@ -1,8 +1,8 @@
1
1
 
2
2
  examples/custom_classes.rb,120
3
- class MyResourceMyResource12,405
4
- class MyBetterArray < Contentful::ArrayMyBetterArray36,919
5
- def lastlast38,1002
3
+ class MyResourceMyResource12,406
4
+ class MyBetterArray < Contentful::ArrayMyBetterArray36,920
5
+ def lastlast38,1003
6
6
 
7
7
  examples/dynamic_entries.rb,0
8
8
 
@@ -13,8 +13,8 @@ examples/raise_errors.rb,0
13
13
  examples/raw_mode.rb,0
14
14
 
15
15
  examples/resource_mapping.rb,84
16
- class MyBetterArray < Contentful::ArrayMyBetterArray12,361
17
- def lastlast14,444
16
+ class MyBetterArray < Contentful::ArrayMyBetterArray12,377
17
+ def lastlast14,460
18
18
 
19
19
  lib/contentful/array.rb,95
20
20
  module ContentfulContentful4,68
@@ -26,28 +26,28 @@ module ContentfulContentful4,70
26
26
  class AssetAsset7,203
27
27
  def image_url(options = {})image_url19,627
28
28
 
29
- lib/contentful/client.rb,1109
30
- module ContentfulContentful10,256
31
- class ClientClient14,419
32
- def self.get_http(url, query, headers = {})get_http32,886
33
- def initialize(given_configuration = {})initialize36,987
34
- def default_configurationdefault_configuration49,1356
35
- def space(query = {})space56,1537
36
- def content_type(id, query = {})content_type63,1742
37
- def content_types(query = {})content_types70,1993
38
- def entry(id, query = {})entry77,2207
39
- def entries(query = {})entries84,2433
40
- def asset(id, query = {})asset91,2635
41
- def assets(query = {})assets98,2859
42
- def base_urlbase_url103,3001
43
- def request_headersrequest_headers108,3190
44
- def request_query(query)request_query117,3660
45
- def get(request, build_resource = true)get128,3998
46
- def update_dynamic_entry_cache!update_dynamic_entry_cache!154,4785
47
- def register_dynamic_entry(key, klass)register_dynamic_entry167,5115
48
- def sync(options = { initial: true })sync174,5355
49
- def normalize_configuration!normalize_configuration!181,5450
50
- def validate_configuration!validate_configuration!186,5700
29
+ lib/contentful/client.rb,1108
30
+ module ContentfulContentful8,132
31
+ class ClientClient12,295
32
+ def self.get_http(url, query, headers = {})get_http30,762
33
+ def initialize(given_configuration = {})initialize34,863
34
+ def default_configurationdefault_configuration47,1232
35
+ def space(query = {})space54,1413
36
+ def content_type(id, query = {})content_type61,1618
37
+ def content_types(query = {})content_types68,1869
38
+ def entry(id, query = {})entry75,2083
39
+ def entries(query = {})entries82,2309
40
+ def asset(id, query = {})asset89,2511
41
+ def assets(query = {})assets96,2735
42
+ def base_urlbase_url101,2877
43
+ def request_headersrequest_headers106,3066
44
+ def request_query(query)request_query115,3536
45
+ def get(request, build_resource = true)get126,3874
46
+ def update_dynamic_entry_cache!update_dynamic_entry_cache!152,4661
47
+ def register_dynamic_entry(key, klass)register_dynamic_entry165,4991
48
+ def sync(options = { initial: true })sync172,5231
49
+ def normalize_configuration!normalize_configuration!179,5326
50
+ def validate_configuration!validate_configuration!184,5576
51
51
 
52
52
  lib/contentful/content_type.rb,72
53
53
  module ContentfulContentful4,54
@@ -70,18 +70,19 @@ lib/contentful/entry.rb,60
70
70
  module ContentfulContentful4,64
71
71
  class EntryEntry7,198
72
72
 
73
- lib/contentful/error.rb,547
73
+ lib/contentful/error.rb,614
74
74
  module ContentfulContentful1,0
75
75
  class Error < StandardErrorError4,142
76
76
  def initialize(response)initialize7,199
77
77
  def self.[](error_status_code)[]14,396
78
- class NotFound < Error; endNotFound33,691
79
- class BadRequest < Error; endBadRequest36,730
80
- class AccessDenied < Error; endAccessDenied39,771
81
- class Unauthorized < Error; endUnauthorized42,814
82
- class ServerError < Error; endServerError45,857
83
- class UnparsableJson < Error; endUnparsableJson48,933
84
- class UnparsableResource < Error; endUnparsableResource51,1037
78
+ class NotFound < Error; endNotFound35,733
79
+ class BadRequest < Error; endBadRequest38,772
80
+ class AccessDenied < Error; endAccessDenied41,813
81
+ class Unauthorized < Error; endUnauthorized44,856
82
+ class ServerError < Error; endServerError47,899
83
+ class ServiceUnavailable < Error; endServiceUnavailable50,941
84
+ class UnparsableJson < Error; endUnparsableJson53,1024
85
+ class UnparsableResource < Error; endUnparsableResource56,1128
85
86
 
86
87
  lib/contentful/field.rb,60
87
88
  module ContentfulContentful3,29
@@ -160,21 +161,21 @@ lib/contentful/resource.rb,1041
160
161
  module ContentfulContentful4,62
161
162
  module ResourceResource13,463
162
163
  def initialize(object, request = nil, client = nil, nested_locale_fields = false, default_locale = Contentful::Client::DEFAULT_CONFIGURATION[:default_locale] )initialize24,743
163
- def inspect(info = nil)inspect34,1184
164
- def array?array?40,1417
165
- def nested_locale_fields?nested_locale_fields?45,1544
166
- def syssys50,1686
167
- def fieldsfields55,1797
168
- def reloadreload61,1941
169
- def extract_from_object(object, namespace, keys = nil)extract_from_object71,2050
170
- def coerce_value_or_array(value, what = nil)coerce_value_or_array85,2459
171
- def coerce_or_create_class(value, what)coerce_or_create_class93,2669
172
- module ClassMethodsClassMethods105,2982
173
- def nested_locale_fields?nested_locale_fields?107,3098
174
- def property_coercionsproperty_coercions111,3155
175
- def property(name, property_class = nil)property126,3829
176
- def update_coercions!update_coercions!134,4100
177
- def self.included(base)included153,4689
164
+ def inspect(info = nil)inspect35,1225
165
+ def array?array?41,1458
166
+ def nested_locale_fields?nested_locale_fields?46,1585
167
+ def syssys51,1727
168
+ def fieldsfields56,1838
169
+ def reloadreload62,1982
170
+ def extract_from_object(object, namespace, keys = nil)extract_from_object72,2091
171
+ def coerce_value_or_array(value, what = nil)coerce_value_or_array85,2510
172
+ def coerce_or_create_class(value, what)coerce_or_create_class95,2755
173
+ module ClassMethodsClassMethods107,3068
174
+ def nested_locale_fields?nested_locale_fields?109,3184
175
+ def property_coercionsproperty_coercions113,3241
176
+ def property(name, property_class = nil)property128,3915
177
+ def update_coercions!update_coercions!136,4186
178
+ def self.included(base)included155,4775
178
179
 
179
180
  lib/contentful/resource_builder.rb,2028
180
181
  module ContentfulContentful13,309
@@ -204,12 +205,14 @@ module ContentfulContentful13,309
204
205
  def maybe_replace_link(link, parent, key)maybe_replace_link255,8011
205
206
  def replace_links_in_included_resources_with_known_resourcesreplace_links_in_included_resources_with_known_resources262,8243
206
207
 
207
- lib/contentful/response.rb,228
208
- module ContentfulContentful4,47
209
- class ResponseResponse22,837
210
- def initialize(raw, request = nil)initialize25,920
211
- def parse_json!parse_json!38,1113
212
- def parse_contentful_error!parse_contentful_error!48,1327
208
+ lib/contentful/response.rb,362
209
+ module ContentfulContentful6,62
210
+ class ResponseResponse24,852
211
+ def initialize(raw, request = nil)initialize27,935
212
+ def service_unavailable_response?service_unavailable_response?45,1377
213
+ def no_content_response?no_content_response?49,1449
214
+ def parse_json!parse_json!53,1531
215
+ def parse_contentful_error!parse_contentful_error!63,1745
213
216
 
214
217
  lib/contentful/space.rb,60
215
218
  module ContentfulContentful4,55
@@ -23,6 +23,8 @@ module Contentful
23
23
  Unauthorized
24
24
  when 500
25
25
  ServerError
26
+ when 503
27
+ ServiceUnavailable
26
28
  else
27
29
  Error
28
30
  end
@@ -44,6 +46,9 @@ module Contentful
44
46
  # 500
45
47
  class ServerError < Error; end
46
48
 
49
+ # 503
50
+ class ServiceUnavailable < Error; end
51
+
47
52
  # Raised when response is no valid json
48
53
  class UnparsableJson < Error; end
49
54
 
@@ -27,7 +27,10 @@ module Contentful
27
27
  @request = request
28
28
  @status = :ok
29
29
 
30
- if no_content_response?
30
+ if service_unavailable_response?
31
+ @status = :service_unavailable
32
+ @error_message = 'Service Unavailable, contenful.com API seems to be down'
33
+ elsif no_content_response?
31
34
  @status = :no_content
32
35
  @object = true
33
36
  elsif parse_json!
@@ -37,6 +40,10 @@ module Contentful
37
40
 
38
41
  private
39
42
 
43
+ def service_unavailable_response?
44
+ @raw.status == 503
45
+ end
46
+
40
47
  def no_content_response?
41
48
  @raw.to_s == '' && @raw.status == 204
42
49
  end
@@ -1,3 +1,3 @@
1
1
  module Contentful
2
- VERSION = '0.3.2'
2
+ VERSION = '0.3.3'
3
3
  end
@@ -7,7 +7,7 @@ describe Contentful::Response do
7
7
 
8
8
  describe "#raw" do
9
9
  it "returns the raw response it has been initalized with" do
10
- expect( successful_response.raw ).to eq raw_fixture('nyancat')
10
+ expect( successful_response.raw.to_s ).to eql raw_fixture('nyancat').to_s
11
11
  end
12
12
  end
13
13
 
@@ -38,7 +38,7 @@ describe Contentful::Response do
38
38
 
39
39
  it 'returns :no_content for responses without content' do
40
40
  raw_response = ''
41
- mock(raw_response).status {204}
41
+ stub(raw_response).status {204}
42
42
  no_content_response = Contentful::Response.new raw_response
43
43
  expect( no_content_response.status).to eq :no_content
44
44
  end
@@ -52,6 +52,10 @@ describe Contentful::Response do
52
52
  it 'returns json parser error message for json parse errors' do
53
53
  expect( unparsable_response.error_message ).to include "unexpected token"
54
54
  end
55
- end
56
55
 
56
+ it 'returns a ServiceUnavailable error on a 503' do
57
+ error_response = Contentful::Response.new raw_fixture('not_found', 503)
58
+ expect(error_response.status).to eql :service_unavailable
59
+ end
60
+ end
57
61
  end
@@ -1,11 +1,15 @@
1
1
  require 'multi_json'
2
2
 
3
- def raw_fixture(which, as_json = false)
4
- File.read File.dirname(__FILE__) + "/../fixtures/json_responses/#{which}.json"
3
+ def raw_fixture(which,status = 200, as_json = false)
4
+ object = Object.new
5
+ stub(object).status { status }
6
+ stub(object).to_s { File.read File.dirname(__FILE__) + "/../fixtures/json_responses/#{which}.json" }
7
+
8
+ object
5
9
  end
6
10
 
7
11
  def json_fixture(which, as_json = false)
8
12
  MultiJson.load(
9
13
  File.read File.dirname(__FILE__) + "/../fixtures/json_responses/#{which}.json"
10
14
  )
11
- end
15
+ end
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: 0.3.2
4
+ version: 0.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-08-06 00:00:00.000000000 Z
12
+ date: 2014-08-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: http
@@ -288,7 +288,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
288
288
  version: '0'
289
289
  segments:
290
290
  - 0
291
- hash: -3768775141988377798
291
+ hash: -1847885584219532891
292
292
  required_rubygems_version: !ruby/object:Gem::Requirement
293
293
  none: false
294
294
  requirements:
@@ -297,10 +297,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
297
297
  version: '0'
298
298
  segments:
299
299
  - 0
300
- hash: -3768775141988377798
300
+ hash: -1847885584219532891
301
301
  requirements: []
302
302
  rubyforge_project:
303
- rubygems_version: 1.8.23
303
+ rubygems_version: 1.8.23.2
304
304
  signing_key:
305
305
  specification_version: 3
306
306
  summary: contentful