fabrication 2.22.0 → 2.25.0
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/config.rb +2 -2
- data/lib/fabrication/cucumber/step_fabricator.rb +1 -1
- data/lib/fabrication/generator/active_record.rb +2 -2
- data/lib/fabrication/generator/base.rb +3 -3
- data/lib/fabrication/generator/sequel.rb +1 -1
- data/lib/fabrication/schematic/definition.rb +1 -1
- data/lib/fabrication/schematic/manager.rb +7 -5
- data/lib/fabrication/sequencer.rb +1 -1
- data/lib/fabrication/support.rb +10 -4
- data/lib/fabrication/version.rb +1 -1
- data/lib/fabrication.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25bf46c387fd321a6b7fb9f35b7a67862ced410dd318ad2c29a0bca8dd61479b
|
4
|
+
data.tar.gz: 367a2d9d5bc7213443a4de423447c99f9141e92c47fecc5ea0092df2b7821dbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ad4fc489704de95e48fd156f043ef22638d5e910e1d684db9e09798e9eb2064003056616cfbd08ec944aab4e024ad65f6bdca6d993e6f5a04aaa395bb48cf2c
|
7
|
+
data.tar.gz: 2f1cbf6bc060c00578234773534148eac605271f32e08b636aa873e232bc532da3e531c301830577dd1a2842a9592d4976485226d6804296110fea358a923c01
|
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)
|
data/lib/fabrication/config.rb
CHANGED
@@ -21,7 +21,7 @@ module Fabrication
|
|
21
21
|
|
22
22
|
def fabricator_dir
|
23
23
|
puts 'DEPRECATION WARNING: Fabrication::Config.fabricator_dir has been ' \
|
24
|
-
|
24
|
+
'replaced by Fabrication::Config.fabricator_path'
|
25
25
|
fabricator_path
|
26
26
|
end
|
27
27
|
|
@@ -31,7 +31,7 @@ module Fabrication
|
|
31
31
|
|
32
32
|
def fabricator_dir=(folders)
|
33
33
|
puts 'DEPRECATION WARNING: Fabrication::Config.fabricator_dir has been ' \
|
34
|
-
|
34
|
+
'replaced by Fabrication::Config.fabricator_path'
|
35
35
|
self.fabricator_path = folders
|
36
36
|
end
|
37
37
|
|
@@ -6,8 +6,8 @@ module Fabrication
|
|
6
6
|
# so we can't assume because we have the ActiveRecord module that we also
|
7
7
|
# have ActiveRecord::Base. Because defined? can return nil we ensure that nil
|
8
8
|
# becomes false.
|
9
|
-
defined?(::ActiveRecord) && defined?(::ActiveRecord::Base) &&
|
10
|
-
klass.ancestors.include?(::ActiveRecord::Base) || false
|
9
|
+
(defined?(::ActiveRecord) && defined?(::ActiveRecord::Base) &&
|
10
|
+
klass.ancestors.include?(::ActiveRecord::Base)) || false
|
11
11
|
end
|
12
12
|
|
13
13
|
def build_instance
|
@@ -54,12 +54,12 @@ module Fabrication
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def build_instance_with_constructor_override(callback)
|
57
|
-
self._instance =
|
57
|
+
self._instance = instance_exec(_transient_attributes, &callback)
|
58
58
|
set_attributes
|
59
59
|
end
|
60
60
|
|
61
61
|
def build_instance_with_init_callback(callback)
|
62
|
-
self._instance = _klass.new(*callback.call)
|
62
|
+
self._instance = _klass.new(*callback.call(_transient_attributes))
|
63
63
|
set_attributes
|
64
64
|
end
|
65
65
|
|
@@ -104,7 +104,7 @@ module Fabrication
|
|
104
104
|
_attributes[attribute.name] = attribute.processed_value(_attributes)
|
105
105
|
_transient_attributes[attribute.name] = _attributes[attribute.name] if attribute.transient?
|
106
106
|
end
|
107
|
-
_attributes.reject! { |k| _transient_attributes.
|
107
|
+
_attributes.reject! { |k| _transient_attributes.key?(k) }
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
@@ -55,14 +55,16 @@ module Fabrication
|
|
55
55
|
def load_definitions
|
56
56
|
preinitialize
|
57
57
|
Fabrication::Config.path_prefixes.each do |prefix|
|
58
|
-
Fabrication::Config.fabricator_paths.each do |
|
59
|
-
|
60
|
-
load
|
58
|
+
Fabrication::Config.fabricator_paths.each do |path|
|
59
|
+
if File.file?(path)
|
60
|
+
load path
|
61
|
+
else
|
62
|
+
Dir.glob(File.join(prefix.to_s, path, '**', '*.rb')).sort.each do |file|
|
63
|
+
load file
|
64
|
+
end
|
61
65
|
end
|
62
66
|
end
|
63
67
|
end
|
64
|
-
rescue StandardError => e
|
65
|
-
raise e
|
66
68
|
ensure
|
67
69
|
freeze
|
68
70
|
end
|
data/lib/fabrication/support.rb
CHANGED
@@ -40,14 +40,20 @@ module Fabrication
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def variable_name_to_class_name(name)
|
43
|
-
name.to_s
|
44
|
-
|
45
|
-
|
43
|
+
name_string = name.to_s
|
44
|
+
|
45
|
+
if name_string.respond_to?(:camelize)
|
46
|
+
name_string.camelize
|
47
|
+
else
|
48
|
+
name_string.gsub(%r{/(.?)}) do
|
49
|
+
"::#{Regexp.last_match(1).upcase}"
|
50
|
+
end.gsub(/(?:^|_)(.)/) { Regexp.last_match(1).upcase }
|
51
|
+
end
|
46
52
|
end
|
47
53
|
|
48
54
|
def find_definitions
|
49
55
|
puts 'DEPRECATION WARNING: Fabrication::Support.find_definitions has been replaced ' \
|
50
|
-
|
56
|
+
'by Fabrication.manager.load_definitions and will be removed in 3.0.0.'
|
51
57
|
Fabrication.manager.load_definitions
|
52
58
|
end
|
53
59
|
|
data/lib/fabrication/version.rb
CHANGED
data/lib/fabrication.rb
CHANGED
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.
|
4
|
+
version: 2.25.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:
|
11
|
+
date: 2022-01-28 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.
|
@@ -63,14 +63,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
63
|
requirements:
|
64
64
|
- - ">="
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: 2.
|
66
|
+
version: 2.6.0
|
67
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
69
|
- - ">="
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: '0'
|
72
72
|
requirements: []
|
73
|
-
rubygems_version: 3.
|
73
|
+
rubygems_version: 3.2.32
|
74
74
|
signing_key:
|
75
75
|
specification_version: 4
|
76
76
|
summary: Implementing the factory pattern in Ruby so you don't have to.
|