plucky 0.6.6 → 0.7.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 +13 -5
- data/.rspec +1 -0
- data/.travis.yml +1 -0
- data/Gemfile +3 -3
- data/lib/plucky/criteria_hash.rb +9 -2
- data/lib/plucky/normalizers/criteria_hash_value.rb +3 -1
- data/lib/plucky/normalizers/options_hash_value.rb +0 -0
- data/lib/plucky/normalizers/sort_value.rb +0 -0
- data/lib/plucky/options_hash.rb +0 -0
- data/lib/plucky/pagination/collection.rb +1 -1
- data/lib/plucky/version.rb +1 -1
- data/spec/functional/options_hash_spec.rb +0 -0
- data/spec/plucky/criteria_hash_spec.rb +31 -1
- data/spec/plucky/normalizers/criteria_hash_value_spec.rb +1 -1
- data/spec/plucky/pagination/collection_spec.rb +5 -0
- data/spec/plucky_spec.rb +4 -4
- metadata +6 -6
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,15 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
             | 
| 2 | 
            +
            !binary "U0hBMQ==":
         | 
| 3 | 
            +
              metadata.gz: !binary |-
         | 
| 4 | 
            +
                YjkzYmEyZjI0NmViZjk3Nzc0N2JlODc5Y2JiZmZiNzhhOWQ4ZTY1OA==
         | 
| 5 | 
            +
              data.tar.gz: !binary |-
         | 
| 6 | 
            +
                MmNmOGM2N2RmYmRmYjllN2Q2MjRjZjQyNzAwYzhkMmZjMzZiN2JkYw==
         | 
| 5 7 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
             | 
| 8 | 
            +
              metadata.gz: !binary |-
         | 
| 9 | 
            +
                MzNiMDVhYTk0MDBmMzI0NmM5ZGNiMzcwZTkwNDEwZGQ3N2E1NTlhMWM3YjMz
         | 
| 10 | 
            +
                NmNjNDliOTc0OTUxNzFmNDU5YWE4N2Q0NDc1ODMyMjMxZDljOWJmNWRiN2Mw
         | 
| 11 | 
            +
                ZmUwNTQ4NTA5ZGFlYWFmZTA5M2E5ZGFjYTA4ZjRkMDcxZGIxNDk=
         | 
| 12 | 
            +
              data.tar.gz: !binary |-
         | 
| 13 | 
            +
                NjExZmVhZjMyNDE2MTk2ODY1ZmRhMTdhYzdkNTliNDk1NmNkZTY3M2NkMTIy
         | 
| 14 | 
            +
                OTgwNjZiNDE0NDUyYzc3YzdmYWQ1MmE4NWU5MDFiZWJiNzkxYjFjYjAxNjFk
         | 
| 15 | 
            +
                YWVlOTA0YjA0NjI1YTkwMTJkNThjZmI1NTQ0MDI1OTYwNGM0OWU=
         | 
    
        data/.rspec
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            --color
         | 
    
        data/.travis.yml
    CHANGED
    
    
    
        data/Gemfile
    CHANGED
    
    | @@ -1,11 +1,11 @@ | |
| 1 1 | 
             
            source 'https://rubygems.org'
         | 
| 2 2 | 
             
            gemspec
         | 
| 3 3 |  | 
| 4 | 
            -
            gem 'bson_ext', '~> 1.5'
         | 
| 4 | 
            +
            gem 'bson_ext', '~> 1.5', :platform => :mri
         | 
| 5 5 | 
             
            gem 'rake'
         | 
| 6 6 |  | 
| 7 | 
            -
            group :performance | 
| 8 | 
            -
              gem 'perftools.rb', :require => 'perftools'
         | 
| 7 | 
            +
            group :performance  do
         | 
| 8 | 
            +
              gem 'perftools.rb', :require => 'perftools', :platform => :mri
         | 
| 9 9 | 
             
            end
         | 
| 10 10 |  | 
| 11 11 | 
             
            group(:test) do
         | 
    
        data/lib/plucky/criteria_hash.rb
    CHANGED
    
    | @@ -125,7 +125,9 @@ module Plucky | |
| 125 125 | 
             
                    old_is_hash = oldval.instance_of? Hash
         | 
| 126 126 | 
             
                    new_is_hash = newval.instance_of? Hash
         | 
| 127 127 |  | 
| 128 | 
            -
                    if  | 
| 128 | 
            +
                    if oldval == newval
         | 
| 129 | 
            +
                      oldval
         | 
| 130 | 
            +
                    elsif old_is_hash && new_is_hash
         | 
| 129 131 | 
             
                      hash_merge(oldval, newval)
         | 
| 130 132 | 
             
                    elsif old_is_hash
         | 
| 131 133 | 
             
                      modifier_merge(oldval, newval)
         | 
| @@ -171,7 +173,12 @@ module Plucky | |
| 171 173 | 
             
                # of the object id. This makes sure it is an array of object ids, not the
         | 
| 172 174 | 
             
                # guts of the object id.
         | 
| 173 175 | 
             
                def array(value)
         | 
| 174 | 
            -
                   | 
| 176 | 
            +
                  case value
         | 
| 177 | 
            +
                  when nil, BSON::ObjectId
         | 
| 178 | 
            +
                    [value]
         | 
| 179 | 
            +
                  else
         | 
| 180 | 
            +
                    Array(value)
         | 
| 181 | 
            +
                  end
         | 
| 175 182 | 
             
                end
         | 
| 176 183 |  | 
| 177 184 | 
             
                # Private
         | 
| @@ -1,10 +1,12 @@ | |
| 1 | 
            +
            require 'set'
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            module Plucky
         | 
| 2 4 | 
             
              module Normalizers
         | 
| 3 5 | 
             
                class CriteriaHashValue
         | 
| 4 6 |  | 
| 5 7 | 
             
                  # Internal: Used by normalized_value to determine if we need to run the
         | 
| 6 8 | 
             
                  # value through another criteria hash to normalize it.
         | 
| 7 | 
            -
                  NestingOperators = [:$or, :$and, :$nor]
         | 
| 9 | 
            +
                  NestingOperators = Set[:$or, :$and, :$nor]
         | 
| 8 10 |  | 
| 9 11 | 
             
                  def initialize(criteria_hash)
         | 
| 10 12 | 
             
                    @criteria_hash = criteria_hash
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
    
        data/lib/plucky/options_hash.rb
    CHANGED
    
    | 
            File without changes
         | 
    
        data/lib/plucky/version.rb
    CHANGED
    
    
| 
            File without changes
         | 
| @@ -90,7 +90,7 @@ describe Plucky::CriteriaHash do | |
| 90 90 | 
             
                it "uniques matching key values" do
         | 
| 91 91 | 
             
                  c1 = described_class.new(:foo => 'bar')
         | 
| 92 92 | 
             
                  c2 = described_class.new(:foo => 'bar')
         | 
| 93 | 
            -
                  c1.merge(c2).source.should eq(:foo =>  | 
| 93 | 
            +
                  c1.merge(c2).source.should eq(:foo => 'bar')
         | 
| 94 94 | 
             
                end
         | 
| 95 95 |  | 
| 96 96 | 
             
                it "correctly merges arrays and non-arrays" do
         | 
| @@ -148,6 +148,36 @@ describe Plucky::CriteriaHash do | |
| 148 148 | 
             
                  c1[:foo].should == 'bar'
         | 
| 149 149 | 
             
                end
         | 
| 150 150 |  | 
| 151 | 
            +
                it "merges two hashes with the same key, but nil values as nil" do
         | 
| 152 | 
            +
                  c1 = described_class.new(:foo => nil)
         | 
| 153 | 
            +
                  c2 = described_class.new(:foo => nil)
         | 
| 154 | 
            +
                  c1.merge(c2).source.should == { :foo => nil }
         | 
| 155 | 
            +
                end
         | 
| 156 | 
            +
             | 
| 157 | 
            +
                it "merges two hashes with the same key, but false values as false" do
         | 
| 158 | 
            +
                  c1 = described_class.new(:foo => false)
         | 
| 159 | 
            +
                  c2 = described_class.new(:foo => false)
         | 
| 160 | 
            +
                  c1.merge(c2).source.should == { :foo => false }
         | 
| 161 | 
            +
                end
         | 
| 162 | 
            +
             | 
| 163 | 
            +
                it "merges two hashes with the same key, but different values with $in" do
         | 
| 164 | 
            +
                  c1 = described_class.new(:foo => false)
         | 
| 165 | 
            +
                  c2 = described_class.new(:foo => true)
         | 
| 166 | 
            +
                  c1.merge(c2).source.should == { :foo => { :'$in' => [false, true] } }
         | 
| 167 | 
            +
                end
         | 
| 168 | 
            +
             | 
| 169 | 
            +
                it "merges two hashes with different keys and different values properly" do
         | 
| 170 | 
            +
                  c1 = described_class.new(:foo => 1)
         | 
| 171 | 
            +
                  c2 = described_class.new(:bar => 2)
         | 
| 172 | 
            +
                  c1.merge(c2).source.should == { :foo => 1, :bar => 2 }
         | 
| 173 | 
            +
                end
         | 
| 174 | 
            +
             | 
| 175 | 
            +
                it "merges two sets" do
         | 
| 176 | 
            +
                  c1 = described_class.new(:foo => Set.new([1, 2]))
         | 
| 177 | 
            +
                  c2 = described_class.new(:foo => Set.new([2, 3]))
         | 
| 178 | 
            +
                  c1.merge(c2).source.should == { :foo => { :'$in' => [1,2,3] } }
         | 
| 179 | 
            +
                end
         | 
| 180 | 
            +
             | 
| 151 181 | 
             
                context "given multiple $or clauses" do
         | 
| 152 182 | 
             
                  before do
         | 
| 153 183 | 
             
                    @c1 = described_class.new(:$or => [{:a => 1}, {:b => 2}])
         | 
| @@ -155,7 +155,7 @@ describe Plucky::Normalizers::CriteriaHashValue do | |
| 155 155 |  | 
| 156 156 | 
             
              context "nested clauses" do
         | 
| 157 157 | 
             
                it "knows constant array of operators that take nested queries" do
         | 
| 158 | 
            -
                  described_class::NestingOperators.should == [:$or, :$and, :$nor]
         | 
| 158 | 
            +
                  described_class::NestingOperators.should == Set[:$or, :$and, :$nor]
         | 
| 159 159 | 
             
                end
         | 
| 160 160 |  | 
| 161 161 | 
             
                described_class::NestingOperators.each do |operator|
         | 
| @@ -26,5 +26,10 @@ describe Plucky::Pagination::Collection do | |
| 26 26 | 
             
                  @object.size.should       == 4
         | 
| 27 27 | 
             
                  @object.select { |o| o > 2 }.should == [3, 4]
         | 
| 28 28 | 
             
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                it "delegates missing methods to the paginator" do
         | 
| 31 | 
            +
                  @paginator.should_receive(:blather_matter).with('hello', :xyz, 4)
         | 
| 32 | 
            +
                  subject.blather_matter('hello', :xyz, 4)
         | 
| 33 | 
            +
                end
         | 
| 29 34 | 
             
              end
         | 
| 30 35 | 
             
            end
         | 
    
        data/spec/plucky_spec.rb
    CHANGED
    
    | @@ -31,21 +31,21 @@ describe Plucky do | |
| 31 31 | 
             
              describe ".modifier?" do
         | 
| 32 32 | 
             
                context "with a string" do
         | 
| 33 33 | 
             
                  it "returns true if modifier" do
         | 
| 34 | 
            -
                    Plucky.modifier?('$in').should  | 
| 34 | 
            +
                    Plucky.modifier?('$in').should == true
         | 
| 35 35 | 
             
                  end
         | 
| 36 36 |  | 
| 37 37 | 
             
                  it "returns false if not modifier" do
         | 
| 38 | 
            -
                    Plucky.modifier?('nope').should  | 
| 38 | 
            +
                    Plucky.modifier?('nope').should == false
         | 
| 39 39 | 
             
                  end
         | 
| 40 40 | 
             
                end
         | 
| 41 41 |  | 
| 42 42 | 
             
                context "with a symbol" do
         | 
| 43 43 | 
             
                  it "returns true if modifier" do
         | 
| 44 | 
            -
                    Plucky.modifier?(:$in).should  | 
| 44 | 
            +
                    Plucky.modifier?(:$in).should == true
         | 
| 45 45 | 
             
                  end
         | 
| 46 46 |  | 
| 47 47 | 
             
                  it "returns false if not modifier" do
         | 
| 48 | 
            -
                    Plucky.modifier?(:nope).should  | 
| 48 | 
            +
                    Plucky.modifier?(:nope).should == false
         | 
| 49 49 | 
             
                  end
         | 
| 50 50 | 
             
                end
         | 
| 51 51 | 
             
              end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: plucky
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.7.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - John Nunemaker
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2016-03-16 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: mongo
         | 
| @@ -32,6 +32,7 @@ extensions: [] | |
| 32 32 | 
             
            extra_rdoc_files: []
         | 
| 33 33 | 
             
            files:
         | 
| 34 34 | 
             
            - .gitignore
         | 
| 35 | 
            +
            - .rspec
         | 
| 35 36 | 
             
            - .travis.yml
         | 
| 36 37 | 
             
            - Gemfile
         | 
| 37 38 | 
             
            - Guardfile
         | 
| @@ -91,17 +92,17 @@ require_paths: | |
| 91 92 | 
             
            - lib
         | 
| 92 93 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 93 94 | 
             
              requirements:
         | 
| 94 | 
            -
              - - '>='
         | 
| 95 | 
            +
              - - ! '>='
         | 
| 95 96 | 
             
                - !ruby/object:Gem::Version
         | 
| 96 97 | 
             
                  version: '0'
         | 
| 97 98 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 98 99 | 
             
              requirements:
         | 
| 99 | 
            -
              - - '>='
         | 
| 100 | 
            +
              - - ! '>='
         | 
| 100 101 | 
             
                - !ruby/object:Gem::Version
         | 
| 101 102 | 
             
                  version: '0'
         | 
| 102 103 | 
             
            requirements: []
         | 
| 103 104 | 
             
            rubyforge_project: 
         | 
| 104 | 
            -
            rubygems_version: 2.0 | 
| 105 | 
            +
            rubygems_version: 2.5.0
         | 
| 105 106 | 
             
            signing_key: 
         | 
| 106 107 | 
             
            specification_version: 4
         | 
| 107 108 | 
             
            summary: Thin layer over the ruby driver that allows you to quickly grab hold of your
         | 
| @@ -124,4 +125,3 @@ test_files: | |
| 124 125 | 
             
            - spec/plucky_spec.rb
         | 
| 125 126 | 
             
            - spec/symbol_operator_spec.rb
         | 
| 126 127 | 
             
            - spec/symbol_spec.rb
         | 
| 127 | 
            -
            has_rdoc: 
         |