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: 7cb941babdd5a40fe72c16cda95ab718b306de5b
4
- data.tar.gz: 94f8213b2adff827cd7cc98edbe23670e0d8e9de
3
+ metadata.gz: 78053799fd00b34373f44d6e10b92223aef69223
4
+ data.tar.gz: 6c5683350d88c8697a45adbc2af32196df2f6b7e
5
5
  SHA512:
6
- metadata.gz: e5e176e536ec16dbc3fbf041e17c18cd0a5e9daffd5f84623b9b13735ea6cfc5a78b1cbcd699b0fb72caffc9b3b0acf6f9ad17a3e768fbde8fb37cc7460e5d0f
7
- data.tar.gz: 0afddbc74e4f8771af760d74c67b8ae0487c369a4bb1cdc3449bc94aa47c2a7d15bfaf2498f8cac8359f3a4e078223f4f15b597b61293eda205753de39bf88ee
6
+ metadata.gz: 4ebf556c00fa905726f619f8baaada9c1c70460f81170e8903db8015f568574accd6ef78bf6b89e10ed2e0ceba18457c4a71977c515c10a20ad0f38ac56b300f
7
+ data.tar.gz: ac89c98188f997eff43c7e6976f061293f5dc957536bb5227e3609d371e4a90fd7c4251cfd429fe89cd1e076ece58117f38087920fce6bb2b9eba4ca234ada9d
@@ -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
@@ -46,7 +46,7 @@ class Fabrication::Schematic::Definition
46
46
  end
47
47
 
48
48
  def generator
49
- @generator ||= GENERATORS.detect { |gen| gen.supports?(klass) }
49
+ @generator ||= Fabrication::Config.generator_for(GENERATORS, klass)
50
50
  end
51
51
 
52
52
  def sorted_attributes
@@ -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 = name.underscore.to_sym
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 = name.underscore.to_sym
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
@@ -1,3 +1,3 @@
1
1
  module Fabrication
2
- VERSION = '2.15.2'
2
+ VERSION = '2.16.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.15.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-05-15 00:00:00.000000000 Z
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.