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 +4 -4
- data/CHANGELOG.md +107 -44
- data/LICENSE +1 -1
- data/README.md +12 -19
- data/lib/rom/factory/attribute_registry.rb +13 -19
- data/lib/rom/factory/attributes/association.rb +157 -173
- data/lib/rom/factory/attributes/callable.rb +32 -23
- data/lib/rom/factory/attributes/sequence.rb +26 -23
- data/lib/rom/factory/attributes/value.rb +25 -22
- data/lib/rom/factory/builder.rb +68 -65
- data/lib/rom/factory/dsl.rb +72 -36
- data/lib/rom/factory/factories.rb +229 -207
- data/lib/rom/factory/tuple_evaluator.rb +15 -7
- data/lib/rom/factory/version.rb +1 -1
- data/rom-factory.gemspec +26 -21
- metadata +39 -48
- data/.devtools/templates/changelog.erb +0 -43
- data/.devtools/templates/release.erb +0 -36
- data/.github/FUNDING.yml +0 -1
- data/.github/ISSUE_TEMPLATE/bug-report.md +0 -26
- data/.github/ISSUE_TEMPLATE/config.yml +0 -5
- data/.github/SUPPORT.md +0 -3
- data/.github/workflows/ci.yml +0 -88
- data/.github/workflows/docsite.yml +0 -62
- data/.github/workflows/rubocop.yml +0 -46
- data/.github/workflows/sync_configs.yml +0 -47
- data/.gitignore +0 -10
- data/.repobot.yml +0 -24
- data/.rspec +0 -4
- data/.rubocop.yml +0 -247
- data/.yardopts +0 -7
- data/CODEOWNERS +0 -1
- data/CODE_OF_CONDUCT.md +0 -13
- data/CONTRIBUTING.md +0 -29
- data/Gemfile +0 -39
- data/Gemfile.devtools +0 -20
- data/Rakefile +0 -8
- data/benchmarks/basic.rb +0 -66
- data/changelog.yml +0 -111
- data/docsite/source/index.html.md +0 -169
- data/project.yml +0 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 76c2c2d443aae25366e10dc9cfb41bc23a9e69abd38597b144214a9b4f861b51
|
|
4
|
+
data.tar.gz: 3aea3e8cf8568962e72c0d8ebda1da5b9ca38b6bcbf6469a9c2ea3f67377a314
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1a463af2b73eca8c24d2a276c678a72e7d7883ed030b241bdc71c58998ce2ce0742f039e30744a0baa12d81cfcab111602f2b960e0db5abf786b3c0f9afe3c03
|
|
7
|
+
data.tar.gz: b60e2dfd2d87136bd3f10a84df790fa2f664babdd9d972682986545ceefabf7353f7811ef6f2f51028f611012e3b9f632cf485fcdf63c0d490ef543b9b59cf8d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,23 +1,100 @@
|
|
|
1
|
-
|
|
1
|
+
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
9
|
-
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
### Deprecated
|
|
15
|
+
|
|
16
|
+
### Removed
|
|
10
17
|
|
|
11
18
|
### Fixed
|
|
12
19
|
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
79
|
+
- Minimum Ruby version is now 3.1 (@flash-gordon)
|
|
18
80
|
|
|
19
|
-
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
data/README.md
CHANGED
|
@@ -1,29 +1,22 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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
|
-
[][
|
|
10
|
-
[][actions]
|
|
11
|
-
[][codacy]
|
|
12
|
-
[][codacy]
|
|
13
|
-
[][inchpages]
|
|
8
|
+
# ROM Factory [][rubygem] [][actions]
|
|
14
9
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* [User documentation](https://rom-rb.org/learn/factory)
|
|
18
|
-
* [API documentation](https://rubydoc.info/gems/rom-factory)
|
|
10
|
+
[][forum]
|
|
11
|
+
[][chat]
|
|
19
12
|
|
|
20
|
-
##
|
|
13
|
+
## Links
|
|
21
14
|
|
|
22
|
-
|
|
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(&
|
|
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(&
|
|
54
|
-
|
|
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(&
|
|
61
|
-
each(&block)
|
|
62
|
-
end
|
|
56
|
+
def tsort_each_node(&) = each(&)
|
|
63
57
|
|
|
64
58
|
# @api private
|
|
65
|
-
def tsort_each_child(attr, &
|
|
66
|
-
attr.dependency_names.map { |name| self[name] }.compact.each(&
|
|
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
|