yaks 0.7.7 → 0.8.0.alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/Rakefile +1 -1
- data/lib/yaks/attributes.rb +17 -11
- data/lib/yaks/builder.rb +43 -0
- data/lib/yaks/changelog.rb +2 -2
- data/lib/yaks/collection_mapper.rb +0 -2
- data/lib/yaks/config.rb +52 -32
- data/lib/yaks/configurable.rb +43 -14
- data/lib/yaks/errors.rb +1 -0
- data/lib/yaks/format/collection_json.rb +37 -5
- data/lib/yaks/format/hal.rb +8 -2
- data/lib/yaks/format/halo.rb +16 -9
- data/lib/yaks/format/json_api.rb +21 -2
- data/lib/yaks/format.rb +21 -15
- data/lib/yaks/html5_forms.rb +3 -2
- data/lib/yaks/identifier/link_relation.rb +17 -0
- data/lib/yaks/mapper/attribute.rb +2 -2
- data/lib/yaks/mapper/config.rb +1 -15
- data/lib/yaks/mapper/form/config.rb +21 -0
- data/lib/yaks/mapper/form/field/option.rb +20 -0
- data/lib/yaks/mapper/form/field.rb +13 -26
- data/lib/yaks/mapper/form/fieldset.rb +43 -0
- data/lib/yaks/mapper/form.rb +41 -16
- data/lib/yaks/mapper/link.rb +9 -7
- data/lib/yaks/mapper.rb +15 -7
- data/lib/yaks/null_resource.rb +2 -1
- data/lib/yaks/pipeline.rb +42 -0
- data/lib/yaks/primitivize.rb +0 -1
- data/lib/yaks/reader/hal.rb +63 -0
- data/lib/yaks/resource/form/field.rb +19 -0
- data/lib/yaks/resource/form/fieldset.rb +13 -0
- data/lib/yaks/resource/form.rb +6 -10
- data/lib/yaks/resource.rb +19 -2
- data/lib/yaks/runner.rb +13 -38
- data/lib/yaks/serializer.rb +34 -1
- data/lib/yaks/util.rb +8 -2
- data/lib/yaks/version.rb +1 -1
- data/lib/yaks.rb +37 -10
- data/resources/iana-link-relations.csv +152 -0
- data/spec/acceptance/acceptance_spec.rb +4 -3
- data/spec/acceptance/json_shared_examples.rb +11 -0
- data/spec/acceptance/models.rb +1 -1
- data/spec/integration/dynamic_form_fields_spec.rb +36 -0
- data/spec/integration/fieldset_spec.rb +62 -0
- data/spec/integration/map_to_resource_spec.rb +0 -2
- data/spec/json/confucius.halo.json +0 -1
- data/spec/sanity_spec.rb +0 -2
- data/spec/spec_helper.rb +3 -3
- data/spec/unit/yaks/attributes_spec.rb +3 -5
- data/spec/unit/yaks/{stateful_builder_spec.rb → builder_spec.rb} +8 -10
- data/spec/unit/yaks/collection_mapper_spec.rb +0 -2
- data/spec/unit/yaks/collection_resource_spec.rb +0 -2
- data/spec/unit/yaks/config_spec.rb +9 -15
- data/spec/unit/yaks/default_policy/derive_mapper_from_object_spec.rb +0 -2
- data/spec/unit/yaks/default_policy_spec.rb +0 -2
- data/spec/unit/yaks/format/collection_json_spec.rb +195 -3
- data/spec/unit/yaks/format/hal_spec.rb +0 -2
- data/spec/unit/yaks/format/halo_spec.rb +0 -1
- data/spec/unit/yaks/format/html_spec.rb +0 -2
- data/spec/unit/yaks/format/json_api_spec.rb +0 -2
- data/spec/unit/yaks/format_spec.rb +4 -6
- data/spec/unit/yaks/fp/callable_spec.rb +0 -2
- data/spec/unit/yaks/fp_spec.rb +0 -2
- data/spec/unit/yaks/mapper/association_mapper_spec.rb +0 -2
- data/spec/unit/yaks/mapper/association_spec.rb +0 -2
- data/spec/unit/yaks/mapper/attribute_spec.rb +0 -2
- data/spec/unit/yaks/mapper/config_spec.rb +6 -167
- data/spec/unit/yaks/mapper/form/field_spec.rb +0 -2
- data/spec/unit/yaks/mapper/form_spec.rb +2 -26
- data/spec/unit/yaks/mapper/has_many_spec.rb +0 -2
- data/spec/unit/yaks/mapper/has_one_spec.rb +0 -2
- data/spec/unit/yaks/mapper/link_spec.rb +13 -2
- data/spec/unit/yaks/mapper_spec.rb +2 -10
- data/spec/unit/yaks/null_resource_spec.rb +2 -4
- data/spec/unit/yaks/pipeline_spec.rb +140 -0
- data/spec/unit/yaks/primitivize_spec.rb +0 -2
- data/spec/unit/yaks/resource/link_spec.rb +0 -2
- data/spec/unit/yaks/resource_spec.rb +2 -4
- data/spec/unit/yaks/runner_spec.rb +52 -92
- data/spec/unit/yaks/serializer_spec.rb +0 -2
- data/spec/unit/yaks/util_spec.rb +12 -2
- metadata +58 -23
- data/lib/yaks/config/dsl.rb +0 -174
- data/lib/yaks/mapper/class_methods.rb +0 -47
- data/lib/yaks/stateful_builder.rb +0 -63
- data/spec/unit/yaks/config/dsl_spec.rb +0 -92
- data/spec/unit/yaks/configurable_spec.rb +0 -55
- data/spec/unit/yaks/mapper/class_methods_spec.rb +0 -83
@@ -0,0 +1,140 @@
|
|
1
|
+
RSpec.describe Yaks::Pipeline do
|
2
|
+
subject(:pipeline) { described_class.new(steps) }
|
3
|
+
let(:steps) {
|
4
|
+
[
|
5
|
+
[:step1, ->(i, e) { i + 1 }],
|
6
|
+
[:step2, ->(i, e) { i + 10 }],
|
7
|
+
[:step3, ->(i, e) { i + e[:foo] }],
|
8
|
+
]
|
9
|
+
}
|
10
|
+
let(:env) {{ foo: 100 }}
|
11
|
+
|
12
|
+
describe '#call' do
|
13
|
+
it 'should call steps in turn, passing in the last result and env' do
|
14
|
+
expect(pipeline.call(1000, env)).to equal 1111
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#insert_hooks' do
|
19
|
+
let(:hooks) { [] }
|
20
|
+
|
21
|
+
describe 'before' do
|
22
|
+
let(:hooks) { [[:before, :step2, :before_step2, ->(i, e) { i - (i % 100) }]] }
|
23
|
+
|
24
|
+
it 'should insert a hook before the step' do
|
25
|
+
expect(pipeline.insert_hooks(hooks).call(1000, env)).to equal 1110
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'after' do
|
30
|
+
let(:hooks) { [[:after, :step2, :after_step2, ->(i, e) { i - (i % 100) }]] }
|
31
|
+
|
32
|
+
it 'should insert a hook after the step' do
|
33
|
+
expect(pipeline.insert_hooks(hooks).call(1000, env)).to equal 1100
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'around' do
|
38
|
+
let(:hooks) { [[:around, :step2, :after_step2, ->(i, e, &b) { e[:foo] + b[i, e] + b[i, e] }]] }
|
39
|
+
|
40
|
+
it 'should insert a hook after the step' do
|
41
|
+
expect(pipeline.insert_hooks(hooks).call(1000, env)).to equal 2222
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'skip' do
|
46
|
+
let(:hooks) { [[:skip, :step2 ]] }
|
47
|
+
|
48
|
+
it 'should insert a hook after the step' do
|
49
|
+
expect(pipeline.insert_hooks(hooks).call(1000, env)).to equal 1101
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'multiple hooks' do
|
54
|
+
let(:hooks) {
|
55
|
+
[
|
56
|
+
[:after, :step2, :after_step2, ->(i, e) { i % 10 }],
|
57
|
+
[:skip, :step3]
|
58
|
+
]
|
59
|
+
}
|
60
|
+
|
61
|
+
it 'should insert the hooks' do
|
62
|
+
expect(pipeline.insert_hooks(hooks).call(1000, env)).to equal 1
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should return a pipeline with the right step names' do
|
67
|
+
expect(pipeline
|
68
|
+
.insert_hooks([[:before, :step2, :step1_1, ->(i, e) { i+1 }]])
|
69
|
+
.insert_hooks([[:before, :step1_1, :step1_0, ->(i, e) { i+10 }]])
|
70
|
+
.insert_hooks([[:after, :step1_1, :step1_2, ->(i, e) { i+100 }]])
|
71
|
+
.insert_hooks([[:around, :step1_1, :step1_1_0, ->(i, e, &b) { b.call(i, e)+1000 }]])
|
72
|
+
.insert_hooks([[:around, :step1_2, :step1_3, ->(i, e, &b) { b.call(i, e)+1000 }]])
|
73
|
+
.insert_hooks([[:after, :step1_3, :step1_4, ->(i, e) { i + 10000 }]])
|
74
|
+
.call(1000, env)
|
75
|
+
).to equal 13222
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
# describe 'after' do
|
83
|
+
# let(:hooks) { proc { after(:format) { :after_format_impl } } }
|
84
|
+
|
85
|
+
# it 'should insert a hook after the step' do
|
86
|
+
# expect(runner.steps.map(&:first)).to eql [
|
87
|
+
# :map, :format, :after_format, :primitivize, :serialize
|
88
|
+
# ]
|
89
|
+
# expect(runner.steps[1].last).to be runner.formatter
|
90
|
+
# expect(runner.steps[2].last.call).to be :after_format_impl
|
91
|
+
# end
|
92
|
+
# end
|
93
|
+
|
94
|
+
# describe 'around' do
|
95
|
+
# let(:hooks) do
|
96
|
+
# proc {
|
97
|
+
# around(:serialize) do |res, env, &block|
|
98
|
+
# "serialized[#{env}][#{block.call(res, env)}]"
|
99
|
+
# end
|
100
|
+
# }
|
101
|
+
# end
|
102
|
+
|
103
|
+
# it 'should insert a hook around the step' do
|
104
|
+
# expect(runner.steps.map(&:first)).to eql [
|
105
|
+
# :map, :format, :primitivize, :serialize
|
106
|
+
# ]
|
107
|
+
# expect(runner.steps.assoc(:serialize).last.call(["res1"], "env1")).to eql(
|
108
|
+
# "serialized[env1][[\n \"res1\"\n]]"
|
109
|
+
# )
|
110
|
+
# end
|
111
|
+
# end
|
112
|
+
|
113
|
+
# describe 'around' do
|
114
|
+
# let(:hooks) { ->(*) { skip(:serialize) } }
|
115
|
+
|
116
|
+
# it 'should skip a certain step' do
|
117
|
+
# expect(runner.steps.map(&:first)).to eql [
|
118
|
+
# :map, :format, :primitivize
|
119
|
+
# ]
|
120
|
+
# end
|
121
|
+
# end
|
122
|
+
|
123
|
+
# describe 'multiple hooks' do
|
124
|
+
# let(:hooks) {
|
125
|
+
# proc {
|
126
|
+
# after(:format) { :after_format_impl }
|
127
|
+
# skip(:serialize)
|
128
|
+
# }
|
129
|
+
# }
|
130
|
+
|
131
|
+
# it 'should insert the hooks' do
|
132
|
+
# expect(runner.steps.map(&:first)).to eql [
|
133
|
+
# :map, :format, :after_format, :primitivize
|
134
|
+
# ]
|
135
|
+
# end
|
136
|
+
|
137
|
+
# it 'should pass on unchanged steps' do
|
138
|
+
# expect(runner.steps.assoc(:map)[1]).to eql runner.mapper
|
139
|
+
# end
|
140
|
+
# end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
RSpec.describe Yaks::Resource do
|
4
2
|
subject(:resource) { described_class.new(init_opts) }
|
5
3
|
let(:init_opts) { {} }
|
@@ -72,10 +70,10 @@ RSpec.describe Yaks::Resource do
|
|
72
70
|
it 'should do updates without modifying the original' do
|
73
71
|
expect(
|
74
72
|
resource
|
75
|
-
.
|
73
|
+
.merge_attributes(foo: :bar)
|
76
74
|
.add_link(:a_link)
|
77
75
|
.add_subresource(:a_subresource)
|
78
|
-
.
|
76
|
+
.merge_attributes(foo: :baz)
|
79
77
|
).to eq Yaks::Resource.new(
|
80
78
|
attributes: {x: :y, foo: :baz},
|
81
79
|
links: [:one, :a_link],
|
@@ -1,20 +1,19 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
RSpec.describe Yaks::Runner do
|
4
2
|
subject(:runner) {
|
5
3
|
described_class.new(object: object, config: config, options: options)
|
6
4
|
}
|
7
5
|
|
8
6
|
let(:object) { Object.new }
|
9
|
-
let(:config) { Yaks
|
7
|
+
let(:config) { Yaks.new }
|
10
8
|
let(:options) { {} }
|
11
9
|
|
12
|
-
|
10
|
+
shared_examples 'high-level runner test' do
|
11
|
+
let(:options) { {env: {foo: "from_env"}} }
|
13
12
|
let(:runner) {
|
14
13
|
Class.new(described_class) do
|
15
14
|
def steps
|
16
15
|
[ [:step1, proc { |x| x + 35 }],
|
17
|
-
[:step2, proc { |x| "#{x} #{x}" }] ]
|
16
|
+
[:step2, proc { |x, env| "#{env[:foo]}[#{x} #{x}]" }] ]
|
18
17
|
end
|
19
18
|
end.new(object: object, config: config, options: options)
|
20
19
|
}
|
@@ -22,10 +21,18 @@ RSpec.describe Yaks::Runner do
|
|
22
21
|
let(:object) { 7 }
|
23
22
|
|
24
23
|
it 'should go through all the steps' do
|
25
|
-
expect(runner.call).to eql "42 42"
|
24
|
+
expect(runner.call).to eql "from_env[42 42]"
|
26
25
|
end
|
27
26
|
end
|
28
27
|
|
28
|
+
describe '#call' do
|
29
|
+
include_examples 'high-level runner test'
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#process' do
|
33
|
+
include_examples 'high-level runner test'
|
34
|
+
end
|
35
|
+
|
29
36
|
describe '#context' do
|
30
37
|
it 'should contain the policy, env, and an empty mapper_stack' do
|
31
38
|
expect(runner.context).to eql(policy: config.policy, env: {}, mapper_stack: [])
|
@@ -42,7 +49,7 @@ RSpec.describe Yaks::Runner do
|
|
42
49
|
|
43
50
|
describe '#format_class' do
|
44
51
|
let(:config) do
|
45
|
-
Yaks
|
52
|
+
Yaks.new do
|
46
53
|
default_format :collection_json
|
47
54
|
end
|
48
55
|
end
|
@@ -89,7 +96,7 @@ RSpec.describe Yaks::Runner do
|
|
89
96
|
end
|
90
97
|
|
91
98
|
context 'with a default format specified' do
|
92
|
-
let(:config) { Yaks
|
99
|
+
let(:config) { Yaks.new { default_format :collection_json } }
|
93
100
|
|
94
101
|
context 'with a format in the options' do
|
95
102
|
let(:options) { { format: :json_api } }
|
@@ -108,7 +115,7 @@ RSpec.describe Yaks::Runner do
|
|
108
115
|
|
109
116
|
describe '#formatter' do
|
110
117
|
let(:config) {
|
111
|
-
Yaks
|
118
|
+
Yaks.new do
|
112
119
|
default_format :json_api
|
113
120
|
format_options :json_api, {format_option: [:foo]}
|
114
121
|
end
|
@@ -142,69 +149,6 @@ RSpec.describe Yaks::Runner do
|
|
142
149
|
end
|
143
150
|
end
|
144
151
|
|
145
|
-
describe '#insert_hooks' do
|
146
|
-
let(:options) { { mapper: Yaks::Mapper } }
|
147
|
-
let(:config) { Yaks::Config.new(&hooks) }
|
148
|
-
|
149
|
-
describe 'before' do
|
150
|
-
let(:hooks) { proc { before(:map) { :before_map_impl } } }
|
151
|
-
|
152
|
-
it 'should insert a hook before the step' do
|
153
|
-
expect(runner.steps.map(&:first)).to eql [
|
154
|
-
:before_map, :map, :format, :primitivize, :serialize
|
155
|
-
]
|
156
|
-
expect(runner.steps.assoc(:before_map).last.call).to be :before_map_impl
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
describe 'after' do
|
161
|
-
let(:hooks) { proc { after(:format) { :after_format_impl } } }
|
162
|
-
|
163
|
-
it 'should insert a hook after the step' do
|
164
|
-
expect(runner.steps.map(&:first)).to eql [
|
165
|
-
:map, :format, :after_format, :primitivize, :serialize
|
166
|
-
]
|
167
|
-
expect(runner.steps.assoc(:after_format).last.call).to be :after_format_impl
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
describe 'around' do
|
172
|
-
let(:hooks) { proc { around(:format) { :around_format_impl } } }
|
173
|
-
|
174
|
-
it 'should insert a hook around the step' do
|
175
|
-
expect(runner.steps.map(&:first)).to eql [
|
176
|
-
:map, :format, :primitivize, :serialize
|
177
|
-
]
|
178
|
-
expect(runner.steps.assoc(:format).last.call(nil, nil)).to be :around_format_impl
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
describe 'around' do
|
183
|
-
let(:hooks) { proc { skip(:serialize) } }
|
184
|
-
|
185
|
-
it 'should insert a hook before the step' do
|
186
|
-
expect(runner.steps.map(&:first)).to eql [
|
187
|
-
:map, :format, :primitivize
|
188
|
-
]
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
describe 'multiple hooks' do
|
193
|
-
let(:hooks) {
|
194
|
-
proc {
|
195
|
-
after(:format) { :after_format_impl }
|
196
|
-
skip(:serialize)
|
197
|
-
}
|
198
|
-
}
|
199
|
-
|
200
|
-
it 'should insert the hooks' do
|
201
|
-
expect(runner.steps.map(&:first)).to eql [
|
202
|
-
:map, :format, :after_format, :primitivize
|
203
|
-
]
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
152
|
describe '#mapper' do
|
209
153
|
context 'with an explicit mapper in the options' do
|
210
154
|
let(:mapper_class) { Class.new(Yaks::Mapper) }
|
@@ -231,8 +175,8 @@ RSpec.describe Yaks::Runner do
|
|
231
175
|
describe '#serializer' do
|
232
176
|
context 'with a serializer configured' do
|
233
177
|
let(:config) {
|
234
|
-
Yaks
|
235
|
-
|
178
|
+
Yaks.new do
|
179
|
+
serializer(:json) do |input|
|
236
180
|
"serialized #{input}"
|
237
181
|
end
|
238
182
|
end
|
@@ -259,24 +203,12 @@ RSpec.describe Yaks::Runner do
|
|
259
203
|
[ :serialize, runner.serializer ]
|
260
204
|
]
|
261
205
|
end
|
262
|
-
|
263
|
-
context 'with hooks' do
|
264
|
-
let(:config) {
|
265
|
-
Yaks::Config.new do
|
266
|
-
after(:format, :my_hook) { :foo }
|
267
|
-
end
|
268
|
-
}
|
269
|
-
|
270
|
-
it 'should insert hooks' do
|
271
|
-
expect(runner.steps.map(&:first)).to eql [:map, :format, :my_hook, :primitivize, :serialize]
|
272
|
-
end
|
273
|
-
end
|
274
206
|
end
|
275
207
|
|
276
208
|
describe '#primitivizer' do
|
277
209
|
describe 'with a non json based format' do
|
278
210
|
let(:config) do
|
279
|
-
Yaks
|
211
|
+
Yaks.new do
|
280
212
|
default_format :html
|
281
213
|
end
|
282
214
|
end
|
@@ -294,11 +226,9 @@ RSpec.describe Yaks::Runner do
|
|
294
226
|
end
|
295
227
|
|
296
228
|
describe '#hooks' do
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
end
|
301
|
-
end
|
229
|
+
let(:config) {
|
230
|
+
super().after(:map, :this_happens_after_map)
|
231
|
+
}
|
302
232
|
|
303
233
|
it 'should contain the hooks from the config' do
|
304
234
|
expect(runner.hooks).to eql [[:after, :map, :this_happens_after_map, nil]]
|
@@ -313,4 +243,34 @@ RSpec.describe Yaks::Runner do
|
|
313
243
|
end
|
314
244
|
end
|
315
245
|
|
246
|
+
describe '#map' do
|
247
|
+
let(:mapper_class) do
|
248
|
+
Struct.new(:options) do
|
249
|
+
include Yaks::FP::Callable
|
250
|
+
def call(obj, env) "mapped[#{obj}]" end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
let(:options) { { mapper: mapper_class } }
|
255
|
+
let(:object) { "foo" }
|
256
|
+
|
257
|
+
it 'should only run the mapper' do
|
258
|
+
expect(runner.map).to eql "mapped[foo]"
|
259
|
+
end
|
260
|
+
|
261
|
+
context 'with a hook on the :map step' do
|
262
|
+
let(:config) do
|
263
|
+
Yaks.new do
|
264
|
+
around(:map) do |res, env, &block|
|
265
|
+
"around[#{block.call(res, env)}]"
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
it 'should invoke the hook as well' do
|
271
|
+
expect(runner.map).to eql "around[mapped[foo]]"
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
316
276
|
end
|
data/spec/unit/yaks/util_spec.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
RSpec.describe Yaks::Util do
|
4
2
|
include Yaks::Util
|
5
3
|
|
@@ -55,6 +53,18 @@ RSpec.describe Yaks::Util do
|
|
55
53
|
end
|
56
54
|
end
|
57
55
|
|
56
|
+
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}]
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should provide an empty hash if none was given' do
|
63
|
+
args, opts = extract_options([:a, :b])
|
64
|
+
expect([args, opts]).to eql [[:a, :b], {}]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
58
68
|
end
|
59
69
|
|
60
70
|
RSpec.describe Yaks::Util::Deprecated do
|
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
|
+
version: 0.8.0.alpha
|
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-12-
|
11
|
+
date: 2014-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inflection
|
@@ -242,16 +242,17 @@ extensions: []
|
|
242
242
|
extra_rdoc_files:
|
243
243
|
- README.md
|
244
244
|
files:
|
245
|
+
- ".rspec"
|
245
246
|
- README.md
|
246
247
|
- Rakefile
|
247
248
|
- lib/yaks.rb
|
248
249
|
- lib/yaks/attributes.rb
|
249
250
|
- lib/yaks/breaking_changes.rb
|
251
|
+
- lib/yaks/builder.rb
|
250
252
|
- lib/yaks/changelog.rb
|
251
253
|
- lib/yaks/collection_mapper.rb
|
252
254
|
- lib/yaks/collection_resource.rb
|
253
255
|
- lib/yaks/config.rb
|
254
|
-
- lib/yaks/config/dsl.rb
|
255
256
|
- lib/yaks/configurable.rb
|
256
257
|
- lib/yaks/default_policy.rb
|
257
258
|
- lib/yaks/errors.rb
|
@@ -263,31 +264,40 @@ files:
|
|
263
264
|
- lib/yaks/fp.rb
|
264
265
|
- lib/yaks/fp/callable.rb
|
265
266
|
- lib/yaks/html5_forms.rb
|
267
|
+
- lib/yaks/identifier/link_relation.rb
|
266
268
|
- lib/yaks/mapper.rb
|
267
269
|
- lib/yaks/mapper/association.rb
|
268
270
|
- lib/yaks/mapper/association_mapper.rb
|
269
271
|
- lib/yaks/mapper/attribute.rb
|
270
|
-
- lib/yaks/mapper/class_methods.rb
|
271
272
|
- lib/yaks/mapper/config.rb
|
272
273
|
- lib/yaks/mapper/form.rb
|
274
|
+
- lib/yaks/mapper/form/config.rb
|
273
275
|
- lib/yaks/mapper/form/field.rb
|
276
|
+
- lib/yaks/mapper/form/field/option.rb
|
277
|
+
- lib/yaks/mapper/form/fieldset.rb
|
274
278
|
- lib/yaks/mapper/has_many.rb
|
275
279
|
- lib/yaks/mapper/has_one.rb
|
276
280
|
- lib/yaks/mapper/link.rb
|
277
281
|
- lib/yaks/null_resource.rb
|
282
|
+
- lib/yaks/pipeline.rb
|
278
283
|
- lib/yaks/primitivize.rb
|
284
|
+
- lib/yaks/reader/hal.rb
|
279
285
|
- lib/yaks/resource.rb
|
280
286
|
- lib/yaks/resource/form.rb
|
287
|
+
- lib/yaks/resource/form/field.rb
|
288
|
+
- lib/yaks/resource/form/fieldset.rb
|
281
289
|
- lib/yaks/resource/link.rb
|
282
290
|
- lib/yaks/runner.rb
|
283
291
|
- lib/yaks/serializer.rb
|
284
|
-
- lib/yaks/stateful_builder.rb
|
285
292
|
- lib/yaks/util.rb
|
286
293
|
- lib/yaks/version.rb
|
294
|
+
- resources/iana-link-relations.csv
|
287
295
|
- spec/acceptance/acceptance_spec.rb
|
288
296
|
- spec/acceptance/json_shared_examples.rb
|
289
297
|
- spec/acceptance/models.rb
|
290
298
|
- spec/fixture_helpers.rb
|
299
|
+
- spec/integration/dynamic_form_fields_spec.rb
|
300
|
+
- spec/integration/fieldset_spec.rb
|
291
301
|
- spec/integration/map_to_resource_spec.rb
|
292
302
|
- spec/json/confucius.collection.json
|
293
303
|
- spec/json/confucius.hal.json
|
@@ -309,11 +319,10 @@ files:
|
|
309
319
|
- spec/support/shared_contexts.rb
|
310
320
|
- spec/support/youtypeit_models_mappers.rb
|
311
321
|
- spec/unit/yaks/attributes_spec.rb
|
322
|
+
- spec/unit/yaks/builder_spec.rb
|
312
323
|
- spec/unit/yaks/collection_mapper_spec.rb
|
313
324
|
- spec/unit/yaks/collection_resource_spec.rb
|
314
|
-
- spec/unit/yaks/config/dsl_spec.rb
|
315
325
|
- spec/unit/yaks/config_spec.rb
|
316
|
-
- spec/unit/yaks/configurable_spec.rb
|
317
326
|
- spec/unit/yaks/default_policy/derive_mapper_from_object_spec.rb
|
318
327
|
- spec/unit/yaks/default_policy_spec.rb
|
319
328
|
- spec/unit/yaks/format/collection_json_spec.rb
|
@@ -327,7 +336,6 @@ files:
|
|
327
336
|
- spec/unit/yaks/mapper/association_mapper_spec.rb
|
328
337
|
- spec/unit/yaks/mapper/association_spec.rb
|
329
338
|
- spec/unit/yaks/mapper/attribute_spec.rb
|
330
|
-
- spec/unit/yaks/mapper/class_methods_spec.rb
|
331
339
|
- spec/unit/yaks/mapper/config_spec.rb
|
332
340
|
- spec/unit/yaks/mapper/form/field_spec.rb
|
333
341
|
- spec/unit/yaks/mapper/form_spec.rb
|
@@ -336,12 +344,12 @@ files:
|
|
336
344
|
- spec/unit/yaks/mapper/link_spec.rb
|
337
345
|
- spec/unit/yaks/mapper_spec.rb
|
338
346
|
- spec/unit/yaks/null_resource_spec.rb
|
347
|
+
- spec/unit/yaks/pipeline_spec.rb
|
339
348
|
- spec/unit/yaks/primitivize_spec.rb
|
340
349
|
- spec/unit/yaks/resource/link_spec.rb
|
341
350
|
- spec/unit/yaks/resource_spec.rb
|
342
351
|
- spec/unit/yaks/runner_spec.rb
|
343
352
|
- spec/unit/yaks/serializer_spec.rb
|
344
|
-
- spec/unit/yaks/stateful_builder_spec.rb
|
345
353
|
- spec/unit/yaks/util_spec.rb
|
346
354
|
- spec/yaml/confucius.yaml
|
347
355
|
- spec/yaml/youtypeitwepostit.yaml
|
@@ -351,18 +359,45 @@ licenses:
|
|
351
359
|
- MIT
|
352
360
|
metadata:
|
353
361
|
changelog: |-
|
354
|
-
|
362
|
+
Improved Collection+JSON support, dynamically generated form fields.
|
355
363
|
|
356
|
-
|
364
|
+
#### Collection+JSON
|
357
365
|
|
358
|
-
|
359
|
-
deprecated alias available.
|
366
|
+
Carles Jove i Buxeda has done some great work to improve support for Collection+JSON, GET forms are now rendered as CJ queries.
|
360
367
|
|
361
|
-
|
362
|
-
form by name.
|
368
|
+
#### Dynamic Form Fields
|
363
369
|
|
364
|
-
|
365
|
-
|
370
|
+
A new introduction are "dynamic" form fields. Up to now it was hard to generate forms based on the object being serialized. Now it's possible to add dynamic sections to a Form definition. These will be evaluated at map-time, they receive the object being mapped, and inside the syntax for defining form fields can be used.
|
371
|
+
|
372
|
+
```
|
373
|
+
form :checkout do
|
374
|
+
text :name
|
375
|
+
text :lastname
|
376
|
+
|
377
|
+
dynamic do |object|
|
378
|
+
object.shipping_options.each do |shipping|
|
379
|
+
radio shipping.type_name, title: shipping.description
|
380
|
+
end
|
381
|
+
end
|
382
|
+
end
|
383
|
+
```
|
384
|
+
|
385
|
+
#### Fieldset and Legend
|
386
|
+
|
387
|
+
Support for the fieldset element type has been added, which works as you would expect
|
388
|
+
|
389
|
+
```
|
390
|
+
form :foo do
|
391
|
+
fieldset do
|
392
|
+
legend "Hello"
|
393
|
+
text :field_1
|
394
|
+
end
|
395
|
+
end
|
396
|
+
```
|
397
|
+
|
398
|
+
#### Remove links
|
399
|
+
|
400
|
+
A link de
|
366
401
|
post_install_message:
|
367
402
|
rdoc_options: []
|
368
403
|
require_paths:
|
@@ -374,9 +409,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
374
409
|
version: '0'
|
375
410
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
376
411
|
requirements:
|
377
|
-
- - "
|
412
|
+
- - ">"
|
378
413
|
- !ruby/object:Gem::Version
|
379
|
-
version:
|
414
|
+
version: 1.3.1
|
380
415
|
requirements: []
|
381
416
|
rubyforge_project:
|
382
417
|
rubygems_version: 2.2.2
|
@@ -388,6 +423,8 @@ test_files:
|
|
388
423
|
- spec/acceptance/json_shared_examples.rb
|
389
424
|
- spec/acceptance/models.rb
|
390
425
|
- spec/fixture_helpers.rb
|
426
|
+
- spec/integration/dynamic_form_fields_spec.rb
|
427
|
+
- spec/integration/fieldset_spec.rb
|
391
428
|
- spec/integration/map_to_resource_spec.rb
|
392
429
|
- spec/json/confucius.collection.json
|
393
430
|
- spec/json/confucius.hal.json
|
@@ -409,11 +446,10 @@ test_files:
|
|
409
446
|
- spec/support/shared_contexts.rb
|
410
447
|
- spec/support/youtypeit_models_mappers.rb
|
411
448
|
- spec/unit/yaks/attributes_spec.rb
|
449
|
+
- spec/unit/yaks/builder_spec.rb
|
412
450
|
- spec/unit/yaks/collection_mapper_spec.rb
|
413
451
|
- spec/unit/yaks/collection_resource_spec.rb
|
414
|
-
- spec/unit/yaks/config/dsl_spec.rb
|
415
452
|
- spec/unit/yaks/config_spec.rb
|
416
|
-
- spec/unit/yaks/configurable_spec.rb
|
417
453
|
- spec/unit/yaks/default_policy/derive_mapper_from_object_spec.rb
|
418
454
|
- spec/unit/yaks/default_policy_spec.rb
|
419
455
|
- spec/unit/yaks/format/collection_json_spec.rb
|
@@ -427,7 +463,6 @@ test_files:
|
|
427
463
|
- spec/unit/yaks/mapper/association_mapper_spec.rb
|
428
464
|
- spec/unit/yaks/mapper/association_spec.rb
|
429
465
|
- spec/unit/yaks/mapper/attribute_spec.rb
|
430
|
-
- spec/unit/yaks/mapper/class_methods_spec.rb
|
431
466
|
- spec/unit/yaks/mapper/config_spec.rb
|
432
467
|
- spec/unit/yaks/mapper/form/field_spec.rb
|
433
468
|
- spec/unit/yaks/mapper/form_spec.rb
|
@@ -436,12 +471,12 @@ test_files:
|
|
436
471
|
- spec/unit/yaks/mapper/link_spec.rb
|
437
472
|
- spec/unit/yaks/mapper_spec.rb
|
438
473
|
- spec/unit/yaks/null_resource_spec.rb
|
474
|
+
- spec/unit/yaks/pipeline_spec.rb
|
439
475
|
- spec/unit/yaks/primitivize_spec.rb
|
440
476
|
- spec/unit/yaks/resource/link_spec.rb
|
441
477
|
- spec/unit/yaks/resource_spec.rb
|
442
478
|
- spec/unit/yaks/runner_spec.rb
|
443
479
|
- spec/unit/yaks/serializer_spec.rb
|
444
|
-
- spec/unit/yaks/stateful_builder_spec.rb
|
445
480
|
- spec/unit/yaks/util_spec.rb
|
446
481
|
- spec/yaml/confucius.yaml
|
447
482
|
- spec/yaml/youtypeitwepostit.yaml
|