rom-factory 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +17 -4
- data/.github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md +10 -0
- data/.github/ISSUE_TEMPLATE/----please-don-t-report-feature-requests-via-issues.md +10 -0
- data/.github/ISSUE_TEMPLATE/---a-detailed-bug-report.md +30 -0
- data/.gitignore +1 -0
- data/.travis.yml +7 -6
- data/CHANGELOG.md +8 -0
- data/Gemfile +8 -5
- data/Rakefile +2 -0
- data/benchmarks/basic.rb +14 -18
- data/lib/rom-factory.rb +2 -0
- data/lib/rom/factory.rb +2 -0
- data/lib/rom/factory/attribute_registry.rb +2 -0
- data/lib/rom/factory/attributes.rb +2 -0
- data/lib/rom/factory/attributes/association.rb +2 -0
- data/lib/rom/factory/attributes/callable.rb +2 -0
- data/lib/rom/factory/attributes/sequence.rb +2 -0
- data/lib/rom/factory/attributes/value.rb +2 -0
- data/lib/rom/factory/builder.rb +2 -0
- data/lib/rom/factory/builder/persistable.rb +2 -0
- data/lib/rom/factory/constants.rb +2 -0
- data/lib/rom/factory/dsl.rb +2 -0
- data/lib/rom/factory/factories.rb +2 -0
- data/lib/rom/factory/registry.rb +2 -0
- data/lib/rom/factory/sequences.rb +2 -0
- data/lib/rom/factory/tuple_evaluator.rb +10 -1
- data/lib/rom/factory/version.rb +3 -1
- data/rom-factory.gemspec +4 -2
- metadata +10 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d518c3e2f7f686c9366ef1c54ba7a2c33d1858fd3507dde56b49a1f1e9c49efd
|
4
|
+
data.tar.gz: 7fdf505e789b85006f9dd639b1bc15b1ed76a2129144dd965494ab0853693ffa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90d96b038566692c001c2eabdee291276ec604910db01343b912d4c56690a6564278183f1315d87d6de42dc7716a4a3f26518dcff6f1ffcad1f3301f1553a737
|
7
|
+
data.tar.gz: 2ea5c2473d2a35b109978079f8ac71c3ea375b19643b787bc0c71b9549b03cfb3e09173fb33b30b1465ff85defabe588a075fc4e6857040d77fdc59fec9c04fe
|
data/.codeclimate.yml
CHANGED
@@ -1,6 +1,19 @@
|
|
1
|
-
|
1
|
+
version: "2"
|
2
|
+
|
3
|
+
prepare:
|
4
|
+
fetch:
|
5
|
+
- url: "https://raw.githubusercontent.com/rom-rb/devtools/master/.rubocop.yml"
|
6
|
+
path: ".rubocop.yml"
|
7
|
+
|
8
|
+
exclude_patterns:
|
9
|
+
- "benchmarks/"
|
10
|
+
- "examples/"
|
11
|
+
- "spec/"
|
12
|
+
- "*/spec/"
|
13
|
+
- "*/examples/"
|
14
|
+
- "*/benchmarks/"
|
15
|
+
- "!*.rb"
|
16
|
+
|
17
|
+
plugins:
|
2
18
|
rubocop:
|
3
19
|
enabled: true
|
4
|
-
ratings:
|
5
|
-
paths:
|
6
|
-
- lib/**
|
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
name: "\U0001F41B A detailed bug report"
|
3
|
+
about: Report a bug
|
4
|
+
title: ''
|
5
|
+
labels: bug
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
**Before you submit this: WE ONLY ACCEPT BUG REPORTS**
|
11
|
+
|
12
|
+
For more information see [our contribution guidelines](https://github.com/rom-rb/rom/blob/master/CONTRIBUTING.md)
|
13
|
+
|
14
|
+
**Describe the bug**
|
15
|
+
|
16
|
+
A clear and concise description of what the bug is.
|
17
|
+
|
18
|
+
**To Reproduce**
|
19
|
+
|
20
|
+
Provide detailed steps to reproduce, an executable script would be best.
|
21
|
+
|
22
|
+
**Expected behavior**
|
23
|
+
|
24
|
+
A clear and concise description of what you expected to happen.
|
25
|
+
|
26
|
+
**Your environment**
|
27
|
+
|
28
|
+
- Affects my production application: **YES/NO**
|
29
|
+
- Ruby version: ...
|
30
|
+
- OS: ...
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,19 +1,20 @@
|
|
1
1
|
language: ruby
|
2
|
-
|
2
|
+
|
3
3
|
services:
|
4
4
|
- postgresql
|
5
5
|
- mysql
|
6
6
|
bundler_args: --without tools benchmarks
|
7
|
+
before_install:
|
8
|
+
- gem install bundler
|
7
9
|
before_script:
|
8
10
|
- psql -c 'create database rom_factory;' -U postgres
|
9
|
-
script: "bundle exec rake spec"
|
10
11
|
after_success:
|
11
12
|
- '[ -d coverage ] && bundle exec codeclimate-test-reporter'
|
12
13
|
rvm:
|
13
|
-
- 2.
|
14
|
-
- 2.
|
15
|
-
- 2.
|
16
|
-
- jruby-9.
|
14
|
+
- 2.6.3
|
15
|
+
- 2.5.5
|
16
|
+
- 2.4.6
|
17
|
+
- jruby-9.2.6.0
|
17
18
|
env:
|
18
19
|
global:
|
19
20
|
- COVERAGE='true'
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 0.8.0 to-be-released
|
2
|
+
|
3
|
+
### Fixed
|
4
|
+
|
5
|
+
* Loaded association structs are no longer rejected by output schemas (issue #34) (flash-gordon + solnic)
|
6
|
+
|
7
|
+
[Compare v0.7.0...v0.8.0](https://github.com/rom-rb/rom-factory/compare/v0.7.0...v0.8.0)
|
8
|
+
|
1
9
|
## 0.7.0 2018-11-17
|
2
10
|
|
3
11
|
### Added
|
data/Gemfile
CHANGED
@@ -1,24 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
gemspec
|
4
6
|
|
7
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
8
|
+
|
5
9
|
gem 'rake', '~> 12.0'
|
6
10
|
gem 'rspec', '~> 3.0'
|
7
11
|
|
8
12
|
group :test do
|
9
|
-
gem 'rom-sql', '~>
|
10
|
-
gem 'rom-core', '~> 4.2', '>= 4.2.1'
|
13
|
+
gem 'rom-sql', '~> 3.0'
|
11
14
|
gem 'inflecto'
|
12
15
|
gem 'pry-byebug', platforms: :mri
|
13
16
|
gem 'pry', platforms: :jruby
|
14
17
|
gem 'codeclimate-test-reporter'
|
15
18
|
gem 'simplecov'
|
16
19
|
|
17
|
-
gem 'pg', '~> 0.21', platforms: :mri
|
18
|
-
gem 'mysql2', platforms: :mri
|
20
|
+
gem 'pg', '~> 0.21', platforms: [:mri, :truffleruby]
|
21
|
+
gem 'mysql2', platforms: [:mri, :truffleruby]
|
19
22
|
gem 'jdbc-postgres', platforms: :jruby
|
20
23
|
gem 'jdbc-mysql', platforms: :jruby
|
21
|
-
gem 'sqlite3', '~> 1.3', platforms: :mri
|
24
|
+
gem 'sqlite3', '~> 1.3', platforms: [:mri, :truffleruby]
|
22
25
|
gem 'jdbc-sqlite3', platforms: :jruby
|
23
26
|
end
|
24
27
|
|
data/Rakefile
CHANGED
data/benchmarks/basic.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rom-factory'
|
2
4
|
require 'rom-core'
|
3
5
|
require 'active_record'
|
@@ -23,9 +25,9 @@ end
|
|
23
25
|
factory = ROM::Factory.configure { |c| c.rom = rom }
|
24
26
|
|
25
27
|
factory.define(:user) do |f|
|
26
|
-
f.first_name "John"
|
27
|
-
f.last_name "Doe"
|
28
|
-
f.admin false
|
28
|
+
f.first_name { "John" }
|
29
|
+
f.last_name { "Doe" }
|
30
|
+
f.admin { false }
|
29
31
|
end
|
30
32
|
|
31
33
|
class User < ActiveRecord::Base
|
@@ -35,35 +37,29 @@ ActiveRecord::Base.establish_connection(DATABASE_URL)
|
|
35
37
|
|
36
38
|
FactoryBot.define do
|
37
39
|
factory(:user) do
|
38
|
-
first_name "John"
|
39
|
-
last_name "Doe"
|
40
|
-
admin false
|
40
|
+
first_name { "John" }
|
41
|
+
last_name { "Doe" }
|
42
|
+
admin { false }
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
46
|
Fabricator(:user) do
|
45
|
-
first_name "John"
|
46
|
-
last_name "Doe"
|
47
|
-
admin false
|
47
|
+
first_name { "John" }
|
48
|
+
last_name { "Doe" }
|
49
|
+
admin { false }
|
48
50
|
end
|
49
51
|
|
50
52
|
Benchmark.ips do |x|
|
51
53
|
x.report('rom-factory persisted struct') do
|
52
|
-
|
53
|
-
factory[:user]
|
54
|
-
end
|
54
|
+
factory[:user]
|
55
55
|
end
|
56
56
|
|
57
57
|
x.report('factory_bot') do
|
58
|
-
|
59
|
-
FactoryBot.create(:user)
|
60
|
-
end
|
58
|
+
FactoryBot.create(:user)
|
61
59
|
end
|
62
60
|
|
63
61
|
x.report('fabrication') do
|
64
|
-
|
65
|
-
Fabricate(:user)
|
66
|
-
end
|
62
|
+
Fabricate(:user)
|
67
63
|
end
|
68
64
|
|
69
65
|
x.compare!
|
data/lib/rom-factory.rb
CHANGED
data/lib/rom/factory.rb
CHANGED
data/lib/rom/factory/builder.rb
CHANGED
data/lib/rom/factory/dsl.rb
CHANGED
data/lib/rom/factory/registry.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rom/factory/sequences'
|
2
4
|
|
3
5
|
module ROM
|
@@ -47,7 +49,14 @@ module ROM
|
|
47
49
|
end
|
48
50
|
|
49
51
|
attributes.merge!(materialized_callables)
|
50
|
-
|
52
|
+
|
53
|
+
associations = assoc_names
|
54
|
+
.map { |key| [key, attributes[key]] if attributes.key?(key) }
|
55
|
+
.compact
|
56
|
+
.to_h
|
57
|
+
|
58
|
+
attributes = relation.output_schema[attributes]
|
59
|
+
attributes.update(associations)
|
51
60
|
|
52
61
|
model.new(attributes)
|
53
62
|
end
|
data/lib/rom/factory/version.rb
CHANGED
data/rom-factory.gemspec
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
lib = File.expand_path('../lib', __FILE__)
|
3
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
6
|
require 'rom/factory/version'
|
@@ -28,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
28
30
|
spec.require_paths = ["lib"]
|
29
31
|
|
30
32
|
spec.add_dependency "dry-configurable", "~> 0.7"
|
31
|
-
spec.add_dependency "dry-core", "~> 0.
|
32
|
-
spec.add_dependency "rom-core", "~>
|
33
|
+
spec.add_dependency "dry-core", "~> 0.4"
|
34
|
+
spec.add_dependency "rom-core", "~> 5.0"
|
33
35
|
spec.add_dependency "faker", "~> 1.7"
|
34
36
|
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.
|
4
|
+
version: 0.8.0
|
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:
|
12
|
+
date: 2019-04-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dry-configurable
|
@@ -31,34 +31,28 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '0.
|
35
|
-
- - ">="
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: 0.3.1
|
34
|
+
version: '0.4'
|
38
35
|
type: :runtime
|
39
36
|
prerelease: false
|
40
37
|
version_requirements: !ruby/object:Gem::Requirement
|
41
38
|
requirements:
|
42
39
|
- - "~>"
|
43
40
|
- !ruby/object:Gem::Version
|
44
|
-
version: '0.
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 0.3.1
|
41
|
+
version: '0.4'
|
48
42
|
- !ruby/object:Gem::Dependency
|
49
43
|
name: rom-core
|
50
44
|
requirement: !ruby/object:Gem::Requirement
|
51
45
|
requirements:
|
52
46
|
- - "~>"
|
53
47
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
48
|
+
version: '5.0'
|
55
49
|
type: :runtime
|
56
50
|
prerelease: false
|
57
51
|
version_requirements: !ruby/object:Gem::Requirement
|
58
52
|
requirements:
|
59
53
|
- - "~>"
|
60
54
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
55
|
+
version: '5.0'
|
62
56
|
- !ruby/object:Gem::Dependency
|
63
57
|
name: faker
|
64
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,6 +76,9 @@ extensions: []
|
|
82
76
|
extra_rdoc_files: []
|
83
77
|
files:
|
84
78
|
- ".codeclimate.yml"
|
79
|
+
- ".github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md"
|
80
|
+
- ".github/ISSUE_TEMPLATE/----please-don-t-report-feature-requests-via-issues.md"
|
81
|
+
- ".github/ISSUE_TEMPLATE/---a-detailed-bug-report.md"
|
85
82
|
- ".gitignore"
|
86
83
|
- ".rspec"
|
87
84
|
- ".travis.yml"
|
@@ -131,8 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
128
|
- !ruby/object:Gem::Version
|
132
129
|
version: '0'
|
133
130
|
requirements: []
|
134
|
-
|
135
|
-
rubygems_version: 2.7.6
|
131
|
+
rubygems_version: 3.0.3
|
136
132
|
signing_key:
|
137
133
|
specification_version: 4
|
138
134
|
summary: ROM based builder library to make your specs awesome. DSL partially inspired
|