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 +4 -4
- data/README.markdown +1 -1
- data/Rakefile +1 -1
- data/lib/fabrication/schematic/attribute.rb +3 -2
- data/lib/fabrication/schematic/definition.rb +8 -4
- data/lib/fabrication/version.rb +1 -1
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 96031c7fe931f6f70a4e0e8b0a51c999151e0865
         | 
| 4 | 
            +
              data.tar.gz: 1714692bcc5f754e34855020a647750322a24fbe
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 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 | 
             
            [](http://travis-ci.org/paulelliott/fabrication)
         | 
| 12 12 | 
             
            [](https://codeclimate.com/github/paulelliott/fabrication)
         | 
    
        data/Rakefile
    CHANGED
    
    
| @@ -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( | 
| 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( | 
| 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( | 
| 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( | 
| 91 | 
            +
                  generator.new(klass).to_hash(sorted_attributes, callbacks)
         | 
| 88 92 | 
             
                end
         | 
| 89 93 | 
             
              end
         | 
| 90 94 |  | 
    
        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.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- | 
| 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. | 
| 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.
         |