fabrication 2.15.2 → 2.16.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78053799fd00b34373f44d6e10b92223aef69223
|
4
|
+
data.tar.gz: 6c5683350d88c8697a45adbc2af32196df2f6b7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ebf556c00fa905726f619f8baaada9c1c70460f81170e8903db8015f568574accd6ef78bf6b89e10ed2e0ceba18457c4a71977c515c10a20ad0f38ac56b300f
|
7
|
+
data.tar.gz: ac89c98188f997eff43c7e6976f061293f5dc957536bb5227e3609d371e4a90fd7c4251cfd429fe89cd1e076ece58117f38087920fce6bb2b9eba4ca234ada9d
|
data/lib/fabrication/config.rb
CHANGED
@@ -8,6 +8,7 @@ module Fabrication
|
|
8
8
|
@fabricator_path =
|
9
9
|
@path_prefix =
|
10
10
|
@sequence_start =
|
11
|
+
@generators =
|
11
12
|
nil
|
12
13
|
end
|
13
14
|
|
@@ -46,5 +47,11 @@ module Fabrication
|
|
46
47
|
def register_with_steps?
|
47
48
|
@register_with_steps ||= nil
|
48
49
|
end
|
50
|
+
|
51
|
+
def generators; @generators ||= [] end
|
52
|
+
|
53
|
+
def generator_for(default_generators, klass)
|
54
|
+
(generators + default_generators).detect { |gen| gen.supports?(klass) }
|
55
|
+
end
|
49
56
|
end
|
50
57
|
end
|
data/lib/fabrication/support.rb
CHANGED
@@ -57,6 +57,14 @@ class Fabrication::Support
|
|
57
57
|
string.end_with?('s') ? string[0..-2] : string
|
58
58
|
end
|
59
59
|
|
60
|
+
def underscore(string)
|
61
|
+
string.gsub(/::/, '/').
|
62
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
63
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
64
|
+
tr("-", "_").
|
65
|
+
downcase
|
66
|
+
end
|
67
|
+
|
60
68
|
end
|
61
69
|
|
62
70
|
end
|
@@ -14,14 +14,14 @@ module Fabrication
|
|
14
14
|
module Make
|
15
15
|
def make(*args, &block)
|
16
16
|
overrides = Fabrication::Support.extract_options!(args)
|
17
|
-
klass =
|
17
|
+
klass = Fabrication::Support.underscore(name).to_sym
|
18
18
|
fabricator_name = args.first.is_a?(Symbol) ? "#{klass}_#{args.first}" : klass
|
19
19
|
Fabricate.build(fabricator_name, overrides, &block)
|
20
20
|
end
|
21
21
|
|
22
22
|
def make!(*args, &block)
|
23
23
|
overrides = Fabrication::Support.extract_options!(args)
|
24
|
-
klass =
|
24
|
+
klass = Fabrication::Support.underscore(name).to_sym
|
25
25
|
fabricator_name = args.first.is_a?(Symbol) ? "#{klass}_#{args.first}" : klass
|
26
26
|
Fabricate(fabricator_name, overrides, &block)
|
27
27
|
end
|
data/lib/fabrication/version.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.16.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: 2016-
|
11
|
+
date: 2016-10-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.
|