fabrication 2.10.0 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e953b16555d4952d603134e3a609f2e18351a01
4
- data.tar.gz: 88df71f9858b36e5911193238d5711ece3058fc5
3
+ metadata.gz: 96031c7fe931f6f70a4e0e8b0a51c999151e0865
4
+ data.tar.gz: 1714692bcc5f754e34855020a647750322a24fbe
5
5
  SHA512:
6
- metadata.gz: c128fe8be585de63e07538b52743672449980bf8c9b09a0c7ec7e105a04a9eb9795ab186315182eaed2b89e1250efcaa1df6f369513ceb264b41968292d5e812
7
- data.tar.gz: c89cf69b9395208ab787f58d9141db782ea37ab1c9ffda90e30a09729250edb045d71cd00c0f985fbd9adfc4d6ef2ce1028ab116d418f4fd777d19eeccccfb04
6
+ metadata.gz: db66d3fe1d78fcdae6fe36fa3c4ddbd0b32c31364f1540ddfc99ed654bcaff0c73e09cb33e8033ec2b580d55da206165ef3970d399c25ef0ca24737634931efa
7
+ data.tar.gz: 5b786db9b68d5c6db2b1d23016f9143dba83b6e465aca3cebe9a7b1464ebf3932ed712049f374979281daccefeb1eb3e6be91deb3318f1952c7453fc0ad8a30c
data/README.markdown CHANGED
@@ -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, 2.0.0, and Rubinius.
9
+ Fabrication is tested against Ruby 1.9.3, 2.0.0, 2.1.x, and Rubinius.
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)
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ task :cucumber do
14
14
  end
15
15
 
16
16
  if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
17
- task default: %i(cucumber appraisal)
17
+ task default: [:cucumber, :appraisal]
18
18
  else
19
19
  task default: :spec
20
20
  end
@@ -31,6 +31,9 @@ class Fabrication::Schematic::Attribute
31
31
  end
32
32
  end
33
33
 
34
+ def value_static?; !value_proc? end
35
+ def value_proc?; Proc === value end
36
+
34
37
  private
35
38
 
36
39
  def execute(*args, &block)
@@ -49,6 +52,4 @@ class Fabrication::Schematic::Attribute
49
52
  Kernel.rand((1..params[:rand])) if params[:rand]
50
53
  end
51
54
 
52
- def value_proc?; Proc === value end
53
-
54
55
  end
@@ -46,6 +46,10 @@ class Fabrication::Schematic::Definition
46
46
  @generator ||= GENERATORS.detect { |gen| gen.supports?(klass) }
47
47
  end
48
48
 
49
+ def sorted_attributes
50
+ attributes.select(&:value_static?) + attributes.select(&:value_proc?)
51
+ end
52
+
49
53
  def build(overrides={}, &block)
50
54
  if Fabrication.manager.to_params_stack.any?
51
55
  to_params(overrides, &block)
@@ -53,7 +57,7 @@ class Fabrication::Schematic::Definition
53
57
  begin
54
58
  Fabrication.manager.build_stack << self
55
59
  merge(overrides, &block).instance_eval do
56
- generator.new(klass).build(attributes, callbacks)
60
+ generator.new(klass).build(sorted_attributes, callbacks)
57
61
  end
58
62
  ensure
59
63
  Fabrication.manager.build_stack.pop
@@ -68,7 +72,7 @@ class Fabrication::Schematic::Definition
68
72
  to_params(overrides, &block)
69
73
  else
70
74
  merge(overrides, &block).instance_eval do
71
- generator.new(klass).create(attributes, callbacks)
75
+ generator.new(klass).create(sorted_attributes, callbacks)
72
76
  end
73
77
  end
74
78
  end
@@ -76,7 +80,7 @@ class Fabrication::Schematic::Definition
76
80
  def to_params(overrides={}, &block)
77
81
  Fabrication.manager.to_params_stack << self
78
82
  merge(overrides, &block).instance_eval do
79
- generator.new(klass).to_params(attributes)
83
+ generator.new(klass).to_params(sorted_attributes)
80
84
  end
81
85
  ensure
82
86
  Fabrication.manager.to_params_stack.pop
@@ -84,7 +88,7 @@ class Fabrication::Schematic::Definition
84
88
 
85
89
  def to_attributes(overrides={}, &block)
86
90
  merge(overrides, &block).instance_eval do
87
- generator.new(klass).to_hash(attributes, callbacks)
91
+ generator.new(klass).to_hash(sorted_attributes, callbacks)
88
92
  end
89
93
  end
90
94
 
@@ -1,3 +1,3 @@
1
1
  module Fabrication
2
- VERSION = '2.10.0'
2
+ VERSION = '2.11.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.10.0
4
+ version: 2.11.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: 2014-03-25 00:00:00.000000000 Z
11
+ date: 2014-03-27 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.
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  version: '0'
70
70
  requirements: []
71
71
  rubyforge_project:
72
- rubygems_version: 2.2.1
72
+ rubygems_version: 2.2.2
73
73
  signing_key:
74
74
  specification_version: 4
75
75
  summary: Implementing the factory pattern in Ruby so you don't have to.