yaks 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +158 -56
  3. data/Rakefile +1 -3
  4. data/ataru_setup.rb +72 -0
  5. data/find_missing_tests.rb +34 -0
  6. data/lib/yaks.rb +8 -10
  7. data/lib/yaks/breaking_changes.rb +4 -6
  8. data/lib/yaks/builder.rb +1 -1
  9. data/lib/yaks/changelog.rb +1 -1
  10. data/lib/yaks/collection_mapper.rb +8 -5
  11. data/lib/yaks/collection_resource.rb +0 -1
  12. data/lib/yaks/config.rb +17 -7
  13. data/lib/yaks/configurable.rb +20 -14
  14. data/lib/yaks/default_policy.rb +82 -33
  15. data/lib/yaks/format.rb +7 -3
  16. data/lib/yaks/format/collection_json.rb +4 -4
  17. data/lib/yaks/format/hal.rb +1 -2
  18. data/lib/yaks/format/halo.rb +2 -4
  19. data/lib/yaks/format/json_api.rb +46 -27
  20. data/lib/yaks/html5_forms.rb +0 -2
  21. data/lib/yaks/mapper.rb +5 -5
  22. data/lib/yaks/mapper/association.rb +7 -7
  23. data/lib/yaks/mapper/association_mapper.rb +2 -0
  24. data/lib/yaks/mapper/attribute.rb +10 -4
  25. data/lib/yaks/mapper/config.rb +2 -2
  26. data/lib/yaks/mapper/form.rb +4 -10
  27. data/lib/yaks/mapper/form/config.rb +16 -17
  28. data/lib/yaks/mapper/form/dynamic_field.rb +1 -1
  29. data/lib/yaks/mapper/form/field.rb +16 -7
  30. data/lib/yaks/mapper/form/field/option.rb +5 -4
  31. data/lib/yaks/mapper/form/fieldset.rb +1 -1
  32. data/lib/yaks/mapper/form/legend.rb +18 -0
  33. data/lib/yaks/mapper/has_many.rb +1 -0
  34. data/lib/yaks/mapper/link.rb +7 -4
  35. data/lib/yaks/null_resource.rb +4 -5
  36. data/lib/yaks/pipeline.rb +2 -2
  37. data/lib/yaks/primitivize.rb +3 -2
  38. data/lib/yaks/reader/hal.rb +12 -13
  39. data/lib/yaks/reader/json_api.rb +50 -33
  40. data/lib/yaks/resource.rb +6 -7
  41. data/lib/yaks/resource/form.rb +2 -12
  42. data/lib/yaks/resource/form/field.rb +4 -3
  43. data/lib/yaks/resource/form/field/option.rb +1 -1
  44. data/lib/yaks/resource/form/fieldset.rb +1 -1
  45. data/lib/yaks/resource/form/legend.rb +18 -0
  46. data/lib/yaks/resource/has_fields.rb +13 -7
  47. data/lib/yaks/resource/link.rb +1 -1
  48. data/lib/yaks/runner.rb +5 -2
  49. data/lib/yaks/serializer.rb +2 -3
  50. data/lib/yaks/util.rb +7 -8
  51. data/lib/yaks/version.rb +1 -1
  52. data/spec/acceptance/acceptance_spec.rb +53 -38
  53. data/spec/acceptance/json_shared_examples.rb +45 -12
  54. data/spec/acceptance/models.rb +1 -1
  55. data/spec/integration/dynamic_form_fields_spec.rb +0 -1
  56. data/spec/integration/fieldset_spec.rb +18 -20
  57. data/spec/integration/map_to_resource_spec.rb +6 -6
  58. data/spec/json/{confucius.collection.json → confucius.collection_json.json} +0 -0
  59. data/spec/json/confucius.json_api.json +43 -27
  60. data/spec/json/list_of_quotes.collection_json.json +43 -0
  61. data/spec/json/list_of_quotes.hal.json +18 -0
  62. data/spec/json/list_of_quotes.json_api.json +25 -0
  63. data/spec/json/youtypeitwepostit.collection_json.json +45 -0
  64. data/spec/spec_helper.rb +4 -3
  65. data/spec/support/classes_for_policy_testing.rb +38 -14
  66. data/spec/support/deep_eql.rb +21 -18
  67. data/spec/support/pet_mapper.rb +2 -0
  68. data/spec/support/shared_contexts.rb +9 -9
  69. data/spec/unit/yaks/builder_spec.rb +41 -18
  70. data/spec/unit/yaks/collection_mapper_spec.rb +22 -19
  71. data/spec/unit/yaks/collection_resource_spec.rb +16 -8
  72. data/spec/unit/yaks/config_spec.rb +215 -19
  73. data/spec/unit/yaks/configurable_spec.rb +66 -7
  74. data/spec/unit/yaks/default_policy/derive_mapper_from_collection_spec.rb +47 -0
  75. data/spec/unit/yaks/default_policy/derive_mapper_from_item_spec.rb +114 -0
  76. data/spec/unit/yaks/default_policy/derive_mapper_from_object_spec.rb +29 -71
  77. data/spec/unit/yaks/default_policy_spec.rb +4 -5
  78. data/spec/unit/yaks/format/collection_json_spec.rb +35 -36
  79. data/spec/unit/yaks/format/hal_spec.rb +3 -3
  80. data/spec/unit/yaks/format/json_api_spec.rb +109 -68
  81. data/spec/unit/yaks/format_spec.rb +34 -0
  82. data/spec/unit/yaks/fp/callable_spec.rb +5 -3
  83. data/spec/unit/yaks/mapper/association_mapper_spec.rb +22 -4
  84. data/spec/unit/yaks/mapper/association_spec.rb +23 -11
  85. data/spec/unit/yaks/mapper/attribute_spec.rb +46 -7
  86. data/spec/unit/yaks/mapper/config_spec.rb +2 -3
  87. data/spec/unit/yaks/mapper/form/config_spec.rb +95 -0
  88. data/spec/unit/yaks/mapper/form/dynamic_field_spec.rb +30 -0
  89. data/spec/unit/yaks/mapper/form/field/option_spec.rb +48 -4
  90. data/spec/unit/yaks/mapper/form/field_spec.rb +43 -2
  91. data/spec/unit/yaks/mapper/form/fieldset_spec.rb +67 -8
  92. data/spec/unit/yaks/mapper/form/legend_spec.rb +52 -0
  93. data/spec/unit/yaks/mapper/form_spec.rb +84 -23
  94. data/spec/unit/yaks/mapper/has_many_spec.rb +39 -36
  95. data/spec/unit/yaks/mapper/has_one_spec.rb +28 -20
  96. data/spec/unit/yaks/mapper/link_spec.rb +68 -16
  97. data/spec/unit/yaks/mapper_spec.rb +118 -30
  98. data/spec/unit/yaks/null_resource_spec.rb +83 -52
  99. data/spec/unit/yaks/pipeline_spec.rb +101 -74
  100. data/spec/unit/yaks/primitivize_spec.rb +25 -6
  101. data/spec/unit/yaks/resource/form/field_spec.rb +5 -5
  102. data/spec/unit/yaks/resource/form/fieldset_spec.rb +7 -0
  103. data/spec/unit/yaks/resource/form/legend_spec.rb +8 -0
  104. data/spec/unit/yaks/resource/form_spec.rb +17 -37
  105. data/spec/unit/yaks/resource/has_fields_spec.rb +44 -3
  106. data/spec/unit/yaks/resource/link_spec.rb +11 -6
  107. data/spec/unit/yaks/resource_spec.rb +87 -98
  108. data/spec/unit/yaks/runner_spec.rb +112 -28
  109. data/spec/unit/yaks/serializer_spec.rb +1 -1
  110. data/spec/unit/yaks/util_spec.rb +30 -10
  111. data/spec/yaml/list_of_quotes.yaml +13 -0
  112. data/yaks.gemspec +21 -13
  113. metadata +129 -41
  114. data/lib/yaks/attributes.rb +0 -86
  115. data/lib/yaks/fp.rb +0 -26
  116. data/lib/yaks/identifier/link_relation.rb +0 -17
  117. data/resources/iana-link-relations.csv +0 -152
  118. data/spec/json/youtypeitwepostit.collection.json +0 -45
  119. data/spec/unit/yaks/attributes_spec.rb +0 -178
  120. data/spec/unit/yaks/fp_spec.rb +0 -29
@@ -8,7 +8,15 @@ RSpec.describe Yaks::Runner do
8
8
  let(:options) { {} }
9
9
 
10
10
  shared_examples 'high-level runner test' do
11
- let(:options) { {env: {foo: "from_env"}} }
11
+ let(:object) { 7 }
12
+
13
+ let(:options) {
14
+ {
15
+ env: {foo: "from_env"},
16
+ hooks: [[:after, :step2, :upcase, ->(x, _env) { x.upcase }]]
17
+ }
18
+ }
19
+
12
20
  let(:runner) {
13
21
  Class.new(described_class) do
14
22
  def steps
@@ -18,10 +26,8 @@ RSpec.describe Yaks::Runner do
18
26
  end.new(object: object, config: config, options: options)
19
27
  }
20
28
 
21
- let(:object) { 7 }
22
-
23
29
  it 'should go through all the steps' do
24
- expect(runner.call).to eql "from_env[42 42]"
30
+ expect(runner.call).to eql "FROM_ENV[42 42]"
25
31
  end
26
32
  end
27
33
 
@@ -33,13 +39,84 @@ RSpec.describe Yaks::Runner do
33
39
  include_examples 'high-level runner test'
34
40
  end
35
41
 
42
+ describe '#format' do
43
+ let(:object) {
44
+ Yaks::Resource.new(attributes: {ronny: :jonny})
45
+ }
46
+
47
+ let(:options) {
48
+ {
49
+ env: {
50
+ 'api.key_prefix' => 'pre_'
51
+ },
52
+ hooks: [
53
+ [:before,
54
+ :format,
55
+ :add_kristel,
56
+ ->(resource, _env) {
57
+ resource.merge_attributes(kristel: :christa)
58
+ },
59
+ ],
60
+ [:after,
61
+ :primitivize,
62
+ :add_prefix,
63
+ ->(hsh, env) {
64
+ hsh.each_with_object({}) do |(k, v), h|
65
+ h[env['api.key_prefix'] + k] = v
66
+ end
67
+ }
68
+ ]
69
+ ]
70
+ }
71
+ }
72
+
73
+ it 'should run the formatter and primitivizer plus hooks' do
74
+ expect(runner.format).to eql("pre_kristel" => "christa", "pre_ronny" => "jonny")
75
+ end
76
+ end
77
+
78
+ describe '#read' do
79
+ let(:object) {
80
+ '{"pre_ronny": "jonny"}'
81
+ }
82
+
83
+ let(:options) {
84
+ {
85
+ env: {
86
+ 'api.key_prefix' => 'pre_'
87
+ },
88
+ hooks: [
89
+ [:after,
90
+ :read,
91
+ :add_kristel,
92
+ ->(resource, _env) {
93
+ resource.merge_attributes(kristel: 'christa')
94
+ },
95
+ ],
96
+ [:before,
97
+ :parse,
98
+ :strip_prefix,
99
+ ->(json, env) {
100
+ json.gsub(env['api.key_prefix'], '')
101
+ }
102
+ ]
103
+ ]
104
+ }
105
+ }
106
+
107
+ it 'should run the parser and reader plus hooks' do
108
+ expect(runner.read)
109
+ .to eql Yaks::Resource.new(attributes: {ronny: "jonny", kristel: "christa"})
110
+ end
111
+ end
112
+
36
113
  describe '#context' do
37
114
  it 'should contain the policy, env, and an empty mapper_stack' do
38
115
  expect(runner.context).to eql(policy: config.policy, env: {}, mapper_stack: [])
39
116
  end
40
117
 
41
118
  context 'with an item mapper' do
42
- let(:options) { { item_mapper: :foo } }
119
+ let(:options) { {item_mapper: :foo} }
43
120
 
44
121
  it 'should contain the item_mapper' do
45
122
  expect(runner.context).to eql(policy: config.policy, env: {}, mapper_stack: [], item_mapper: :foo)
@@ -55,35 +132,35 @@ RSpec.describe Yaks::Runner do
55
132
  end
56
133
 
57
134
  let(:rack_env) {
58
- { 'HTTP_ACCEPT' => 'application/hal+json;q=0.8, application/vnd.api+json' }
135
+ {'HTTP_ACCEPT' => 'application/hal+json;q=0.8, application/vnd.api+json'}
59
136
  }
60
137
 
61
138
  it 'should fall back to the default when no HTTP_ACCEPT key is present' do
62
- runner = described_class.new(object: nil, config: config, options: { env: {} })
139
+ runner = described_class.new(object: nil, config: config, options: {env: {}})
63
140
  expect(runner.format_class).to equal Yaks::Format::CollectionJson
64
141
  end
65
142
 
66
143
  it 'should detect format based on accept header' do
67
- rack_env = { 'HTTP_ACCEPT' => 'application/hal+json;q=0.8, application/vnd.api+json' }
68
- runner = described_class.new(object: nil, config: config, options: { env: rack_env })
144
+ rack_env = {'HTTP_ACCEPT' => 'application/hal+json;q=0.8, application/vnd.api+json'}
145
+ runner = described_class.new(object: nil, config: config, options: {env: rack_env})
69
146
  expect(runner.format_class).to equal Yaks::Format::JsonAPI
70
147
  end
71
148
 
72
149
  it 'should know to pick the best match' do
73
- rack_env = { 'HTTP_ACCEPT' => 'application/hal+json;q=0.8, application/vnd.api+json;q=0.7' }
74
- runner = described_class.new(object: nil, config: config, options: { env: rack_env })
150
+ rack_env = {'HTTP_ACCEPT' => 'application/hal+json;q=0.8, application/vnd.api+json;q=0.7'}
151
+ runner = described_class.new(object: nil, config: config, options: {env: rack_env})
75
152
  expect(runner.format_class).to equal Yaks::Format::Hal
76
153
  end
77
154
 
78
155
  it 'should pick the one given in the options if no header matches' do
79
- rack_env = { 'HTTP_ACCEPT' => 'text/xml, application/json' }
80
- runner = described_class.new(object: nil, config: config, options: { format: :hal, env: rack_env })
156
+ rack_env = {'HTTP_ACCEPT' => 'text/xml, application/json'}
157
+ runner = described_class.new(object: nil, config: config, options: {format: :hal, env: rack_env})
81
158
  expect(runner.format_class).to equal Yaks::Format::Hal
82
159
  end
83
160
 
84
161
  it 'should fall back to the default when no mime type is recognized' do
85
- rack_env = { 'HTTP_ACCEPT' => 'text/xml, application/json' }
86
- runner = described_class.new(object: nil, config: config, options: { env: rack_env })
162
+ rack_env = {'HTTP_ACCEPT' => 'text/xml, application/json'}
163
+ runner = described_class.new(object: nil, config: config, options: {env: rack_env})
87
164
  expect(runner.format_class).to equal Yaks::Format::CollectionJson
88
165
  end
89
166
  end
@@ -99,7 +176,7 @@ RSpec.describe Yaks::Runner do
99
176
  let(:config) { Yaks.new { default_format :collection_json } }
100
177
 
101
178
  context 'with a format in the options' do
102
- let(:options) { { format: :json_api } }
179
+ let(:options) { {format: :json_api} }
103
180
  it 'should give preference to that one' do
104
181
  expect(runner.format_name).to eql :json_api
105
182
  end
@@ -117,7 +194,7 @@ RSpec.describe Yaks::Runner do
117
194
  let(:config) {
118
195
  Yaks.new do
119
196
  default_format :json_api
120
- format_options :json_api, {format_option: [:foo]}
197
+ format_options :json_api, format_option: [:foo]
121
198
  end
122
199
  }
123
200
 
@@ -135,7 +212,7 @@ RSpec.describe Yaks::Runner do
135
212
 
136
213
  describe '#env' do
137
214
  describe 'when env is set in the options' do
138
- let(:options) { { env: 123 } }
215
+ let(:options) { {env: 123} }
139
216
 
140
217
  it 'returns the env passed in' do
141
218
  expect(runner.env).to be 123
@@ -152,7 +229,7 @@ RSpec.describe Yaks::Runner do
152
229
  describe '#mapper' do
153
230
  context 'with an explicit mapper in the options' do
154
231
  let(:mapper_class) { Class.new(Yaks::Mapper) }
155
- let(:options) { { mapper: mapper_class } }
232
+ let(:options) { {mapper: mapper_class} }
156
233
 
157
234
  it 'should take the mapper from options' do
158
235
  expect(runner.mapper).to be_a mapper_class
@@ -188,12 +265,12 @@ RSpec.describe Yaks::Runner do
188
265
  end
189
266
 
190
267
  it 'should fall back to the policy' do
191
- expect(runner.serializer.call([1,2,3], {})).to eql "[\n 1,\n 2,\n 3\n]"
268
+ expect(runner.serializer.call([1, 2, 3], {})).to eql "[\n 1,\n 2,\n 3\n]"
192
269
  end
193
270
  end
194
271
 
195
272
  describe '#steps' do
196
- let(:options) {{ mapper: Yaks::Mapper }}
273
+ let(:options) {{mapper: Yaks::Mapper}}
197
274
 
198
275
  it 'should have all four steps' do
199
276
  expect(runner.steps).to eql [
@@ -235,7 +312,7 @@ RSpec.describe Yaks::Runner do
235
312
  end
236
313
 
237
314
  context 'with extra blocks in the options' do
238
- let(:options) { { hooks: [[:foo]] } }
315
+ let(:options) { {hooks: [[:foo]]} }
239
316
 
240
317
  it 'should combine the hooks' do
241
318
  expect(runner.hooks).to eql [[:after, :map, :this_happens_after_map, nil], [:foo]]
@@ -247,11 +324,19 @@ RSpec.describe Yaks::Runner do
247
324
  let(:mapper_class) do
248
325
  Struct.new(:options) do
249
326
  include Yaks::FP::Callable
250
- def call(obj, env) "mapped[#{obj}]" end
327
+ def call(obj, _env)
328
+ "mapped[#{obj}]"
329
+ end
251
330
  end
252
331
  end
253
332
 
254
- let(:options) { { mapper: mapper_class } }
333
+ let(:options) {
334
+ {
335
+ mapper: mapper_class,
336
+ env: {'api.prefix' => 'pre_'}
337
+ }
338
+ }
339
+
255
340
  let(:object) { "foo" }
256
341
 
257
342
  it 'should only run the mapper' do
@@ -262,15 +347,14 @@ RSpec.describe Yaks::Runner do
262
347
  let(:config) do
263
348
  Yaks.new do
264
349
  around(:map) do |res, env, &block|
265
- "around[#{block.call(res, env)}]"
350
+ "#{env['api.prefix']}around[#{block.call(res, env)}]"
266
351
  end
267
352
  end
268
353
  end
269
354
 
270
- it 'should invoke the hook as well' do
271
- expect(runner.map).to eql "around[mapped[foo]]"
355
+ it 'should invoke the hook and pass in the env' do
356
+ expect(runner.map).to eql "pre_around[mapped[foo]]"
272
357
  end
273
358
  end
274
359
  end
275
-
276
360
  end
@@ -9,7 +9,7 @@ RSpec.describe Yaks::Serializer do
9
9
  end
10
10
 
11
11
  it 'should by default have a serializer for JSON' do
12
- expect(Yaks::Serializer.all[:json].call([1,2,3], {})).to eql "[\n 1,\n 2,\n 3\n]"
12
+ expect(Yaks::Serializer.all[:json].call([1, 2, 3], {})).to eql "[\n 1,\n 2,\n 3\n]"
13
13
  end
14
14
 
15
15
  it 'should warn when registering a key again' do
@@ -48,15 +48,32 @@ RSpec.describe Yaks::Util do
48
48
  end
49
49
 
50
50
  describe '#slice_hash' do
51
- it '#should retain the given keys from a hash' do
52
- expect(slice_hash({a: 1, b:2, c:3}, :a, :c, :d)).to eql(a: 1, c:3)
51
+ it 'should retain the given keys from a hash' do
52
+ expect(slice_hash({a: 1, b: 2, c: 3}, :a, :c, :d)).to eql(a: 1, c: 3)
53
+ end
54
+ end
55
+
56
+ describe '#reject_keys' do
57
+ it 'should reject specific keys from a hash' do
58
+ expect(reject_keys({foo: 1, bar: 2}, :foo)).to eql(bar: 2)
59
+ end
60
+ end
61
+
62
+ describe "#symbolize_keys" do
63
+ it "should turn string keys into symbols" do
64
+ expect(symbolize_keys('foo' => 1, 'bar' => 2)).to eql(foo: 1, bar: 2)
53
65
  end
54
66
  end
55
67
 
56
68
  describe '#extract_options' do
57
- it 'should extract a final hash' do
58
- args, opts = extract_options([:a, :b, {hello: :world}])
59
- expect([args, opts]).to eql [[:a, :b], {hello: :world}]
69
+ it 'should extract a final hash - one arg given' do
70
+ args, opts = extract_options([:a, {hello: :world}])
71
+ expect([args, opts]).to eql [[:a], {hello: :world}]
72
+ end
73
+
74
+ it 'should extract a final hash - multi arg given' do
75
+ args, opts = extract_options([:a, :b, :c, {hello: :world}])
76
+ expect([args, opts]).to eql [[:a, :b, :c], {hello: :world}]
60
77
  end
61
78
 
62
79
  it 'should provide an empty hash if none was given' do
@@ -64,16 +81,19 @@ RSpec.describe Yaks::Util do
64
81
  expect([args, opts]).to eql [[:a, :b], {}]
65
82
  end
66
83
  end
67
-
68
84
  end
69
85
 
70
- RSpec.describe Yaks::Util::Deprecated do
86
+ RSpec.describe Yaks::Util::Deprecated, '#deprecated_alias' do
71
87
  let(:klass) {
72
88
  Class.new do
73
89
  extend Yaks::Util::Deprecated
74
90
 
75
- def self.to_s ; 'FancyClass' end
76
- def foo(x); "#{x}yz#{yield}" end
91
+ def self.to_s
92
+ 'FancyClass'
93
+ end
94
+ def foo(x)
95
+ "#{x}yz#{yield}"
96
+ end
77
97
  deprecated_alias :bar, :foo
78
98
  end
79
99
  }
@@ -96,6 +116,6 @@ RSpec.describe Yaks::Util::Deprecated do
96
116
  capture_stderr do
97
117
  expect(klass.new.bar('x') {'a'}).to eql 'xyza'
98
118
  end
99
- ).to match /WARNING: FancyClass#bar is deprecated, use `foo'\. at \/.*util_spec.rb:#{__LINE__ - 2}:in/
119
+ ).to match %r{WARNING: FancyClass#bar is deprecated, use `foo'\. at /.*util_spec.rb:#{__LINE__ - 2}:in}
100
120
  end
101
121
  end
@@ -0,0 +1,13 @@
1
+ - !ruby/object:Quote
2
+ id: 17
3
+ chinese: "廄焚。子退朝,曰:“傷人乎?” 不問馬。"
4
+ english: "When the stables were burnt down, on returning from court Confucius said, “Was anyone hurt?” He did not ask about the horses."
5
+ sources: "Analects X.11 (tr. Waley), 10–13 (tr. Legge), or X-17 (tr. Lau)"
6
+ - !ruby/object:Quote
7
+ id: 18
8
+ chinese: "子曰:“其恕乎!己所不欲、勿施於人。”"
9
+ english: "The Master replied: “How about 'reciprocity'! Never impose on others what you would not choose for yourself.”"
10
+ sources: "Analects XV.24, tr. David Hinton"
11
+ - !ruby/object:Quote
12
+ id: 99
13
+ english: "How do you know they are happy? You are not a fish."
data/yaks.gemspec CHANGED
@@ -1,5 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'English'
3
4
  require File.expand_path('../lib/yaks/version', __FILE__)
4
5
  require File.expand_path('../lib/yaks/breaking_changes', __FILE__)
5
6
 
@@ -14,7 +15,7 @@ Gem::Specification.new do |gem|
14
15
  gem.license = 'MIT'
15
16
 
16
17
  gem.require_paths = %w[lib]
17
- gem.files = `git ls-files`.split($/)
18
+ gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
18
19
  gem.test_files = gem.files.grep(/^spec/)
19
20
  gem.extra_rdoc_files = %w[README.md]
20
21
 
@@ -22,21 +23,28 @@ Gem::Specification.new do |gem|
22
23
  gem.post_install_message = Yaks::BreakingChanges[Yaks::VERSION]
23
24
  end
24
25
 
25
- gem.add_runtime_dependency 'inflection' , '~> 1.0'
26
- gem.add_runtime_dependency 'concord' , '~> 0.1.4'
27
- gem.add_runtime_dependency 'uri_template' , '~> 0.6.0'
28
- gem.add_runtime_dependency 'rack-accept' , '~> 0.4.5'
29
- gem.add_runtime_dependency 'anima' , '~> 0.2.0'
30
- gem.add_runtime_dependency 'adamantium' , '~> 0.2.0'
26
+ gem.required_ruby_version = '>= 1.9.3'
31
27
 
32
- gem.add_development_dependency 'virtus'
33
- gem.add_development_dependency 'rspec', '~> 3.0'
28
+ gem.add_runtime_dependency 'abstract_type', '~> 0.0.7'
29
+ gem.add_runtime_dependency 'adamantium', '~> 0.2.0'
30
+ gem.add_runtime_dependency 'anima', '~> 0.2.0'
31
+ gem.add_runtime_dependency 'attribs', '~> 1.0'
32
+ gem.add_runtime_dependency 'concord', '~> 0.1.4'
33
+ gem.add_runtime_dependency 'inflection', '~> 1.0'
34
+ gem.add_runtime_dependency 'rack-accept', '~> 0.4.5'
35
+ gem.add_runtime_dependency 'uri_template', '~> 0.6.0'
36
+
37
+ gem.add_development_dependency 'ataru'
38
+ gem.add_development_dependency 'benchmark-ips'
34
39
  gem.add_development_dependency 'bogus'
40
+ gem.add_development_dependency 'hamster'
41
+ gem.add_development_dependency 'mutant'
42
+ gem.add_development_dependency 'mutant-rspec'
35
43
  gem.add_development_dependency 'rake'
36
- gem.add_development_dependency 'yard'
37
- gem.add_development_dependency 'mutant-rspec' if RUBY_VERSION > '1.9'
38
- gem.add_development_dependency 'mutant' if RUBY_VERSION > '1.9'
44
+ gem.add_development_dependency 'rubocop'
45
+ gem.add_development_dependency 'rspec', '~> 3.0'
39
46
  gem.add_development_dependency 'rspec-its'
40
- gem.add_development_dependency 'benchmark-ips'
47
+ gem.add_development_dependency 'virtus'
41
48
  gem.add_development_dependency 'yaks-html'
49
+ gem.add_development_dependency 'yard'
42
50
  end
metadata CHANGED
@@ -1,17 +1,59 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arne Brasseur
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-17 00:00:00.000000000 Z
11
+ date: 2015-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: inflection
14
+ name: abstract_type
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.7
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.7
27
+ - !ruby/object:Gem::Dependency
28
+ name: adamantium
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.2.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.2.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: anima
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.2.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.2.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: attribs
15
57
  requirement: !ruby/object:Gem::Requirement
16
58
  requirements:
17
59
  - - "~>"
@@ -39,19 +81,19 @@ dependencies:
39
81
  - !ruby/object:Gem::Version
40
82
  version: 0.1.4
41
83
  - !ruby/object:Gem::Dependency
42
- name: uri_template
84
+ name: inflection
43
85
  requirement: !ruby/object:Gem::Requirement
44
86
  requirements:
45
87
  - - "~>"
46
88
  - !ruby/object:Gem::Version
47
- version: 0.6.0
89
+ version: '1.0'
48
90
  type: :runtime
49
91
  prerelease: false
50
92
  version_requirements: !ruby/object:Gem::Requirement
51
93
  requirements:
52
94
  - - "~>"
53
95
  - !ruby/object:Gem::Version
54
- version: 0.6.0
96
+ version: '1.0'
55
97
  - !ruby/object:Gem::Dependency
56
98
  name: rack-accept
57
99
  requirement: !ruby/object:Gem::Requirement
@@ -67,35 +109,35 @@ dependencies:
67
109
  - !ruby/object:Gem::Version
68
110
  version: 0.4.5
69
111
  - !ruby/object:Gem::Dependency
70
- name: anima
112
+ name: uri_template
71
113
  requirement: !ruby/object:Gem::Requirement
72
114
  requirements:
73
115
  - - "~>"
74
116
  - !ruby/object:Gem::Version
75
- version: 0.2.0
117
+ version: 0.6.0
76
118
  type: :runtime
77
119
  prerelease: false
78
120
  version_requirements: !ruby/object:Gem::Requirement
79
121
  requirements:
80
122
  - - "~>"
81
123
  - !ruby/object:Gem::Version
82
- version: 0.2.0
124
+ version: 0.6.0
83
125
  - !ruby/object:Gem::Dependency
84
- name: adamantium
126
+ name: ataru
85
127
  requirement: !ruby/object:Gem::Requirement
86
128
  requirements:
87
- - - "~>"
129
+ - - ">="
88
130
  - !ruby/object:Gem::Version
89
- version: 0.2.0
90
- type: :runtime
131
+ version: '0'
132
+ type: :development
91
133
  prerelease: false
92
134
  version_requirements: !ruby/object:Gem::Requirement
93
135
  requirements:
94
- - - "~>"
136
+ - - ">="
95
137
  - !ruby/object:Gem::Version
96
- version: 0.2.0
138
+ version: '0'
97
139
  - !ruby/object:Gem::Dependency
98
- name: virtus
140
+ name: benchmark-ips
99
141
  requirement: !ruby/object:Gem::Requirement
100
142
  requirements:
101
143
  - - ">="
@@ -109,21 +151,21 @@ dependencies:
109
151
  - !ruby/object:Gem::Version
110
152
  version: '0'
111
153
  - !ruby/object:Gem::Dependency
112
- name: rspec
154
+ name: bogus
113
155
  requirement: !ruby/object:Gem::Requirement
114
156
  requirements:
115
- - - "~>"
157
+ - - ">="
116
158
  - !ruby/object:Gem::Version
117
- version: '3.0'
159
+ version: '0'
118
160
  type: :development
119
161
  prerelease: false
120
162
  version_requirements: !ruby/object:Gem::Requirement
121
163
  requirements:
122
- - - "~>"
164
+ - - ">="
123
165
  - !ruby/object:Gem::Version
124
- version: '3.0'
166
+ version: '0'
125
167
  - !ruby/object:Gem::Dependency
126
- name: bogus
168
+ name: hamster
127
169
  requirement: !ruby/object:Gem::Requirement
128
170
  requirements:
129
171
  - - ">="
@@ -137,7 +179,7 @@ dependencies:
137
179
  - !ruby/object:Gem::Version
138
180
  version: '0'
139
181
  - !ruby/object:Gem::Dependency
140
- name: rake
182
+ name: mutant
141
183
  requirement: !ruby/object:Gem::Requirement
142
184
  requirements:
143
185
  - - ">="
@@ -151,7 +193,7 @@ dependencies:
151
193
  - !ruby/object:Gem::Version
152
194
  version: '0'
153
195
  - !ruby/object:Gem::Dependency
154
- name: yard
196
+ name: mutant-rspec
155
197
  requirement: !ruby/object:Gem::Requirement
156
198
  requirements:
157
199
  - - ">="
@@ -165,7 +207,7 @@ dependencies:
165
207
  - !ruby/object:Gem::Version
166
208
  version: '0'
167
209
  - !ruby/object:Gem::Dependency
168
- name: mutant-rspec
210
+ name: rake
169
211
  requirement: !ruby/object:Gem::Requirement
170
212
  requirements:
171
213
  - - ">="
@@ -179,7 +221,7 @@ dependencies:
179
221
  - !ruby/object:Gem::Version
180
222
  version: '0'
181
223
  - !ruby/object:Gem::Dependency
182
- name: mutant
224
+ name: rubocop
183
225
  requirement: !ruby/object:Gem::Requirement
184
226
  requirements:
185
227
  - - ">="
@@ -192,6 +234,20 @@ dependencies:
192
234
  - - ">="
193
235
  - !ruby/object:Gem::Version
194
236
  version: '0'
237
+ - !ruby/object:Gem::Dependency
238
+ name: rspec
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: '3.0'
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: '3.0'
195
251
  - !ruby/object:Gem::Dependency
196
252
  name: rspec-its
197
253
  requirement: !ruby/object:Gem::Requirement
@@ -207,7 +263,7 @@ dependencies:
207
263
  - !ruby/object:Gem::Version
208
264
  version: '0'
209
265
  - !ruby/object:Gem::Dependency
210
- name: benchmark-ips
266
+ name: virtus
211
267
  requirement: !ruby/object:Gem::Requirement
212
268
  requirements:
213
269
  - - ">="
@@ -234,6 +290,20 @@ dependencies:
234
290
  - - ">="
235
291
  - !ruby/object:Gem::Version
236
292
  version: '0'
293
+ - !ruby/object:Gem::Dependency
294
+ name: yard
295
+ requirement: !ruby/object:Gem::Requirement
296
+ requirements:
297
+ - - ">="
298
+ - !ruby/object:Gem::Version
299
+ version: '0'
300
+ type: :development
301
+ prerelease: false
302
+ version_requirements: !ruby/object:Gem::Requirement
303
+ requirements:
304
+ - - ">="
305
+ - !ruby/object:Gem::Version
306
+ version: '0'
237
307
  description: Serialize to hypermedia. HAL, JSON-API, etc.
238
308
  email:
239
309
  - arne@arnebrasseur.net
@@ -245,8 +315,9 @@ files:
245
315
  - ".rspec"
246
316
  - README.md
247
317
  - Rakefile
318
+ - ataru_setup.rb
319
+ - find_missing_tests.rb
248
320
  - lib/yaks.rb
249
- - lib/yaks/attributes.rb
250
321
  - lib/yaks/breaking_changes.rb
251
322
  - lib/yaks/builder.rb
252
323
  - lib/yaks/changelog.rb
@@ -261,10 +332,8 @@ files:
261
332
  - lib/yaks/format/hal.rb
262
333
  - lib/yaks/format/halo.rb
263
334
  - lib/yaks/format/json_api.rb
264
- - lib/yaks/fp.rb
265
335
  - lib/yaks/fp/callable.rb
266
336
  - lib/yaks/html5_forms.rb
267
- - lib/yaks/identifier/link_relation.rb
268
337
  - lib/yaks/mapper.rb
269
338
  - lib/yaks/mapper/association.rb
270
339
  - lib/yaks/mapper/association_mapper.rb
@@ -276,6 +345,7 @@ files:
276
345
  - lib/yaks/mapper/form/field.rb
277
346
  - lib/yaks/mapper/form/field/option.rb
278
347
  - lib/yaks/mapper/form/fieldset.rb
348
+ - lib/yaks/mapper/form/legend.rb
279
349
  - lib/yaks/mapper/has_many.rb
280
350
  - lib/yaks/mapper/has_one.rb
281
351
  - lib/yaks/mapper/link.rb
@@ -289,13 +359,13 @@ files:
289
359
  - lib/yaks/resource/form/field.rb
290
360
  - lib/yaks/resource/form/field/option.rb
291
361
  - lib/yaks/resource/form/fieldset.rb
362
+ - lib/yaks/resource/form/legend.rb
292
363
  - lib/yaks/resource/has_fields.rb
293
364
  - lib/yaks/resource/link.rb
294
365
  - lib/yaks/runner.rb
295
366
  - lib/yaks/serializer.rb
296
367
  - lib/yaks/util.rb
297
368
  - lib/yaks/version.rb
298
- - resources/iana-link-relations.csv
299
369
  - spec/acceptance/acceptance_spec.rb
300
370
  - spec/acceptance/json_shared_examples.rb
301
371
  - spec/acceptance/models.rb
@@ -303,14 +373,17 @@ files:
303
373
  - spec/integration/dynamic_form_fields_spec.rb
304
374
  - spec/integration/fieldset_spec.rb
305
375
  - spec/integration/map_to_resource_spec.rb
306
- - spec/json/confucius.collection.json
376
+ - spec/json/confucius.collection_json.json
307
377
  - spec/json/confucius.hal.json
308
378
  - spec/json/confucius.halo.json
309
379
  - spec/json/confucius.json_api.json
310
380
  - spec/json/john.hal.json
381
+ - spec/json/list_of_quotes.collection_json.json
382
+ - spec/json/list_of_quotes.hal.json
383
+ - spec/json/list_of_quotes.json_api.json
311
384
  - spec/json/plant_collection.collection.json
312
385
  - spec/json/plant_collection.hal.json
313
- - spec/json/youtypeitwepostit.collection.json
386
+ - spec/json/youtypeitwepostit.collection_json.json
314
387
  - spec/sanity_spec.rb
315
388
  - spec/spec_helper.rb
316
389
  - spec/support/classes_for_policy_testing.rb
@@ -322,12 +395,13 @@ files:
322
395
  - spec/support/pet_peeve_mapper.rb
323
396
  - spec/support/shared_contexts.rb
324
397
  - spec/support/youtypeit_models_mappers.rb
325
- - spec/unit/yaks/attributes_spec.rb
326
398
  - spec/unit/yaks/builder_spec.rb
327
399
  - spec/unit/yaks/collection_mapper_spec.rb
328
400
  - spec/unit/yaks/collection_resource_spec.rb
329
401
  - spec/unit/yaks/config_spec.rb
330
402
  - spec/unit/yaks/configurable_spec.rb
403
+ - spec/unit/yaks/default_policy/derive_mapper_from_collection_spec.rb
404
+ - spec/unit/yaks/default_policy/derive_mapper_from_item_spec.rb
331
405
  - spec/unit/yaks/default_policy/derive_mapper_from_object_spec.rb
332
406
  - spec/unit/yaks/default_policy_spec.rb
333
407
  - spec/unit/yaks/format/collection_json_spec.rb
@@ -337,14 +411,16 @@ files:
337
411
  - spec/unit/yaks/format/json_api_spec.rb
338
412
  - spec/unit/yaks/format_spec.rb
339
413
  - spec/unit/yaks/fp/callable_spec.rb
340
- - spec/unit/yaks/fp_spec.rb
341
414
  - spec/unit/yaks/mapper/association_mapper_spec.rb
342
415
  - spec/unit/yaks/mapper/association_spec.rb
343
416
  - spec/unit/yaks/mapper/attribute_spec.rb
344
417
  - spec/unit/yaks/mapper/config_spec.rb
418
+ - spec/unit/yaks/mapper/form/config_spec.rb
419
+ - spec/unit/yaks/mapper/form/dynamic_field_spec.rb
345
420
  - spec/unit/yaks/mapper/form/field/option_spec.rb
346
421
  - spec/unit/yaks/mapper/form/field_spec.rb
347
422
  - spec/unit/yaks/mapper/form/fieldset_spec.rb
423
+ - spec/unit/yaks/mapper/form/legend_spec.rb
348
424
  - spec/unit/yaks/mapper/form_spec.rb
349
425
  - spec/unit/yaks/mapper/has_many_spec.rb
350
426
  - spec/unit/yaks/mapper/has_one_spec.rb
@@ -354,6 +430,8 @@ files:
354
430
  - spec/unit/yaks/pipeline_spec.rb
355
431
  - spec/unit/yaks/primitivize_spec.rb
356
432
  - spec/unit/yaks/resource/form/field_spec.rb
433
+ - spec/unit/yaks/resource/form/fieldset_spec.rb
434
+ - spec/unit/yaks/resource/form/legend_spec.rb
357
435
  - spec/unit/yaks/resource/form_spec.rb
358
436
  - spec/unit/yaks/resource/has_fields_spec.rb
359
437
  - spec/unit/yaks/resource/link_spec.rb
@@ -362,6 +440,7 @@ files:
362
440
  - spec/unit/yaks/serializer_spec.rb
363
441
  - spec/unit/yaks/util_spec.rb
364
442
  - spec/yaml/confucius.yaml
443
+ - spec/yaml/list_of_quotes.yaml
365
444
  - spec/yaml/youtypeitwepostit.yaml
366
445
  - yaks.gemspec
367
446
  homepage: https://github.com/plexus/yaks
@@ -376,7 +455,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
376
455
  requirements:
377
456
  - - ">="
378
457
  - !ruby/object:Gem::Version
379
- version: '0'
458
+ version: 1.9.3
380
459
  required_rubygems_version: !ruby/object:Gem::Requirement
381
460
  requirements:
382
461
  - - ">="
@@ -384,7 +463,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
384
463
  version: '0'
385
464
  requirements: []
386
465
  rubyforge_project:
387
- rubygems_version: 2.2.2
466
+ rubygems_version: 2.4.5
388
467
  signing_key:
389
468
  specification_version: 4
390
469
  summary: Serialize to hypermedia. HAL, JSON-API, etc.
@@ -396,14 +475,17 @@ test_files:
396
475
  - spec/integration/dynamic_form_fields_spec.rb
397
476
  - spec/integration/fieldset_spec.rb
398
477
  - spec/integration/map_to_resource_spec.rb
399
- - spec/json/confucius.collection.json
478
+ - spec/json/confucius.collection_json.json
400
479
  - spec/json/confucius.hal.json
401
480
  - spec/json/confucius.halo.json
402
481
  - spec/json/confucius.json_api.json
403
482
  - spec/json/john.hal.json
483
+ - spec/json/list_of_quotes.collection_json.json
484
+ - spec/json/list_of_quotes.hal.json
485
+ - spec/json/list_of_quotes.json_api.json
404
486
  - spec/json/plant_collection.collection.json
405
487
  - spec/json/plant_collection.hal.json
406
- - spec/json/youtypeitwepostit.collection.json
488
+ - spec/json/youtypeitwepostit.collection_json.json
407
489
  - spec/sanity_spec.rb
408
490
  - spec/spec_helper.rb
409
491
  - spec/support/classes_for_policy_testing.rb
@@ -415,12 +497,13 @@ test_files:
415
497
  - spec/support/pet_peeve_mapper.rb
416
498
  - spec/support/shared_contexts.rb
417
499
  - spec/support/youtypeit_models_mappers.rb
418
- - spec/unit/yaks/attributes_spec.rb
419
500
  - spec/unit/yaks/builder_spec.rb
420
501
  - spec/unit/yaks/collection_mapper_spec.rb
421
502
  - spec/unit/yaks/collection_resource_spec.rb
422
503
  - spec/unit/yaks/config_spec.rb
423
504
  - spec/unit/yaks/configurable_spec.rb
505
+ - spec/unit/yaks/default_policy/derive_mapper_from_collection_spec.rb
506
+ - spec/unit/yaks/default_policy/derive_mapper_from_item_spec.rb
424
507
  - spec/unit/yaks/default_policy/derive_mapper_from_object_spec.rb
425
508
  - spec/unit/yaks/default_policy_spec.rb
426
509
  - spec/unit/yaks/format/collection_json_spec.rb
@@ -430,14 +513,16 @@ test_files:
430
513
  - spec/unit/yaks/format/json_api_spec.rb
431
514
  - spec/unit/yaks/format_spec.rb
432
515
  - spec/unit/yaks/fp/callable_spec.rb
433
- - spec/unit/yaks/fp_spec.rb
434
516
  - spec/unit/yaks/mapper/association_mapper_spec.rb
435
517
  - spec/unit/yaks/mapper/association_spec.rb
436
518
  - spec/unit/yaks/mapper/attribute_spec.rb
437
519
  - spec/unit/yaks/mapper/config_spec.rb
520
+ - spec/unit/yaks/mapper/form/config_spec.rb
521
+ - spec/unit/yaks/mapper/form/dynamic_field_spec.rb
438
522
  - spec/unit/yaks/mapper/form/field/option_spec.rb
439
523
  - spec/unit/yaks/mapper/form/field_spec.rb
440
524
  - spec/unit/yaks/mapper/form/fieldset_spec.rb
525
+ - spec/unit/yaks/mapper/form/legend_spec.rb
441
526
  - spec/unit/yaks/mapper/form_spec.rb
442
527
  - spec/unit/yaks/mapper/has_many_spec.rb
443
528
  - spec/unit/yaks/mapper/has_one_spec.rb
@@ -447,6 +532,8 @@ test_files:
447
532
  - spec/unit/yaks/pipeline_spec.rb
448
533
  - spec/unit/yaks/primitivize_spec.rb
449
534
  - spec/unit/yaks/resource/form/field_spec.rb
535
+ - spec/unit/yaks/resource/form/fieldset_spec.rb
536
+ - spec/unit/yaks/resource/form/legend_spec.rb
450
537
  - spec/unit/yaks/resource/form_spec.rb
451
538
  - spec/unit/yaks/resource/has_fields_spec.rb
452
539
  - spec/unit/yaks/resource/link_spec.rb
@@ -455,4 +542,5 @@ test_files:
455
542
  - spec/unit/yaks/serializer_spec.rb
456
543
  - spec/unit/yaks/util_spec.rb
457
544
  - spec/yaml/confucius.yaml
545
+ - spec/yaml/list_of_quotes.yaml
458
546
  - spec/yaml/youtypeitwepostit.yaml