smart_params 3.0.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +440 -0
- data/README.md +5 -14
- data/Rakefile +1 -0
- data/lib/smart_params/error/invalid_property_type.rb +3 -0
- data/lib/smart_params/error/invalid_property_type_spec.rb +2 -0
- data/lib/smart_params/error.rb +2 -0
- data/lib/smart_params/field.rb +19 -17
- data/lib/smart_params/version.rb +3 -1
- data/lib/smart_params.rb +12 -7
- data/lib/smart_params_spec.rb +42 -41
- metadata +24 -111
- data/lib/smart_params/version_spec.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa09497154b8fcffacbdb4a2d90e277eb00ca8b159279eb3220532c7cb604160
|
4
|
+
data.tar.gz: ace3cfdc1a43e66979a5a562b2458321892c1b93c1bc50a2790ebd07b6886c35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94e685f378e35aa4098d88c2c110abc7f101e60223202746b06aa70f45ee648f5203d1c4cb526072747505b30475ffa092a92d8db4c4b20ae7011053414b6b75
|
7
|
+
data.tar.gz: 7761f7c49ab88765088d92864fc81735499b57b2388e0286a9a90f11a57d73c68101f6fa215b58f6c330e601e7a6898e1097189983a8e4ce9ee05b1694e424ca
|
data/LICENSE
ADDED
@@ -0,0 +1,440 @@
|
|
1
|
+
HIPPOCRATIC LICENSE
|
2
|
+
|
3
|
+
Version 3.0, October 2021
|
4
|
+
|
5
|
+
https://firstdonoharm.dev/version/3/0/full.txt
|
6
|
+
|
7
|
+
TERMS AND CONDITIONS
|
8
|
+
|
9
|
+
TERMS AND CONDITIONS FOR USE, COPY, MODIFICATION, PREPARATION OF DERIVATIVE
|
10
|
+
WORK, REPRODUCTION, AND DISTRIBUTION:
|
11
|
+
|
12
|
+
1. DEFINITIONS:
|
13
|
+
|
14
|
+
This section defines certain terms used throughout this license agreement.
|
15
|
+
|
16
|
+
1.1. “License” means the terms and conditions, as stated herein, for use, copy,
|
17
|
+
modification, preparation of derivative work, reproduction, and distribution of
|
18
|
+
Software (as defined below).
|
19
|
+
|
20
|
+
1.2. “Licensor” means the copyright and/or patent owner or entity authorized by
|
21
|
+
the copyright and/or patent owner that is granting the License.
|
22
|
+
|
23
|
+
1.3. “Licensee” means the individual or entity exercising permissions granted by
|
24
|
+
this License, including the use, copy, modification, preparation of derivative
|
25
|
+
work, reproduction, and distribution of Software (as defined below).
|
26
|
+
|
27
|
+
1.4. “Software” means any copyrighted work, including but not limited to
|
28
|
+
software code, authored by Licensor and made available under this License.
|
29
|
+
|
30
|
+
1.5. “Supply Chain” means the sequence of processes involved in the production
|
31
|
+
and/or distribution of a commodity, good, or service offered by the Licensee.
|
32
|
+
|
33
|
+
1.6. “Supply Chain Impacted Party” or “Supply Chain Impacted Parties” means any
|
34
|
+
person(s) directly impacted by any of Licensee’s Supply Chain, including the
|
35
|
+
practices of all persons or entities within the Supply Chain prior to a good or
|
36
|
+
service reaching the Licensee.
|
37
|
+
|
38
|
+
1.7. “Duty of Care” is defined by its use in tort law, delict law, and/or
|
39
|
+
similar bodies of law closely related to tort and/or delict law, including
|
40
|
+
without limitation, a requirement to act with the watchfulness, attention,
|
41
|
+
caution, and prudence that a reasonable person in the same or similar
|
42
|
+
circumstances would use towards any Supply Chain Impacted Party.
|
43
|
+
|
44
|
+
1.8. “Worker” is defined to include any and all permanent, temporary, and agency
|
45
|
+
workers, as well as piece-rate, salaried, hourly paid, legal young (minors),
|
46
|
+
part-time, night, and migrant workers.
|
47
|
+
|
48
|
+
2. INTELLECTUAL PROPERTY GRANTS:
|
49
|
+
|
50
|
+
This section identifies intellectual property rights granted to a Licensee.
|
51
|
+
|
52
|
+
2.1. Grant of Copyright License: Subject to the terms and conditions of this
|
53
|
+
License, Licensor hereby grants to Licensee a worldwide, non-exclusive,
|
54
|
+
no-charge, royalty-free copyright license to use, copy, modify, prepare
|
55
|
+
derivative work, reproduce, or distribute the Software, Licensor authored
|
56
|
+
modified software, or other work derived from the Software.
|
57
|
+
|
58
|
+
2.2. Grant of Patent License: Subject to the terms and conditions of this
|
59
|
+
License, Licensor hereby grants Licensee a worldwide, non-exclusive, no-charge,
|
60
|
+
royalty-free patent license to make, have made, use, offer to sell, sell,
|
61
|
+
import, and otherwise transfer Software.
|
62
|
+
|
63
|
+
3. ETHICAL STANDARDS:
|
64
|
+
|
65
|
+
This section lists conditions the Licensee must comply with in order to have
|
66
|
+
rights under this License.
|
67
|
+
|
68
|
+
The rights granted to the Licensee by this License are expressly made subject to
|
69
|
+
the Licensee’s ongoing compliance with the following conditions:
|
70
|
+
|
71
|
+
* 3.1. The Licensee SHALL NOT, whether directly or indirectly, through agents
|
72
|
+
or assigns:
|
73
|
+
|
74
|
+
* 3.1.1. Infringe upon any person’s right to life or security of person,
|
75
|
+
engage in extrajudicial killings, or commit murder, without lawful cause
|
76
|
+
(See Article 3, United Nations Universal Declaration of Human Rights;
|
77
|
+
Article 6, International Covenant on Civil and Political Rights)
|
78
|
+
|
79
|
+
* 3.1.2. Hold any person in slavery, servitude, or forced labor (See Article
|
80
|
+
4, United Nations Universal Declaration of Human Rights; Article 8,
|
81
|
+
International Covenant on Civil and Political Rights);
|
82
|
+
|
83
|
+
* 3.1.3. Contribute to the institution of slavery, slave trading, forced
|
84
|
+
labor, or unlawful child labor (See Article 4, United Nations Universal
|
85
|
+
Declaration of Human Rights; Article 8, International Covenant on Civil and
|
86
|
+
Political Rights);
|
87
|
+
|
88
|
+
* 3.1.4. Torture or subject any person to cruel, inhumane, or degrading
|
89
|
+
treatment or punishment (See Article 5, United Nations Universal
|
90
|
+
Declaration of Human Rights; Article 7, International Covenant on Civil and
|
91
|
+
Political Rights);
|
92
|
+
|
93
|
+
* 3.1.5. Discriminate on the basis of sex, gender, sexual orientation, race,
|
94
|
+
ethnicity, nationality, religion, caste, age, medical disability or
|
95
|
+
impairment, and/or any other like circumstances (See Article 7, United
|
96
|
+
Nations Universal Declaration of Human Rights; Article 2, International
|
97
|
+
Covenant on Economic, Social and Cultural Rights; Article 26, International
|
98
|
+
Covenant on Civil and Political Rights);
|
99
|
+
|
100
|
+
* 3.1.6. Prevent any person from exercising his/her/their right to seek an
|
101
|
+
effective remedy by a competent court or national tribunal (including
|
102
|
+
domestic judicial systems, international courts, arbitration bodies, and
|
103
|
+
other adjudicating bodies) for actions violating the fundamental rights
|
104
|
+
granted to him/her/them by applicable constitutions, applicable laws, or by
|
105
|
+
this License (See Article 8, United Nations Universal Declaration of Human
|
106
|
+
Rights; Articles 9 and 14, International Covenant on Civil and Political
|
107
|
+
Rights);
|
108
|
+
|
109
|
+
* 3.1.7. Subject any person to arbitrary arrest, detention, or exile (See
|
110
|
+
Article 9, United Nations Universal Declaration of Human Rights; Article 9,
|
111
|
+
International Covenant on Civil and Political Rights);
|
112
|
+
|
113
|
+
* 3.1.8. Subject any person to arbitrary interference with a person’s
|
114
|
+
privacy, family, home, or correspondence without the express written
|
115
|
+
consent of the person (See Article 12, United Nations Universal Declaration
|
116
|
+
of Human Rights; Article 17, International Covenant on Civil and Political
|
117
|
+
Rights);
|
118
|
+
|
119
|
+
* 3.1.9. Arbitrarily deprive any person of his/her/their property (See
|
120
|
+
Article 17, United Nations Universal Declaration of Human Rights);
|
121
|
+
|
122
|
+
* 3.1.10. Forcibly remove indigenous peoples from their lands or territories
|
123
|
+
or take any action with the aim or effect of dispossessing indigenous
|
124
|
+
peoples from their lands, territories, or resources, including without
|
125
|
+
limitation the intellectual property or traditional knowledge of indigenous
|
126
|
+
peoples, without the free, prior, and informed consent of indigenous
|
127
|
+
peoples concerned (See Articles 8 and 10, United Nations Declaration on the
|
128
|
+
Rights of Indigenous Peoples);
|
129
|
+
|
130
|
+
* 3.1.11. Fossil Fuel Divestment: Be an individual or entity, or a
|
131
|
+
representative, agent, affiliate, successor, attorney, or assign of an
|
132
|
+
individual or entity, on the FFI Solutions Carbon Underground 200 list
|
133
|
+
[https://www.ffisolutions.com/research-analytics-index-solutions/research-screening/the-carbon-underground-200/?cn-reloaded=1];
|
134
|
+
|
135
|
+
* 3.1.12. Ecocide: Commit ecocide:
|
136
|
+
|
137
|
+
* 3.1.12.1. For the purpose of this section, “ecocide” means unlawful or
|
138
|
+
wanton acts committed with knowledge that there is a substantial
|
139
|
+
likelihood of severe and either widespread or long-term damage to the
|
140
|
+
environment being caused by those acts;
|
141
|
+
|
142
|
+
* 3.1.12.2. For the purpose of further defining ecocide and the terms
|
143
|
+
contained in the previous paragraph:
|
144
|
+
|
145
|
+
* 3.1.12.2.1. “Wanton” means with reckless disregard for damage which
|
146
|
+
would be clearly excessive in relation to the social and economic
|
147
|
+
benefits anticipated;
|
148
|
+
|
149
|
+
* 3.1.12.2.2. “Severe” means damage which involves very serious adverse
|
150
|
+
changes, disruption, or harm to any element of the environment,
|
151
|
+
including grave impacts on human life or natural, cultural, or
|
152
|
+
economic resources;
|
153
|
+
|
154
|
+
* 3.1.12.2.3. “Widespread” means damage which extends beyond a limited
|
155
|
+
geographic area, crosses state boundaries, or is suffered by an entire
|
156
|
+
ecosystem or species or a large number of human beings;
|
157
|
+
|
158
|
+
* 3.1.12.2.4. “Long-term” means damage which is irreversible or which
|
159
|
+
cannot be redressed through natural recovery within a reasonable
|
160
|
+
period of time; and
|
161
|
+
|
162
|
+
* 3.1.12.2.5. “Environment” means the earth, its biosphere, cryosphere,
|
163
|
+
lithosphere, hydrosphere, and atmosphere, as well as outer space
|
164
|
+
|
165
|
+
(See Section II, Independent Expert Panel for the Legal Definition of
|
166
|
+
Ecocide, Stop Ecocide Foundation and the Promise Institute for Human
|
167
|
+
Rights at UCLA School of Law, June 2021);
|
168
|
+
|
169
|
+
* 3.1.13. Extractive Industries: Be an individual or entity, or a
|
170
|
+
representative, agent, affiliate, successor, attorney, or assign of an
|
171
|
+
individual or entity, that engages in fossil fuel or mineral exploration,
|
172
|
+
extraction, development, or sale;
|
173
|
+
|
174
|
+
* 3.1.14. Boycott / Divestment / Sanctions: Be an individual or entity, or a
|
175
|
+
representative, agent, affiliate, successor, attorney, or assign of an
|
176
|
+
individual or entity, identified by the Boycott, Divestment, Sanctions
|
177
|
+
(“BDS”) movement on its website (https://bdsmovement.net/
|
178
|
+
[https://bdsmovement.net/] and
|
179
|
+
https://bdsmovement.net/get-involved/what-to-boycott
|
180
|
+
[https://bdsmovement.net/get-involved/what-to-boycott]) as a target for
|
181
|
+
boycott;
|
182
|
+
|
183
|
+
* 3.1.15. Taliban: Be an individual or entity that:
|
184
|
+
|
185
|
+
* 3.1.15.1. engages in any commercial transactions with the Taliban; or
|
186
|
+
|
187
|
+
* 3.1.15.2. is a representative, agent, affiliate, successor, attorney, or
|
188
|
+
assign of the Taliban;
|
189
|
+
|
190
|
+
* 3.1.16. Myanmar: Be an individual or entity that:
|
191
|
+
|
192
|
+
* 3.1.16.1. engages in any commercial transactions with the
|
193
|
+
Myanmar/Burmese military junta; or
|
194
|
+
|
195
|
+
* 3.1.16.2. is a representative, agent, affiliate, successor, attorney, or
|
196
|
+
assign of the Myanmar/Burmese government;
|
197
|
+
|
198
|
+
* 3.1.17. Xinjiang Uygur Autonomous Region: Be an individual or entity, or a
|
199
|
+
representative, agent, affiliate, successor, attorney, or assign of any
|
200
|
+
individual or entity, that does business in, purchases goods from, or
|
201
|
+
otherwise benefits from goods produced in the Xinjiang Uygur Autonomous
|
202
|
+
Region of China;
|
203
|
+
|
204
|
+
* 3.1.18. US Tariff Act: Be an individual or entity:
|
205
|
+
|
206
|
+
* 3.1.18.1. which U.S. Customs and Border Protection (CBP) has currently
|
207
|
+
issued a Withhold Release Order (WRO) or finding against based on
|
208
|
+
reasonable suspicion of forced labor; or
|
209
|
+
|
210
|
+
* 3.1.18.2. that is a representative, agent, affiliate, successor,
|
211
|
+
attorney, or assign of an individual or entity that does business with
|
212
|
+
an individual or entity which currently has a WRO or finding from CBP
|
213
|
+
issued against it based on reasonable suspicion of forced labor;
|
214
|
+
|
215
|
+
* 3.1.19. Mass Surveillance: Be a government agency or multinational
|
216
|
+
corporation, or a representative, agent, affiliate, successor, attorney,
|
217
|
+
or assign of a government or multinational corporation, which participates
|
218
|
+
in mass surveillance programs;
|
219
|
+
|
220
|
+
* 3.1.20. Military Activities: Be an entity or a representative, agent,
|
221
|
+
affiliate, successor, attorney, or assign of an entity which conducts
|
222
|
+
military activities;
|
223
|
+
|
224
|
+
* 3.1.21. Law Enforcement: Be an individual or entity, or a or a
|
225
|
+
representative, agent, affiliate, successor, attorney, or assign of an
|
226
|
+
individual or entity, that provides good or services to, or otherwise
|
227
|
+
enters into any commercial contracts with, any local, state, or federal
|
228
|
+
law enforcement agency;
|
229
|
+
|
230
|
+
* 3.1.22. Media: Be an individual or entity, or a or a representative,
|
231
|
+
agent, affiliate, successor, attorney, or assign of an individual or
|
232
|
+
entity, that broadcasts messages promoting killing, torture, or other
|
233
|
+
forms of extreme violence;
|
234
|
+
|
235
|
+
* 3.1.23. Interfere with Workers' free exercise of the right to organize and
|
236
|
+
associate (See Article 20, United Nations Universal Declaration of Human
|
237
|
+
Rights; C087 - Freedom of Association and Protection of the Right to
|
238
|
+
Organise Convention, 1948 (No. 87), International Labour Organization;
|
239
|
+
Article 8, International Covenant on Economic, Social and Cultural Rights);
|
240
|
+
and
|
241
|
+
|
242
|
+
* 3.1.24. Harm the environment in a manner inconsistent with local, state,
|
243
|
+
national, or international law.
|
244
|
+
|
245
|
+
* 3.2. The Licensee SHALL:
|
246
|
+
|
247
|
+
* 3.2.1. Social Auditing: Only use social auditing mechanisms that adhere to
|
248
|
+
Worker-Driven Social Responsibility Network’s Statement of Principles
|
249
|
+
(https://wsr-network.org/what-is-wsr/statement-of-principles/
|
250
|
+
[https://wsr-network.org/what-is-wsr/statement-of-principles/]) over
|
251
|
+
traditional social auditing mechanisms, to the extent the Licensee uses
|
252
|
+
any social auditing mechanisms at all;
|
253
|
+
|
254
|
+
* 3.2.2. Workers on Board of Directors: Ensure that if the Licensee has a
|
255
|
+
Board of Directors, 30% of Licensee’s board seats are held by Workers paid
|
256
|
+
no more than 200% of the compensation of the lowest paid Worker of the
|
257
|
+
Licensee;
|
258
|
+
|
259
|
+
* 3.2.3. Supply Chain: Provide clear, accessible supply chain data to the
|
260
|
+
public in accordance with the following conditions:
|
261
|
+
|
262
|
+
* 3.2.3.1. All data will be on Licensee’s website and/or, to the extent
|
263
|
+
Licensee is a representative, agent, affiliate, successor, attorney,
|
264
|
+
subsidiary, or assign, on Licensee’s principal’s or parent’s website or
|
265
|
+
some other online platform accessible to the public via an internet
|
266
|
+
search on a common internet search engine; and
|
267
|
+
|
268
|
+
* 3.2.3.2. Data published will include, where applicable, manufacturers,
|
269
|
+
top tier suppliers, subcontractors, cooperatives, component parts
|
270
|
+
producers, and farms;
|
271
|
+
|
272
|
+
* 3.2.4. Provide equal pay for equal work where the performance of such work
|
273
|
+
requires equal skill, effort, and responsibility, and which are performed
|
274
|
+
under similar working conditions, except where such payment is made
|
275
|
+
pursuant to:
|
276
|
+
|
277
|
+
* 3.2.4.1. A seniority system;
|
278
|
+
|
279
|
+
* 3.2.4.2. A merit system;
|
280
|
+
|
281
|
+
* 3.2.4.3. A system which measures earnings by quantity or quality of
|
282
|
+
production; or
|
283
|
+
|
284
|
+
* 3.2.4.4. A differential based on any other factor other than sex, gender,
|
285
|
+
sexual orientation, race, ethnicity, nationality, religion, caste, age,
|
286
|
+
medical disability or impairment, and/or any other like circumstances
|
287
|
+
(See 29 U.S.C.A. § 206(d)(1); Article 23, United Nations Universal
|
288
|
+
Declaration of Human Rights; Article 7, International Covenant on
|
289
|
+
Economic, Social and Cultural Rights; Article 26, International Covenant
|
290
|
+
on Civil and Political Rights); and
|
291
|
+
|
292
|
+
* 3.2.5. Allow for reasonable limitation of working hours and periodic
|
293
|
+
holidays with pay (See Article 24, United Nations Universal Declaration of
|
294
|
+
Human Rights; Article 7, International Covenant on Economic, Social and
|
295
|
+
Cultural Rights).
|
296
|
+
|
297
|
+
4. SUPPLY CHAIN IMPACTED PARTIES:
|
298
|
+
|
299
|
+
This section identifies additional individuals or entities that a Licensee could
|
300
|
+
harm as a result of violating the Ethical Standards section, the condition that
|
301
|
+
the Licensee must voluntarily accept a Duty of Care for those individuals or
|
302
|
+
entities, and the right to a private right of action that those individuals or
|
303
|
+
entities possess as a result of violations of the Ethical Standards section.
|
304
|
+
|
305
|
+
4.1. In addition to the above Ethical Standards, Licensee voluntarily accepts a
|
306
|
+
Duty of Care for Supply Chain Impacted Parties of this License, including
|
307
|
+
individuals and communities impacted by violations of the Ethical Standards. The
|
308
|
+
Duty of Care is breached when a provision within the Ethical Standards section
|
309
|
+
is violated by a Licensee, one of its successors or assigns, or by an individual
|
310
|
+
or entity that exists within the Supply Chain prior to a good or service
|
311
|
+
reaching the Licensee.
|
312
|
+
|
313
|
+
4.2. Breaches of the Duty of Care, as stated within this section, shall create a
|
314
|
+
private right of action, allowing any Supply Chain Impacted Party harmed by the
|
315
|
+
Licensee to take legal action against the Licensee in accordance with applicable
|
316
|
+
negligence laws, whether they be in tort law, delict law, and/or similar bodies
|
317
|
+
of law closely related to tort and/or delict law, regardless if Licensee is
|
318
|
+
directly responsible for the harms suffered by a Supply Chain Impacted Party.
|
319
|
+
Nothing in this section shall be interpreted to include acts committed by
|
320
|
+
individuals outside of the scope of his/her/their employment.
|
321
|
+
|
322
|
+
5. NOTICE: This section explains when a Licensee must notify others of the
|
323
|
+
License.
|
324
|
+
|
325
|
+
5.1. Distribution of Notice: Licensee must ensure that everyone who receives a
|
326
|
+
copy of or uses any part of Software from Licensee, with or without changes,
|
327
|
+
also receives the License and the copyright notice included with Software (and
|
328
|
+
if included by the Licensor, patent, trademark, and attribution notice).
|
329
|
+
Licensee must ensure that License is prominently displayed so that any
|
330
|
+
individual or entity seeking to download, copy, use, or otherwise receive any
|
331
|
+
part of Software from Licensee is notified of this License and its terms and
|
332
|
+
conditions. Licensee must cause any modified versions of the Software to carry
|
333
|
+
prominent notices stating that Licensee changed the Software.
|
334
|
+
|
335
|
+
5.2. Modified Software: Licensee is free to create modifications of the Software
|
336
|
+
and distribute only the modified portion created by Licensee, however, any
|
337
|
+
derivative work stemming from the Software or its code must be distributed
|
338
|
+
pursuant to this License, including this Notice provision.
|
339
|
+
|
340
|
+
5.3. Recipients as Licensees: Any individual or entity that uses, copies,
|
341
|
+
modifies, reproduces, distributes, or prepares derivative work based upon the
|
342
|
+
Software, all or part of the Software’s code, or a derivative work developed by
|
343
|
+
using the Software, including a portion of its code, is a Licensee as defined
|
344
|
+
above and is subject to the terms and conditions of this License.
|
345
|
+
|
346
|
+
6. REPRESENTATIONS AND WARRANTIES:
|
347
|
+
|
348
|
+
6.1. Disclaimer of Warranty: TO THE FULL EXTENT ALLOWED BY LAW, THIS SOFTWARE
|
349
|
+
COMES “AS IS,” WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED, AND LICENSOR SHALL NOT
|
350
|
+
BE LIABLE TO ANY PERSON OR ENTITY FOR ANY DAMAGES OR OTHER LIABILITY ARISING
|
351
|
+
FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THIS LICENSE, UNDER ANY
|
352
|
+
LEGAL CLAIM.
|
353
|
+
|
354
|
+
6.2. Limitation of Liability: LICENSEE SHALL HOLD LICENSOR HARMLESS AGAINST ANY
|
355
|
+
AND ALL CLAIMS, DEBTS, DUES, LIABILITIES, LIENS, CAUSES OF ACTION, DEMANDS,
|
356
|
+
OBLIGATIONS, DISPUTES, DAMAGES, LOSSES, EXPENSES, ATTORNEYS' FEES, COSTS,
|
357
|
+
LIABILITIES, AND ALL OTHER CLAIMS OF EVERY KIND AND NATURE WHATSOEVER, WHETHER
|
358
|
+
KNOWN OR UNKNOWN, ANTICIPATED OR UNANTICIPATED, FORESEEN OR UNFORESEEN, ACCRUED
|
359
|
+
OR UNACCRUED, DISCLOSED OR UNDISCLOSED, ARISING OUT OF OR RELATING TO LICENSEE’S
|
360
|
+
USE OF THE SOFTWARE. NOTHING IN THIS SECTION SHOULD BE INTERPRETED TO REQUIRE
|
361
|
+
LICENSEE TO INDEMNIFY LICENSOR, NOR REQUIRE LICENSOR TO INDEMNIFY LICENSEE.
|
362
|
+
|
363
|
+
7. TERMINATION
|
364
|
+
|
365
|
+
7.1. Violations of Ethical Standards or Breaching Duty of Care: If Licensee
|
366
|
+
violates the Ethical Standards section or Licensee, or any other person or
|
367
|
+
entity within the Supply Chain prior to a good or service reaching the Licensee,
|
368
|
+
breaches its Duty of Care to Supply Chain Impacted Parties, Licensee must remedy
|
369
|
+
the violation or harm caused by Licensee within 30 days of being notified of the
|
370
|
+
violation or harm. If Licensee fails to remedy the violation or harm within 30
|
371
|
+
days, all rights in the Software granted to Licensee by License will be null and
|
372
|
+
void as between Licensor and Licensee.
|
373
|
+
|
374
|
+
7.2. Failure of Notice: If any person or entity notifies Licensee in writing
|
375
|
+
that Licensee has not complied with the Notice section of this License, Licensee
|
376
|
+
can keep this License by taking all practical steps to comply within 30 days
|
377
|
+
after the notice of noncompliance. If Licensee does not do so, Licensee’s
|
378
|
+
License (and all rights licensed hereunder) will end immediately.
|
379
|
+
|
380
|
+
7.3. Judicial Findings: In the event Licensee is found by a civil, criminal,
|
381
|
+
administrative, or other court of competent jurisdiction, or some other
|
382
|
+
adjudicating body with legal authority, to have committed actions which are in
|
383
|
+
violation of the Ethical Standards or Supply Chain Impacted Party sections of
|
384
|
+
this License, all rights granted to Licensee by this License will terminate
|
385
|
+
immediately.
|
386
|
+
|
387
|
+
7.4. Patent Litigation: If Licensee institutes patent litigation against any
|
388
|
+
entity (including a cross-claim or counterclaim in a suit) alleging that the
|
389
|
+
Software, all or part of the Software’s code, or a derivative work developed
|
390
|
+
using the Software, including a portion of its code, constitutes direct or
|
391
|
+
contributory patent infringement, then any patent license, along with all other
|
392
|
+
rights, granted to Licensee under this License will terminate as of the date
|
393
|
+
such litigation is filed.
|
394
|
+
|
395
|
+
7.5. Additional Remedies: Termination of the License by failing to remedy harms
|
396
|
+
in no way prevents Licensor or Supply Chain Impacted Party from seeking
|
397
|
+
appropriate remedies at law or in equity.
|
398
|
+
|
399
|
+
8. MISCELLANEOUS:
|
400
|
+
|
401
|
+
8.1. Conditions: Sections 3, 4.1, 5.1, 5.2, 7.1, 7.2, 7.3, and 7.4 are
|
402
|
+
conditions of the rights granted to Licensee in the License.
|
403
|
+
|
404
|
+
8.2. Equitable Relief: Licensor and any Supply Chain Impacted Party shall be
|
405
|
+
entitled to equitable relief, including injunctive relief or specific
|
406
|
+
performance of the terms hereof, in addition to any other remedy to which they
|
407
|
+
are entitled at law or in equity.
|
408
|
+
|
409
|
+
8.3. Copyleft: Modified software, source code, or other derivative work must be
|
410
|
+
licensed, in its entirety, under the exact same conditions as this License.
|
411
|
+
|
412
|
+
8.4. Severability: If any term or provision of this License is determined to be
|
413
|
+
invalid, illegal, or unenforceable by a court of competent jurisdiction, any
|
414
|
+
such determination of invalidity, illegality, or unenforceability shall not
|
415
|
+
affect any other term or provision of this License or invalidate or render
|
416
|
+
unenforceable such term or provision in any other jurisdiction. If the
|
417
|
+
determination of invalidity, illegality, or unenforceability by a court of
|
418
|
+
competent jurisdiction pertains to the terms or provisions contained in the
|
419
|
+
Ethical Standards section of this License, all rights in the Software granted to
|
420
|
+
Licensee shall be deemed null and void as between Licensor and Licensee.
|
421
|
+
|
422
|
+
8.5. Section Titles: Section titles are solely written for organizational
|
423
|
+
purposes and should not be used to interpret the language within each section.
|
424
|
+
|
425
|
+
8.6. Citations: Citations are solely written to provide context for the source
|
426
|
+
of the provisions in the Ethical Standards.
|
427
|
+
|
428
|
+
8.7. Section Summaries: Some sections have a brief italicized description which
|
429
|
+
is provided for the sole purpose of briefly describing the section and should
|
430
|
+
not be used to interpret the terms of the License.
|
431
|
+
|
432
|
+
8.8. Entire License: This is the entire License between the Licensor and
|
433
|
+
Licensee with respect to the claims released herein and that the consideration
|
434
|
+
stated herein is the only consideration or compensation to be paid or exchanged
|
435
|
+
between them for this License. This License cannot be modified or amended except
|
436
|
+
in a writing signed by Licensor and Licensee.
|
437
|
+
|
438
|
+
8.9. Successors and Assigns: This License shall be binding upon and inure to the
|
439
|
+
benefit of the Licensor’s and Licensee’s respective heirs, successors, and
|
440
|
+
assigns.
|
data/README.md
CHANGED
@@ -1,10 +1,5 @@
|
|
1
1
|
# smart_params
|
2
2
|
|
3
|
-
- [![Build](http://img.shields.io/travis-ci/krainboltgreene/smart_params.svg?style=flat-square)](https://travis-ci.org/krainboltgreene/smart_params.rb)
|
4
|
-
- [![Downloads](http://img.shields.io/gem/dtv/smart_params.svg?style=flat-square)](https://rubygems.org/gems/smart_params)
|
5
|
-
- [![Version](http://img.shields.io/gem/v/smart_params.svg?style=flat-square)](https://rubygems.org/gems/smart_params)
|
6
|
-
|
7
|
-
|
8
3
|
Work smart, not strong. This gem gives developers an easy to understand and easy to maintain schema for request parameters. Meant as a drop-in replacement for strong_params.
|
9
4
|
|
10
5
|
|
@@ -109,11 +104,11 @@ For more information on what types and options you can use, please read: http://
|
|
109
104
|
|
110
105
|
Okay so sure strong_params exists and it's definitely better than `attr_accessible` (if you remember that mess), but it often leaves you with code like this:
|
111
106
|
|
112
|
-
https://github.com/diaspora/diaspora/blob/
|
107
|
+
https://github.com/diaspora/diaspora/blob/744f5449fb7bfd1ac2bfd50d2e157d97c77a3bca/app/controllers/users_controller.rb#L132
|
113
108
|
|
114
109
|
Which while fine to start with usually evolves into:
|
115
110
|
|
116
|
-
https://github.com/discourse/discourse/blob/
|
111
|
+
https://github.com/discourse/discourse/blob/82a56334a3099297d14e1a0355e8ad19e61631e3/app/controllers/application_controller.rb#L565
|
117
112
|
|
118
113
|
None of this is very maintainable and it's definitely not easy to teach. So my solution is to follow the wake of other libraries: Define a maintainable interface that can be easily tested and easily integrated. It doesn't require wholesale adoption nor is it hard to remove.
|
119
114
|
|
@@ -130,13 +125,9 @@ Your model is already complex enough and it doesn't need the added baggage of fi
|
|
130
125
|
|
131
126
|
## Installing
|
132
127
|
|
133
|
-
|
134
|
-
|
135
|
-
gem "smart_params", "2.0.7"
|
136
|
-
|
137
|
-
And then execute:
|
128
|
+
Run this command:
|
138
129
|
|
139
|
-
$ bundle
|
130
|
+
$ bundle add smart_params
|
140
131
|
|
141
132
|
Or install it yourself with:
|
142
133
|
|
@@ -145,7 +136,7 @@ Or install it yourself with:
|
|
145
136
|
|
146
137
|
## Contributing
|
147
138
|
|
148
|
-
1. Read the [Code of Conduct](/CONDUCT
|
139
|
+
1. Read the [Code of Conduct](/CONDUCT)
|
149
140
|
2. Fork it
|
150
141
|
3. Create your feature branch (`git checkout -b my-new-feature`)
|
151
142
|
4. Test your code: `rake spec`
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SmartParams
|
2
4
|
class Error
|
3
5
|
class InvalidPropertyType < Error
|
@@ -6,6 +8,7 @@ module SmartParams
|
|
6
8
|
attr_reader :raw
|
7
9
|
|
8
10
|
def initialize(keychain:, wanted:, raw:)
|
11
|
+
super
|
9
12
|
@keychain = keychain
|
10
13
|
@wanted = wanted
|
11
14
|
@raw = raw
|
data/lib/smart_params/error.rb
CHANGED
data/lib/smart_params/field.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SmartParams
|
2
4
|
class Field
|
3
5
|
attr_reader :keychain
|
@@ -12,20 +14,21 @@ module SmartParams
|
|
12
14
|
@specified = false
|
13
15
|
@dirty = false
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
17
|
+
return unless nesting
|
18
|
+
|
19
|
+
instance_eval(&nesting)
|
18
20
|
end
|
19
21
|
|
20
22
|
def deep?
|
21
23
|
# We check @specified directly because we want to know if ANY
|
22
24
|
# subfields have been passed, not just ones that match the schema.
|
23
|
-
return false if nullable? &&
|
25
|
+
return false if nullable? && @specified
|
26
|
+
|
24
27
|
subfields.present?
|
25
28
|
end
|
26
29
|
|
27
30
|
def root?
|
28
|
-
keychain.
|
31
|
+
keychain.empty?
|
29
32
|
end
|
30
33
|
|
31
34
|
def value
|
@@ -53,23 +56,24 @@ module SmartParams
|
|
53
56
|
|
54
57
|
def clean?
|
55
58
|
return false if dirty?
|
56
|
-
return true if empty? || subfields.
|
59
|
+
return true if empty? || subfields.reject(&:empty?).any?
|
60
|
+
|
57
61
|
false
|
58
62
|
end
|
59
63
|
|
60
64
|
# Check if we should consider this value even when empty.
|
61
65
|
def allow_empty?
|
62
66
|
return true if specified? && nullable?
|
63
|
-
|
64
|
-
|
67
|
+
|
68
|
+
subfields.any?(&:allow_empty?)
|
65
69
|
end
|
66
70
|
|
67
71
|
def claim(raw)
|
68
72
|
return type[dug(raw)] if deep?
|
69
73
|
|
70
74
|
@value = type[dug(raw)]
|
71
|
-
rescue Dry::Types::ConstraintError
|
72
|
-
raise SmartParams::Error::InvalidPropertyType
|
75
|
+
rescue Dry::Types::ConstraintError
|
76
|
+
raise SmartParams::Error::InvalidPropertyType.new(keychain:, wanted: type, raw: keychain.empty? ? raw : raw.dig(*keychain))
|
73
77
|
end
|
74
78
|
|
75
79
|
def to_hash
|
@@ -92,10 +96,8 @@ module SmartParams
|
|
92
96
|
end
|
93
97
|
|
94
98
|
private def field(key, type:, nullable: false, &subfield)
|
95
|
-
if nullable
|
96
|
-
|
97
|
-
end
|
98
|
-
@subfields << self.class.new(keychain: [*keychain, key], type: type, nullable: nullable, &subfield)
|
99
|
+
type |= SmartParams::Strict::Nil if nullable
|
100
|
+
@subfields << self.class.new(keychain: [*keychain, key], type:, nullable:, &subfield)
|
99
101
|
end
|
100
102
|
|
101
103
|
# Very busy method with recent changes. TODO: clean-up
|
@@ -107,7 +109,7 @@ module SmartParams
|
|
107
109
|
if nullable?
|
108
110
|
hash = raw.dig(*keychain)
|
109
111
|
if hash.respond_to?(:keys)
|
110
|
-
others =
|
112
|
+
others = hash.keys - [keychain.last]
|
111
113
|
@dirty = others.any?
|
112
114
|
end
|
113
115
|
end
|
@@ -116,14 +118,14 @@ module SmartParams
|
|
116
118
|
# input hash.
|
117
119
|
at = raw
|
118
120
|
exact = true
|
119
|
-
keychain.each
|
121
|
+
keychain.each do |key|
|
120
122
|
if at.respond_to?(:key?) && at.key?(key)
|
121
123
|
at = at[key]
|
122
124
|
else
|
123
125
|
exact = false
|
124
126
|
break
|
125
127
|
end
|
126
|
-
|
128
|
+
end
|
127
129
|
@specified = exact
|
128
130
|
|
129
131
|
raw.dig(*keychain)
|
data/lib/smart_params/version.rb
CHANGED
data/lib/smart_params.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "dry-types"
|
2
4
|
require "recursive-open-struct"
|
3
5
|
require "active_support/concern"
|
@@ -20,11 +22,12 @@ module SmartParams
|
|
20
22
|
@safe = safe
|
21
23
|
@raw = raw
|
22
24
|
@schema = self.class.instance_variable_get(:@schema)
|
25
|
+
|
23
26
|
@fields = [@schema, *unfold(@schema.subfields)].sort_by(&:weight).each { |field| field.claim(raw) }
|
24
|
-
rescue SmartParams::Error::InvalidPropertyType =>
|
25
|
-
raise
|
27
|
+
rescue SmartParams::Error::InvalidPropertyType => e
|
28
|
+
raise e if safe?
|
26
29
|
|
27
|
-
@exception =
|
30
|
+
@exception = e
|
28
31
|
end
|
29
32
|
|
30
33
|
def payload
|
@@ -42,7 +45,7 @@ module SmartParams
|
|
42
45
|
structure.as_json(options) || {}
|
43
46
|
end
|
44
47
|
end
|
45
|
-
|
48
|
+
alias as_json to_hash
|
46
49
|
|
47
50
|
delegate :[], to: :to_hash
|
48
51
|
delegate :fetch, to: :to_hash
|
@@ -57,7 +60,9 @@ module SmartParams
|
|
57
60
|
delegate :dig, to: :to_hash
|
58
61
|
delegate :to_s, to: :to_hash
|
59
62
|
|
60
|
-
def
|
63
|
+
def respond_to_missing? = true
|
64
|
+
|
65
|
+
def method_missing(name, *arguments, &)
|
61
66
|
if payload.respond_to?(name)
|
62
67
|
payload.public_send(name)
|
63
68
|
else
|
@@ -77,7 +82,7 @@ module SmartParams
|
|
77
82
|
private def unfold(subfields)
|
78
83
|
subfields.to_a.reduce([]) do |list, field|
|
79
84
|
if field.deep?
|
80
|
-
[*list, field, *unfold(field.subfields)]
|
85
|
+
[*list, field, *unfold(field.subfields.to_a)]
|
81
86
|
else
|
82
87
|
[*list, field]
|
83
88
|
end
|
@@ -90,7 +95,7 @@ module SmartParams
|
|
90
95
|
|
91
96
|
class_methods do
|
92
97
|
def schema(type:, &subfield)
|
93
|
-
@schema = Field.new(keychain: [], type
|
98
|
+
@schema = Field.new(keychain: [], type:, &subfield)
|
94
99
|
end
|
95
100
|
end
|
96
101
|
end
|
data/lib/smart_params_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
RSpec.describe SmartParams do
|
@@ -10,25 +12,25 @@ RSpec.describe SmartParams do
|
|
10
12
|
let(:params) { {} }
|
11
13
|
|
12
14
|
it "throws an error with a message detailing the invalid property type and given properties" do
|
13
|
-
expect {schema}.to raise_exception(SmartParams::Error::InvalidPropertyType, "expected [:data] to be Hash, but was nil")
|
15
|
+
expect { schema }.to raise_exception(SmartParams::Error::InvalidPropertyType, "expected [:data] to be Hash, but was nil")
|
14
16
|
end
|
15
17
|
|
16
18
|
it "throws an error with the missing property and given properties" do
|
17
|
-
expect {schema}.to raise_exception do |exception|
|
19
|
+
expect { schema }.to raise_exception do |exception|
|
18
20
|
expect(exception).to have_attributes(keychain: [:data], wanted: SmartParams::Strict::Hash, raw: nil)
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
23
25
|
context "with a good key but bad type" do
|
24
|
-
let(:params) { {data: ""} }
|
26
|
+
let(:params) { { data: "" } }
|
25
27
|
|
26
28
|
it "throws an error with a message detailing the invalid property, expected type, given type, and given value" do
|
27
29
|
expect { schema }.to raise_exception(SmartParams::Error::InvalidPropertyType, "expected [:data] to be Hash, but was \"\"")
|
28
30
|
end
|
29
31
|
|
30
32
|
it "throws an error with the invalid property, expected type, given type, and given value" do
|
31
|
-
expect {schema }.to raise_exception do |exception|
|
33
|
+
expect { schema }.to raise_exception do |exception|
|
32
34
|
expect(exception).to have_attributes(keychain: [:data], wanted: SmartParams::Strict::Hash, raw: "")
|
33
35
|
end
|
34
36
|
end
|
@@ -36,7 +38,7 @@ RSpec.describe SmartParams do
|
|
36
38
|
end
|
37
39
|
|
38
40
|
describe "#payload" do
|
39
|
-
subject {schema.payload}
|
41
|
+
subject { schema.payload }
|
40
42
|
|
41
43
|
context "with a reasonably good params" do
|
42
44
|
let(:params) do
|
@@ -57,7 +59,7 @@ RSpec.describe SmartParams do
|
|
57
59
|
id: "a",
|
58
60
|
type: "widget",
|
59
61
|
attributes: {
|
60
|
-
title: "Widget A"
|
62
|
+
title: "Widget A"
|
61
63
|
}
|
62
64
|
}
|
63
65
|
}
|
@@ -74,7 +76,7 @@ RSpec.describe SmartParams do
|
|
74
76
|
end
|
75
77
|
|
76
78
|
it "has a chain path data.attributes.password" do
|
77
|
-
expect(subject.data.attributes.password).to
|
79
|
+
expect(subject.data.attributes.password).to be_a(String)
|
78
80
|
end
|
79
81
|
|
80
82
|
it "has a chain path meta.jsonapi_version" do
|
@@ -108,11 +110,11 @@ RSpec.describe SmartParams do
|
|
108
110
|
"type" => "accounts",
|
109
111
|
"attributes" => hash_including(
|
110
112
|
{
|
111
|
-
"email" => "kurtis@example.com"
|
113
|
+
"email" => "kurtis@example.com"
|
112
114
|
}
|
113
115
|
)
|
114
116
|
}
|
115
|
-
)
|
117
|
+
)
|
116
118
|
}
|
117
119
|
)
|
118
120
|
end
|
@@ -146,7 +148,7 @@ RSpec.describe SmartParams do
|
|
146
148
|
}
|
147
149
|
)
|
148
150
|
}
|
149
|
-
)
|
151
|
+
)
|
150
152
|
}
|
151
153
|
)
|
152
154
|
end
|
@@ -171,7 +173,7 @@ RSpec.describe SmartParams do
|
|
171
173
|
id: "a",
|
172
174
|
type: "widget",
|
173
175
|
attributes: {
|
174
|
-
title: "Widget A"
|
176
|
+
title: "Widget A"
|
175
177
|
}
|
176
178
|
}
|
177
179
|
}
|
@@ -218,19 +220,19 @@ RSpec.describe SmartParams do
|
|
218
220
|
end
|
219
221
|
|
220
222
|
describe "#to_hash" do
|
221
|
-
subject {schema.to_hash}
|
223
|
+
subject { schema.to_hash }
|
222
224
|
|
223
225
|
include_examples "native types"
|
224
226
|
end
|
225
227
|
|
226
228
|
describe "#as_json" do
|
227
|
-
subject {schema.as_json}
|
229
|
+
subject { schema.as_json }
|
228
230
|
|
229
231
|
include_examples "native types"
|
230
232
|
end
|
231
233
|
|
232
234
|
describe "#fetch" do
|
233
|
-
subject {schema.fetch("data")}
|
235
|
+
subject { schema.fetch("data") }
|
234
236
|
|
235
237
|
context "with a reasonably good params" do
|
236
238
|
let(:params) do
|
@@ -251,7 +253,7 @@ RSpec.describe SmartParams do
|
|
251
253
|
id: "a",
|
252
254
|
type: "widget",
|
253
255
|
attributes: {
|
254
|
-
title: "Widget A"
|
256
|
+
title: "Widget A"
|
255
257
|
}
|
256
258
|
}
|
257
259
|
}
|
@@ -280,7 +282,7 @@ RSpec.describe SmartParams do
|
|
280
282
|
end
|
281
283
|
|
282
284
|
describe "#dig" do
|
283
|
-
subject {schema.dig("data", "attributes", "email")}
|
285
|
+
subject { schema.dig("data", "attributes", "email") }
|
284
286
|
|
285
287
|
context "with a reasonably good params" do
|
286
288
|
let(:params) do
|
@@ -300,7 +302,7 @@ RSpec.describe SmartParams do
|
|
300
302
|
id: "a",
|
301
303
|
type: "widget",
|
302
304
|
attributes: {
|
303
|
-
title: "Widget A"
|
305
|
+
title: "Widget A"
|
304
306
|
}
|
305
307
|
}
|
306
308
|
}
|
@@ -319,7 +321,7 @@ RSpec.describe SmartParams do
|
|
319
321
|
end
|
320
322
|
|
321
323
|
describe "#fetch_values" do
|
322
|
-
subject {schema.fetch_values("data", "meta")}
|
324
|
+
subject { schema.fetch_values("data", "meta") }
|
323
325
|
|
324
326
|
context "with a reasonably good params" do
|
325
327
|
let(:params) do
|
@@ -340,7 +342,7 @@ RSpec.describe SmartParams do
|
|
340
342
|
id: "a",
|
341
343
|
type: "widget",
|
342
344
|
attributes: {
|
343
|
-
title: "Widget A"
|
345
|
+
title: "Widget A"
|
344
346
|
}
|
345
347
|
}
|
346
348
|
}
|
@@ -376,8 +378,8 @@ RSpec.describe SmartParams do
|
|
376
378
|
end
|
377
379
|
|
378
380
|
describe "nullable values" do
|
379
|
-
context "set to nil" do
|
380
|
-
subject {nullable_schema.to_hash}
|
381
|
+
context "when set to nil" do
|
382
|
+
subject { nullable_schema.to_hash }
|
381
383
|
|
382
384
|
let(:params) do
|
383
385
|
{
|
@@ -398,8 +400,8 @@ RSpec.describe SmartParams do
|
|
398
400
|
end
|
399
401
|
end
|
400
402
|
|
401
|
-
context "provided matching data" do
|
402
|
-
subject {nullable_schema.to_hash}
|
403
|
+
context "when provided matching data" do
|
404
|
+
subject { nullable_schema.to_hash }
|
403
405
|
|
404
406
|
let(:params) do
|
405
407
|
{
|
@@ -428,12 +430,11 @@ RSpec.describe SmartParams do
|
|
428
430
|
end
|
429
431
|
end
|
430
432
|
|
431
|
-
context "not provided" do
|
432
|
-
subject {nullable_schema.to_hash}
|
433
|
+
context "when not provided" do
|
434
|
+
subject { nullable_schema.to_hash }
|
433
435
|
|
434
436
|
let(:params) do
|
435
|
-
{
|
436
|
-
}
|
437
|
+
{}
|
437
438
|
end
|
438
439
|
|
439
440
|
it "does not set nil relationship" do
|
@@ -450,7 +451,7 @@ RSpec.describe SmartParams do
|
|
450
451
|
end
|
451
452
|
|
452
453
|
context "with non matching subfield data" do
|
453
|
-
subject {nullable_schema.to_hash}
|
454
|
+
subject { nullable_schema.to_hash }
|
454
455
|
|
455
456
|
let(:params) do
|
456
457
|
{
|
@@ -473,28 +474,28 @@ RSpec.describe SmartParams do
|
|
473
474
|
end
|
474
475
|
end
|
475
476
|
|
476
|
-
context "specified with unclean data" do
|
477
|
-
subject {nullable_required_subfield_schema.to_hash}
|
477
|
+
context "when specified with unclean data" do
|
478
|
+
subject { nullable_required_subfield_schema.to_hash }
|
478
479
|
|
479
480
|
let(:params) do
|
480
481
|
{
|
481
482
|
# This will raise an exception becase the data hash is specified
|
482
483
|
# but its required subfields are not.
|
483
484
|
data: {
|
484
|
-
is:
|
485
|
+
is: "garbage"
|
485
486
|
}
|
486
487
|
}
|
487
488
|
end
|
488
489
|
|
489
490
|
it "checks subfields" do
|
490
|
-
expect
|
491
|
+
expect do
|
491
492
|
subject
|
492
|
-
|
493
|
+
end.to raise_exception(SmartParams::Error::InvalidPropertyType)
|
493
494
|
end
|
494
495
|
end
|
495
496
|
|
496
|
-
context "specified as null" do
|
497
|
-
subject {nullable_required_subfield_schema.to_hash}
|
497
|
+
context "when specified as null" do
|
498
|
+
subject { nullable_required_subfield_schema.to_hash }
|
498
499
|
|
499
500
|
let(:params) do
|
500
501
|
{
|
@@ -505,14 +506,14 @@ RSpec.describe SmartParams do
|
|
505
506
|
end
|
506
507
|
|
507
508
|
it "checks subfields" do
|
508
|
-
expect
|
509
|
+
expect do
|
509
510
|
subject
|
510
|
-
|
511
|
+
end.not_to raise_exception
|
511
512
|
end
|
512
513
|
end
|
513
514
|
|
514
|
-
context "unspecified with required subfield" do
|
515
|
-
subject {nullable_required_subfield_schema.to_hash}
|
515
|
+
context "when unspecified with required subfield" do
|
516
|
+
subject { nullable_required_subfield_schema.to_hash }
|
516
517
|
|
517
518
|
let(:params) do
|
518
519
|
{
|
@@ -522,9 +523,9 @@ RSpec.describe SmartParams do
|
|
522
523
|
end
|
523
524
|
|
524
525
|
it "allows null value" do
|
525
|
-
expect
|
526
|
+
expect do
|
526
527
|
subject
|
527
|
-
|
528
|
+
end.not_to raise_exception
|
528
529
|
end
|
529
530
|
end
|
530
531
|
end
|
metadata
CHANGED
@@ -1,145 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_params
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kurtis Rainbolt-Greene
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2.0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '2.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rspec
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '3.7'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '3.7'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '12.2'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '12.2'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: pry
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.11'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0.11'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: pry-doc
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0.11'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0.11'
|
83
13
|
- !ruby/object:Gem::Dependency
|
84
14
|
name: activesupport
|
85
15
|
requirement: !ruby/object:Gem::Requirement
|
86
16
|
requirements:
|
87
17
|
- - ">="
|
88
18
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
90
|
-
- - ">="
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
version: '4.1'
|
93
|
-
- - ">="
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: 5.0.0
|
96
|
-
- - ">="
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
version: '5.2'
|
19
|
+
version: '0'
|
99
20
|
type: :runtime
|
100
21
|
prerelease: false
|
101
22
|
version_requirements: !ruby/object:Gem::Requirement
|
102
23
|
requirements:
|
103
24
|
- - ">="
|
104
25
|
- !ruby/object:Gem::Version
|
105
|
-
version:
|
106
|
-
- - ">="
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
version: '4.1'
|
109
|
-
- - ">="
|
110
|
-
- !ruby/object:Gem::Version
|
111
|
-
version: 5.0.0
|
112
|
-
- - ">="
|
113
|
-
- !ruby/object:Gem::Version
|
114
|
-
version: '5.2'
|
26
|
+
version: '0'
|
115
27
|
- !ruby/object:Gem::Dependency
|
116
28
|
name: dry-types
|
117
29
|
requirement: !ruby/object:Gem::Requirement
|
118
30
|
requirements:
|
119
|
-
- - "
|
31
|
+
- - ">="
|
120
32
|
- !ruby/object:Gem::Version
|
121
|
-
version: '
|
33
|
+
version: '0'
|
122
34
|
type: :runtime
|
123
35
|
prerelease: false
|
124
36
|
version_requirements: !ruby/object:Gem::Requirement
|
125
37
|
requirements:
|
126
|
-
- - "
|
38
|
+
- - ">="
|
127
39
|
- !ruby/object:Gem::Version
|
128
|
-
version: '
|
40
|
+
version: '0'
|
129
41
|
- !ruby/object:Gem::Dependency
|
130
42
|
name: recursive-open-struct
|
131
43
|
requirement: !ruby/object:Gem::Requirement
|
132
44
|
requirements:
|
133
|
-
- - "
|
45
|
+
- - ">="
|
134
46
|
- !ruby/object:Gem::Version
|
135
|
-
version: '
|
47
|
+
version: '0'
|
136
48
|
type: :runtime
|
137
49
|
prerelease: false
|
138
50
|
version_requirements: !ruby/object:Gem::Requirement
|
139
51
|
requirements:
|
140
|
-
- - "
|
52
|
+
- - ">="
|
141
53
|
- !ruby/object:Gem::Version
|
142
|
-
version: '
|
54
|
+
version: '0'
|
143
55
|
description: Apply an organized and easy to maintain schema to request params
|
144
56
|
email:
|
145
57
|
- kurtis@rainbolt-greene.online
|
@@ -147,6 +59,7 @@ executables: []
|
|
147
59
|
extensions: []
|
148
60
|
extra_rdoc_files: []
|
149
61
|
files:
|
62
|
+
- LICENSE
|
150
63
|
- README.md
|
151
64
|
- Rakefile
|
152
65
|
- lib/smart_params.rb
|
@@ -155,29 +68,29 @@ files:
|
|
155
68
|
- lib/smart_params/error/invalid_property_type_spec.rb
|
156
69
|
- lib/smart_params/field.rb
|
157
70
|
- lib/smart_params/version.rb
|
158
|
-
- lib/smart_params/version_spec.rb
|
159
71
|
- lib/smart_params_spec.rb
|
160
|
-
homepage:
|
72
|
+
homepage: https://github.com/krainboltgreene/smart_params.rb
|
161
73
|
licenses:
|
162
|
-
-
|
163
|
-
metadata:
|
164
|
-
|
74
|
+
- HL3
|
75
|
+
metadata:
|
76
|
+
rubygems_mfa_required: 'true'
|
77
|
+
post_install_message:
|
165
78
|
rdoc_options: []
|
166
79
|
require_paths:
|
167
80
|
- lib
|
168
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
169
82
|
requirements:
|
170
|
-
- - "
|
83
|
+
- - "~>"
|
171
84
|
- !ruby/object:Gem::Version
|
172
|
-
version: '
|
85
|
+
version: '3.2'
|
173
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
87
|
requirements:
|
175
88
|
- - ">="
|
176
89
|
- !ruby/object:Gem::Version
|
177
90
|
version: '0'
|
178
91
|
requirements: []
|
179
|
-
rubygems_version: 3.
|
180
|
-
signing_key:
|
92
|
+
rubygems_version: 3.4.10
|
93
|
+
signing_key:
|
181
94
|
specification_version: 4
|
182
95
|
summary: Apply an organized and easy to maintain schema to request params
|
183
96
|
test_files: []
|