media_types-serialization 0.7.0.beta1 → 0.7.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
  SHA256:
3
- metadata.gz: 9d865beb9427149817eab4cefff9778571c295259c1779351fd720d46276f312
4
- data.tar.gz: c96c8372252d7f832028870ea74bfb1972a0f7c56325fa38492a81f21df17fab
3
+ metadata.gz: 07bdf0bb72927f6e29b245e02fca50612f571370519faf4d700b86faa83c64fe
4
+ data.tar.gz: 9cd9142ee960df19c85914a673f0a45f109eee0a32fece4a9b62fe1106ecbec8
5
5
  SHA512:
6
- metadata.gz: 1204aaa35637f97fafca495a691d2f07524e2e85c7742ebcf94ae6869e38cea9b4a0fa152bca0274aa1db86a43dd377ef98b49036fedae4e2f1b964663e6c444
7
- data.tar.gz: cca3b6cfe51cfa3a0785e3f1dbe3d13b5c442d845171408e2e735940eb22aba6bfdefb5769d791e2908878150cd790366f43fc24006d23fce072def4cf43254d
6
+ metadata.gz: 10a829365e6763894eb52638198da8012e00b90e2c19ce173fb9d4c21a69dea968cab6662b4f02e833f21ef06249b5854e1b43875c1ca20017c1ead9bb4bcf50
7
+ data.tar.gz: 396e9b9ac84b983585ff8b832fb098924be39c513787317da71a5b0987783f4c623748c089b50b583f7b253995643d53631fc724191b1bcb84adecf3b44ba46c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.0
4
+
5
+ - ✨ Add `extract_set_links` to serializer for collection links
6
+
3
7
  ## 0.7.0.beta1
4
8
 
5
9
  - 🐛 Fix non-serializer media types replacing known serializers
@@ -12,7 +16,7 @@
12
16
  - For representations: use `.api_viewer` unless it's `.html`
13
17
  - For body links: use .api_viewer unless it already has a `.format`
14
18
  - For HTTP links: leave them alone
15
-
19
+
16
20
  ## 0.6.2
17
21
 
18
22
  - 🐛 Update `http_headers-accept`: 0.2.1 → 0.2.2
@@ -73,7 +77,7 @@
73
77
  ## 0.2.0
74
78
 
75
79
  - Change `method_missing` and base methods for `Base`
76
- - Add test for `HtmlWrapper`
80
+ - Add test for `HtmlWrapper`
77
81
 
78
82
  ## 0.1.0
79
83
 
data/Gemfile.lock CHANGED
@@ -1,146 +1,146 @@
1
- PATH
2
- remote: .
3
- specs:
4
- media_types-serialization (0.7.0.beta1)
5
- actionpack (>= 4.0.0)
6
- activesupport (>= 4.0.0)
7
- http_headers-accept (>= 0.2.2, < 1.0.0)
8
- http_headers-link (< 1.0.0)
9
- media_types (>= 0.6.2)
10
- oj (>= 3.5.0)
11
-
12
- GEM
13
- remote: https://rubygems.org/
14
- specs:
15
- actioncable (5.2.2)
16
- actionpack (= 5.2.2)
17
- nio4r (~> 2.0)
18
- websocket-driver (>= 0.6.1)
19
- actionmailer (5.2.2)
20
- actionpack (= 5.2.2)
21
- actionview (= 5.2.2)
22
- activejob (= 5.2.2)
23
- mail (~> 2.5, >= 2.5.4)
24
- rails-dom-testing (~> 2.0)
25
- actionpack (5.2.2)
26
- actionview (= 5.2.2)
27
- activesupport (= 5.2.2)
28
- rack (~> 2.0)
29
- rack-test (>= 0.6.3)
30
- rails-dom-testing (~> 2.0)
31
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
32
- actionview (5.2.2)
33
- activesupport (= 5.2.2)
34
- builder (~> 3.1)
35
- erubi (~> 1.4)
36
- rails-dom-testing (~> 2.0)
37
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
38
- activejob (5.2.2)
39
- activesupport (= 5.2.2)
40
- globalid (>= 0.3.6)
41
- activemodel (5.2.2)
42
- activesupport (= 5.2.2)
43
- activerecord (5.2.2)
44
- activemodel (= 5.2.2)
45
- activesupport (= 5.2.2)
46
- arel (>= 9.0)
47
- activestorage (5.2.2)
48
- actionpack (= 5.2.2)
49
- activerecord (= 5.2.2)
50
- marcel (~> 0.3.1)
51
- activesupport (5.2.2)
52
- concurrent-ruby (~> 1.0, >= 1.0.2)
53
- i18n (>= 0.7, < 2)
54
- minitest (~> 5.1)
55
- tzinfo (~> 1.1)
56
- arel (9.0.0)
57
- awesome_print (1.8.0)
58
- builder (3.2.3)
59
- concurrent-ruby (1.1.4)
60
- crass (1.0.4)
61
- erubi (1.8.0)
62
- globalid (0.4.2)
63
- activesupport (>= 4.2.0)
64
- http_headers-accept (0.2.2)
65
- http_headers-utils (>= 0.2.0, < 1.0.0)
66
- http_headers-link (0.2.1)
67
- http_headers-utils (>= 0.2.0, < 1.0.0)
68
- http_headers-utils (0.2.0)
69
- i18n (1.6.0)
70
- concurrent-ruby (~> 1.0)
71
- loofah (2.2.3)
72
- crass (~> 1.0.2)
73
- nokogiri (>= 1.5.9)
74
- mail (2.7.1)
75
- mini_mime (>= 0.1.1)
76
- marcel (0.3.3)
77
- mimemagic (~> 0.3.2)
78
- media_types (0.6.2)
79
- method_source (0.9.2)
80
- mimemagic (0.3.3)
81
- mini_mime (1.0.1)
82
- mini_portile2 (2.4.0)
83
- minitest (5.11.3)
84
- nio4r (2.3.1)
85
- nokogiri (1.10.3)
86
- mini_portile2 (~> 2.4.0)
87
- nokogiri (1.10.3-x64-mingw32)
88
- mini_portile2 (~> 2.4.0)
89
- oj (3.7.12)
90
- rack (2.0.6)
91
- rack-test (1.1.0)
92
- rack (>= 1.0, < 3)
93
- rails (5.2.2)
94
- actioncable (= 5.2.2)
95
- actionmailer (= 5.2.2)
96
- actionpack (= 5.2.2)
97
- actionview (= 5.2.2)
98
- activejob (= 5.2.2)
99
- activemodel (= 5.2.2)
100
- activerecord (= 5.2.2)
101
- activestorage (= 5.2.2)
102
- activesupport (= 5.2.2)
103
- bundler (>= 1.3.0)
104
- railties (= 5.2.2)
105
- sprockets-rails (>= 2.0.0)
106
- rails-dom-testing (2.0.3)
107
- activesupport (>= 4.2.0)
108
- nokogiri (>= 1.6)
109
- rails-html-sanitizer (1.0.4)
110
- loofah (~> 2.2, >= 2.2.2)
111
- railties (5.2.2)
112
- actionpack (= 5.2.2)
113
- activesupport (= 5.2.2)
114
- method_source
115
- rake (>= 0.8.7)
116
- thor (>= 0.19.0, < 2.0)
117
- rake (10.5.0)
118
- sprockets (3.7.2)
119
- concurrent-ruby (~> 1.0)
120
- rack (> 1, < 3)
121
- sprockets-rails (3.2.1)
122
- actionpack (>= 4.0)
123
- activesupport (>= 4.0)
124
- sprockets (>= 3.0.0)
125
- thor (0.20.3)
126
- thread_safe (0.3.6)
127
- tzinfo (1.2.5)
128
- thread_safe (~> 0.1)
129
- websocket-driver (0.7.0)
130
- websocket-extensions (>= 0.1.0)
131
- websocket-extensions (0.1.3)
132
-
133
- PLATFORMS
134
- ruby
135
- x64-mingw32
136
-
137
- DEPENDENCIES
138
- awesome_print
139
- bundler (~> 2.0)
140
- media_types-serialization!
141
- minitest (~> 5.0)
142
- rails (~> 5.2)
143
- rake (~> 10.0)
144
-
145
- BUNDLED WITH
146
- 2.0.1
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ media_types-serialization (0.7.0.beta1)
5
+ actionpack (>= 4.0.0)
6
+ activesupport (>= 4.0.0)
7
+ http_headers-accept (>= 0.2.2, < 1.0.0)
8
+ http_headers-link (< 1.0.0)
9
+ media_types (>= 0.6.2)
10
+ oj (>= 3.5.0)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ actioncable (5.2.2)
16
+ actionpack (= 5.2.2)
17
+ nio4r (~> 2.0)
18
+ websocket-driver (>= 0.6.1)
19
+ actionmailer (5.2.2)
20
+ actionpack (= 5.2.2)
21
+ actionview (= 5.2.2)
22
+ activejob (= 5.2.2)
23
+ mail (~> 2.5, >= 2.5.4)
24
+ rails-dom-testing (~> 2.0)
25
+ actionpack (5.2.2)
26
+ actionview (= 5.2.2)
27
+ activesupport (= 5.2.2)
28
+ rack (~> 2.0)
29
+ rack-test (>= 0.6.3)
30
+ rails-dom-testing (~> 2.0)
31
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
32
+ actionview (5.2.2)
33
+ activesupport (= 5.2.2)
34
+ builder (~> 3.1)
35
+ erubi (~> 1.4)
36
+ rails-dom-testing (~> 2.0)
37
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
38
+ activejob (5.2.2)
39
+ activesupport (= 5.2.2)
40
+ globalid (>= 0.3.6)
41
+ activemodel (5.2.2)
42
+ activesupport (= 5.2.2)
43
+ activerecord (5.2.2)
44
+ activemodel (= 5.2.2)
45
+ activesupport (= 5.2.2)
46
+ arel (>= 9.0)
47
+ activestorage (5.2.2)
48
+ actionpack (= 5.2.2)
49
+ activerecord (= 5.2.2)
50
+ marcel (~> 0.3.1)
51
+ activesupport (5.2.2)
52
+ concurrent-ruby (~> 1.0, >= 1.0.2)
53
+ i18n (>= 0.7, < 2)
54
+ minitest (~> 5.1)
55
+ tzinfo (~> 1.1)
56
+ arel (9.0.0)
57
+ awesome_print (1.8.0)
58
+ builder (3.2.3)
59
+ concurrent-ruby (1.1.4)
60
+ crass (1.0.4)
61
+ erubi (1.8.0)
62
+ globalid (0.4.2)
63
+ activesupport (>= 4.2.0)
64
+ http_headers-accept (0.2.2)
65
+ http_headers-utils (>= 0.2.0, < 1.0.0)
66
+ http_headers-link (0.2.1)
67
+ http_headers-utils (>= 0.2.0, < 1.0.0)
68
+ http_headers-utils (0.2.0)
69
+ i18n (1.6.0)
70
+ concurrent-ruby (~> 1.0)
71
+ loofah (2.2.3)
72
+ crass (~> 1.0.2)
73
+ nokogiri (>= 1.5.9)
74
+ mail (2.7.1)
75
+ mini_mime (>= 0.1.1)
76
+ marcel (0.3.3)
77
+ mimemagic (~> 0.3.2)
78
+ media_types (0.6.2)
79
+ method_source (0.9.2)
80
+ mimemagic (0.3.3)
81
+ mini_mime (1.0.1)
82
+ mini_portile2 (2.4.0)
83
+ minitest (5.12.2)
84
+ nio4r (2.3.1)
85
+ nokogiri (1.10.4)
86
+ mini_portile2 (~> 2.4.0)
87
+ nokogiri (1.10.4-x64-mingw32)
88
+ mini_portile2 (~> 2.4.0)
89
+ oj (3.9.2)
90
+ rack (2.0.6)
91
+ rack-test (1.1.0)
92
+ rack (>= 1.0, < 3)
93
+ rails (5.2.2)
94
+ actioncable (= 5.2.2)
95
+ actionmailer (= 5.2.2)
96
+ actionpack (= 5.2.2)
97
+ actionview (= 5.2.2)
98
+ activejob (= 5.2.2)
99
+ activemodel (= 5.2.2)
100
+ activerecord (= 5.2.2)
101
+ activestorage (= 5.2.2)
102
+ activesupport (= 5.2.2)
103
+ bundler (>= 1.3.0)
104
+ railties (= 5.2.2)
105
+ sprockets-rails (>= 2.0.0)
106
+ rails-dom-testing (2.0.3)
107
+ activesupport (>= 4.2.0)
108
+ nokogiri (>= 1.6)
109
+ rails-html-sanitizer (1.0.4)
110
+ loofah (~> 2.2, >= 2.2.2)
111
+ railties (5.2.2)
112
+ actionpack (= 5.2.2)
113
+ activesupport (= 5.2.2)
114
+ method_source
115
+ rake (>= 0.8.7)
116
+ thor (>= 0.19.0, < 2.0)
117
+ rake (10.5.0)
118
+ sprockets (3.7.2)
119
+ concurrent-ruby (~> 1.0)
120
+ rack (> 1, < 3)
121
+ sprockets-rails (3.2.1)
122
+ actionpack (>= 4.0)
123
+ activesupport (>= 4.0)
124
+ sprockets (>= 3.0.0)
125
+ thor (0.20.3)
126
+ thread_safe (0.3.6)
127
+ tzinfo (1.2.5)
128
+ thread_safe (~> 0.1)
129
+ websocket-driver (0.7.0)
130
+ websocket-extensions (>= 0.1.0)
131
+ websocket-extensions (0.1.3)
132
+
133
+ PLATFORMS
134
+ ruby
135
+ x64-mingw32
136
+
137
+ DEPENDENCIES
138
+ awesome_print
139
+ bundler (~> 2.0)
140
+ media_types-serialization!
141
+ minitest (~> 5.0)
142
+ rails (~> 5.2)
143
+ rake (~> 10.0)
144
+
145
+ BUNDLED WITH
146
+ 2.0.1
data/README.md CHANGED
@@ -73,7 +73,7 @@ class Book < ApplicationRecord
73
73
  { href: context.api_book_url(serializable) }
74
74
  end
75
75
 
76
- def extract_links(view:)
76
+ def extract_links
77
77
  {
78
78
  'self': extract_self,
79
79
  'signatures': { href: context.api_book_signatures_url(serializable) }
@@ -14,8 +14,8 @@ require 'media_types/serialization/media_type/register'
14
14
  # to define +_links+ for the root level from your serializer.
15
15
  #
16
16
  #
17
- # MediaTypes::Serialization.collect_links_for_collection = true
18
- # MediaTypes::Serialization.collect_links_for_index = true
17
+ MediaTypes::Serialization.collect_links_for_collection = true
18
+ MediaTypes::Serialization.collect_links_for_index = true
19
19
 
20
20
  ##
21
21
  # The API Viewer template is provided if you used the generator. You can change
@@ -65,7 +65,7 @@ module MediaTypes
65
65
  end
66
66
 
67
67
  def header_links(view: current_view)
68
- extract_links(view: view)
68
+ extract_view_links(view: view)
69
69
  end
70
70
 
71
71
  def set(serializable)
@@ -78,10 +78,21 @@ module MediaTypes
78
78
  attr_accessor :context
79
79
  attr_writer :current_media_type, :current_view, :serializable
80
80
 
81
- def extract_links(view: current_view)
81
+ def extract_links
82
82
  {}
83
83
  end
84
84
 
85
+ def extract_set_links(view: current_view)
86
+ {}
87
+ end
88
+
89
+ def extract_view_links(view: current_view)
90
+ return extract_set_links(view: view) if view == ::MediaTypes::INDEX_VIEW
91
+ return extract_set_links(view: view) if view == ::MediaTypes::COLLECTION_VIEW
92
+
93
+ extract_links
94
+ end
95
+
85
96
  def extract(extractable, *keys)
86
97
  return {} unless keys.present?
87
98
  extractable.slice(*keys)
@@ -1,5 +1,5 @@
1
1
  module MediaTypes
2
2
  module Serialization
3
- VERSION = '0.7.0.beta1'
3
+ VERSION = '0.7.0'
4
4
  end
5
5
  end
@@ -34,7 +34,7 @@ module MediaTypes
34
34
  protected
35
35
 
36
36
  def extract_links(view: current_view)
37
- return __getobj__.send(:extract_links, view: view) if ::MediaTypes::Serialization.collect_links_for_collection
37
+ return __getobj__.send(:extract_set_links, view: view) if ::MediaTypes::Serialization.collect_links_for_collection
38
38
  {}
39
39
  end
40
40
 
@@ -46,7 +46,7 @@ module MediaTypes
46
46
  end
47
47
 
48
48
  def extract_links(view: current_view)
49
- return __getobj__.send(:extract_links, view: view) if ::MediaTypes::Serialization.collect_links_for_index
49
+ return __getobj__.send(:extract_set_links, view: view) if ::MediaTypes::Serialization.collect_links_for_index
50
50
  {}
51
51
  end
52
52
 
@@ -43,7 +43,7 @@ module MediaTypes
43
43
  end
44
44
 
45
45
  def extract_links(view: current_view)
46
- __getobj__.send(:extract_links, view: view)
46
+ __getobj__.send(:extract_set_links, view: view)
47
47
  end
48
48
 
49
49
  def root_key(view: current_view)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: media_types-serialization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0.beta1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derk-Jan Karrenbeld
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-23 00:00:00.000000000 Z
11
+ date: 2019-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -239,9 +239,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
239
239
  version: '0'
240
240
  required_rubygems_version: !ruby/object:Gem::Requirement
241
241
  requirements:
242
- - - ">"
242
+ - - ">="
243
243
  - !ruby/object:Gem::Version
244
- version: 1.3.1
244
+ version: '0'
245
245
  requirements: []
246
246
  rubygems_version: 3.0.3
247
247
  signing_key: