fabrication 2.16.3 → 2.17.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
  SHA1:
3
- metadata.gz: ebbcd0d926e9fb5a2b0e33611a2e72d640a00962
4
- data.tar.gz: 8bdf7c0ca1b511c402a06bba08a7b63a274163a8
3
+ metadata.gz: f77d2a10a03e1420c0e2e5ec08f156c990a088d8
4
+ data.tar.gz: 75d2e8a00f8cc4916c6a8837f518e6de90e9daf0
5
5
  SHA512:
6
- metadata.gz: c7cd396b0582d085e1b45e60d6c1fe7caeaa12df8812a42b3ec2807232d6b0ab4e32ce21661706839dbbc134b88f699c197cec36a8f908b34becbb95ee3980b2
7
- data.tar.gz: fc5331e5f162c5d2fc7740b89276a4aefefa4ca60f36669ce7bfe073f88269f62ff83930dd1586f04520c579d025f08e97b6a41154210ddeeb03fe82386517be
6
+ metadata.gz: 25cfb81ca168bab05a52c1921738dc6243f59b2a95da01f699058bd734ff10c21b893ec3a018ebee6f1b033dcd2ee7d2601dffd3700b2975998554c5c32f6a62
7
+ data.tar.gz: 5992742810af94e0f92496fdbc666479aacbf96ff308e0bc009a2dac68171af9662f63e080f49cddae6686b48bb87a415a501b1fdbc713da72cd3a44b36448f0
@@ -6,7 +6,7 @@ Fabrication is an object generation framework for Ruby.
6
6
 
7
7
  ## Compatibility
8
8
 
9
- Fabrication is tested against Ruby 1.9.3 and above.
9
+ Fabrication is tested against Ruby 2.2 and above.
10
10
 
11
11
  [![Build Status](https://secure.travis-ci.org/paulelliott/fabrication.png)](http://travis-ci.org/paulelliott/fabrication)
12
12
  [![Code Climate](https://codeclimate.com/github/paulelliott/fabrication.png)](https://codeclimate.com/github/paulelliott/fabrication)
@@ -12,44 +12,4 @@ class Fabrication::Generator::ActiveRecord < Fabrication::Generator::Base
12
12
  end
13
13
  end
14
14
 
15
- def build_default_expansion(field_name, params)
16
- # When an inverse field is found, we can override this in the fabricator so we
17
- # don't run into an endless recursion
18
- build_args = {}
19
- if inverse_of = inverse_of(field_name)
20
- inverse_name = inverse_of.name.to_s
21
- if belongs_to_or_has_one?(inverse_of)
22
- build_args[inverse_name] = nil
23
- else
24
- build_args[inverse_name] = []
25
- end
26
- end
27
-
28
- if params[:count]
29
- fabricator_name = params[:fabricator] || Fabrication::Support.singularize(field_name.to_s)
30
- proc { Fabricate.build(params[:fabricator] || fabricator_name, build_args) }
31
- else
32
- fabricator_name = params[:fabricator] || field_name
33
- proc { Fabricate(params[:fabricator] || fabricator_name, build_args) }
34
- end
35
- end
36
-
37
- private
38
-
39
- # Returns the inverse field name of a given relation
40
- def inverse_of(name)
41
- reflection = _klass.reflections.fetch(name.to_s, nil) || # >= Rails 4.3
42
- _klass.reflections.fetch(name.to_sym, nil) # < Rails 4.3
43
- reflection.inverse_of if reflection
44
- end
45
-
46
- # Returns true if the reflection is a belongs_to or has_one association
47
- def belongs_to_or_has_one?(reflection)
48
- if reflection.respond_to?(:macro) # < Rails 4.3
49
- return true if reflection.macro == :belongs_to || reflection.macro == :has_one
50
- else # >= Rails 5.3
51
- return true if reflection.instance_of?(ActiveRecord::Reflection::BelongsToReflection) ||
52
- reflection.instance_of?(ActiveRecord::Reflection::HasOneReflection)
53
- end
54
- end
55
15
  end
@@ -79,15 +79,6 @@ class Fabrication::Generator::Base
79
79
  _attributes[method_name] || super
80
80
  end
81
81
 
82
- def build_default_expansion(name, params)
83
- if params[:count]
84
- name = Fabrication::Support.singularize(name.to_s)
85
- proc { Fabricate.build(params[:fabricator] || name) }
86
- else
87
- proc { Fabricate(params[:fabricator] || name) }
88
- end
89
- end
90
-
91
82
  protected
92
83
 
93
84
  attr_accessor :_klass, :_instance, :_transient_attributes
@@ -105,7 +105,12 @@ class Fabrication::Schematic::Definition
105
105
  end
106
106
 
107
107
  def generate_value(name, params)
108
- generator.new(klass).build_default_expansion(name, params)
108
+ if params[:count]
109
+ name = Fabrication::Support.singularize(name.to_s)
110
+ proc { Fabricate.build(params[:fabricator] || name) }
111
+ else
112
+ proc { Fabricate(params[:fabricator] || name) }
113
+ end
109
114
  end
110
115
 
111
116
  def merge(overrides={}, &block)
@@ -1,3 +1,3 @@
1
1
  module Fabrication
2
- VERSION = '2.16.3'
2
+ VERSION = '2.17.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fabrication
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.16.3
4
+ version: 2.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Elliott
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-19 00:00:00.000000000 Z
11
+ date: 2017-10-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Fabrication is an object generation framework for ActiveRecord, Mongoid,
14
14
  DataMapper, Sequel, or any other Ruby object.
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  version: '0'
71
71
  requirements: []
72
72
  rubyforge_project:
73
- rubygems_version: 2.5.1
73
+ rubygems_version: 2.6.13
74
74
  signing_key:
75
75
  specification_version: 4
76
76
  summary: Implementing the factory pattern in Ruby so you don't have to.