contentful 0.10.0 → 0.11.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
  SHA1:
3
- metadata.gz: b4b2933230edf4826b39a5a7d4d6b351556df06e
4
- data.tar.gz: bc501b5ebf3ec6c371601e4042722d02fb34abe5
3
+ metadata.gz: 4ba77ca80d0071ad28546271729538c6a701616d
4
+ data.tar.gz: 65a9ee25b3709bb641deed8345862914480068e7
5
5
  SHA512:
6
- metadata.gz: c1dde750063924ec1d9986608d5b66eb68862823ff50b175f2d1cd7e6b32f3c1df37dc00f1fb177a8f7e372ffd6aa00012016e97a625aa1fa05905ff47c03851
7
- data.tar.gz: dae89c9fccdc81b19db54f9c8f2ed9daaddf5a222ce194d82ac3f801eef9bed26fe2a77da609c2f36979e7cc28c8b7f5801f062a8bbf70728aba1bd29289d3ff
6
+ metadata.gz: 51c966da267b2dc62c189a57dd69200ec9a83f81cba5bccd4695c5ef756babdc6aeccbb53a7c98bde97325fbfff86c68eac08912871192d035d36188828de389
7
+ data.tar.gz: d5c14ff5244ef3463bfec9cac959be1de527f45ca0f48e8885101ea473dc5f53f1b8d471a2479b668504cc8ee003ccb23ea4be549a3e5aee1135929f03039c91
@@ -1,6 +1,10 @@
1
1
  # Change Log
2
2
  ## Unreleased
3
3
 
4
+ ## 0.11.0
5
+ ### Fixed
6
+ * Fixed Locale handling [#98](https://github.com/contentful/contentful.rb/issues/98)
7
+
4
8
  ## 0.10.0
5
9
  ### Added
6
10
  * Added `:fl` parameter to `Asset#image_url` to support `progressive` File Layering
data/Gemfile CHANGED
@@ -2,6 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
+ gem 'listen', '3.0.6'
5
6
 
6
7
  group :documentation do
7
8
  gem 'coveralls', :require => false
data/README.md CHANGED
@@ -89,7 +89,7 @@ However, you can (and should) set `:dynamic_entries` to `:auto` in your client c
89
89
  client = Contentful::Client.new(
90
90
  access_token: 'b4c0n73n7fu1',
91
91
  space: 'cfexampleapi',
92
- dynamic_entries: :auto,
92
+ dynamic_entries: :auto
93
93
  )
94
94
 
95
95
  entry = client.entry 'nyancat' # => #<Contentful::DynamicEntry[cat]: ...>
@@ -15,8 +15,9 @@ Gem::Specification.new do |gem|
15
15
  gem.test_files = gem.files.grep(%r{^spec/})
16
16
  gem.require_paths = ['lib']
17
17
 
18
- gem.add_dependency 'http', '~> 0.8'
18
+ gem.add_dependency 'http', '~> 1.0'
19
19
  gem.add_dependency 'multi_json', '~> 1'
20
+ gem.add_dependency 'json', '~> 1.8'
20
21
 
21
22
  gem.add_development_dependency 'bundler', '~> 1.5'
22
23
  gem.add_development_dependency 'rake', '~> 10'
@@ -26,9 +27,10 @@ Gem::Specification.new do |gem|
26
27
  gem.add_development_dependency 'guard-rspec'
27
28
  gem.add_development_dependency 'guard-rubocop'
28
29
  gem.add_development_dependency 'guard-yard'
29
- gem.add_development_dependency 'rubocop'
30
+ gem.add_development_dependency 'rubocop', '~> 0.41.0'
30
31
  gem.add_development_dependency 'rspec', '~> 2'
31
32
  gem.add_development_dependency 'rr'
32
33
  gem.add_development_dependency 'vcr'
33
34
  gem.add_development_dependency 'webmock', '~> 1', '>= 1.17.3'
35
+ gem.add_development_dependency 'tins', '~> 1.6.0'
34
36
  end
@@ -31,7 +31,7 @@ module Contentful
31
31
 
32
32
  Class.new DynamicEntry do
33
33
  content_type.fields.each do |f|
34
- define_method Support.snakify(f.id).to_sym do |wanted_locale = default_locale|
34
+ define_method Support.snakify(f.id).to_sym do |wanted_locale = nil|
35
35
  fields(wanted_locale)[f.id.to_sym]
36
36
  end
37
37
  end
@@ -174,9 +174,7 @@ module Contentful
174
174
  end
175
175
 
176
176
  def coerce_value_or_array(value, what = nil)
177
- if value.nil?
178
- nil
179
- elsif value.is_a? ::Array
177
+ if value.is_a? ::Array
180
178
  value.map { |v| coerce_or_create_class(v, what) }
181
179
  elsif should_coerce_hash?(value)
182
180
  ::Hash[value.map do |k, v|
@@ -214,8 +212,10 @@ module Contentful
214
212
  case what
215
213
  when Symbol
216
214
  COERCIONS[what] ? COERCIONS[what][value] : value
215
+ when Proc
216
+ what[value]
217
217
  when Class
218
- what.new(value, client)
218
+ what.new(value, client) if value
219
219
  else
220
220
  value
221
221
  end
@@ -17,7 +17,7 @@ module Contentful
17
17
  #
18
18
  # @return [Hash] localized fields
19
19
  def fields(wanted_locale = default_locale)
20
- @fields[locale || wanted_locale]
20
+ @fields[locale || wanted_locale] || {}
21
21
  end
22
22
 
23
23
  # @private
@@ -10,9 +10,9 @@ module Contentful
10
10
  # Returns all fields of the asset
11
11
  #
12
12
  # @return [Hash] fields for Resource on selected locale
13
- def fields(wanted_locale = default_locale)
14
- wanted_locale = wanted_locale.to_s
15
- @fields.key?(wanted_locale) ? @fields[wanted_locale] : @fields[locale]
13
+ def fields(wanted_locale = nil)
14
+ wanted_locale = (locale || default_locale) if wanted_locale.nil?
15
+ @fields[wanted_locale.to_s] || {}
16
16
  end
17
17
 
18
18
  # Returns all fields of the asset with locales nested by field
@@ -69,9 +69,10 @@ module Contentful
69
69
 
70
70
  unless @included_resources.empty?
71
71
  replace_links_in_included_resources_with_known_resources
72
- replace_links_with_known_resources @resource
73
72
  end
74
73
 
74
+ replace_links_with_known_resources @resource
75
+
75
76
  @resource
76
77
  rescue UnparsableResource => error
77
78
  error
@@ -1,5 +1,5 @@
1
1
  # Contentful Namespace
2
2
  module Contentful
3
3
  # Gem Version
4
- VERSION = '0.10.0'
4
+ VERSION = '0.11.0'
5
5
  end
@@ -7,4 +7,17 @@ describe 'Coercion Examples' do
7
7
  expect(entry.created_at).to be_a DateTime
8
8
  expect(entry.created_at.day).to eq 27
9
9
  end
10
+
11
+ describe 'custom coercion' do
12
+ class TestCar
13
+ include Contentful::Resource
14
+
15
+ property :parts, ->(v) { Array(v) unless v }
16
+ end
17
+
18
+ it 'can use proc' do
19
+ car = TestCar.new("parts" => nil)
20
+ expect(car.parts).to be_empty
21
+ end
22
+ end
10
23
  end
@@ -121,7 +121,7 @@ describe Contentful::Entry do
121
121
  expect(entry).to be_a Kategorie
122
122
  expect(entry.title).to eq "Some Title"
123
123
  expect(entry.slug).to eq "/asda.html"
124
- expect(entry.featured_articles.first.is_a?(Contentful::Link)).to be_truthy
124
+ expect(entry.featured_articles.first.is_a?(Contentful::Entry)).to be_truthy
125
125
  expect(entry.top).to be_truthy
126
126
  }
127
127
  end
@@ -4,3 +4,8 @@ require 'securerandom'
4
4
  require 'rr'
5
5
 
6
6
  Dir[File.dirname(__FILE__) + '/support/**/*.rb'].each { |f| require f }
7
+
8
+ RSpec.configure do |config|
9
+ config.filter_run :focus => true
10
+ config.run_all_when_everything_filtered = true
11
+ 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.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Contentful GmbH (Jan Lelis)
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-04-11 00:00:00.000000000 Z
12
+ date: 2016-08-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: http
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '0.8'
20
+ version: '1.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '0.8'
27
+ version: '1.0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: multi_json
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -39,6 +39,20 @@ dependencies:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: '1'
42
+ - !ruby/object:Gem::Dependency
43
+ name: json
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.8'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.8'
42
56
  - !ruby/object:Gem::Dependency
43
57
  name: bundler
44
58
  requirement: !ruby/object:Gem::Requirement
@@ -141,16 +155,16 @@ dependencies:
141
155
  name: rubocop
142
156
  requirement: !ruby/object:Gem::Requirement
143
157
  requirements:
144
- - - ">="
158
+ - - "~>"
145
159
  - !ruby/object:Gem::Version
146
- version: '0'
160
+ version: 0.41.0
147
161
  type: :development
148
162
  prerelease: false
149
163
  version_requirements: !ruby/object:Gem::Requirement
150
164
  requirements:
151
- - - ">="
165
+ - - "~>"
152
166
  - !ruby/object:Gem::Version
153
- version: '0'
167
+ version: 0.41.0
154
168
  - !ruby/object:Gem::Dependency
155
169
  name: rspec
156
170
  requirement: !ruby/object:Gem::Requirement
@@ -213,6 +227,20 @@ dependencies:
213
227
  - - ">="
214
228
  - !ruby/object:Gem::Version
215
229
  version: 1.17.3
230
+ - !ruby/object:Gem::Dependency
231
+ name: tins
232
+ requirement: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - "~>"
235
+ - !ruby/object:Gem::Version
236
+ version: 1.6.0
237
+ type: :development
238
+ prerelease: false
239
+ version_requirements: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: 1.6.0
216
244
  description: Ruby client for the https://www.contentful.com Content Delivery API
217
245
  email: rubygems@contentful.com
218
246
  executables: []