yaks 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/lib/yaks/breaking_changes.rb +5 -0
- data/lib/yaks/collection_mapper.rb +2 -0
- data/lib/yaks/config.rb +3 -3
- data/lib/yaks/default_policy.rb +8 -0
- data/lib/yaks/version.rb +1 -1
- data/spec/unit/yaks/collection_mapper_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e75dbaa5cc865ca07fb16ae3e4662f3983652d96
|
4
|
+
data.tar.gz: bedaee826c1ae525bf0aa5511c62ccb3c02a0738
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f43aa2b03a6beb9f37009d3540ac8a75623e8dd3fb2b634785be696b81e20a3e7918cb3aef5eac86c63df49390f3ffd806c8a83596beff94e6dfb53793eba3d
|
7
|
+
data.tar.gz: 326578cce03f31740ceb6e927d431b8a42eefc0f79d8c65e0255bcd4475b952a6b0393eaf5ff11fcc5ae15f738bd7983ee767bd5964148cebccd9f8d68f50547
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
### Development
|
2
|
-
[full changelog](http://github.com/plexus/yaks/compare/v0.4.
|
2
|
+
[full changelog](http://github.com/plexus/yaks/compare/v0.4.3...master)
|
3
|
+
|
4
|
+
Mapping a non-empty collection will try to infer the type, and hence rel of the nested items, based on the first object in the collection. This is only relevant for formats like HAL that don't have a top-level collection representation, and only matters when mapping a collection at the top level, not when mapping a collection from an association.
|
5
|
+
|
6
|
+
### 0.4.3
|
3
7
|
|
4
8
|
* when specifying a rel_template, instead of allowing for {src} and {dest} fields, now a single {rel} field is expected, which corresponds more with typical usage.
|
5
9
|
|
@@ -1,5 +1,8 @@
|
|
1
1
|
module Yaks
|
2
2
|
|
3
|
+
# These are displayed in a post-install message when installing the
|
4
|
+
# gem to aid upgraiding
|
5
|
+
|
3
6
|
BreakingChanges = {
|
4
7
|
'0.4.3' => %q~
|
5
8
|
|
@@ -19,4 +22,6 @@ documentation.
|
|
19
22
|
~
|
20
23
|
}
|
21
24
|
|
25
|
+
BreakingChanges['0.4.4'] = BreakingChanges['0.4.3']
|
26
|
+
|
22
27
|
end
|
data/lib/yaks/config.rb
CHANGED
@@ -35,10 +35,10 @@ module Yaks
|
|
35
35
|
|
36
36
|
# @param [Hash] opts
|
37
37
|
# @param [Hash] env
|
38
|
-
# @return [
|
38
|
+
# @return [Class]
|
39
39
|
def format_class(opts, env)
|
40
|
-
accept = Rack::Accept::
|
41
|
-
mime_type = accept.best_of(Format.mime_types.values)
|
40
|
+
accept = Rack::Accept::MediaType.new(env['HTTP_ACCEPT'])
|
41
|
+
mime_type = accept.best_of([nil] + Format.mime_types.values)
|
42
42
|
return Format.by_mime_type(mime_type) if mime_type
|
43
43
|
Format.by_name(opts.fetch(:format) { @default_format })
|
44
44
|
end
|
data/lib/yaks/default_policy.rb
CHANGED
@@ -54,6 +54,14 @@ module Yaks
|
|
54
54
|
# @param [Yaks::Mapper::Association] association
|
55
55
|
# @return [Class] of subclass Yaks::Mapper
|
56
56
|
# @raise [NameError]
|
57
|
+
def derive_type_from_collection(collection)
|
58
|
+
if collection.any?
|
59
|
+
derive_type_from_mapper_class(
|
60
|
+
derive_mapper_from_object(collection.first)
|
61
|
+
)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
57
65
|
def derive_mapper_from_association(association)
|
58
66
|
@options[:namespace].const_get("#{camelize(association.singular_name)}Mapper")
|
59
67
|
end
|
data/lib/yaks/version.rb
CHANGED
@@ -58,14 +58,14 @@ RSpec.describe Yaks::CollectionMapper do
|
|
58
58
|
|
59
59
|
it 'should infer the item mapper' do
|
60
60
|
expect(mapper.call(collection)).to eql Yaks::CollectionResource.new(
|
61
|
-
type:
|
61
|
+
type: 'pet',
|
62
62
|
links: [],
|
63
63
|
attributes: {},
|
64
64
|
members: [
|
65
65
|
Yaks::Resource.new(type: 'pet', attributes: {:id => 2, :species => "dog", :name => "boingboing"}),
|
66
66
|
Yaks::Resource.new(type: 'pet', attributes: {:id => 3, :species => "cat", :name => "wassup"})
|
67
67
|
],
|
68
|
-
collection_rel: '
|
68
|
+
collection_rel: 'rel:pets'
|
69
69
|
)
|
70
70
|
end
|
71
71
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yaks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arne Brasseur
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inflection
|