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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f2cad99dc93108f4bb7e9ac571ed198eaedee1b541b886fc018bb4501360817
4
- data.tar.gz: 7fde94283a3d31672b6fa3ea8c082320524dc106025d4f50ac64ab3005bda6c7
3
+ metadata.gz: d518c3e2f7f686c9366ef1c54ba7a2c33d1858fd3507dde56b49a1f1e9c49efd
4
+ data.tar.gz: 7fdf505e789b85006f9dd639b1bc15b1ed76a2129144dd965494ab0853693ffa
5
5
  SHA512:
6
- metadata.gz: 8d14003a058a9eda9b2a407be0d4571de6213ded73532a01a0dbee8bdb3de47836a517425a742cf117b8674b67b64bf00d7e2ac9f47887f110a05d8143d7e0be
7
- data.tar.gz: 389317084e6d7331c8e1fafcd304f34c458e393a63aee70debf0e04bd78d026b005a5f5ff5678eb3be29e499fdb2f1052b27a3602c31232d8ca14588cd506bfa
6
+ metadata.gz: 90d96b038566692c001c2eabdee291276ec604910db01343b912d4c56690a6564278183f1315d87d6de42dc7716a4a3f26518dcff6f1ffcad1f3301f1553a737
7
+ data.tar.gz: 2ea5c2473d2a35b109978079f8ac71c3ea375b19643b787bc0c71b9549b03cfb3e09173fb33b30b1465ff85defabe588a075fc4e6857040d77fdc59fec9c04fe
data/.codeclimate.yml CHANGED
@@ -1,6 +1,19 @@
1
- engines:
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,10 @@
1
+ ---
2
+ name: "⚠️ Please don't ask for support via issues"
3
+ about: "See CONTRIBUTING.md for more information"
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+
@@ -0,0 +1,10 @@
1
+ ---
2
+ name: "⚠️ Please don't report feature requests via issues"
3
+ about: See CONTRIBUTING.md for more information
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+
@@ -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
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ .rubocop.yml
data/.travis.yml CHANGED
@@ -1,19 +1,20 @@
1
1
  language: ruby
2
- sudo: false
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.5.0
14
- - 2.4.2
15
- - 2.3.6
16
- - jruby-9.1.13.0
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', '~> 2.1'
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rspec/core/rake_task"
3
5
 
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
- 1000.times do
53
- factory[:user]
54
- end
54
+ factory[:user]
55
55
  end
56
56
 
57
57
  x.report('factory_bot') do
58
- 1000.times do
59
- FactoryBot.create(:user)
60
- end
58
+ FactoryBot.create(:user)
61
59
  end
62
60
 
63
61
  x.report('fabrication') do
64
- 1000.times do
65
- Fabricate(:user)
66
- end
62
+ Fabricate(:user)
67
63
  end
68
64
 
69
65
  x.compare!
data/lib/rom-factory.rb CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rom/factory'
data/lib/rom/factory.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'dry/core/class_builder'
2
4
  require 'rom/factory/factories'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'tsort'
2
4
 
3
5
  module ROM
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'dry/core/constants'
2
4
 
3
5
  module ROM
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ROM::Factory
2
4
  module Attributes
3
5
  # @api private
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ROM::Factory
2
4
  module Attributes
3
5
  # @api private
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ROM::Factory
2
4
  module Attributes
3
5
  class Sequence
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ROM::Factory
2
4
  module Attributes
3
5
  # @api private
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'dry/core/constants'
2
4
 
3
5
  require 'rom/struct'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'delegate'
2
4
 
3
5
  module ROM
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ROM
2
4
  module Factory
3
5
  class FactoryNotDefinedError < StandardError
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'faker'
2
4
  require 'dry/core/inflector'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'dry/configurable'
2
4
  require 'dry/core/inflector'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rom/factory/constants'
2
4
 
3
5
  module ROM
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'singleton'
2
4
 
3
5
  module ROM
@@ -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
- attributes = relation.output_schema.call(attributes)
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
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ROM
2
4
  module Factory
3
- VERSION = '0.7.0'.freeze
5
+ VERSION = '0.8.0'
4
6
  end
5
7
  end
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.3", ">= 0.3.1"
32
- spec.add_dependency "rom-core", "~> 4.0"
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.7.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: 2018-11-17 00:00:00.000000000 Z
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.3'
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.3'
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: '4.0'
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: '4.0'
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
- rubyforge_project:
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