fabrication 2.23.0 → 2.23.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fabricate.rb +3 -3
- data/lib/fabrication/cucumber/step_fabricator.rb +1 -1
- data/lib/fabrication/generator/base.rb +3 -7
- data/lib/fabrication/generator/mongoid.rb +17 -0
- data/lib/fabrication/schematic/definition.rb +2 -1
- data/lib/fabrication/sequencer.rb +1 -1
- data/lib/fabrication/version.rb +1 -1
- data/lib/fabrication.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb03268f2dae8ad098c0c78fee669b1e7334c14ea030f4c699a82a4fa7e79fd7
|
4
|
+
data.tar.gz: ec4ac22aed152e6f7fb7dbfcbb5fb60f6d8dce60b5d2eff12b544b1088e7d990
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8eb03fd946d25ecc85932f8743c405395106b84d72989c5b6400baa0f969b6ddcfc021cf09b681a62bfd431a76cc75d86d8cb727a2b8c64df42603365975fbd5
|
7
|
+
data.tar.gz: 5e6489ad45c74381336c412ef0c229af8e2d7f9758a3a0c65605a3fabd959c106c08dd0d7a998ddc1a2d19915a3c021538ff8014e6bcdd57cf1b1b986e4e34cf
|
data/lib/fabricate.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
class Fabricate
|
2
2
|
def self.times(count, name, overrides = {}, &block)
|
3
|
-
count.
|
3
|
+
Array.new(count).map { Fabricate(name, overrides, &block) }
|
4
4
|
end
|
5
5
|
|
6
6
|
def self.build_times(count, name, overrides = {}, &block)
|
7
|
-
count.
|
7
|
+
Array.new(count).map { Fabricate.build(name, overrides, &block) }
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.attributes_for_times(count, name, overrides = {}, &block)
|
11
|
-
count.
|
11
|
+
Array.new(count).map { Fabricate.attributes_for(name, overrides, &block) }
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.attributes_for(name, overrides = {}, &block)
|
@@ -69,12 +69,8 @@ module Fabrication
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def set_attributes
|
72
|
-
|
73
|
-
_instance.
|
74
|
-
else
|
75
|
-
_attributes.each do |k, v|
|
76
|
-
_instance.send("#{k}=", v)
|
77
|
-
end
|
72
|
+
_attributes.each do |k, v|
|
73
|
+
_instance.send("#{k}=", v)
|
78
74
|
end
|
79
75
|
end
|
80
76
|
|
@@ -108,7 +104,7 @@ module Fabrication
|
|
108
104
|
_attributes[attribute.name] = attribute.processed_value(_attributes)
|
109
105
|
_transient_attributes[attribute.name] = _attributes[attribute.name] if attribute.transient?
|
110
106
|
end
|
111
|
-
_attributes.reject! { |k| _transient_attributes.
|
107
|
+
_attributes.reject! { |k| _transient_attributes.key?(k) }
|
112
108
|
end
|
113
109
|
end
|
114
110
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Fabrication
|
2
|
+
module Generator
|
3
|
+
class Mongoid < Fabrication::Generator::Base
|
4
|
+
def self.supports?(klass)
|
5
|
+
defined?(::Mongoid) && klass.ancestors.include?(::Mongoid::Document)
|
6
|
+
end
|
7
|
+
|
8
|
+
def build_instance
|
9
|
+
self._instance = if _klass.respond_to?(:protected_attributes)
|
10
|
+
_klass.new(_attributes, without_protection: true)
|
11
|
+
else
|
12
|
+
_klass.new(_attributes)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -5,6 +5,7 @@ module Fabrication
|
|
5
5
|
Fabrication::Generator::ActiveRecord,
|
6
6
|
Fabrication::Generator::DataMapper,
|
7
7
|
Fabrication::Generator::Sequel,
|
8
|
+
Fabrication::Generator::Mongoid,
|
8
9
|
Fabrication::Generator::Base
|
9
10
|
].freeze
|
10
11
|
|
@@ -17,7 +18,7 @@ module Fabrication
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def process_block(&block)
|
20
|
-
Fabrication::Schematic::Evaluator.new.process(self, &block) if
|
21
|
+
Fabrication::Schematic::Evaluator.new.process(self, &block) if block
|
21
22
|
end
|
22
23
|
|
23
24
|
def attribute(name)
|
data/lib/fabrication/version.rb
CHANGED
data/lib/fabrication.rb
CHANGED
@@ -33,6 +33,7 @@ module Fabrication
|
|
33
33
|
autoload :ActiveRecord, 'fabrication/generator/active_record'
|
34
34
|
autoload :ActiveRecord4, 'fabrication/generator/active_record_4'
|
35
35
|
autoload :DataMapper, 'fabrication/generator/data_mapper'
|
36
|
+
autoload :Mongoid, 'fabrication/generator/mongoid'
|
36
37
|
autoload :Sequel, 'fabrication/generator/sequel'
|
37
38
|
autoload :Base, 'fabrication/generator/base'
|
38
39
|
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.23.
|
4
|
+
version: 2.23.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Elliott
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-14 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.
|
@@ -33,6 +33,7 @@ files:
|
|
33
33
|
- lib/fabrication/generator/active_record.rb
|
34
34
|
- lib/fabrication/generator/base.rb
|
35
35
|
- lib/fabrication/generator/data_mapper.rb
|
36
|
+
- lib/fabrication/generator/mongoid.rb
|
36
37
|
- lib/fabrication/generator/sequel.rb
|
37
38
|
- lib/fabrication/railtie.rb
|
38
39
|
- lib/fabrication/schematic/attribute.rb
|
@@ -69,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
70
|
- !ruby/object:Gem::Version
|
70
71
|
version: '0'
|
71
72
|
requirements: []
|
72
|
-
rubygems_version: 3.2.
|
73
|
+
rubygems_version: 3.2.32
|
73
74
|
signing_key:
|
74
75
|
specification_version: 4
|
75
76
|
summary: Implementing the factory pattern in Ruby so you don't have to.
|