refinements 8.5.2 → 9.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b644a4f4754003280ccfcfb7acf3fa4437465597394bc1e372b5333a8b17b84c
4
- data.tar.gz: b81645b91f2f298beccfddc0c16da395d5b127b1951faf9f2601fd25a14f8475
3
+ metadata.gz: 4d3e2ba6964cfd39388a7f055fa830a5654ee264d04b2f519c1a735b922c08a7
4
+ data.tar.gz: f711604bba6cd3809398a5a2f6cb0ec867851538e58355c403a2b26aac4d75e3
5
5
  SHA512:
6
- metadata.gz: 8218cde7644c575f3f1a9b6fc9ba60b9dcafed837816cda0d764920db4ed31198b8b4318f73a10ed92b3e7793f29e073468784414e4d9043a6749d037aed3ab1
7
- data.tar.gz: d666de445357fe098f795bcfcbbaa49214b7aa11273c578b0ee3e49e2a796544d6baf35ce8246075c62b6b9c8f65f447c6f08d717e50eefa2c003c6b4d5ddf31
6
+ metadata.gz: a72da7caf3a0698ae29bce0c51e3ce66829c41ac471e90a0f8777dc0f2e587c79304daf5ffb98983bf6ac50c79afb621d570216e557e550d0771208a039a52ed
7
+ data.tar.gz: ad031fb50b8d0c747d69b856d6e3a41eea74ba7de959bb8bfeda6b17c5b866ef2480fadce96ba50baa9b66c8e2fa6469d82e0a115cfa09a0d645668c2b3a0ef3
checksums.yaml.gz.sig CHANGED
Binary file
data/LICENSE.adoc CHANGED
@@ -1,162 +1,214 @@
1
- = Apache License
1
+ = HIPPOCRATIC LICENSE
2
2
 
3
- Version 2.0, January 2004
4
-
5
- http://www.apache.org/licenses
6
-
7
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
-
9
- == 1. Definitions
3
+ *Version 3.0, October 2021*
10
4
 
11
- "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by
12
- Sections 1 through 9 of this document.
13
-
14
- "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is
15
- granting the License.
16
-
17
- "Legal Entity" shall mean the union of the acting entity and all other entities that control, are
18
- controlled by, or are under common control with that entity. For the purposes of this definition,
19
- "control" means (i) the power, direct or indirect, to cause the direction or management of such
20
- entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
5
+ https://firstdonoharm.dev
22
6
 
23
- "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this
24
- License.
7
+ *TERMS AND CONDITIONS*
25
8
 
26
- "Source" form shall mean the preferred form for making modifications, including but not limited to
27
- software source code, documentation source, and configuration files.
28
-
29
- "Object" form shall mean any form resulting from mechanical transformation or translation of a
30
- Source form, including but not limited to compiled object code, generated documentation, and
31
- conversions to other media types.
9
+ TERMS AND CONDITIONS FOR USE, COPY, MODIFICATION, PREPARATION OF DERIVATIVE WORK, REPRODUCTION, AND DISTRIBUTION:
32
10
 
33
- "Work" shall mean the work of authorship, whether in Source or Object form, made available under the
34
- License, as indicated by a copyright notice that is included in or attached to the work (an example
35
- is provided in the Appendix below).
36
-
37
- "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or
38
- derived from) the Work and for which the editorial revisions, annotations, elaborations, or other
39
- modifications represent, as a whole, an original work of authorship. For the purposes of this
40
- License, Derivative Works shall not include works that remain separable from, or merely link (or
41
- bind by name) to the interfaces of, the Work and Derivative Works thereof.
11
+ == 1. DEFINITIONS
42
12
 
43
- "Contribution" shall mean any work of authorship, including the original version of the Work and any
44
- modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted
45
- to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity
46
- authorized to submit on behalf of the copyright owner. For the purposes of this definition,
47
- "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or
48
- its representatives, including but not limited to communication on electronic mailing lists, source
49
- code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor
50
- for the purpose of discussing and improving the Work, but excluding communication that is
51
- conspicuously marked or otherwise designated in writing by the copyright owner as "Not a
52
- Contribution."
53
-
54
- "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a
55
- Contribution has been received by Licensor and subsequently incorporated within the Work.
56
-
57
- == 2. Grant of Copyright License
13
+ _This section defines certain terms used throughout this license agreement._
58
14
 
59
- Subject to the terms and conditions of this License, each Contributor hereby grants to You a
60
- perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to
61
- reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and
62
- distribute the Work and such Derivative Works in Source or Object form.
63
-
64
- == 3. Grant of Patent License
65
-
66
- Subject to the terms and conditions of this License, each Contributor hereby grants to You a
67
- perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
68
- section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer
69
- the Work, where such license applies only to those patent claims licensable by such Contributor that
70
- are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s)
71
- with the Work to which such Contribution(s) was submitted. If You institute patent litigation
72
- against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or
73
- a Contribution incorporated within the Work constitutes direct or contributory patent infringement,
74
- then any patent licenses granted to You under this License for that Work shall terminate as of the
75
- date such litigation is filed.
76
-
77
- == 4. Redistribution
78
-
79
- You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with
80
- or without modifications, and in Source or Object form, provided that You meet the following
81
- conditions:
82
-
83
- . You must give any other recipients of the Work or Derivative Works a copy of this License; and
84
-
85
- . You must cause any modified files to carry prominent notices stating that You changed the files;
86
- and
87
-
88
- . You must retain, in the Source form of any Derivative Works that You distribute, all copyright,
89
- patent, trademark, and attribution notices from the Source form of the Work, excluding those
90
- notices that do not pertain to any part of the Derivative Works; and
91
-
92
- . If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works
93
- that You distribute must include a readable copy of the attribution notices contained within such
94
- NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in
95
- at least one of the following places: within a NOTICE text file distributed as part of the
96
- Derivative Works; within the Source form or documentation, if provided along with the Derivative
97
- Works; or, within a display generated by the Derivative Works, if and wherever such third-party
98
- notices normally appear. The contents of the NOTICE file are for informational purposes only and
99
- do not modify the License. You may add Your own attribution notices within Derivative Works that
100
- You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such
101
- additional attribution notices cannot be construed as modifying the License.
102
-
103
- You may add Your own copyright statement to Your modifications and may provide additional or
104
- different license terms and conditions for use, reproduction, or distribution of Your modifications,
105
- or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of
106
- the Work otherwise complies with the conditions stated in this License.
107
-
108
- == 5. Submission of Contributions
109
-
110
- Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the
111
- Work by You to the Licensor shall be under the terms and conditions of this License, without any
112
- additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify
113
- the terms of any separate license agreement you may have executed with Licensor regarding such
114
- Contributions.
115
-
116
- == 6. Trademarks
117
-
118
- This License does not grant permission to use the trade names, trademarks, service marks, or product
119
- names of the Licensor, except as required for reasonable and customary use in describing the origin
120
- of the Work and reproducing the content of the NOTICE file.
121
-
122
- == 7. Disclaimer of Warranty
123
-
124
- Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each
125
- Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
126
- KIND, either express or implied, including, without limitation, any warranties or conditions of
127
- TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely
128
- responsible for determining the appropriateness of using or redistributing the Work and assume any
129
- risks associated with Your exercise of permissions under this License.
130
-
131
- == 8. Limitation of Liability
132
-
133
- In no event and under no legal theory, whether in tort (including negligence), contract, or
134
- otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or
135
- agreed to in writing, shall any Contributor be liable to You for damages, including any direct,
136
- indirect, special, incidental, or consequential damages of any character arising as a result of this
137
- License or out of the use or inability to use the Work (including but not limited to damages for
138
- loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial
139
- damages or losses), even if such Contributor has been advised of the possibility of such damages.
140
-
141
- == 9. Accepting Warranty or Additional Liability
142
-
143
- While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee
144
- for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights
145
- consistent with this License. However, in accepting such obligations, You may act only on Your own
146
- behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You
147
- agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or
148
- claims asserted against, such Contributor by reason of your accepting any such warranty or
149
- additional liability.
150
-
151
- END OF TERMS AND CONDITIONS
152
-
153
- Copyright 2015 link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
154
-
155
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
156
- compliance with the License. You may obtain a link:https://www.apache.org/licenses/LICENSE-2.0[copy]
157
- of the License.
158
-
159
- Unless required by applicable law or agreed to in writing, software distributed under the License is
160
- distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
161
- implied. See the License for the specific language governing permissions and limitations under the
162
- License.
15
+ 1.1. "License" means the terms and conditions, as stated herein, for use, copy, modification, preparation of derivative work, reproduction, and distribution of Software (as defined below).
16
+
17
+ 1.2. "Licensor" means the copyright and/or patent owner or entity authorized by the copyright and/or patent owner that is granting the License.
18
+
19
+ 1.3. "Licensee" means the individual or entity exercising permissions granted by this License, including the use, copy, modification, preparation of derivative work, reproduction, and distribution of Software (as defined below).
20
+
21
+ 1.4. "Software" means any copyrighted work, including but not limited to software code, authored by Licensor and made available under this License.
22
+
23
+ 1.5. "Supply Chain" means the sequence of processes involved in the production and/or distribution of a commodity, good, or service offered by the Licensee.
24
+
25
+ 1.6. "Supply Chain Impacted Party" or "Supply Chain Impacted Parties" means any person(s) directly impacted by any of Licensee’s Supply Chain, including the practices of all persons or entities within the Supply Chain prior to a good or service reaching the Licensee.
26
+
27
+ 1.7. "Duty of Care" is defined by its use in tort law, delict law, and/or similar bodies of law closely related to tort and/or delict law, including without limitation, a requirement to act with the watchfulness, attention, caution, and prudence that a reasonable person in the same or similar circumstances would use towards any Supply Chain Impacted Party.
28
+
29
+ 1.8. "Worker" is defined to include any and all permanent, temporary, and agency workers, as well as piece-rate, salaried, hourly paid, legal young (minors), part-time, night, and migrant workers.
30
+
31
+ == 2. INTELLECTUAL PROPERTY GRANTS
32
+
33
+ _This section identifies intellectual property rights granted to a Licensee_.
34
+
35
+ 2.1. _Grant of Copyright License_: Subject to the terms and conditions of this License, Licensor hereby grants to Licensee a worldwide, non-exclusive, no-charge, royalty-free copyright license to use, copy, modify, prepare derivative work, reproduce, or distribute the Software, Licensor authored modified software, or other work derived from the Software.
36
+
37
+ 2.2 _Grant of Patent License_: Subject to the terms and conditions of this License, Licensor hereby grants Licensee a worldwide, non-exclusive, no-charge, royalty-free patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer Software.
38
+
39
+ == 3. ETHICAL STANDARDS
40
+
41
+ _This section lists conditions the Licensee must comply with in order to have rights under this License._
42
+
43
+ The rights granted to the Licensee by this License are expressly made subject to the Licensee’s ongoing compliance with the following conditions:
44
+
45
+ 3.1. The Licensee SHALL NOT, whether directly or indirectly, through agents or assigns:
46
+
47
+ 3.1.1. Infringe upon any person’s right to life or security of person, engage in extrajudicial killings, or commit murder, without lawful cause +
48
+ (See Article 3, _United Nations Universal Declaration of Human Rights_; Article 6, _International Covenant on Civil and Political Rights_)
49
+
50
+ 3.1.2. Hold any person in slavery, servitude, or forced labor +
51
+ (See Article 4, _United Nations Universal Declaration of Human Rights_; Article 8, _International Covenant on Civil and Political Rights_);
52
+
53
+ 3.1.3. Contribute to the institution of slavery, slave trading, forced labor, or unlawful child labor +
54
+ (See Article 4, _United Nations Universal Declaration of Human Rights_; Article 8, _International Covenant on Civil and Political Rights_);
55
+
56
+ 3.1.4. Torture or subject any person to cruel, inhumane, or degrading treatment or punishment +
57
+ (See Article 5, _United Nations Universal Declaration of Human Rights_; Article 7, _International Covenant on Civil and Political Rights_);
58
+
59
+ 3.1.5. Discriminate on the basis of sex, gender, sexual orientation, race, ethnicity, nationality, religion, caste, age, medical disability or impairment, and/or any other like circumstances +
60
+ (See Article 7, _United Nations Universal Declaration of Human Rights_; Article 2, _International Covenant on Economic, Social and Cultural Rights_; Article 26, _International Covenant on Civil and Political Rights_);
61
+
62
+ 3.1.6. Prevent any person from exercising his/her/their right to seek an effective remedy by a competent court or national tribunal (including domestic judicial systems, international courts, arbitration bodies, and other adjudicating bodies) for actions violating the fundamental rights granted to him/her/them by applicable constitutions, applicable laws, or by this License +
63
+ (See Article 8, _United Nations Universal Declaration of Human Rights_; Articles 9 and 14, _International Covenant on Civil and Political Rights_);
64
+
65
+ 3.1.7. Subject any person to arbitrary arrest, detention, or exile +
66
+ (See Article 9, _United Nations Universal Declaration of Human Rights_; Article 9, _International Covenant on Civil and Political Rights_);
67
+
68
+ 3.1.8. Subject any person to arbitrary interference with a person’s privacy, family, home, or correspondence without the express written consent of the person +
69
+ (See Article 12, _United Nations Universal Declaration of Human Rights_; Article 17, _International Covenant on Civil and Political Rights_);
70
+
71
+ 3.1.9. Arbitrarily deprive any person of his/her/their property +
72
+ (See Article 17, _United Nations Universal Declaration of Human Rights_);
73
+
74
+ 3.1.10. Forcibly remove indigenous peoples from their lands or territories or take any action with the aim or effect of dispossessing indigenous peoples from their lands, territories, or resources, including without limitation the intellectual property or traditional knowledge of indigenous peoples, without the free, prior, and informed consent of indigenous peoples concerned +
75
+ (See Articles 8 and 10, _United Nations Declaration on the Rights of Indigenous Peoples_);
76
+
77
+ 3.1.11. Be an individual or entity, or a representative, agent, affiliate, successor, attorney, or assign of an individual or entity, on the FFI Solutions Carbon Underground 200 list;
78
+
79
+ 3.1.12. Commit ecocide:
80
+
81
+ 3.1.12.1 For the purpose of this section, "ecocide" means unlawful or wanton acts committed with knowledge that there is a substantial likelihood of severe and either widespread or long-term damage to the environment being caused by those acts;
82
+
83
+ 3.1.12.2 For the purpose of further defining ecocide and the terms contained in the previous paragraph:
84
+
85
+ 3.1.12.2.1. "Wanton" means with reckless disregard for damage which would be clearly excessive in relation to the social and economic benefits anticipated;
86
+
87
+ 3.1.12.2.2. "Severe" means damage which involves very serious adverse changes, disruption, or harm to any element of the environment, including grave impacts on human life or natural, cultural, or economic resources;
88
+
89
+ 3.1.12.2.3. "Widespread" means damage which extends beyond a limited geographic area, crosses state boundaries, or is suffered by an entire ecosystem or species or a large number of human beings;
90
+
91
+ 3.1.12.2.4. "Long-term" means damage which is irreversible or which cannot be redressed through natural recovery within a reasonable period of time; and
92
+
93
+ 3.1.12.2.5. "Environment" means the earth, its biosphere, cryosphere, lithosphere, hydrosphere, and atmosphere, as well as outer space
94
+
95
+ (See Section II, _Independent Expert Panel for the Legal Definition of Ecocide_, Stop Ecocide Foundation and the Promise Institute for Human Rights at UCLA School of Law, June 2021);
96
+
97
+ 3.1.13. Be an individual or entity, or a representative, agent, affiliate, successor, attorney, or assign of an individual or entity, that engages in fossil fuel or mineral exploration, extraction, development, or sale;
98
+
99
+ 3.1.14. Be an individual or entity, or a representative, agent, affiliate, successor, attorney, or assign of an individual or entity, identified by the Boycott, Divestment, Sanctions ("BDS") movement on its website (https://bdsmovement.net/ and https://bdsmovement.net/get-involved/what-to-boycott) as a target for boycott;
100
+
101
+ 3.1.15. Be an individual or entity that:
102
+
103
+ 3.1.15.1. engages in any commercial transactions with the Taliban; or
104
+
105
+ 3.1.15.2. is a representative, agent, affiliate, successor, attorney, or assign of the Taliban;
106
+
107
+ 3.1.16. Be an individual or entity that:
108
+
109
+ 3.1.16.1. engages in any commercial transactions with the Myanmar/Burmese military junta; or
110
+
111
+ 3.1.16.2. is a representative, agent, affiliate, successor, attorney, or assign of the Myanmar/Burmese government;
112
+
113
+ 3.1.17. Be an individual or entity, or a representative, agent, affiliate, successor, attorney, or assign of any individual or entity, that does business in, purchases goods from, or otherwise benefits from goods produced in the Xinjiang Uygur Autonomous Region of China;
114
+
115
+ 3.1.18. Be an individual or entity:
116
+
117
+ 3.1.18.1. which U.S. Customs and Border Protection (CBP) has currently issued a Withhold Release Order (WRO) or finding against based on reasonable suspicion of forced labor; or
118
+
119
+ 3.1.18.2. that is a representative, agent, affiliate, successor, attorney, or assign of an individual or entity that does business with an individual or entity which currently has a WRO or finding from CBP issued against it based on reasonable suspicion of forced labor;
120
+
121
+ 3.1.19. Be a government agency or multinational corporation, or a representative, agent, affiliate, successor, attorney, or assign of a government or multinational corporation, which participates in mass surveillance programs;
122
+
123
+ 3.1.20. Be an entity or a representative, agent, affiliate, successor, attorney, or assign of an entity which conducts military activities;
124
+
125
+ 3.1.21. Be an individual or entity, or a or a representative, agent, affiliate, successor, attorney, or assign of an individual or entity, that provides good or services to, or otherwise enters into any commercial contracts with, any local, state, or federal law enforcement agency;
126
+
127
+ 3.1.22. Be an individual or entity, or a or a representative, agent, affiliate, successor, attorney, or assign of an individual or entity, that broadcasts messages promoting killing, torture, or other forms of extreme violence;
128
+
129
+ 3.1.23. Interfere with Workers’ free exercise of the right to organize and associate +
130
+ (See Article 20, United Nations Universal Declaration of Human Rights; C087 - Freedom of Association and Protection of the Right to Organise Convention, 1948 (No. 87), International Labour Organization; Article 8, International Covenant on Economic, Social and Cultural Rights); and
131
+
132
+ 3.1.24. Harm the environment in a manner inconsistent with local, state, national, or international law.
133
+
134
+ 3.2. The Licensee SHALL:
135
+
136
+ 3.2.1. Only use social auditing mechanisms that adhere to Worker-Driven Social Responsibility Network’s Statement of Principles (https://wsr-network.org/what-is-wsr/statement-of-principles/) over traditional social auditing mechanisms, to the extent the Licensee uses any social auditing mechanisms at all;
137
+
138
+ 3.2.2. Ensure that if the Licensee has a Board of Directors, 30% of Licensee’s board seats are held by Workers paid no more than 200% of the compensation of the lowest paid Worker of the Licensee;
139
+
140
+ 3.2.3. Provide clear, accessible supply chain data to the public in accordance with the following conditions:
141
+
142
+ 3.2.3.1. All data will be on Licensee’s website and/or, to the extent Licensee is a representative, agent, affiliate, successor, attorney, subsidiary, or assign, on Licensee’s principal’s or parent’s website or some other online platform accessible to the public via an internet search on a common internet search engine; and
143
+
144
+ 3.2.3.2. Data published will include, where applicable, manufacturers, top tier suppliers, subcontractors, cooperatives, component parts producers, and farms;
145
+
146
+ 3.2.4. Provide equal pay for equal work where the performance of such work requires equal skill, effort, and responsibility, and which are performed under similar working conditions, except where such payment is made pursuant to:
147
+
148
+ 3.2.4.1. A seniority system;
149
+
150
+ 3.2.4.2. A merit system;
151
+
152
+ 3.2.4.3. A system which measures earnings by quantity or quality of production; or
153
+
154
+ 3.2.4.4. A differential based on any other factor other than sex, gender, sexual orientation, race, ethnicity, nationality, religion, caste, age, medical disability or impairment, and/or any other like circumstances +
155
+ (See 29 U.S.C.A. § 206(d)(1); Article 23, _United Nations Universal Declaration of Human Rights_; Article 7, _International Covenant on Economic, Social and Cultural Rights_; Article 26, _International Covenant on Civil and Political Rights_); and
156
+
157
+ 3.2.5. Allow for reasonable limitation of working hours and periodic holidays with pay +
158
+ (See Article 24, _United Nations Universal Declaration of Human Rights_; Article 7, _International Covenant on Economic, Social and Cultural Rights_).
159
+
160
+ == 4. SUPPLY CHAIN IMPACTED PARTIES
161
+
162
+ _This section identifies additional individuals or entities that a Licensee could harm as a result of violating the Ethical Standards section, the condition that the Licensee must voluntarily accept a Duty of Care for those individuals or entities, and the right to a private right of action that those individuals or entities possess as a result of violations of the Ethical Standards section._
163
+
164
+ 4.1. In addition to the above Ethical Standards, Licensee voluntarily accepts a Duty of Care for Supply Chain Impacted Parties of this License, including individuals and communities impacted by violations of the Ethical Standards. The Duty of Care is breached when a provision within the Ethical Standards section is violated by a Licensee, one of its successors or assigns, or by an individual or entity that exists within the Supply Chain prior to a good or service reaching the Licensee.
165
+
166
+ 4.2. Breaches of the Duty of Care, as stated within this section, shall create a private right of action, allowing any Supply Chain Impacted Party harmed by the Licensee to take legal action against the Licensee in accordance with applicable negligence laws, whether they be in tort law, delict law, and/or similar bodies of law closely related to tort and/or delict law, regardless if Licensee is directly responsible for the harms suffered by a Supply Chain Impacted Party. Nothing in this section shall be interpreted to include acts committed by individuals outside of the scope of his/her/their employment.
167
+
168
+ == 5. NOTICE
169
+
170
+ _This section explains when a Licensee must notify others of the License._
171
+
172
+ 5.1. _Distribution of Notice_: Licensee must ensure that everyone who receives a copy of or uses any part of Software from Licensee, with or without changes, also receives the License and the copyright notice included with Software (and if included by the Licensor, patent, trademark, and attribution notice). Licensee must ensure that License is prominently displayed so that any individual or entity seeking to download, copy, use, or otherwise receive any part of Software from Licensee is notified of this License and its terms and conditions. Licensee must cause any modified versions of the Software to carry prominent notices stating that Licensee changed the Software.
173
+
174
+ 5.2. _Modified Software_: Licensee is free to create modifications of the Software and distribute only the modified portion created by Licensee, however, any derivative work stemming from the Software or its code must be distributed pursuant to this License, including this Notice provision.
175
+
176
+ 5.3. _Recipients as Licensees_: Any individual or entity that uses, copies, modifies, reproduces, distributes, or prepares derivative work based upon the Software, all or part of the Software’s code, or a derivative work developed by using the Software, including a portion of its code, is a Licensee as defined above and is subject to the terms and conditions of this License.
177
+
178
+ == 6. REPRESENTATIONS AND WARRANTIES
179
+
180
+ 6.1. _Disclaimer of Warranty_: TO THE FULL EXTENT ALLOWED BY LAW, THIS SOFTWARE COMES "AS IS," WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED, AND LICENSOR SHALL NOT BE LIABLE TO ANY PERSON OR ENTITY FOR ANY DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THIS LICENSE, UNDER ANY LEGAL CLAIM.
181
+
182
+ 6.2. _Limitation of Liability_: LICENSEE SHALL HOLD LICENSOR HARMLESS AGAINST ANY AND ALL CLAIMS, DEBTS, DUES, LIABILITIES, LIENS, CAUSES OF ACTION, DEMANDS, OBLIGATIONS, DISPUTES, DAMAGES, LOSSES, EXPENSES, ATTORNEYS’ FEES, COSTS, LIABILITIES, AND ALL OTHER CLAIMS OF EVERY KIND AND NATURE WHATSOEVER, WHETHER KNOWN OR UNKNOWN, ANTICIPATED OR UNANTICIPATED, FORESEEN OR UNFORESEEN, ACCRUED OR UNACCRUED, DISCLOSED OR UNDISCLOSED, ARISING OUT OF OR RELATING TO LICENSEE’S USE OF THE SOFTWARE. NOTHING IN THIS SECTION SHOULD BE INTERPRETED TO REQUIRE LICENSEE TO INDEMNIFY LICENSOR, NOR REQUIRE LICENSOR TO INDEMNIFY LICENSEE.
183
+
184
+ == 7. TERMINATION
185
+
186
+ 7.1. _Violations of Ethical Standards or Breaching Duty of Care_: If Licensee violates the Ethical Standards section or Licensee, or any other person or entity within the Supply Chain prior to a good or service reaching the Licensee, breaches its Duty of Care to Supply Chain Impacted Parties, Licensee must remedy the violation or harm caused by Licensee within 30 days of being notified of the violation or harm. If Licensee fails to remedy the violation or harm within 30 days, all rights in the Software granted to Licensee by License will be null and void as between Licensor and Licensee.
187
+
188
+ 7.2. _Failure of Notice_: If any person or entity notifies Licensee in writing that Licensee has not complied with the Notice section of this License, Licensee can keep this License by taking all practical steps to comply within 30 days after the notice of noncompliance. If Licensee does not do so, Licensee’s License (and all rights licensed hereunder) will end immediately.
189
+
190
+ 7.3. _Judicial Findings_: In the event Licensee is found by a civil, criminal, administrative, or other court of competent jurisdiction, or some other adjudicating body with legal authority, to have committed actions which are in violation of the Ethical Standards or Supply Chain Impacted Party sections of this License, all rights granted to Licensee by this License will terminate immediately.
191
+
192
+ 7.4. _Patent Litigation_: If Licensee institutes patent litigation against any entity (including a cross-claim or counterclaim in a suit) alleging that the Software, all or part of the Software’s code, or a derivative work developed using the Software, including a portion of its code, constitutes direct or contributory patent infringement, then any patent license, along with all other rights, granted to Licensee under this License will terminate as of the date such litigation is filed.
193
+
194
+ 7.5. _Additional Remedies_: Termination of the License by failing to remedy harms in no way prevents Licensor or Supply Chain Impacted Party from seeking appropriate remedies at law or in equity.
195
+
196
+ == 8. MISCELLANEOUS
197
+
198
+ 8.1. _Conditions_: Sections 3, 4.1, 5.1, 5.2, 7.1, 7.2, 7.3, and 7.4 are conditions of the rights granted to Licensee in the License.
199
+
200
+ 8.2. _Equitable Relief_: Licensor and any Supply Chain Impacted Party shall be entitled to equitable relief, including injunctive relief or specific performance of the terms hereof, in addition to any other remedy to which they are entitled at law or in equity.
201
+
202
+ 8.3. _Copyleft_: Modified software, source code, or other derivative work must be licensed, in its entirety, under the exact same conditions as this License.
203
+
204
+ 8.4. _Severability_: If any term or provision of this License is determined to be invalid, illegal, or unenforceable by a court of competent jurisdiction, any such determination of invalidity, illegality, or unenforceability shall not affect any other term or provision of this License or invalidate or render unenforceable such term or provision in any other jurisdiction. If the determination of invalidity, illegality, or unenforceability by a court of competent jurisdiction pertains to the terms or provisions contained in the Ethical Standards section of this License, all rights in the Software granted to Licensee shall be deemed null and void as between Licensor and Licensee.
205
+
206
+ 8.5. _Section Titles_: Section titles are solely written for organizational purposes and should not be used to interpret the language within each section.
207
+
208
+ 8.6. _Citations_: Citations are solely written to provide context for the source of the provisions in the Ethical Standards.
209
+
210
+ 8.7. _Section Summaries_: Some sections have a brief _italicized description_ which is provided for the sole purpose of briefly describing the section and should not be used to interpret the terms of the License.
211
+
212
+ 8.8. _Entire License_: This is the entire License between the Licensor and Licensee with respect to the claims released herein and that the consideration stated herein is the only consideration or compensation to be paid or exchanged between them for this License. This License cannot be modified or amended except in a writing signed by Licensor and Licensee.
213
+
214
+ 8.9. _Successors and Assigns_: This License shall be binding upon and inure to the benefit of the Licensor’s and Licensee’s respective heirs, successors, and assigns.
data/README.adoc CHANGED
@@ -11,12 +11,11 @@ image::https://img.shields.io/badge/code_style-alchemists-brightgreen.svg[Alchem
11
11
  [link=https://circleci.com/gh/bkuhlmann/refinements]
12
12
  image::https://circleci.com/gh/bkuhlmann/refinements.svg?style=svg[Circle CI Status]
13
13
 
14
- Refinements are a collection of enhancements to primitive Ruby objects without needing to resort to
15
- painful and hard to debug
16
- link:https://www.alchemists.io/articles/ruby_antipatterns/#_monkey_patches[monkey patches]. These
17
- refinements give you additional syntactic sugar to develop clean and concise implementations while
18
- using less code. By refining our code we can acquire the functionality we wish the core primitives
19
- had!
14
+ Refinements are a collection primitive Ruby objects enhancements without needing to resort to hard
15
+ to debug link:https://www.alchemists.io/articles/ruby_antipatterns/#_monkey_patches[monkey patches].
16
+ These refinements give you additional syntactic sugar to develop clean and concise implementations
17
+ while using less code. By refining our code we can acquire the functionality we wish the core
18
+ primitives had!
20
19
 
21
20
  toc::[]
22
21
 
@@ -73,7 +72,6 @@ gem "refinements", require: false
73
72
  ----
74
73
  require "refinements/arrays"
75
74
  require "refinements/big_decimals"
76
- require "refinements/classes"
77
75
  require "refinements/date_times"
78
76
  require "refinements/hashes"
79
77
  require "refinements/ios"
@@ -94,7 +92,6 @@ refinement(s):
94
92
  class Example
95
93
  using Refinements::Arrays
96
94
  using Refinements::BigDecimals
97
- using Refinements::Classes
98
95
  using Refinements::DateTimes
99
96
  using Refinements::Hashes
100
97
  using Refinements::IOs
@@ -150,7 +147,7 @@ Removes given array or elements without mutating itself.
150
147
 
151
148
  ===== #filter_find
152
149
 
153
- Answers the first truthy and filtered result from a collection.
150
+ Answers the first element which evaluates to true from a filtered collection.
154
151
 
155
152
  [source,ruby]
156
153
  ----
@@ -186,6 +183,19 @@ Inserts additional elements or array between all members of given array.
186
183
  [1, 2, 3].intersperse %i[a b c] # [1, :a, :b, :c, 2, :a, :b, :c, 3]
187
184
  ----
188
185
 
186
+ ===== #many?
187
+
188
+ Answers true if an array has more than one element. Can take a block which evaluates as truthy or
189
+ falsey.
190
+
191
+ [source,ruby]
192
+ ----
193
+ [1, 2].many? # true
194
+ [1, 2, 3].many?(&:odd?) # true
195
+ [1].many? # false
196
+ [].many? # false
197
+ ----
198
+
189
199
  ===== #maximum
190
200
 
191
201
  Answers the maximum extracted value from a collection of objects.
@@ -262,22 +272,6 @@ Allows one to inspect a big decimal with numeric representation.
262
272
  BigDecimal.new("5.0E-10").inspect # "#<BigDecimal:3fd3d458fe84 0.0000000005>"
263
273
  ----
264
274
 
265
- ==== Class
266
-
267
- ===== #descendants
268
-
269
- Answers descendants of a class.
270
-
271
- [source,ruby]
272
- ----
273
- a = Class.new
274
- b = Class.new a
275
- c = Class.new a
276
-
277
- a.descendants # [b, c]
278
- Class.new.descendants # []
279
- ----
280
-
281
275
  ==== DateTime
282
276
 
283
277
  ===== .utc
@@ -367,7 +361,7 @@ example # {a: "A", b: {one: 1, two: "Two"}}
367
361
 
368
362
  ===== #deep_stringify_keys
369
363
 
370
- Stringifies keys of nested hash without mutating itself. Does not handle nested arrays, though.
364
+ Answers string keys of a nested hash without mutating itself. Does not handle nested arrays, though.
371
365
 
372
366
  [source,ruby]
373
367
  ----
@@ -378,7 +372,7 @@ example # {a: {b: 2}}
378
372
 
379
373
  ===== #deep_stringify_keys!
380
374
 
381
- Stringifies keys of nested hash while mutating itself. Does not handle nested arrays, though.
375
+ Answers string keys of nested hash while mutating itself. Does not handle nested arrays, though.
382
376
 
383
377
  [source,ruby]
384
378
  ----
@@ -455,6 +449,19 @@ example.flatten_keys! # {a_b: 1}
455
449
  example # {a_b: 1}
456
450
  ----
457
451
 
452
+ ===== #many?
453
+
454
+ Answers true if a hash has more than one element. Can take a block which evaluates as truthy or
455
+ falsey.
456
+
457
+ [source,ruby]
458
+ ----
459
+ {a: 1, b: 2}.many? # true
460
+ {a: 1, b: 2, c: 2}.many? { |_key, value| value == 2 } # true
461
+ {a: 1}.many? # false
462
+ {}.many? # false
463
+ ----
464
+
458
465
  ===== #recurse
459
466
 
460
467
  Recursively iterates over the hash and any hash value by applying the given block to it. Does not
@@ -713,6 +720,28 @@ Pathname("/example.txt").touch.delete # Pathname("/example")
713
720
  Pathname("/example.txt").delete # Errno::ENOENT
714
721
  ----
715
722
 
723
+ ===== #delete_prefix
724
+
725
+ Deletes a path prefix and answers new pathname.
726
+
727
+ [source,ruby]
728
+ ----
729
+ Pathname("a/path/example-test.rb").delete_prefix("example-") # Pathname("a/path/test.rb")
730
+ Pathname("example-test.rb").delete_prefix("example-") # Pathname("test.rb")
731
+ Pathname("example-test.rb").delete_prefix("miss") # Pathname("example-test.rb")
732
+ ----
733
+
734
+ ===== #delete_suffix
735
+
736
+ Deletes a path suffix and answers new pathname.
737
+
738
+ [source,ruby]
739
+ ----
740
+ Pathname("a/path/test-example.rb").delete_suffix("-example") # Pathname("a/path/test.rb")
741
+ Pathname("test-example.rb").delete_suffix("-example") # Pathname("test.rb")
742
+ Pathname("test-example.rb").delete_suffix("miss") # Pathname("test-example.rb")
743
+ ----
744
+
716
745
  ===== #directories
717
746
 
718
747
  Answers all directories or filtered directories for current path.
@@ -845,14 +874,14 @@ parent_path = Pathname "/one"
845
874
  child_path = parent_path.join "two"
846
875
 
847
876
  child_path.make_path
848
- child_path.remove_tree # Pathname "/one/two"
877
+ parent_path.remove_tree # Pathname "/one"
849
878
  child_path.exist? # false
850
- paremt_path.exist? # true
879
+ parent_path.exist? # false
851
880
 
852
881
  child_path.make_path
853
- parent_path.remove_tree # Pathname "/one"
882
+ child_path.remove_tree # Pathname "/one/two"
854
883
  child_path.exist? # false
855
- parent_path.exist? # false
884
+ parent_path.exist? # true
856
885
  ----
857
886
 
858
887
  ===== #rewrite
@@ -904,7 +933,7 @@ Answers `true`/`false` based on whether string is blank, `<space>`, `\n`, `\t`,
904
933
 
905
934
  ===== #camelcase
906
935
 
907
- Answers a camelcased string.
936
+ Answers a camel cased string.
908
937
 
909
938
  [source,ruby]
910
939
  ----
@@ -913,7 +942,7 @@ Answers a camelcased string.
913
942
 
914
943
  ===== #down
915
944
 
916
- Answers string with only first letter downcased.
945
+ Answers string with only first letter down cased.
917
946
 
918
947
  [source,ruby]
919
948
  ----
@@ -995,7 +1024,7 @@ well in other languages.
995
1024
 
996
1025
  ===== #snakecase
997
1026
 
998
- Answers a snakecased string.
1027
+ Answers a snake cased string.
999
1028
 
1000
1029
  [source,ruby]
1001
1030
  ----
@@ -1004,7 +1033,7 @@ Answers a snakecased string.
1004
1033
 
1005
1034
  ===== #titleize
1006
1035
 
1007
- Answers titleized string.
1036
+ Answers a title string with proper capitalization of each word.
1008
1037
 
1009
1038
  [source,ruby]
1010
1039
  ----
@@ -1026,7 +1055,7 @@ Answers string as a boolean.
1026
1055
 
1027
1056
  ===== #up
1028
1057
 
1029
- Answers string with only first letter upcased.
1058
+ Answers string with only first letter capitalized.
1030
1059
 
1031
1060
  [source,ruby]
1032
1061
  ----
@@ -1056,6 +1085,8 @@ buffer # "This is a test."
1056
1085
 
1057
1086
  ===== .keyworded?
1058
1087
 
1088
+ ⚠️ Will be removed in the next major version. Use `.keyword_init?` instead.
1089
+
1059
1090
  Answers whether a struct was constructed with keyword or positional arguments.
1060
1091
 
1061
1092
  [source,ruby]
@@ -1072,14 +1103,14 @@ whether the struct was constructed with positional or keyword arguments.
1072
1103
  [source,ruby]
1073
1104
  ----
1074
1105
  Example = Struct.new :a, :b, :c
1075
- Example.with_keywords a: 1, b: 2, c: 3 # "#<struct a=1, b=2, c=3>"
1076
- Example.with_keywords a: 1 # "#<struct a=1, b=nil, c=nil>"
1077
- Example.with_keywords c: 1 # "#<struct a=nil, b=nil, c=1>"
1106
+ Example.with_keywords a: 1, b: 2, c: 3 # #<struct a=1, b=2, c=3>
1107
+ Example.with_keywords a: 1 # #<struct a=1, b=nil, c=nil>
1108
+ Example.with_keywords c: 1 # #<struct a=nil, b=nil, c=1>
1078
1109
 
1079
1110
  Example = Struct.new :a, :b, :c, keyword_init: true
1080
- Example.with_keywords a: 1, b: 2, c: 3 # "#<struct a=1, b=2, c=3>"
1081
- Example.with_keywords a: 1 # "#<struct a=1, b=nil, c=nil>"
1082
- Example.with_keywords c: 1 # "#<struct a=nil, b=nil, c=1>"
1111
+ Example.with_keywords a: 1, b: 2, c: 3 # #<struct a=1, b=2, c=3>
1112
+ Example.with_keywords a: 1 # #<struct a=1, b=nil, c=nil>
1113
+ Example.with_keywords c: 1 # #<struct a=nil, b=nil, c=1>
1083
1114
  ----
1084
1115
 
1085
1116
  ===== .with_positions
@@ -1090,101 +1121,125 @@ whether the struct was constructed with positional or keyword arguments.
1090
1121
  [source,ruby]
1091
1122
  ----
1092
1123
  Example = Struct.new :a, :b, :c
1093
- Example.with_positions 1, 2, 3 # "#<struct a=1, b=2, c=3>"
1094
- Example.with_positions 1 # "#<struct a=1, b=nil, c=nil>"
1124
+ Example.with_positions 1, 2, 3 # #<struct a=1, b=2, c=3>
1125
+ Example.with_positions 1 # #<struct a=1, b=nil, c=nil>
1095
1126
 
1096
1127
  Example = Struct.new :a, :b, :c, keyword_init: true
1097
- Example.with_positions 1, 2, 3 # "#<struct a=1, b=2, c=3>"
1098
- Example.with_positions 1 # "#<struct a=1, b=nil, c=nil>"
1128
+ Example.with_positions 1, 2, 3 # #<struct a=1, b=2, c=3>
1129
+ Example.with_positions 1 # #<struct a=1, b=nil, c=nil>
1099
1130
  ----
1100
1131
 
1101
1132
  ===== #merge
1102
1133
 
1103
- Merges multiple attributes without mutating itself.
1134
+ Merges multiple attributes without mutating itself and supports any object that responds to `#to_h`.
1135
+ Works regardless of whether the struct is constructed with positional or keyword arguments.
1104
1136
 
1105
1137
  [source,ruby]
1106
1138
  ----
1107
- Example = Struct.new :a, :b, :c
1108
- example = Example[1, 2, 3]
1109
- example.merge a: 10 # "#<struct a=10, b=2, c=3>"
1110
- example.merge a: 10, c: 30 # "#<struct a=10, b=2, c=30>"
1111
- example.merge a: 10, b: 20, c: 30 # "#<struct a=10, b=20, c=30>"
1112
- example # "#<struct a=1, b=2, c=3>"
1139
+ example = Struct.new("Example", :a, :b, :c).new 1, 2, 3
1140
+ other = Struct.new("Other", :a, :b, :c).new 7, 8, 9
1113
1141
 
1114
- Example = Struct.new :a, :b, :c, keyword_init: true
1115
- example = Example[a: 1, b: 2, c: 3]
1116
- example.merge a: 10 # "#<struct a=10, b=2, c=3>"
1117
- example.merge a: 10, c: 30 # "#<struct a=10, b=2, c=30>"
1118
- example.merge a: 10, b: 20, c: 30 # "#<struct a=10, b=20, c=30>"
1119
- example # "#<struct a=1, b=2, c=3>"
1142
+ example.merge a: 10 # #<struct Struct::Example a=10, b=2, c=3>
1143
+ example.merge a: 10, c: 30 # #<struct Struct::Example a=10, b=2, c=30>
1144
+ example.merge a: 10, b: 20, c: 30 # #<struct Struct::Example a=10, b=20, c=30>
1145
+ example.merge other # #<struct Struct::Example a=7, b=8, c=9>
1146
+ example # #<struct Struct::Example a=1, b=2, c=3>
1120
1147
  ----
1121
1148
 
1122
1149
  ===== #merge!
1123
1150
 
1124
- Merges multiple attributes while mutating itself.
1151
+ Merges multiple attributes while mutating itself and supports any object that responds to `#to_h`.
1152
+ Works regardless of whether the struct is constructed with positional or keyword arguments.
1125
1153
 
1126
1154
  [source,ruby]
1127
1155
  ----
1128
- Example = Struct.new :a, :b, :c
1129
- example = Example[1, 2, 3]
1130
- example.merge! a: 10 # "#<struct a=10, b=2, c=3>"
1131
- example.merge! a: 10, c: 30 # "#<struct a=10, b=2, c=30>"
1132
- example.merge! a: 10, b: 20, c: 30 # "#<struct a=10, b=20, c=30>"
1133
- example # "#<struct a=10, b=20, c=30>"
1156
+ example = Struct.new("Example", :a, :b, :c).new 1, 2, 3
1157
+ other = Struct.new("Other", :a, :b, :c).new 7, 8, 9
1134
1158
 
1135
- Example = Struct.new :a, :b, :c, keyword_init: true
1136
- example = Example[a: 1, b: 2, c: 3]
1137
- example.merge! a: 10 # "#<struct a=10, b=2, c=3>"
1138
- example.merge! a: 10, c: 30 # "#<struct a=10, b=2, c=30>"
1139
- example.merge! a: 10, b: 20, c: 30 # "#<struct a=10, b=20, c=30>"
1140
- example # "#<struct a=10, b=20, c=30>"
1159
+ example.merge! a: 10 # #<struct Struct::Example a=10, b=2, c=3>
1160
+ example.merge! a: 10, c: 30 # #<struct Struct::Example a=10, b=2, c=30>
1161
+ example.merge! other # #<struct Struct::Example a=7, b=8, c=9>
1162
+ example.merge! a: 10, b: 20, c: 30 # #<struct Struct::Example a=10, b=20, c=30>
1163
+ example # #<struct Struct::Example a=10, b=20, c=30>
1141
1164
  ----
1142
1165
 
1143
1166
  ===== #revalue
1144
1167
 
1145
- Transforms values without mutating itself. An optional hash can be supplied to pinpoint and
1146
- transform specific attributes. In the event that a block isn't supplied, the struct will answer
1147
- itself since there is nothing to operate on. Behavior is the same regardless of whether the struct
1148
- is constructed using positional or keyword arguments. A positional struct is used in the examples
1149
- below but a keyword struct would work too.
1168
+ Transforms values without mutating itself. An optional hash can be supplied to target specific
1169
+ attributes. In the event that a block isn't supplied, the struct will answer itself since there is
1170
+ nothing to operate on. Behavior is the same regardless of whether the struct is constructed using
1171
+ positional or keyword arguments. Works regardless of whether the struct is constructed with
1172
+ positional or keyword arguments.
1150
1173
 
1151
1174
  [source,ruby]
1152
1175
  ----
1153
- Example = Struct.new :a, :b, :c
1154
-
1155
- example = Example[1, 2, 3]
1156
- example.revalue { |value| value * 2 } # "#<struct a=2, b=4, c=6>"
1157
- example.revalue(c: 2) { |previous, current| previous + current } # "#<struct a=1, b=2, c=5>"
1158
- example.revalue c: 2 # "#<struct a=1, b=2, c=3>"
1159
- example.revalue # "#<struct a=1, b=2, c=3>"
1160
- example # "#<struct a=1, b=2, c=3>"
1176
+ example = Struct.new("Example", :a, :b, :c).new 1, 2, 3
1161
1177
 
1178
+ example.revalue { |value| value * 2 } # #<struct Struct::Example a=2, b=4, c=6>
1179
+ example.revalue(c: 2) { |previous, current| previous + current } # #<struct Struct::Example a=1, b=2, c=5>
1180
+ example.revalue c: 2 # #<struct Struct::Example a=1, b=2, c=3>
1181
+ example.revalue # #<struct Struct::Example a=1, b=2, c=3>
1182
+ example # #<struct Struct::Example a=1, b=2, c=3>
1162
1183
  ----
1163
1184
 
1164
1185
  ===== #revalue!
1165
1186
 
1166
- Transforms values while mutating itself. An optional hash can be supplied to pinpoint and transform
1167
- specific attributes. In the event that a block isn't supplied, the struct will answer itself since
1168
- there is nothing to operate on. Behavior is the same regardless of whether the struct is constructed
1169
- using positional or keyword arguments. A positional struct is used in the examples below but a
1170
- keyword struct would work too.
1187
+ Transforms values while mutating itself. An optional hash can be supplied to target specific
1188
+ attributes. In the event that a block isn't supplied, the struct will answer itself since there is
1189
+ nothing to operate on. Behavior is the same regardless of whether the struct is constructed using
1190
+ positional or keyword arguments. Works regardless of whether the struct is constructed with
1191
+ positional or keyword arguments.
1171
1192
 
1172
1193
  [source,ruby]
1173
1194
  ----
1174
- Example = Struct.new :a, :b, :c
1195
+ one = Struct.new("One", :a, :b, :c).new 1, 2, 3
1196
+ one.revalue! { |value| value * 2 } # #<struct Struct::One a=2, b=4, c=6>
1197
+ one # #<struct Struct::One a=2, b=4, c=6>
1175
1198
 
1176
- example = Example[1, 2, 3]
1177
- example.revalue! { |value| value * 2 } # "#<struct a=2, b=4, c=6>"
1178
- example # "#<struct a=2, b=4, c=6>"
1199
+ two = Struct.new("Two", :a, :b, :c).new 1, 2, 3
1200
+ two.revalue!(c: 2) { |previous, current| previous + current } # #<struct Struct::Two a=1, b=2, c=5>
1201
+ two # #<struct Struct::Two a=1, b=2, c=5>
1179
1202
 
1180
- example = Example[1, 2, 3]
1181
- example.revalue!(c: 2) { |previous, current| previous + current } # "#<struct a=1, b=2, c=5>"
1182
- example # "#<struct a=1, b=2, c=5>"
1203
+ three = Struct.new("Three", :a, :b, :c).new 1, 2, 3
1204
+ three.revalue! c: 2 # #<struct Struct::Three a=1, b=2, c=3>
1205
+ three.revalue! # #<struct Struct::Three a=1, b=2, c=3>
1206
+ three # #<struct Struct::Three a=1, b=2, c=3>
1207
+ ----
1208
+
1209
+ ===== #transmute
1183
1210
 
1184
- example = Example[1, 2, 3]
1185
- example.revalue! c: 2 # "#<struct a=1, b=2, c=3>"
1186
- example.revalue! # "#<struct a=1, b=2, c=3>"
1187
- example # "#<struct a=1, b=2, c=3>"
1211
+ Transmutes given enumerable by using the foreign key map and merging those key values into the
1212
+ current struct while not mutating itself. Works regardless of whether the struct is constructed with
1213
+ positional or keyword arguments.
1214
+
1215
+ [source,ruby]
1216
+ ----
1217
+ a = Struct.new("A", :a, :b, :c).new 1, 2, 3
1218
+ b = Struct.new("B", :x, :y, :z).new 7, 8, 9
1219
+ c = {r: 10, s: 20, t: 30}
1220
+
1221
+ a.transmute b, a: :x, b: :y, c: :z # #<struct Struct::A a=7, b=8, c=9>
1222
+ a.transmute b, b: :y # #<struct Struct::A a=1, b=8, c=3>
1223
+ a.transmute c, c: :t # #<struct Struct::A a=1, b=2, c=30>
1224
+ a # #<struct Struct::A a=1, b=2, c=3>
1225
+ ----
1226
+
1227
+ ===== #transmute!
1228
+
1229
+ Transmutes given enumerable by using the foreign key map and merging those key values into the
1230
+ current struct while mutating itself. Works regardless of whether the struct is constructed with
1231
+ positional or keyword arguments.
1232
+
1233
+ [source,ruby]
1234
+ ----
1235
+ a = Struct.new("A", :a, :b, :c).new 1, 2, 3
1236
+ b = Struct.new("B", :x, :y, :z).new 7, 8, 9
1237
+ c = {r: 10, s: 20, t: 30}
1238
+
1239
+ a.transmute! b, a: :x, b: :y, c: :z # #<struct Struct::A a=7, b=8, c=9>
1240
+ a.transmute! b, b: :y # #<struct Struct::A a=1, b=8, c=3>
1241
+ a.transmute! c, c: :t # #<struct Struct::A a=1, b=2, c=30>
1242
+ a # #<struct Struct::A a=7, b=8, c=30>
1188
1243
  ----
1189
1244
 
1190
1245
  ==== Symbol
@@ -1232,36 +1287,19 @@ To test, run:
1232
1287
  bundle exec rake
1233
1288
  ----
1234
1289
 
1235
- == Versioning
1236
-
1237
- Read link:https://semver.org[Semantic Versioning] for details. Briefly, it means:
1238
-
1239
- * Major (X.y.z) - Incremented for any backwards incompatible public API changes.
1240
- * Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
1241
- * Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
1242
-
1243
- == Code of Conduct
1244
-
1245
- Please note that this project is released with a link:CODE_OF_CONDUCT.adoc[CODE OF CONDUCT]. By
1246
- participating in this project you agree to abide by its terms.
1247
-
1248
- == Contributions
1249
-
1250
- Read link:CONTRIBUTING.adoc[CONTRIBUTING] for details.
1251
-
1252
- == Community
1290
+ == link:https://www.alchemists.io/policies/license[License]
1253
1291
 
1254
- Feel free to link:https://www.alchemists.io/community[join the commmunity] for discussions related
1255
- to this project and much more.
1292
+ == link:https://www.alchemists.io/policies/security[Security]
1256
1293
 
1257
- == License
1294
+ == link:https://www.alchemists.io/policies/code_of_conduct[Code of Conduct]
1258
1295
 
1259
- Read link:LICENSE.adoc[LICENSE] for details.
1296
+ == link:https://www.alchemists.io/policies/contributions[Contributions]
1260
1297
 
1261
- == History
1298
+ == link:https://www.alchemists.io/projects/refinements/versions[Versions]
1262
1299
 
1263
- Read link:CHANGES.adoc[CHANGES] for details.
1300
+ == link:https://www.alchemists.io/community[Community]
1264
1301
 
1265
1302
  == Credits
1266
1303
 
1267
- Engineered by link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
1304
+ * Built with link:https://www.alchemists.io/projects/gemsmith[Gemsmith].
1305
+ * Engineered by link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
@@ -1,9 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "refinements/shared/enumerables/many"
4
+
3
5
  module Refinements
4
6
  # Provides additional enhancements to the Array primitive.
5
7
  module Arrays
6
8
  refine Array do
9
+ import_methods Shared::Enumerables::Many
10
+
7
11
  def compress = dup.compress!
8
12
 
9
13
  def compress!
@@ -27,7 +31,7 @@ module Refinements
27
31
 
28
32
  def pad(value, max: size) = dup.fill(value, size..(max - 1))
29
33
 
30
- def ring(&block) = [last, *self, first].each_cons(3, &block)
34
+ def ring(&) = [last, *self, first].each_cons(3, &)
31
35
  end
32
36
  end
33
37
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "refinements/shared/enumerables/many"
4
+
3
5
  module Refinements
4
6
  # Provides additional enhancements to the Hash primitive.
5
7
  module Hashes
@@ -12,6 +14,8 @@ module Refinements
12
14
  end
13
15
 
14
16
  refine Hash do
17
+ import_methods Shared::Enumerables::Many
18
+
15
19
  def compress = dup.compress!
16
20
 
17
21
  def compress!
@@ -42,8 +46,8 @@ module Refinements
42
46
 
43
47
  def deep_symbolize_keys! = replace(deep_symbolize_keys)
44
48
 
45
- def fetch_value key, *default_value, &block
46
- fetch(key, *default_value, &block) || default_value.first
49
+ def fetch_value(key, *default_value, &)
50
+ fetch(key, *default_value, &) || default_value.first
47
51
  end
48
52
 
49
53
  # :reek:TooManyStatements
@@ -56,13 +60,13 @@ module Refinements
56
60
  next flat.merge flat_key.public_send(cast) => value unless value.is_a? self.class
57
61
 
58
62
  flat.merge(
59
- recurse { value.flatten_keys prefix: flat_key, delimiter: delimiter, cast: cast }
63
+ recurse { value.flatten_keys prefix: flat_key, delimiter:, cast: }
60
64
  )
61
65
  end
62
66
  end
63
67
 
64
68
  def flatten_keys! prefix: nil, delimiter: "_", cast: :to_sym
65
- replace flatten_keys(prefix: prefix, delimiter: delimiter, cast: cast)
69
+ replace flatten_keys(prefix:, delimiter:, cast:)
66
70
  end
67
71
 
68
72
  def recurse &block
@@ -5,7 +5,7 @@ module Refinements
5
5
  module Identity
6
6
  NAME = "refinements"
7
7
  LABEL = "Refinements"
8
- VERSION = "8.5.2"
8
+ VERSION = "9.1.0"
9
9
  VERSION_LABEL = "#{LABEL} #{VERSION}".freeze
10
10
  end
11
11
  end
@@ -26,7 +26,7 @@ module Refinements
26
26
 
27
27
  def reread(length = nil, buffer: nil) = tap(&:rewind).read(length, buffer)
28
28
 
29
- def squelch(&block) = self.class.void.then { |void| redirect(void, &block) }
29
+ def squelch(&) = self.class.void.then { |void| redirect(void, &) }
30
30
  end
31
31
  end
32
32
  end
@@ -17,7 +17,11 @@ module Refinements
17
17
  def home = new(ENV["HOME"])
18
18
 
19
19
  def make_temp_dir prefix: "temp-", suffix: nil, root: nil
20
- Dir.mktmpdir([prefix, suffix], root) { |path| block_given? ? yield(new path) : new(path) }
20
+ if block_given?
21
+ Dir.mktmpdir([prefix, suffix], root) { |path| yield new(path) }
22
+ else
23
+ new Dir.mktmpdir([prefix, suffix], root)
24
+ end
21
25
  end
22
26
 
23
27
  def require_tree root, pattern = "**/*.rb"
@@ -46,6 +50,10 @@ module Refinements
46
50
 
47
51
  def delete = super && self
48
52
 
53
+ def delete_prefix(pattern) = parent.join %(#{name.sub(/\A#{pattern}/, "")}#{extname})
54
+
55
+ def delete_suffix(pattern) = parent.join %(#{name.sub(/#{pattern}\z/, "")}#{extname})
56
+
49
57
  def directories pattern = "*", flag: File::FNM_SYSCASE
50
58
  glob(pattern, flag).select(&:directory?).sort
51
59
  end
@@ -70,7 +78,7 @@ module Refinements
70
78
  self
71
79
  end
72
80
 
73
- def name = basename(extname)
81
+ def name = basename extname
74
82
 
75
83
  def relative_parent(root_dir) = relative_path_from(root_dir).parent
76
84
 
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Refinements
4
+ module Shared
5
+ module Enumerables
6
+ # Provides shared functionality for knowing whether an enumerable has many elements or not.
7
+ module Many
8
+ def many?
9
+ return size > 1 unless block_given?
10
+
11
+ total = reduce(0) { |count, item| yield(item) ? count + 1 : count }
12
+ total > 1
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -64,11 +64,10 @@ module Refinements
64
64
 
65
65
  private
66
66
 
67
- # :reek:DuplicateMethodCall
68
67
  # :reek:UtilityFunction
69
68
  def combine parts, method, delimiter = ""
70
69
  parts.reduce "" do |result, part|
71
- next part.__send__ method if result.empty?
70
+ next part.public_send method if result.empty?
72
71
 
73
72
  "#{result}#{delimiter}#{part.__send__ method}"
74
73
  end
@@ -4,18 +4,21 @@ module Refinements
4
4
  # Provides additional enhancements to the Struct primitive.
5
5
  module Structs
6
6
  refine Struct.singleton_class do
7
- def keyworded? = inspect.include?("keyword_init: true")
7
+ def keyworded?
8
+ warn "[DEPRECATION]: .keyworded? is deprecated, use .keyword_init? instead."
9
+ inspect.include?("keyword_init: true")
10
+ end
8
11
 
9
- def with_keywords(**arguments) = keyworded? ? new(**arguments) : new.merge!(**arguments)
12
+ def with_keywords(**arguments) = keyword_init? ? new(**arguments) : new.merge!(**arguments)
10
13
 
11
- def with_positions(*values) = keyworded? ? new(**members.zip(values).to_h) : new(*values)
14
+ def with_positions(*values) = keyword_init? ? new(**members.zip(values).to_h) : new(*values)
12
15
  end
13
16
 
14
17
  refine Struct do
15
- def merge(**attributes) = dup.merge!(**attributes)
18
+ def merge(...) = dup.merge!(...)
16
19
 
17
- def merge! **attributes
18
- to_h.merge(**attributes).each { |key, value| self[key] = value }
20
+ def merge! object = nil
21
+ to_h.merge!(**object.to_h).each { |key, value| self[key] = value }
19
22
  self
20
23
  end
21
24
 
@@ -31,6 +34,13 @@ module Refinements
31
34
  attributes.each { |key, value| self[key] = yield self[key], value }
32
35
  self
33
36
  end
37
+
38
+ def transmute(...) = dup.transmute!(...)
39
+
40
+ def transmute! object, **key_map
41
+ mapping = key_map.invert
42
+ merge! object.to_h.slice(*mapping.keys).transform_keys!(mapping)
43
+ end
34
44
  end
35
45
  end
36
46
  end
@@ -4,8 +4,8 @@ module Refinements
4
4
  # Provides additional enhancements to the Symbol primitive.
5
5
  module Symbols
6
6
  refine Symbol do
7
- def call *arguments, &block
8
- proc { |receiver| receiver.public_send self, *arguments, &block }
7
+ def call(*arguments, &)
8
+ proc { |receiver| receiver.public_send self, *arguments, & }
9
9
  end
10
10
  end
11
11
  end
data/lib/refinements.rb CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "refinements/identity"
4
4
  require "refinements/arrays"
5
- require "refinements/classes"
6
5
  require "refinements/big_decimals"
7
6
  require "refinements/date_times"
8
7
  require "refinements/hashes"
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinements
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.5.2
4
+ version: 9.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -28,7 +28,7 @@ cert_chain:
28
28
  lkHilIrX69jq8wMPpBhlaw2mRmeSL50Wv5u6xVBvOHhXFSP1crXM95vfLhLyRYod
29
29
  W2A=
30
30
  -----END CERTIFICATE-----
31
- date: 2021-11-20 00:00:00.000000000 Z
31
+ date: 2022-01-17 00:00:00.000000000 Z
32
32
  dependencies: []
33
33
  description:
34
34
  email:
@@ -44,22 +44,22 @@ files:
44
44
  - lib/refinements.rb
45
45
  - lib/refinements/arrays.rb
46
46
  - lib/refinements/big_decimals.rb
47
- - lib/refinements/classes.rb
48
47
  - lib/refinements/date_times.rb
49
48
  - lib/refinements/hashes.rb
50
49
  - lib/refinements/identity.rb
51
50
  - lib/refinements/ios.rb
52
51
  - lib/refinements/pathnames.rb
52
+ - lib/refinements/shared/enumerables/many.rb
53
53
  - lib/refinements/string_ios.rb
54
54
  - lib/refinements/strings.rb
55
55
  - lib/refinements/structs.rb
56
56
  - lib/refinements/symbols.rb
57
57
  homepage: https://www.alchemists.io/projects/refinements
58
58
  licenses:
59
- - Apache-2.0
59
+ - Hippocratic-3.0
60
60
  metadata:
61
61
  bug_tracker_uri: https://github.com/bkuhlmann/refinements/issues
62
- changelog_uri: https://www.alchemists.io/projects/refinements/changes.html
62
+ changelog_uri: https://www.alchemists.io/projects/refinements/versions
63
63
  documentation_uri: https://www.alchemists.io/projects/refinements
64
64
  rubygems_mfa_required: 'true'
65
65
  source_code_uri: https://github.com/bkuhlmann/refinements
@@ -71,14 +71,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '3.0'
74
+ version: '3.1'
75
75
  required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  requirements:
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
79
  version: '0'
80
80
  requirements: []
81
- rubygems_version: 3.2.31
81
+ rubygems_version: 3.3.5
82
82
  signing_key:
83
83
  specification_version: 4
84
84
  summary: A collection of refinements to core Ruby objects.
metadata.gz.sig CHANGED
Binary file
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Refinements
4
- # Provides additional enhancements to Class objects.
5
- module Classes
6
- refine Class do
7
- def descendants
8
- ObjectSpace.each_object(singleton_class)
9
- .reject { |klass| klass.singleton_class? || klass == self }
10
- end
11
- end
12
- end
13
- end