rom-factory 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0cae4bd0ca2ec550f5fdfb9e17151f6e4be3b575f382935281721f75f905f46b
4
- data.tar.gz: 1c6291ac1413d16b15fe946378d1eb59e08d8bafa61f2c8eb7743412bd53d31a
3
+ metadata.gz: 76c2c2d443aae25366e10dc9cfb41bc23a9e69abd38597b144214a9b4f861b51
4
+ data.tar.gz: 3aea3e8cf8568962e72c0d8ebda1da5b9ca38b6bcbf6469a9c2ea3f67377a314
5
5
  SHA512:
6
- metadata.gz: 14b6dcc4ea8a9077684b372baba986a0bd51b081ab75faadb954156c9b09dbcdf5f05bfe1a0cfc886e915b461c13afa8c0d42213337264188d438a0064ab8c34
7
- data.tar.gz: 5705eb8df8fd99a9ff93c53b769a3c3c7f09749740642abf9a2d8f6907b67104147286d667d18de8ae372c8bafd7edad86d1baba8273cd2e67613ecc68a474c9
6
+ metadata.gz: 1a463af2b73eca8c24d2a276c678a72e7d7883ed030b241bdc71c58998ce2ce0742f039e30744a0baa12d81cfcab111602f2b960e0db5abf786b3c0f9afe3c03
7
+ data.tar.gz: b60e2dfd2d87136bd3f10a84df790fa2f664babdd9d972682986545ceefabf7353f7811ef6f2f51028f611012e3b9f632cf485fcdf63c0d490ef543b9b59cf8d
data/CHANGELOG.md CHANGED
@@ -1,23 +1,100 @@
1
- <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
1
+ # Changelog
2
2
 
3
- ## 0.12.0 2024-01-19
3
+ All notable changes to this project will be documented in this file.
4
4
 
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Break Versioning](https://www.taoensso.com/break-versioning).
7
+
8
+ ## [Unreleased]
5
9
 
6
10
  ### Added
7
11
 
8
- - Support for many-to-many and one-to-one-through associations (via
9
- - Support for UUID as PKs in associations (via
12
+ ### Changed
13
+
14
+ ### Deprecated
15
+
16
+ ### Removed
10
17
 
11
18
  ### Fixed
12
19
 
13
- - Relations without PKs should work too (via
14
- - Relations with PK values generated on the Ruby side should work in SQlite too (via
20
+ ### Security
21
+
22
+ [Unreleased]: https://github.com/rom-rb/rom-factory/compare/v0.14.0...main
23
+
24
+ ## [0.14.0] - 2026-10-03
25
+
26
+ ### Added
27
+
28
+ - Support transient attributes. (@rickenharp in #97)
29
+
30
+ Define transient attributes inside a `transient` block. Other attributes can depend on them, but they are not part of the resulting tuple or struct. You can override them when building, like any other attribute.
31
+
32
+ ```ruby
33
+ Factory.define(:user) do |f|
34
+ f.transient do |t|
35
+ t.password "secret"
36
+ end
37
+ f.password_hash { |password| BCrypt::Password.create(password) }
38
+ end
39
+
40
+ Factory[:user, password: "something else"]
41
+ ```
42
+
43
+ ### Changed
44
+
45
+ - Minimum Ruby version is now 3.3. (@alassek)
46
+ - Add `tsort` as an explicit runtime dependency. (@flash-gordon)
47
+
48
+ [0.13.0]: https://github.com/rom-rb/rom-factory/compare/v0.13.0...v0.14.0
49
+
50
+ ## [0.13.0] - 2025-01-21
51
+
52
+ ### Added
53
+
54
+ - Support for unique options in `fake` DSL (via #94) (@sean-dickinson)
55
+
56
+ ```ruby
57
+ Factory.define(:user) do |f|
58
+ f.name { fake(:name, unique: true) }
59
+ end
60
+ ```
61
+
62
+ Be advised there's `Faker::UniqueGenerator.clear` to clear the cache of unique values.
63
+
64
+ - Support for setting traits with a keyword argument for associations (via #84) (@parndt)
65
+
66
+ ```ruby
67
+ Factory.define :category do |f|
68
+ f.association :image, traits: [:fancy]
69
+ end
70
+ ```
71
+
72
+ - Aliases for factory methods (via #92) (@cflipse)
15
73
 
74
+ `Factory.create` is aliased to `Factory.[]`
75
+ `Factory.build` is aliased to `Factory.structs[]`
76
+
77
+ ### Changed
16
78
 
17
- [Compare v0.11.0...v0.12.0](https://github.com/rom-rb/rom-factory/compare/v0.11.0...v0.12.0)
79
+ - Minimum Ruby version is now 3.1 (@flash-gordon)
18
80
 
19
- ## 0.11.0 2022-11-11
81
+ [0.13.0]: https://github.com/rom-rb/rom-factory/compare/v0.12.0...v0.13.0
20
82
 
83
+ ## [0.12.0] - 2024-01-19
84
+
85
+ ### Added
86
+
87
+ - Support for many-to-many and one-to-one-through associations (via #86) (@solnic)
88
+ - Support for UUID as PKs in associations (via #87) (@solnic)
89
+
90
+ ### Fixed
91
+
92
+ - Relations without PKs should work too (via #87) (@solnic)
93
+ - Relations with PK values generated on the Ruby side should work in SQlite too (via #87) (@solnic)
94
+
95
+ [0.12.0]: https://github.com/rom-rb/rom-factory/compare/v0.11.0...v0.12.0
96
+
97
+ ## [0.11.0] - 2022-11-11
21
98
 
22
99
  ### Added
23
100
 
@@ -50,20 +127,17 @@ Factory[:user, **user_attributes]
50
127
  - Upgraded to the latest versions of dry-rb dependencies, compatible with rom 5.3 (@flash-gordon)
51
128
  - Support for Faker 1.x was dropped (@alassek)
52
129
 
53
- [Compare v0.10.2...v0.11.0](https://github.com/rom-rb/rom-factory/compare/v0.10.2...v0.11.0)
54
-
55
- ## 0.10.2 2020-04-05
130
+ [0.11.0]: https://github.com/rom-rb/rom-factory/compare/v0.10.2...v0.11.0
56
131
 
132
+ ## [0.10.2] - 2020-04-05
57
133
 
58
134
  ### Fixed
59
135
 
60
136
  - Fix more keyword warnings (@flash-gordon)
61
137
 
138
+ [0.10.2]: https://github.com/rom-rb/rom-factory/compare/v0.10.1...v0.10.2
62
139
 
63
- [Compare v0.10.1...v0.10.2](https://github.com/rom-rb/rom-factory/compare/v0.10.1...v0.10.2)
64
-
65
- ## 0.10.1 2019-12-28
66
-
140
+ ## [0.10.1] - 2019-12-28
67
141
 
68
142
  ### Added
69
143
 
@@ -73,11 +147,9 @@ Factory[:user, **user_attributes]
73
147
 
74
148
  - Keyword warnings reported by Ruby 2.7 (@flash-gordon)
75
149
 
150
+ [0.10.1]: https://github.com/rom-rb/rom-factory/compare/v0.10.0...v0.10.1
76
151
 
77
- [Compare v0.10.0...v0.10.1](https://github.com/rom-rb/rom-factory/compare/v0.10.0...v0.10.1)
78
-
79
- ## 0.10.0 2019-12-11
80
-
152
+ ## [0.10.0] - 2019-12-11
81
153
 
82
154
  ### Added
83
155
 
@@ -94,41 +166,33 @@ Factory[:user, **user_attributes]
94
166
  - Support building structs when child assoc does not define parent (@psparrow)
95
167
  - Fixed `TupleEvaluator#struct_attrs` for non-standard output schema (@AMHOL)
96
168
 
169
+ [0.10.0]: https://github.com/rom-rb/rom-factory/compare/v0.9.1...v0.10.0
97
170
 
98
- [Compare v0.9.1...v0.10.0](https://github.com/rom-rb/rom-factory/compare/v0.9.1...v0.10.0)
99
-
100
- ## 0.9.1 2019-10-23
101
-
171
+ ## [0.9.1] - 2019-10-23
102
172
 
103
173
  ### Fixed
104
174
 
105
175
  - Attributes of a struct are no longer accidentally passed to their associations (@psparrow)
106
176
 
177
+ [0.9.1]: https://github.com/rom-rb/rom-factory/compare/v0.9.0...v0.9.1
107
178
 
108
- [Compare v0.9.0...v0.9.1](https://github.com/rom-rb/rom-factory/compare/v0.9.0...v0.9.1)
109
-
110
- ## 0.9.0 2019-08-12
111
-
179
+ ## [0.9.0] - 2019-08-12
112
180
 
113
181
  ### Added
114
182
 
115
183
  - When attributes hash includes unknown attributes, a `ROM::Factory::UnknownAttributeError` will be raised (@rawburt)
116
184
 
185
+ [0.9.0]: https://github.com/rom-rb/rom-factory/compare/v0.8.0...v0.9.0
117
186
 
118
- [Compare v0.8.0...v0.9.0](https://github.com/rom-rb/rom-factory/compare/v0.8.0...v0.9.0)
119
-
120
- ## 0.8.0 2019-04-24
121
-
187
+ ## [0.8.0] - 2019-04-24
122
188
 
123
189
  ### Fixed
124
190
 
125
191
  - Loaded association structs are no longer rejected by output schemas (issue #34) (flash-gordon + solnic)
126
192
 
193
+ [0.8.0]: https://github.com/rom-rb/rom-factory/compare/v0.7.0...v0.8.0
127
194
 
128
- [Compare v0.7.0...v0.8.0](https://github.com/rom-rb/rom-factory/compare/v0.7.0...v0.8.0)
129
-
130
- ## 0.7.0 2018-11-17
131
-
195
+ ## [0.7.0] - 2018-11-17
132
196
 
133
197
  ### Added
134
198
 
@@ -139,11 +203,9 @@ Factory[:user, **user_attributes]
139
203
 
140
204
  - Overwritten attributes with dependencies (JanaVPetrova)
141
205
 
206
+ [0.7.0]: https://github.com/rom-rb/rom-factory/compare/v0.6.0...v0.7.0
142
207
 
143
- [Compare v0.6.0...v0.7.0](https://github.com/rom-rb/rom-factory/compare/v0.6.0...v0.7.0)
144
-
145
- ## 0.6.0 2018-01-31
146
-
208
+ ## [0.6.0] - 2018-01-31
147
209
 
148
210
  ### Added
149
211
 
@@ -157,10 +219,9 @@ Factory[:user, **user_attributes]
157
219
 
158
220
  - Accessing a factory which is not defined will result in `FactoryNotDefinedError` exception (GustavoCaso + solnic)
159
221
 
160
- [Compare v0.5.0...v0.6.0](https://github.com/rom-rb/rom-factory/compare/v0.5.0...v0.6.0)
161
-
162
- ## 0.5.0 2017-10-24
222
+ [0.6.0]: https://github.com/rom-rb/rom-factory/compare/v0.5.0...v0.6.0
163
223
 
224
+ ## [0.5.0] - 2017-10-24
164
225
 
165
226
  ### Added
166
227
 
@@ -173,9 +234,9 @@ Factory[:user, **user_attributes]
173
234
 
174
235
  - Depends on `rom-core` now (solnic)
175
236
 
176
- [Compare v0.4.0...v0.5.0](https://github.com/rom-rb/rom-factory/compare/v0.4.0...v0.5.0)
237
+ [0.5.0]: https://github.com/rom-rb/rom-factory/compare/v0.4.0...v0.5.0
177
238
 
178
- ## 0.4.0 2017-03-03
239
+ ## [0.4.0] - 2017-03-03
179
240
 
180
241
  improves internals.
181
242
 
@@ -194,3 +255,5 @@ improves internals.
194
255
  - `Rom::Factory::Config.configure` was replaced with `ROM::Factory.configure` (solnic)
195
256
  - Global factory config and builders are gone (solnic)
196
257
  - Structs are now based on dry-struct (solnic)
258
+
259
+ [0.4.0]: https://github.com/rom-rb/rom-factory/tree/v0.4.0
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2021 rom-rb team
3
+ Copyright (c) 2015-2026 Hanakai team
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -1,29 +1,22 @@
1
- [gem]: https://rubygems.org/gems/rom-factory
2
- [actions]: https://github.com/rom-rb/rom-factory/actions
3
- [codacy]: https://www.codacy.com/gh/rom-rb/rom-factory
4
- [chat]: https://rom-rb.zulipchat.com
5
- [inchpages]: http://inch-ci.org/github/rom-rb/rom-factory
1
+ <!--- This file is synced from hanakai-rb/repo-sync -->
6
2
 
7
- # rom-factory [![Join the chat at https://rom-rb.zulipchat.com](https://img.shields.io/badge/rom--rb-join%20chat-%23346b7a.svg)][chat]
3
+ [actions]: https://github.com/hanakai-rb/rom-factory/actions
4
+ [chat]: https://discord.gg/naQApPAsZB
5
+ [forum]: https://discourse.hanakai.org
6
+ [rubygem]: https://rubygems.org/gems/rom-factory
8
7
 
9
- [![Gem Version](https://badge.fury.io/rb/rom-factory.svg)][gem]
10
- [![CI Status](https://github.com/rom-rb/rom-factory/workflows/ci/badge.svg)][actions]
11
- [![Codacy Badge](https://api.codacy.com/project/badge/Grade/5fd26fae687549218458879b1a607e18)][codacy]
12
- [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/5fd26fae687549218458879b1a607e18)][codacy]
13
- [![Inline docs](http://inch-ci.org/github/rom-rb/rom-factory.svg?branch=master)][inchpages]
8
+ # ROM Factory [![Gem Version](https://badge.fury.io/rb/rom-factory.svg)][rubygem] [![CI Status](https://github.com/hanakai-rb/rom-factory/workflows/CI/badge.svg)][actions]
14
9
 
15
- ## Links
16
-
17
- * [User documentation](https://rom-rb.org/learn/factory)
18
- * [API documentation](https://rubydoc.info/gems/rom-factory)
10
+ [![Forum](https://img.shields.io/badge/Forum-dc360f?logo=discourse&logoColor=white)][forum]
11
+ [![Chat](https://img.shields.io/badge/Chat-717cf8?logo=discord&logoColor=white)][chat]
19
12
 
20
- ## Supported Ruby versions
13
+ ## Links
21
14
 
22
- This library officially supports the following Ruby versions:
15
+ - [User documentation](https://hanakai.org/learn/rom/factories)
16
+ - [API documentation](http://rubydoc.info/gems/rom-factory)
23
17
 
24
- * MRI >= `2.5`
25
- * jruby >= `9.2`
26
18
 
27
19
  ## License
28
20
 
29
21
  See `LICENSE` file.
22
+
@@ -18,14 +18,10 @@ module ROM
18
18
  end
19
19
 
20
20
  # @api private
21
- def each(&block)
22
- elements.each(&block)
23
- end
21
+ def each(&) = elements.each(&)
24
22
 
25
23
  # @api private
26
- def [](name)
27
- detect { |e| e.name.equal?(name) }
28
- end
24
+ def [](name) = detect { |e| e.name.equal?(name) }
29
25
 
30
26
  # @api private
31
27
  def <<(element)
@@ -36,34 +32,32 @@ module ROM
36
32
  end
37
33
 
38
34
  # @api private
39
- def dup
40
- self.class.new(elements.dup)
41
- end
35
+ def dup = self.class.new(elements.dup)
42
36
 
43
37
  # @api private
44
- def values
45
- self.class.new(elements.select(&:value?))
46
- end
38
+ def values = self.class.new(elements.select(&:value?))
47
39
 
48
40
  # @api private
49
41
  def associations
50
42
  self.class.new(elements.select { |e| e.is_a?(Attributes::Association::Core) })
51
43
  end
52
44
 
53
- def reject(&block)
54
- self.class.new(elements.reject(&block))
45
+ def reject(&) = self.class.new(elements.reject(&))
46
+
47
+ # @api private
48
+ def inspect
49
+ "#<#{self.class} #{elements.inspect}>"
55
50
  end
51
+ alias_method :to_s, :inspect
56
52
 
57
53
  private
58
54
 
59
55
  # @api private
60
- def tsort_each_node(&block)
61
- each(&block)
62
- end
56
+ def tsort_each_node(&) = each(&)
63
57
 
64
58
  # @api private
65
- def tsort_each_child(attr, &block)
66
- attr.dependency_names.map { |name| self[name] }.compact.each(&block)
59
+ def tsort_each_child(attr, &)
60
+ attr.dependency_names.map { |name| self[name] }.compact.each(&)
67
61
  end
68
62
  end
69
63
  end