rom-factory 0.10.0 → 0.10.1

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: 6d9ea536ecec5b699d9d75f0f738a4213922eaae03c7fca0f707934d7744f71a
4
- data.tar.gz: bbf3688728b9d282bebeed47c38b083542af414d28c80adeefa5b33db103899c
3
+ metadata.gz: 504ab61b3360ec9a28fd62e995f5968cee1f26ac566ab8f4fa5058626f192b62
4
+ data.tar.gz: 0f657fa936e822c49e6fca236b0adbac14d661ae4340dbb22c2387a65326fc6b
5
5
  SHA512:
6
- metadata.gz: 85246d5ba4663c72a9e34cd2145af5e905eb95f2ee288d9b9920e176298ebc0c8729f619aac1b6402db15c03cd4bf66268ba57182740bfeeaccc38e73c6cc5dc
7
- data.tar.gz: 4d2c58b4bb729efce704e6bc62999cfc0662b9e90513e9569e8991fe8863d14feb4dd2b014dfbd65a5e9a20a15809547afd1b00df98042f132e4ad8f675d5887
6
+ metadata.gz: a3bccee8f544c0022d71a6b1652a86d228ff93e97708568192c6027d33bbd1c723bc0f0a303a57c3d673ae614da240c1523436247a35fc5599fecb365e02545f
7
+ data.tar.gz: dced3ab7a97199b676e64d5b71aec8ffafc00ff578e3800f78200024c62b82a07f41a125c2bf37b2a4534fde5e8155e9ab84fc31e0279e50d2b3d6113a766983
@@ -11,10 +11,6 @@ assignees: ''
11
11
 
12
12
  For more information see [our contribution guidelines](https://github.com/rom-rb/rom/blob/master/CONTRIBUTING.md)
13
13
 
14
- **Before you report**
15
-
16
- :warning: If you have a problem related to a schema, please **report it under [dry-schema issues](https://github.com/rom-rb/dry-schema/issues/new?assignees=&labels=bug&template=---bug-report.md&title=)** instead.
17
-
18
14
  **Describe the bug**
19
15
 
20
16
  A clear and concise description of what the bug is.
@@ -30,6 +30,7 @@ jobs:
30
30
  fail-fast: false
31
31
  matrix:
32
32
  ruby: ["2.6.x", "2.5.x", "2.4.x"]
33
+ appraisal: ["faker_1", "faker_2"]
33
34
  include:
34
35
  - ruby: "2.6.x"
35
36
  coverage: "true"
@@ -44,14 +45,20 @@ jobs:
44
45
  - name: Install bundler
45
46
  run: gem install bundler
46
47
  - name: Bundle
48
+ env:
49
+ BUNDLE_GEMFILE: gemfiles/${{matrix.appraisal}}.gemfile
47
50
  run: bundle install --jobs 4 --retry 3 --without tools docs benchmarks
48
51
  - name: Run all tests
49
52
  env:
50
53
  COVERAGE: ${{matrix.coverage}}
54
+ BUNDLE_GEMFILE: gemfiles/${{matrix.appraisal}}.gemfile
51
55
  run: bundle exec rake
52
56
  - name: Download test reporter
53
57
  if: "matrix.coverage == 'true'"
58
+ env:
59
+ CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
54
60
  run: |
61
+ [ "$CC_TEST_REPORTER_ID" = "" ] && exit 0
55
62
  mkdir -p tmp/
56
63
  curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter
57
64
  chmod +x ./tmp/cc-test-reporter
@@ -64,6 +71,7 @@ jobs:
64
71
  GIT_BRANCH: ${{github.ref}}
65
72
  GIT_COMMITTED_AT: ${{github.event.head_commit.timestamp}}
66
73
  run: |
74
+ [ "$CC_TEST_REPORTER_ID" = "" ] && exit 0
67
75
  GIT_BRANCH=`ruby -e "puts ENV['GITHUB_REF'].split('/', 3).last"` \
68
76
  GIT_COMMITTED_AT=`ruby -r time -e "puts Time.iso8601(ENV['GIT_COMMITTED_AT']).to_i"` \
69
77
  ./tmp/cc-test-reporter after-build
@@ -29,6 +29,6 @@ jobs:
29
29
  run: mkdir -p bin && ln -sf "$(bundle show ossy)/bin/ossy" bin/ossy
30
30
  - name: Trigger rom-rb.org deploy
31
31
  env:
32
- GITHUB_LOGIN: ${{ github.actor }}
32
+ GITHUB_LOGIN: rom-bot
33
33
  GITHUB_TOKEN: ${{ secrets.GH_PAT }}
34
34
  run: bin/ossy github workflow rom-rb/rom-rb.org ci
data/.gitignore CHANGED
@@ -7,4 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
- .rubocop.yml
10
+ .vscode
data/.rubocop.yml ADDED
@@ -0,0 +1,89 @@
1
+ # this file is managed by rom-rb/devtools project
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.4
5
+
6
+ Style/EachWithObject:
7
+ Enabled: false
8
+
9
+ Style/StringLiterals:
10
+ Enabled: true
11
+ EnforcedStyle: single_quotes
12
+
13
+ Style/Alias:
14
+ Enabled: false
15
+
16
+ Style/LambdaCall:
17
+ Enabled: false
18
+
19
+ Style/StabbyLambdaParentheses:
20
+ Enabled: false
21
+
22
+ Style/FormatString:
23
+ Enabled: false
24
+
25
+ Style/Documentation:
26
+ Enabled: false
27
+
28
+ Layout/SpaceInLambdaLiteral:
29
+ Enabled: false
30
+
31
+ Layout/MultilineMethodCallIndentation:
32
+ Enabled: true
33
+ EnforcedStyle: indented
34
+
35
+ Metrics/LineLength:
36
+ Max: 100
37
+
38
+ Metrics/MethodLength:
39
+ Max: 22
40
+
41
+ Metrics/ClassLength:
42
+ Max: 150
43
+
44
+ Metrics/AbcSize:
45
+ Max: 20
46
+
47
+ Metrics/BlockLength:
48
+ Enabled: false
49
+
50
+ Metrics/CyclomaticComplexity:
51
+ Enabled: true
52
+ Max: 10
53
+
54
+ Lint/BooleanSymbol:
55
+ Enabled: false
56
+
57
+ Style/AccessModifierDeclarations:
58
+ Enabled: false
59
+
60
+ Style/BlockDelimiters:
61
+ Enabled: false
62
+
63
+ Layout/IndentFirstArrayElement:
64
+ EnforcedStyle: consistent
65
+
66
+ Style/ClassAndModuleChildren:
67
+ Exclude:
68
+ - "spec/**/*_spec.rb"
69
+
70
+ Lint/HandleExceptions:
71
+ Exclude:
72
+ - "spec/spec_helper.rb"
73
+
74
+ Naming/PredicateName:
75
+ Enabled: false
76
+
77
+ Naming/FileName:
78
+ Exclude:
79
+ - "lib/rom-*.rb"
80
+
81
+ Style/SymbolArray:
82
+ Exclude:
83
+ - "spec/**/*_spec.rb"
84
+
85
+ Style/ConditionalAssignment:
86
+ Enabled: false
87
+
88
+ Naming/MethodName:
89
+ Enabled: false
data/Appraisals ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ appraise 'faker-1' do
4
+ gem 'faker', '~> 1.7'
5
+ end
6
+
7
+ appraise 'faker-2' do
8
+ gem 'faker', '~> 2.8'
9
+ end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
- ## 0.10.0 2019-12-11
1
+ ## 0.10.1 2019-12-28
2
+
3
+ ### Added
2
4
 
5
+ - Support for faker 2 (@ianks)
6
+
7
+ ### Fixed
8
+
9
+ - Keyword warnings reported by Ruby 2.7 (@flash-gordon)
10
+
11
+ [Compare v0.10.0...v0.10.1](https://github.com/rom-rb/rom-factory/compare/v0.10.0...v0.10.1)
12
+
13
+ ## 0.10.0 2019-12-11
3
14
 
4
15
  ### Added
5
16
 
@@ -13,12 +24,12 @@
13
24
 
14
25
  ### Fixed
15
26
 
16
- * Support building structs when child assoc does not define parent (@psparrow)
27
+ * Support building structs when child assoc does not define parent (@psparrow)
17
28
  * Fixed `TupleEvaluator#struct_attrs` for non-standard output schema (@AMHOL)
18
29
 
19
30
  [Compare v0.9.1...v0.10.0](https://github.com/rom-rb/rom-factory/compare/v0.9.1...v0.10.0)
20
31
 
21
- ## 0.9.1 2019-10-23
32
+ ## 0.9.1 2019-10-23
22
33
 
23
34
  ### Fixed
24
35
 
data/Gemfile CHANGED
@@ -8,10 +8,13 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
8
8
 
9
9
  gem 'rake', '~> 12.0'
10
10
  gem 'rspec', '~> 3.0'
11
- gem 'faker', '<= 1.9'
11
+
12
+ gem 'rom', github: 'rom-rb/rom', branch: 'master' do
13
+ gem 'rom-core'
14
+ end
12
15
 
13
16
  group :test do
14
- gem 'rom-sql', '~> 3.0'
17
+ gem 'rom-sql', github: 'rom-rb/rom-sql', branch: 'master'
15
18
  gem 'inflecto'
16
19
  gem 'pry-byebug', platforms: :mri
17
20
  gem 'pry', platforms: :jruby
@@ -20,6 +23,7 @@ group :test do
20
23
 
21
24
  gem 'pg', '~> 0.21', platforms: [:mri, :truffleruby]
22
25
  gem 'jdbc-postgres', platforms: :jruby
26
+ gem 'warning'
23
27
  end
24
28
 
25
29
  group :tools do
@@ -1,3 +1,8 @@
1
+ ---
2
+ position: 7
3
+ chapter: Factory
4
+ ---
5
+
1
6
  # rom-factory
2
7
 
3
8
  TODO: write docs :)
@@ -0,0 +1,34 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 12.0"
6
+ gem "rspec", "~> 3.0"
7
+ gem "rom", branch: "master", git: "https://github.com/rom-rb/rom"
8
+ gem "faker", "~> 1.7"
9
+
10
+ group :test do
11
+ gem "rom-sql", github: "rom-rb/rom-sql", branch: "master"
12
+ gem "inflecto"
13
+ gem "pry-byebug", platforms: :mri
14
+ gem "pry", platforms: :jruby
15
+ gem "codeclimate-test-reporter"
16
+ gem "simplecov"
17
+ gem "pg", "~> 0.21", platforms: [:mri, :truffleruby]
18
+ gem "jdbc-postgres", platforms: :jruby
19
+ gem "warning"
20
+ end
21
+
22
+ group :tools do
23
+ gem "byebug", platform: :mri
24
+ gem "redcarpet"
25
+ end
26
+
27
+ group :benchmarks do
28
+ gem "activerecord"
29
+ gem "benchmark-ips"
30
+ gem "factory_bot"
31
+ gem "fabrication"
32
+ end
33
+
34
+ gemspec path: "../"
@@ -0,0 +1,178 @@
1
+ GIT
2
+ remote: https://github.com/rom-rb/rom
3
+ revision: 3db318e22550d17ce21e14a035329b33c7e6f5d5
4
+ branch: master
5
+ specs:
6
+ rom (5.1.2)
7
+ rom-changeset (~> 5.1)
8
+ rom-core (~> 5.1, >= 5.1.2)
9
+ rom-repository (~> 5.1)
10
+ rom-changeset (5.1.2)
11
+ dry-core (~> 0.4)
12
+ rom-core (~> 5.1, >= 5.1.2)
13
+ transproc (~> 1.0, >= 1.1.0)
14
+ rom-core (5.1.2)
15
+ concurrent-ruby (~> 1.1)
16
+ dry-container (~> 0.7)
17
+ dry-core (~> 0.4)
18
+ dry-equalizer (~> 0.2)
19
+ dry-inflector (~> 0.1)
20
+ dry-initializer (~> 3.0, >= 3.0.1)
21
+ dry-struct (~> 1.0)
22
+ dry-types (~> 1.0)
23
+ transproc (~> 1.0, >= 1.1.0)
24
+ rom-repository (5.1.2)
25
+ dry-core (~> 0.4)
26
+ dry-initializer (~> 3.0, >= 3.0.1)
27
+ rom-core (~> 5.1, >= 5.1.2)
28
+
29
+ GIT
30
+ remote: https://github.com/rom-rb/rom-sql.git
31
+ revision: b678e410eef1a608e48613120c30ccee6c02ab7f
32
+ branch: master
33
+ specs:
34
+ rom-sql (3.1.0)
35
+ dry-core (~> 0.4)
36
+ dry-equalizer (~> 0.2)
37
+ dry-types (~> 1.0)
38
+ rom-core (~> 5.0, >= 5.0.1)
39
+ sequel (>= 4.49)
40
+
41
+ PATH
42
+ remote: ..
43
+ specs:
44
+ rom-factory (0.10.0)
45
+ dry-configurable (~> 0.7)
46
+ dry-core (~> 0.4)
47
+ faker (>= 1.7, < 3.0)
48
+ rom-core (~> 5.0)
49
+
50
+ GEM
51
+ remote: https://rubygems.org/
52
+ specs:
53
+ activemodel (6.0.2)
54
+ activesupport (= 6.0.2)
55
+ activerecord (6.0.2)
56
+ activemodel (= 6.0.2)
57
+ activesupport (= 6.0.2)
58
+ activesupport (6.0.2)
59
+ concurrent-ruby (~> 1.0, >= 1.0.2)
60
+ i18n (>= 0.7, < 2)
61
+ minitest (~> 5.1)
62
+ tzinfo (~> 1.1)
63
+ zeitwerk (~> 2.2)
64
+ appraisal (2.2.0)
65
+ bundler
66
+ rake
67
+ thor (>= 0.14.0)
68
+ benchmark-ips (2.7.2)
69
+ byebug (11.0.1)
70
+ codeclimate-test-reporter (1.0.9)
71
+ simplecov (<= 0.13)
72
+ coderay (1.1.2)
73
+ concurrent-ruby (1.1.5)
74
+ diff-lcs (1.3)
75
+ docile (1.1.5)
76
+ dry-configurable (0.9.0)
77
+ concurrent-ruby (~> 1.0)
78
+ dry-core (~> 0.4, >= 0.4.7)
79
+ dry-container (0.7.2)
80
+ concurrent-ruby (~> 1.0)
81
+ dry-configurable (~> 0.1, >= 0.1.3)
82
+ dry-core (0.4.9)
83
+ concurrent-ruby (~> 1.0)
84
+ dry-equalizer (0.3.0)
85
+ dry-inflector (0.2.0)
86
+ dry-initializer (3.0.2)
87
+ dry-logic (1.0.5)
88
+ concurrent-ruby (~> 1.0)
89
+ dry-core (~> 0.2)
90
+ dry-equalizer (~> 0.2)
91
+ dry-struct (1.2.0)
92
+ dry-core (~> 0.4, >= 0.4.3)
93
+ dry-equalizer (~> 0.3)
94
+ dry-types (~> 1.0)
95
+ ice_nine (~> 0.11)
96
+ dry-types (1.2.2)
97
+ concurrent-ruby (~> 1.0)
98
+ dry-container (~> 0.3)
99
+ dry-core (~> 0.4, >= 0.4.4)
100
+ dry-equalizer (~> 0.3)
101
+ dry-inflector (~> 0.1, >= 0.1.2)
102
+ dry-logic (~> 1.0, >= 1.0.2)
103
+ fabrication (2.21.0)
104
+ factory_bot (5.1.1)
105
+ activesupport (>= 4.2.0)
106
+ faker (1.9.6)
107
+ i18n (>= 0.7)
108
+ i18n (1.7.0)
109
+ concurrent-ruby (~> 1.0)
110
+ ice_nine (0.11.2)
111
+ inflecto (0.0.2)
112
+ json (2.3.0)
113
+ method_source (0.9.2)
114
+ minitest (5.13.0)
115
+ pg (0.21.0)
116
+ pry (0.12.2)
117
+ coderay (~> 1.1.0)
118
+ method_source (~> 0.9.0)
119
+ pry-byebug (3.7.0)
120
+ byebug (~> 11.0)
121
+ pry (~> 0.10)
122
+ rake (12.3.3)
123
+ redcarpet (3.5.0)
124
+ rspec (3.9.0)
125
+ rspec-core (~> 3.9.0)
126
+ rspec-expectations (~> 3.9.0)
127
+ rspec-mocks (~> 3.9.0)
128
+ rspec-core (3.9.0)
129
+ rspec-support (~> 3.9.0)
130
+ rspec-expectations (3.9.0)
131
+ diff-lcs (>= 1.2.0, < 2.0)
132
+ rspec-support (~> 3.9.0)
133
+ rspec-mocks (3.9.0)
134
+ diff-lcs (>= 1.2.0, < 2.0)
135
+ rspec-support (~> 3.9.0)
136
+ rspec-support (3.9.0)
137
+ sequel (5.27.0)
138
+ simplecov (0.13.0)
139
+ docile (~> 1.1.0)
140
+ json (>= 1.8, < 3)
141
+ simplecov-html (~> 0.10.0)
142
+ simplecov-html (0.10.2)
143
+ thor (1.0.0)
144
+ thread_safe (0.3.6)
145
+ transproc (1.1.1)
146
+ tzinfo (1.2.5)
147
+ thread_safe (~> 0.1)
148
+ warning (0.10.1)
149
+ zeitwerk (2.2.2)
150
+
151
+ PLATFORMS
152
+ ruby
153
+
154
+ DEPENDENCIES
155
+ activerecord
156
+ appraisal
157
+ benchmark-ips
158
+ byebug
159
+ codeclimate-test-reporter
160
+ fabrication
161
+ factory_bot
162
+ faker (~> 1.7)
163
+ inflecto
164
+ jdbc-postgres
165
+ pg (~> 0.21)
166
+ pry
167
+ pry-byebug
168
+ rake (~> 12.0)
169
+ redcarpet
170
+ rom!
171
+ rom-factory!
172
+ rom-sql!
173
+ rspec (~> 3.0)
174
+ simplecov
175
+ warning
176
+
177
+ BUNDLED WITH
178
+ 2.1.2
@@ -0,0 +1,34 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 12.0"
6
+ gem "rspec", "~> 3.0"
7
+ gem "rom", branch: "master", git: "https://github.com/rom-rb/rom"
8
+ gem "faker", "~> 2.8"
9
+
10
+ group :test do
11
+ gem "rom-sql", github: "rom-rb/rom-sql", branch: "master"
12
+ gem "inflecto"
13
+ gem "pry-byebug", platforms: :mri
14
+ gem "pry", platforms: :jruby
15
+ gem "codeclimate-test-reporter"
16
+ gem "simplecov"
17
+ gem "pg", "~> 0.21", platforms: [:mri, :truffleruby]
18
+ gem "jdbc-postgres", platforms: :jruby
19
+ gem "warning"
20
+ end
21
+
22
+ group :tools do
23
+ gem "byebug", platform: :mri
24
+ gem "redcarpet"
25
+ end
26
+
27
+ group :benchmarks do
28
+ gem "activerecord"
29
+ gem "benchmark-ips"
30
+ gem "factory_bot"
31
+ gem "fabrication"
32
+ end
33
+
34
+ gemspec path: "../"
@@ -0,0 +1,178 @@
1
+ GIT
2
+ remote: https://github.com/rom-rb/rom
3
+ revision: 3db318e22550d17ce21e14a035329b33c7e6f5d5
4
+ branch: master
5
+ specs:
6
+ rom (5.1.2)
7
+ rom-changeset (~> 5.1)
8
+ rom-core (~> 5.1, >= 5.1.2)
9
+ rom-repository (~> 5.1)
10
+ rom-changeset (5.1.2)
11
+ dry-core (~> 0.4)
12
+ rom-core (~> 5.1, >= 5.1.2)
13
+ transproc (~> 1.0, >= 1.1.0)
14
+ rom-core (5.1.2)
15
+ concurrent-ruby (~> 1.1)
16
+ dry-container (~> 0.7)
17
+ dry-core (~> 0.4)
18
+ dry-equalizer (~> 0.2)
19
+ dry-inflector (~> 0.1)
20
+ dry-initializer (~> 3.0, >= 3.0.1)
21
+ dry-struct (~> 1.0)
22
+ dry-types (~> 1.0)
23
+ transproc (~> 1.0, >= 1.1.0)
24
+ rom-repository (5.1.2)
25
+ dry-core (~> 0.4)
26
+ dry-initializer (~> 3.0, >= 3.0.1)
27
+ rom-core (~> 5.1, >= 5.1.2)
28
+
29
+ GIT
30
+ remote: https://github.com/rom-rb/rom-sql.git
31
+ revision: b678e410eef1a608e48613120c30ccee6c02ab7f
32
+ branch: master
33
+ specs:
34
+ rom-sql (3.1.0)
35
+ dry-core (~> 0.4)
36
+ dry-equalizer (~> 0.2)
37
+ dry-types (~> 1.0)
38
+ rom-core (~> 5.0, >= 5.0.1)
39
+ sequel (>= 4.49)
40
+
41
+ PATH
42
+ remote: ..
43
+ specs:
44
+ rom-factory (0.10.0)
45
+ dry-configurable (~> 0.7)
46
+ dry-core (~> 0.4)
47
+ faker (>= 1.7, < 3.0)
48
+ rom-core (~> 5.0)
49
+
50
+ GEM
51
+ remote: https://rubygems.org/
52
+ specs:
53
+ activemodel (6.0.2)
54
+ activesupport (= 6.0.2)
55
+ activerecord (6.0.2)
56
+ activemodel (= 6.0.2)
57
+ activesupport (= 6.0.2)
58
+ activesupport (6.0.2)
59
+ concurrent-ruby (~> 1.0, >= 1.0.2)
60
+ i18n (>= 0.7, < 2)
61
+ minitest (~> 5.1)
62
+ tzinfo (~> 1.1)
63
+ zeitwerk (~> 2.2)
64
+ appraisal (2.2.0)
65
+ bundler
66
+ rake
67
+ thor (>= 0.14.0)
68
+ benchmark-ips (2.7.2)
69
+ byebug (11.0.1)
70
+ codeclimate-test-reporter (1.0.9)
71
+ simplecov (<= 0.13)
72
+ coderay (1.1.2)
73
+ concurrent-ruby (1.1.5)
74
+ diff-lcs (1.3)
75
+ docile (1.1.5)
76
+ dry-configurable (0.9.0)
77
+ concurrent-ruby (~> 1.0)
78
+ dry-core (~> 0.4, >= 0.4.7)
79
+ dry-container (0.7.2)
80
+ concurrent-ruby (~> 1.0)
81
+ dry-configurable (~> 0.1, >= 0.1.3)
82
+ dry-core (0.4.9)
83
+ concurrent-ruby (~> 1.0)
84
+ dry-equalizer (0.3.0)
85
+ dry-inflector (0.2.0)
86
+ dry-initializer (3.0.2)
87
+ dry-logic (1.0.5)
88
+ concurrent-ruby (~> 1.0)
89
+ dry-core (~> 0.2)
90
+ dry-equalizer (~> 0.2)
91
+ dry-struct (1.2.0)
92
+ dry-core (~> 0.4, >= 0.4.3)
93
+ dry-equalizer (~> 0.3)
94
+ dry-types (~> 1.0)
95
+ ice_nine (~> 0.11)
96
+ dry-types (1.2.2)
97
+ concurrent-ruby (~> 1.0)
98
+ dry-container (~> 0.3)
99
+ dry-core (~> 0.4, >= 0.4.4)
100
+ dry-equalizer (~> 0.3)
101
+ dry-inflector (~> 0.1, >= 0.1.2)
102
+ dry-logic (~> 1.0, >= 1.0.2)
103
+ fabrication (2.21.0)
104
+ factory_bot (5.1.1)
105
+ activesupport (>= 4.2.0)
106
+ faker (2.8.1)
107
+ i18n (>= 1.6, < 1.8)
108
+ i18n (1.7.0)
109
+ concurrent-ruby (~> 1.0)
110
+ ice_nine (0.11.2)
111
+ inflecto (0.0.2)
112
+ json (2.3.0)
113
+ method_source (0.9.2)
114
+ minitest (5.13.0)
115
+ pg (0.21.0)
116
+ pry (0.12.2)
117
+ coderay (~> 1.1.0)
118
+ method_source (~> 0.9.0)
119
+ pry-byebug (3.7.0)
120
+ byebug (~> 11.0)
121
+ pry (~> 0.10)
122
+ rake (12.3.3)
123
+ redcarpet (3.5.0)
124
+ rspec (3.9.0)
125
+ rspec-core (~> 3.9.0)
126
+ rspec-expectations (~> 3.9.0)
127
+ rspec-mocks (~> 3.9.0)
128
+ rspec-core (3.9.0)
129
+ rspec-support (~> 3.9.0)
130
+ rspec-expectations (3.9.0)
131
+ diff-lcs (>= 1.2.0, < 2.0)
132
+ rspec-support (~> 3.9.0)
133
+ rspec-mocks (3.9.0)
134
+ diff-lcs (>= 1.2.0, < 2.0)
135
+ rspec-support (~> 3.9.0)
136
+ rspec-support (3.9.0)
137
+ sequel (5.27.0)
138
+ simplecov (0.13.0)
139
+ docile (~> 1.1.0)
140
+ json (>= 1.8, < 3)
141
+ simplecov-html (~> 0.10.0)
142
+ simplecov-html (0.10.2)
143
+ thor (1.0.0)
144
+ thread_safe (0.3.6)
145
+ transproc (1.1.1)
146
+ tzinfo (1.2.5)
147
+ thread_safe (~> 0.1)
148
+ warning (0.10.1)
149
+ zeitwerk (2.2.2)
150
+
151
+ PLATFORMS
152
+ ruby
153
+
154
+ DEPENDENCIES
155
+ activerecord
156
+ appraisal
157
+ benchmark-ips
158
+ byebug
159
+ codeclimate-test-reporter
160
+ fabrication
161
+ factory_bot
162
+ faker (~> 2.8)
163
+ inflecto
164
+ jdbc-postgres
165
+ pg (~> 0.21)
166
+ pry
167
+ pry-byebug
168
+ rake (~> 12.0)
169
+ redcarpet
170
+ rom!
171
+ rom-factory!
172
+ rom-sql!
173
+ rspec (~> 3.0)
174
+ simplecov
175
+ warning
176
+
177
+ BUNDLED WITH
178
+ 2.1.2
@@ -4,8 +4,11 @@ module ROM::Factory
4
4
  module Attributes
5
5
  # @api private
6
6
  module Association
7
- def self.new(assoc, builder, *traits, **options)
8
- const_get(assoc.definition.type).new(assoc, builder, *traits, **options)
7
+ class << self
8
+ def new(assoc, builder, *args)
9
+ const_get(assoc.definition.type).new(assoc, builder, *args)
10
+ end
11
+ ruby2_keywords(:new) if respond_to?(:ruby2_keywords, true)
9
12
  end
10
13
 
11
14
  # @api private
@@ -44,11 +47,11 @@ module ROM::Factory
44
47
  # @api private
45
48
  class ManyToOne < Core
46
49
  # @api private
47
- def call(attrs, opts)
50
+ def call(attrs, persist: true)
48
51
  if attrs.key?(name) && !attrs[foreign_key]
49
52
  assoc.associate(attrs, attrs[name])
50
53
  elsif !attrs[foreign_key]
51
- struct = if opts.fetch(:persist, true)
54
+ struct = if persist
52
55
  builder.persistable.create(*traits)
53
56
  else
54
57
  builder.struct(*traits)
@@ -98,7 +101,7 @@ module ROM::Factory
98
101
  # @api private
99
102
  class OneToOne < OneToMany
100
103
  # @api private
101
- def call(attrs = EMPTY_HASH, parent, opts)
104
+ def call(attrs = EMPTY_HASH, parent, persist: true)
102
105
  # do not associate if count is 0
103
106
  return { name => nil } if count.zero?
104
107
 
@@ -106,7 +109,7 @@ module ROM::Factory
106
109
 
107
110
  association_hash = assoc.associate(attrs, parent)
108
111
 
109
- struct = if opts.fetch(:persist, true)
112
+ struct = if persist
110
113
  builder.persistable.create(*traits, association_hash)
111
114
  else
112
115
  belongs_to_name = Dry::Core::Inflector.singularize(assoc.source_alias)
@@ -31,15 +31,18 @@ module ROM::Factory
31
31
  option :struct_namespace, reader: false
32
32
 
33
33
  # @api private
34
- def tuple(*traits, **attrs)
34
+ def tuple(*args)
35
+ traits, attrs = extract_tuple(args)
36
+
35
37
  tuple_evaluator.defaults(traits, attrs)
36
38
  end
37
39
 
38
40
  # @api private
39
- def struct(*traits, **attrs)
41
+ def struct(*args)
42
+ traits, attrs = extract_tuple(args)
40
43
  validate_keys(traits, attrs, allow_associations: true)
41
44
 
42
- tuple_evaluator.struct(*traits, attrs)
45
+ tuple_evaluator.struct(*args)
43
46
  end
44
47
  alias_method :create, :struct
45
48
 
@@ -72,6 +75,11 @@ module ROM::Factory
72
75
  tuple_evaluator.relation
73
76
  end
74
77
 
78
+ # @api private
79
+ def extract_tuple(args)
80
+ tuple_evaluator.extract_tuple(args)
81
+ end
82
+
75
83
  # @api private
76
84
  def validate_keys(traits, tuple, allow_associations: false)
77
85
  schema_keys = relation.schema.attributes.map(&:name)
@@ -21,7 +21,9 @@ module ROM
21
21
  end
22
22
 
23
23
  # @api private
24
- def create(*traits, **attrs)
24
+ def create(*args)
25
+ traits, attrs = builder.extract_tuple(args)
26
+
25
27
  tuple = tuple(*traits, attrs)
26
28
  validate_keys(traits, attrs)
27
29
  persisted = persist(tuple)
@@ -9,16 +9,18 @@ require 'rom/factory/attributes'
9
9
 
10
10
  module ROM
11
11
  module Factory
12
- # @api private
13
- def self.fake(type, *args)
14
- api = Faker.const_get(Dry::Core::Inflector.classify(type.to_s))
15
- meth, *rest = args
16
-
17
- if meth.is_a?(Symbol)
18
- api.public_send(meth, *rest)
19
- else
20
- api.public_send(type, *args)
12
+ class << self
13
+ # @api private
14
+ def fake(type, *args)
15
+ api = ::Faker.const_get(::Dry::Core::Inflector.classify(type.to_s))
16
+
17
+ if args[0].is_a?(Symbol)
18
+ api.public_send(*args)
19
+ else
20
+ api.public_send(type, *args)
21
+ end
21
22
  end
23
+ ruby2_keywords(:fake) if respond_to?(:ruby2_keywords, true)
22
24
  end
23
25
 
24
26
  # Factory builder DSL
@@ -129,7 +129,7 @@ module ROM::Factory
129
129
  # @return [ROM::Factory::Builder]
130
130
  #
131
131
  # @api public
132
- def define(spec, **opts, &block)
132
+ def define(spec, opts = EMPTY_HASH, &block)
133
133
  name, parent = spec.is_a?(Hash) ? spec.flatten(1) : spec
134
134
  namespace = opts[:struct_namespace]
135
135
  relation_name = opts.fetch(:relation) { infer_relation(name) }
@@ -143,9 +143,13 @@ module ROM::Factory
143
143
  extend_builder(name, registry[parent], relation_name, namespace, &block)
144
144
  else
145
145
  relation = rom.relations[relation_name]
146
- DSL.new(name, { relation: relation,
147
- factories: self,
148
- struct_namespace: builder_sturct_namespace(namespace) }, &block).call
146
+ DSL.new(
147
+ name,
148
+ relation: relation,
149
+ factories: self,
150
+ struct_namespace: builder_sturct_namespace(namespace),
151
+ &block
152
+ ).call
149
153
  end
150
154
 
151
155
  registry[name] = builder
@@ -165,8 +169,8 @@ module ROM::Factory
165
169
  # @return [ROM::Struct]
166
170
  #
167
171
  # @api public
168
- def [](name, *traits, **attrs)
169
- registry[name].struct_namespace(struct_namespace).persistable.create(*traits, attrs)
172
+ def [](name, *args)
173
+ registry[name].struct_namespace(struct_namespace).persistable.create(*args)
170
174
  end
171
175
 
172
176
  # Return in-memory struct builder
@@ -224,10 +228,14 @@ module ROM::Factory
224
228
  namespace = parent.options[:struct_namespace]
225
229
  namespace = builder_sturct_namespace(ns) if ns
226
230
  relation = rom.relations.fetch(relation_name) { parent.relation }
227
- DSL.new(name, { attributes: parent.attributes,
228
- relation: relation,
229
- factories: self,
230
- struct_namespace: namespace }, &block).call
231
+ DSL.new(
232
+ name,
233
+ attributes: parent.attributes,
234
+ relation: relation,
235
+ factories: self,
236
+ struct_namespace: namespace,
237
+ &block
238
+ ).call
231
239
  end
232
240
  end
233
241
  end
@@ -36,7 +36,8 @@ module ROM
36
36
  end
37
37
 
38
38
  # @api private
39
- def struct(*traits, attrs)
39
+ def struct(*args)
40
+ traits, attrs = extract_tuple(args)
40
41
  merged_attrs = struct_attrs.merge(defaults(traits, attrs, persist: false))
41
42
  is_callable = proc { |_name, value| value.respond_to?(:call) }
42
43
 
@@ -91,6 +92,17 @@ module ROM
91
92
  relation.primary_key
92
93
  end
93
94
 
95
+ # @api private
96
+ def extract_tuple(args)
97
+ if !args.empty? && args.last.is_a?(::Hash)
98
+ *traits, attrs = args
99
+
100
+ [traits, attrs]
101
+ else
102
+ [args, EMPTY_HASH]
103
+ end
104
+ end
105
+
94
106
  private
95
107
 
96
108
  # @api private
@@ -125,10 +137,10 @@ module ROM
125
137
  attributes.associations.each_with_object({}) do |assoc, h|
126
138
  if assoc.dependency?(relation)
127
139
  h[assoc.name] = ->(parent, call_opts) do
128
- assoc.call(parent, opts.merge(call_opts))
140
+ assoc.call(parent, **opts, **call_opts)
129
141
  end
130
142
  else
131
- result = assoc.(attrs, opts)
143
+ result = assoc.(attrs, **opts)
132
144
  h.update(result) if result
133
145
  end
134
146
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ROM
4
4
  module Factory
5
- VERSION = '0.10.0'
5
+ VERSION = '0.10.1'
6
6
  end
7
7
  end
data/rom-factory.gemspec CHANGED
@@ -31,6 +31,8 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  spec.add_dependency "dry-configurable", "~> 0.7"
33
33
  spec.add_dependency "dry-core", "~> 0.4"
34
- spec.add_dependency "rom-core", "~> 5.0"
35
- spec.add_dependency "faker", "~> 1.7"
34
+ spec.add_dependency 'faker', '>= 1.7', '< 3.0'
35
+ spec.add_dependency 'rom-core', '~> 5.0'
36
+
37
+ spec.add_development_dependency 'appraisal'
36
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rom-factory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janis Miezitis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-12-11 00:00:00.000000000 Z
12
+ date: 2019-12-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dry-configurable
@@ -39,6 +39,26 @@ dependencies:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0.4'
42
+ - !ruby/object:Gem::Dependency
43
+ name: faker
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '1.7'
49
+ - - "<"
50
+ - !ruby/object:Gem::Version
51
+ version: '3.0'
52
+ type: :runtime
53
+ prerelease: false
54
+ version_requirements: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '1.7'
59
+ - - "<"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
42
62
  - !ruby/object:Gem::Dependency
43
63
  name: rom-core
44
64
  requirement: !ruby/object:Gem::Requirement
@@ -54,19 +74,19 @@ dependencies:
54
74
  - !ruby/object:Gem::Version
55
75
  version: '5.0'
56
76
  - !ruby/object:Gem::Dependency
57
- name: faker
77
+ name: appraisal
58
78
  requirement: !ruby/object:Gem::Requirement
59
79
  requirements:
60
- - - "~>"
80
+ - - ">="
61
81
  - !ruby/object:Gem::Version
62
- version: '1.7'
63
- type: :runtime
82
+ version: '0'
83
+ type: :development
64
84
  prerelease: false
65
85
  version_requirements: !ruby/object:Gem::Requirement
66
86
  requirements:
67
- - - "~>"
87
+ - - ">="
68
88
  - !ruby/object:Gem::Version
69
- version: '1.7'
89
+ version: '0'
70
90
  description: ''
71
91
  email:
72
92
  - janjiss@gmail.com
@@ -86,7 +106,9 @@ files:
86
106
  - ".github/workflows/sync_configs.yml"
87
107
  - ".gitignore"
88
108
  - ".rspec"
109
+ - ".rubocop.yml"
89
110
  - ".yardopts"
111
+ - Appraisals
90
112
  - CHANGELOG.md
91
113
  - CODE_OF_CONDUCT.md
92
114
  - CONTRIBUTING.md
@@ -97,6 +119,10 @@ files:
97
119
  - Rakefile
98
120
  - benchmarks/basic.rb
99
121
  - docsite/source/index.html.md
122
+ - gemfiles/faker_1.gemfile
123
+ - gemfiles/faker_1.gemfile.lock
124
+ - gemfiles/faker_2.gemfile
125
+ - gemfiles/faker_2.gemfile.lock
100
126
  - lib/rom-factory.rb
101
127
  - lib/rom/factory.rb
102
128
  - lib/rom/factory/attribute_registry.rb
@@ -135,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
161
  - !ruby/object:Gem::Version
136
162
  version: '0'
137
163
  requirements: []
138
- rubygems_version: 3.0.3
164
+ rubygems_version: 3.1.2
139
165
  signing_key:
140
166
  specification_version: 4
141
167
  summary: ROM based builder library to make your specs awesome. DSL partially inspired