tire-multisort 0.2.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 +7 -0
 - data/.gitignore +17 -0
 - data/.travis.yml +4 -0
 - data/Gemfile +4 -0
 - data/LICENSE.txt +22 -0
 - data/README.md +130 -0
 - data/Rakefile +4 -0
 - data/lib/tire-multisort.rb +5 -0
 - data/lib/tire-multisort/tire/search.rb +16 -0
 - data/lib/tire-multisort/tire/search/multi_sort.rb +96 -0
 - data/lib/tire-multisort/version.rb +5 -0
 - data/spec/by_collection_method_spec.rb +67 -0
 - data/spec/by_default_method_spec.rb +66 -0
 - data/spec/by_method_spec.rb +99 -0
 - data/spec/helper.rb +15 -0
 - data/tire-multisort.gemspec +26 -0
 - metadata +134 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 47dd158d717fd7f4031f044e6f44a22ef705ba0b
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c012f4c898c95115d5f6ccd60c0133cf138a8999
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 29bf3d7ffaca9349ef1014e9867199f6a4e58ac25f97799b7f0641e4b38ab85a44deded8574841f2992ba0d1250985892945278c2a5b4d4860b91e32c1b01d5e
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 3c2eb527de681d91375a079b4765457ae9717977b37c297a48f370b6e954b64fd4b23b412c317a42fc373446c770eefddc190cbae2a5a6e2f6437d02b8ffcd10
         
     | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (c) 2015 igor04
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            MIT License
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 6 
     | 
    
         
            +
            a copy of this software and associated documentation files (the
         
     | 
| 
      
 7 
     | 
    
         
            +
            "Software"), to deal in the Software without restriction, including
         
     | 
| 
      
 8 
     | 
    
         
            +
            without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 9 
     | 
    
         
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 10 
     | 
    
         
            +
            permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 11 
     | 
    
         
            +
            the following conditions:
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be
         
     | 
| 
      
 14 
     | 
    
         
            +
            included in all copies or substantial portions of the Software.
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 17 
     | 
    
         
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 18 
     | 
    
         
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         
     | 
| 
      
 19 
     | 
    
         
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         
     | 
| 
      
 20 
     | 
    
         
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         
     | 
| 
      
 21 
     | 
    
         
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         
     | 
| 
      
 22 
     | 
    
         
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,130 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Tire Multisort
         
     | 
| 
      
 2 
     | 
    
         
            +
            [](http://badge.fury.io/rb/tire-multisort)
         
     | 
| 
      
 3 
     | 
    
         
            +
            [](https://codeclimate.com/github/igor04/tire-multisort)
         
     | 
| 
      
 4 
     | 
    
         
            +
            [](https://codeclimate.com/github/igor04/tire-multisort)
         
     | 
| 
      
 5 
     | 
    
         
            +
            [](https://travis-ci.org/igor04/tire-multisort)
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            `multi_sort` extended tire `sort` with some abilities
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            Add this line to your application's Gemfile:
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                gem 'tire-multisort'
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            And then execute:
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                $ bundle
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            Or install it yourself as:
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                $ gem install tire-multisort
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 26 
     | 
    
         
            +
             multi_sort sort, order do
         
     | 
| 
      
 27 
     | 
    
         
            +
               by_default :premium
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
               by :date
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
               by :name,      :title
         
     | 
| 
      
 32 
     | 
    
         
            +
               by :rating,    :subject_rating
         
     | 
| 
      
 33 
     | 
    
         
            +
               by :relevance, :_score
         
     | 
| 
      
 34 
     | 
    
         
            +
               by :category,  :category_name
         
     | 
| 
      
 35 
     | 
    
         
            +
               by :distance,  :_geo_distance, location: "test", unit: 'mi'
         
     | 
| 
      
 36 
     | 
    
         
            +
               by :premium,   :premium, :desc
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
               by_collection  :category,  [:category, :name]
         
     | 
| 
      
 39 
     | 
    
         
            +
               by_collection  :premium,   [:premium, :relevance, :name]
         
     | 
| 
      
 40 
     | 
    
         
            +
             end
         
     | 
| 
      
 41 
     | 
    
         
            +
            ```
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            ## Checkpoints
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
            - `multi sort` - accept `sort` argument as string `name,rating,date` which
         
     | 
| 
      
 46 
     | 
    
         
            +
              will be translated to propper sorting field
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            - `auto order`
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
              ```ruby
         
     | 
| 
      
 51 
     | 
    
         
            +
                # multi_sort
         
     | 
| 
      
 52 
     | 
    
         
            +
                by :date
         
     | 
| 
      
 53 
     | 
    
         
            +
              ```
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
              ```ruby
         
     | 
| 
      
 56 
     | 
    
         
            +
                # sort
         
     | 
| 
      
 57 
     | 
    
         
            +
                by :date, order
         
     | 
| 
      
 58 
     | 
    
         
            +
              ```
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
            - `predefined order` - using predefined order instead `order` parameter
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
              ```ruby
         
     | 
| 
      
 63 
     | 
    
         
            +
                # multi_sort
         
     | 
| 
      
 64 
     | 
    
         
            +
                by :date, :asc
         
     | 
| 
      
 65 
     | 
    
         
            +
                by :date, invert(order) # helper method (useful for some combination with using `collections`)
         
     | 
| 
      
 66 
     | 
    
         
            +
              ```
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
              ```ruby
         
     | 
| 
      
 69 
     | 
    
         
            +
                # sort
         
     | 
| 
      
 70 
     | 
    
         
            +
                by :date, :asc
         
     | 
| 
      
 71 
     | 
    
         
            +
                by :date, (order == :asc ? :desc : :asc)
         
     | 
| 
      
 72 
     | 
    
         
            +
              ```
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
            - `auto check` - run sort just from `collection`, `default` or from `sort` param
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
              ```ruby
         
     | 
| 
      
 77 
     | 
    
         
            +
                # multi_sort
         
     | 
| 
      
 78 
     | 
    
         
            +
                by :date
         
     | 
| 
      
 79 
     | 
    
         
            +
              ```
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
              ```ruby
         
     | 
| 
      
 82 
     | 
    
         
            +
                # sort
         
     | 
| 
      
 83 
     | 
    
         
            +
                if sort == :date
         
     | 
| 
      
 84 
     | 
    
         
            +
                  by :date, order
         
     | 
| 
      
 85 
     | 
    
         
            +
                end
         
     | 
| 
      
 86 
     | 
    
         
            +
              ```
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
            - `aliasing`
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
              ```ruby
         
     | 
| 
      
 92 
     | 
    
         
            +
                # multi_sort
         
     | 
| 
      
 93 
     | 
    
         
            +
                by :name, :title
         
     | 
| 
      
 94 
     | 
    
         
            +
              ```
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
              ```ruby
         
     | 
| 
      
 97 
     | 
    
         
            +
                # sort
         
     | 
| 
      
 98 
     | 
    
         
            +
                if sort == :name
         
     | 
| 
      
 99 
     | 
    
         
            +
                  by :title, order
         
     | 
| 
      
 100 
     | 
    
         
            +
                end
         
     | 
| 
      
 101 
     | 
    
         
            +
              ```
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
            - `collections` - group fiew sort fields to sort collection
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
              ```ruby
         
     | 
| 
      
 106 
     | 
    
         
            +
                # multi_sort
         
     | 
| 
      
 107 
     | 
    
         
            +
                by_collection  :category, [:category, :name]
         
     | 
| 
      
 108 
     | 
    
         
            +
              ```
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
              ```ruby
         
     | 
| 
      
 111 
     | 
    
         
            +
                # sort
         
     | 
| 
      
 112 
     | 
    
         
            +
                if sort == :category
         
     | 
| 
      
 113 
     | 
    
         
            +
                  by :category, order
         
     | 
| 
      
 114 
     | 
    
         
            +
                  by :name, order
         
     | 
| 
      
 115 
     | 
    
         
            +
                end
         
     | 
| 
      
 116 
     | 
    
         
            +
              ```
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
            - `default` - is used if passed sort param is incorrect or missed
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
              ```ruby
         
     | 
| 
      
 121 
     | 
    
         
            +
                by_default :premium
         
     | 
| 
      
 122 
     | 
    
         
            +
              ```
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
      
 126 
     | 
    
         
            +
            1. Fork it ( http://github.com/igor04/tire-multisort/fork )
         
     | 
| 
      
 127 
     | 
    
         
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         
     | 
| 
      
 128 
     | 
    
         
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         
     | 
| 
      
 129 
     | 
    
         
            +
            4. Push to the branch (`git push origin my-new-feature`)
         
     | 
| 
      
 130 
     | 
    
         
            +
            5. Create new Pull Request
         
     | 
    
        data/Rakefile
    ADDED
    
    
| 
         @@ -0,0 +1,16 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Tire
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Search
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
                class Search
         
     | 
| 
      
 5 
     | 
    
         
            +
                  # sort: "category,name,distance,.." or single "category", :category
         
     | 
| 
      
 6 
     | 
    
         
            +
                  # order: "asc", :desc
         
     | 
| 
      
 7 
     | 
    
         
            +
                  # block methods: by, by_default, by_collection
         
     | 
| 
      
 8 
     | 
    
         
            +
                  #
         
     | 
| 
      
 9 
     | 
    
         
            +
                  def multi_sort(sort, order, &block)
         
     | 
| 
      
 10 
     | 
    
         
            +
                    @sort = MultiSort.new(sort, order, &block).to_ary
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                    self
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,96 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Tire
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Search
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
                # EXAMPLE of using:
         
     | 
| 
      
 5 
     | 
    
         
            +
                #
         
     | 
| 
      
 6 
     | 
    
         
            +
                #
         
     | 
| 
      
 7 
     | 
    
         
            +
                # multi_sort sort, order do
         
     | 
| 
      
 8 
     | 
    
         
            +
                #
         
     | 
| 
      
 9 
     | 
    
         
            +
                #   by_default :premium
         
     | 
| 
      
 10 
     | 
    
         
            +
                #
         
     | 
| 
      
 11 
     | 
    
         
            +
                #   by :date
         
     | 
| 
      
 12 
     | 
    
         
            +
                #   by :rating,    invert(order)
         
     | 
| 
      
 13 
     | 
    
         
            +
                #
         
     | 
| 
      
 14 
     | 
    
         
            +
                #   by :name,      :title
         
     | 
| 
      
 15 
     | 
    
         
            +
                #   by :rating,    :licensee_rating
         
     | 
| 
      
 16 
     | 
    
         
            +
                #   by :relevance, :_score
         
     | 
| 
      
 17 
     | 
    
         
            +
                #   by :category,  :category_name
         
     | 
| 
      
 18 
     | 
    
         
            +
                #   by :distance,  :_geo_distance, location: "test", unit: 'mi'
         
     | 
| 
      
 19 
     | 
    
         
            +
                #   by :premium,   :premium, :desc
         
     | 
| 
      
 20 
     | 
    
         
            +
                #
         
     | 
| 
      
 21 
     | 
    
         
            +
                #   by_collection  :category,  [:category, :name]
         
     | 
| 
      
 22 
     | 
    
         
            +
                #   by_collection  :premium,   [:premium, :relevance, :name]
         
     | 
| 
      
 23 
     | 
    
         
            +
                #
         
     | 
| 
      
 24 
     | 
    
         
            +
                # end
         
     | 
| 
      
 25 
     | 
    
         
            +
                #
         
     | 
| 
      
 26 
     | 
    
         
            +
                class MultiSort < Sort
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  alias :origin_by :by
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  def initialize(sort_param, order, &block)
         
     | 
| 
      
 31 
     | 
    
         
            +
                    @collections = {}
         
     | 
| 
      
 32 
     | 
    
         
            +
                    @fields = {}
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                    super(&block)
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                    @sort = sort_by(sort_param)
         
     | 
| 
      
 37 
     | 
    
         
            +
                    @order = order
         
     | 
| 
      
 38 
     | 
    
         
            +
                    fields_with_order.each { |opts| origin_by *opts }
         
     | 
| 
      
 39 
     | 
    
         
            +
                  end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                  def by_default(sort_param)
         
     | 
| 
      
 42 
     | 
    
         
            +
                    @default = sort_by(sort_param)
         
     | 
| 
      
 43 
     | 
    
         
            +
                  end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                  def by_collection(sort, collection)
         
     | 
| 
      
 46 
     | 
    
         
            +
                    if collection.is_a? Array
         
     | 
| 
      
 47 
     | 
    
         
            +
                      @collections[sort] = collection
         
     | 
| 
      
 48 
     | 
    
         
            +
                    else
         
     | 
| 
      
 49 
     | 
    
         
            +
                      raise ArgumentError, "expect Array (got #{collection.class}) for collection param"
         
     | 
| 
      
 50 
     | 
    
         
            +
                    end
         
     | 
| 
      
 51 
     | 
    
         
            +
                  end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                  def by(sort, *options)
         
     | 
| 
      
 54 
     | 
    
         
            +
                    if options.blank? || [:desc, :asc].include?(options.first)
         
     | 
| 
      
 55 
     | 
    
         
            +
                      @fields[sort] = options.unshift(sort)
         
     | 
| 
      
 56 
     | 
    
         
            +
                    else
         
     | 
| 
      
 57 
     | 
    
         
            +
                      @fields[sort] = options
         
     | 
| 
      
 58 
     | 
    
         
            +
                    end
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                  def invert(order)
         
     | 
| 
      
 62 
     | 
    
         
            +
                    order.to_s == 'asc' ? :desc : :asc
         
     | 
| 
      
 63 
     | 
    
         
            +
                  end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                  private
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                  def add_order_to_field(field)
         
     | 
| 
      
 68 
     | 
    
         
            +
                    if field.size == 1
         
     | 
| 
      
 69 
     | 
    
         
            +
                      field.push @order
         
     | 
| 
      
 70 
     | 
    
         
            +
                    elsif field.last.is_a?(Hash) && !field.last.has_key?(:order)
         
     | 
| 
      
 71 
     | 
    
         
            +
                      field.last.merge!(order: @order)
         
     | 
| 
      
 72 
     | 
    
         
            +
                    end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                    field
         
     | 
| 
      
 75 
     | 
    
         
            +
                  end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                  def fields_with_order
         
     | 
| 
      
 78 
     | 
    
         
            +
                    @sort = @default if fields.empty?
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
                    fields.map { |field| add_order_to_field field.dup }
         
     | 
| 
      
 81 
     | 
    
         
            +
                  end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                  def fields
         
     | 
| 
      
 84 
     | 
    
         
            +
                    collections.map { |name| @fields[name.to_sym] }.compact
         
     | 
| 
      
 85 
     | 
    
         
            +
                  end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
                  def collections
         
     | 
| 
      
 88 
     | 
    
         
            +
                    @sort.size == 1 ? (@collections[@sort.first] || @sort) : @sort
         
     | 
| 
      
 89 
     | 
    
         
            +
                  end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                  def sort_by(param)
         
     | 
| 
      
 92 
     | 
    
         
            +
                    param.to_s.split(',').map { |s| s.strip.to_sym }
         
     | 
| 
      
 93 
     | 
    
         
            +
                  end
         
     | 
| 
      
 94 
     | 
    
         
            +
                end
         
     | 
| 
      
 95 
     | 
    
         
            +
              end
         
     | 
| 
      
 96 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,67 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe "Tire::Search::MultiSort" do
         
     | 
| 
      
 4 
     | 
    
         
            +
              subject(:search) { Tire::Search::Search.new }
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              context 'by_collection method' do
         
     | 
| 
      
 7 
     | 
    
         
            +
                it 'simple collection' do
         
     | 
| 
      
 8 
     | 
    
         
            +
                  search.multi_sort(:sort, :asc) do
         
     | 
| 
      
 9 
     | 
    
         
            +
                    by_default :sort_field
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                    by :name
         
     | 
| 
      
 12 
     | 
    
         
            +
                    by :sort_field, :asc
         
     | 
| 
      
 13 
     | 
    
         
            +
                    by :sort_param2, :sort_field2, :desc
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                    by_collection :sort,  [:sort_param2, :sort_field, :name]
         
     | 
| 
      
 16 
     | 
    
         
            +
                    by_collection :sort2, [:name, :sort_field, :sort_param2]
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                  expect(search.to_hash[:sort]).to eq [{sort_field2: :desc}, {sort_field: :asc}, {name: :asc}]
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                it 'with the same name as existed sort' do
         
     | 
| 
      
 23 
     | 
    
         
            +
                  search.multi_sort(:sort, :asc) do
         
     | 
| 
      
 24 
     | 
    
         
            +
                    by_default :sort_field
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                    by :sort
         
     | 
| 
      
 27 
     | 
    
         
            +
                    by :name
         
     | 
| 
      
 28 
     | 
    
         
            +
                    by :sort_field, :asc
         
     | 
| 
      
 29 
     | 
    
         
            +
                    by :sort_param2, :sort_field2, :desc
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                    by_collection :sort,  [:sort_param2, :sort_field, :name]
         
     | 
| 
      
 32 
     | 
    
         
            +
                  end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  expect(search.to_hash[:sort]).to eq [{sort_field2: :desc}, {sort_field: :asc}, {name: :asc}]
         
     | 
| 
      
 35 
     | 
    
         
            +
                end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                it 'ignore with multiple sort' do
         
     | 
| 
      
 38 
     | 
    
         
            +
                  search.multi_sort('sort,name,sort_param2', :asc) do
         
     | 
| 
      
 39 
     | 
    
         
            +
                    by_default :sort_field
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                    by :sort
         
     | 
| 
      
 42 
     | 
    
         
            +
                    by :name
         
     | 
| 
      
 43 
     | 
    
         
            +
                    by :sort_field, :asc
         
     | 
| 
      
 44 
     | 
    
         
            +
                    by :sort_param2, :sort_field2, :desc
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                    by_collection :sort,  [:sort_param2, :sort_field, :name]
         
     | 
| 
      
 47 
     | 
    
         
            +
                  end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                  expect(search.to_hash[:sort]).to eq [{sort: :asc}, {name: :asc}, {sort_field2: :desc}]
         
     | 
| 
      
 50 
     | 
    
         
            +
                end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                it 'with incorrect sort parameter' do
         
     | 
| 
      
 53 
     | 
    
         
            +
                  search.multi_sort(:sort, :asc) do
         
     | 
| 
      
 54 
     | 
    
         
            +
                    by_default :sort_field
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                    by :sort
         
     | 
| 
      
 57 
     | 
    
         
            +
                    by :name
         
     | 
| 
      
 58 
     | 
    
         
            +
                    by :sort_field, :asc
         
     | 
| 
      
 59 
     | 
    
         
            +
                    by :sort_param2, :sort_field2, :desc
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                    by_collection :sort,  [:sort_param2, :sort_field, :name2]
         
     | 
| 
      
 62 
     | 
    
         
            +
                  end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                  expect(search.to_hash[:sort]).to eq [{sort_field2: :desc}, {sort_field: :asc}]
         
     | 
| 
      
 65 
     | 
    
         
            +
                end
         
     | 
| 
      
 66 
     | 
    
         
            +
              end
         
     | 
| 
      
 67 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,66 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe "Tire::Search::MultiSort" do
         
     | 
| 
      
 4 
     | 
    
         
            +
              subject(:search) { Tire::Search::Search.new }
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              context 'by_default method' do
         
     | 
| 
      
 7 
     | 
    
         
            +
                it 'with invalid sort parameter' do
         
     | 
| 
      
 8 
     | 
    
         
            +
                  search.multi_sort(:invalid_sort, :asc) do
         
     | 
| 
      
 9 
     | 
    
         
            +
                    by_default :sort_field
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                    by :sort_field
         
     | 
| 
      
 12 
     | 
    
         
            +
                    by :sort_field2
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                  expect(search.to_hash[:sort]).to eq [{sort_field: :asc}]
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                it 'with missing sort parameter' do
         
     | 
| 
      
 19 
     | 
    
         
            +
                  search.multi_sort(nil, :asc) do
         
     | 
| 
      
 20 
     | 
    
         
            +
                    by_default :sort_field
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                    by :sort_field
         
     | 
| 
      
 23 
     | 
    
         
            +
                    by :sort_field2
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  expect(search.to_hash[:sort]).to eq [{sort_field: :asc}]
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                it 'could be redefined' do
         
     | 
| 
      
 30 
     | 
    
         
            +
                  search.multi_sort(nil, :asc) do
         
     | 
| 
      
 31 
     | 
    
         
            +
                    by_default :sort_field
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                    by :sort_field, :asc
         
     | 
| 
      
 34 
     | 
    
         
            +
                    by :sort_param2, :sort_field2, :desc
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                    by_default :sort_param2
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                  expect(search.to_hash[:sort]).to eq [{sort_field2: :desc}]
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                it 'ignore when sort correct' do
         
     | 
| 
      
 43 
     | 
    
         
            +
                  search.multi_sort(:sort_param2, :asc) do
         
     | 
| 
      
 44 
     | 
    
         
            +
                    by_default :sort_field
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                    by :sort_field, :asc
         
     | 
| 
      
 47 
     | 
    
         
            +
                    by :sort_param2, :sort_field2, :desc
         
     | 
| 
      
 48 
     | 
    
         
            +
                  end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                  expect(search.to_hash[:sort]).to eq [{sort_field2: :desc}]
         
     | 
| 
      
 51 
     | 
    
         
            +
                end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                it 'with sort collection' do
         
     | 
| 
      
 54 
     | 
    
         
            +
                  search.multi_sort(nil, :asc) do
         
     | 
| 
      
 55 
     | 
    
         
            +
                    by_default :sort_param3
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                    by :sort_field
         
     | 
| 
      
 58 
     | 
    
         
            +
                    by :sort_param2, :sort_field2, :desc
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                    by_collection :sort_param3,   [:sort_field, :sort_param2]
         
     | 
| 
      
 61 
     | 
    
         
            +
                  end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                  expect(search.to_hash[:sort]).to eq [{sort_field: :asc}, {sort_field2: :desc}]
         
     | 
| 
      
 64 
     | 
    
         
            +
                end
         
     | 
| 
      
 65 
     | 
    
         
            +
              end
         
     | 
| 
      
 66 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,99 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe "Tire::Search::MultiSort" do
         
     | 
| 
      
 4 
     | 
    
         
            +
              subject(:search) { Tire::Search::Search.new }
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              context 'by method' do
         
     | 
| 
      
 7 
     | 
    
         
            +
                it 'with alias and predefined order' do
         
     | 
| 
      
 8 
     | 
    
         
            +
                  search.multi_sort(:sort_param, :desc) do
         
     | 
| 
      
 9 
     | 
    
         
            +
                    by :sort_param,  :sort_field,  :asc
         
     | 
| 
      
 10 
     | 
    
         
            +
                    by :sort_param2, :sort_field2, :desc
         
     | 
| 
      
 11 
     | 
    
         
            +
                  end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  expect(search.to_hash[:sort]).to eq [{sort_field: :asc}]
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                it 'with alias' do
         
     | 
| 
      
 17 
     | 
    
         
            +
                  search.multi_sort(:sort_param, :desc) do
         
     | 
| 
      
 18 
     | 
    
         
            +
                    by :sort_param,  :sort_field
         
     | 
| 
      
 19 
     | 
    
         
            +
                    by :sort_param2, :sort_field2
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  expect(search.to_hash[:sort]).to eq [{sort_field: :desc}]
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                it 'without alias and with predefined order' do
         
     | 
| 
      
 26 
     | 
    
         
            +
                  search.multi_sort(:sort_field, :desc) do
         
     | 
| 
      
 27 
     | 
    
         
            +
                    by :sort_field, :asc
         
     | 
| 
      
 28 
     | 
    
         
            +
                    by :sort_field2, :order
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  expect(search.to_hash[:sort]).to eq [{sort_field: :asc}]
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                it 'without alias' do
         
     | 
| 
      
 35 
     | 
    
         
            +
                  search.multi_sort(:sort_field, :desc) do
         
     | 
| 
      
 36 
     | 
    
         
            +
                    by :sort_field
         
     | 
| 
      
 37 
     | 
    
         
            +
                    by :sort_field2
         
     | 
| 
      
 38 
     | 
    
         
            +
                  end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                  expect(search.to_hash[:sort]).to eq [{sort_field: :desc}]
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                it 'with multiple sort' do
         
     | 
| 
      
 44 
     | 
    
         
            +
                  search.multi_sort('sort_field2,sort_field,sort_param2,sort_param', :desc) do
         
     | 
| 
      
 45 
     | 
    
         
            +
                    by :sort_field
         
     | 
| 
      
 46 
     | 
    
         
            +
                    by :sort_field2
         
     | 
| 
      
 47 
     | 
    
         
            +
                    by :sort_param, :sort_field3
         
     | 
| 
      
 48 
     | 
    
         
            +
                    by :sort_param2, :sort_field4, :asc
         
     | 
| 
      
 49 
     | 
    
         
            +
                  end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                  expect(search.to_hash[:sort]).to eq [{sort_field2: :desc}, {sort_field: :desc}, {sort_field4: :asc}, {sort_field3: :desc}]
         
     | 
| 
      
 52 
     | 
    
         
            +
                end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                it 'with incorrect multiple sort parameter' do
         
     | 
| 
      
 55 
     | 
    
         
            +
                  search.multi_sort('sort_field0,sort_field,sort_param2,sort_param', :desc) do
         
     | 
| 
      
 56 
     | 
    
         
            +
                    by :sort_field
         
     | 
| 
      
 57 
     | 
    
         
            +
                    by :sort_field2
         
     | 
| 
      
 58 
     | 
    
         
            +
                    by :sort_param, :sort_field3
         
     | 
| 
      
 59 
     | 
    
         
            +
                    by :sort_param2, :sort_field4, :asc
         
     | 
| 
      
 60 
     | 
    
         
            +
                  end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                  expect(search.to_hash[:sort]).to eq [{sort_field: :desc}, {sort_field4: :asc}, {sort_field3: :desc}]
         
     | 
| 
      
 63 
     | 
    
         
            +
                end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                it 'with multiple sort and spaces' do
         
     | 
| 
      
 66 
     | 
    
         
            +
                  search.multi_sort(' sort_field, sort_param2, sort_param ', :desc) do
         
     | 
| 
      
 67 
     | 
    
         
            +
                    by :sort_field
         
     | 
| 
      
 68 
     | 
    
         
            +
                    by :sort_field2
         
     | 
| 
      
 69 
     | 
    
         
            +
                    by :sort_param, :sort_field3
         
     | 
| 
      
 70 
     | 
    
         
            +
                    by :sort_param2, :sort_field4, :asc
         
     | 
| 
      
 71 
     | 
    
         
            +
                  end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                  expect(search.to_hash[:sort]).to eq [{sort_field: :desc}, {sort_field4: :asc}, {sort_field3: :desc}]
         
     | 
| 
      
 74 
     | 
    
         
            +
                end
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                it 'with invert' do
         
     | 
| 
      
 77 
     | 
    
         
            +
                  order = :asc
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                  search.multi_sort(:sort_field, order) do
         
     | 
| 
      
 80 
     | 
    
         
            +
                    by :sort_field, invert(order)
         
     | 
| 
      
 81 
     | 
    
         
            +
                    by :sort_field2
         
     | 
| 
      
 82 
     | 
    
         
            +
                    by :sort_param, :sort_field3
         
     | 
| 
      
 83 
     | 
    
         
            +
                    by :sort_param2, :sort_field4, :asc
         
     | 
| 
      
 84 
     | 
    
         
            +
                  end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                  expect(search.to_hash[:sort]).to eq [{sort_field: :desc}]
         
     | 
| 
      
 87 
     | 
    
         
            +
                end
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
                it 'with additional parameters' do
         
     | 
| 
      
 90 
     | 
    
         
            +
                  search.multi_sort(:distance, :asc) do
         
     | 
| 
      
 91 
     | 
    
         
            +
                    by :sort_param, :sort_field3
         
     | 
| 
      
 92 
     | 
    
         
            +
                    by :sort_param2, :sort_field4, :asc
         
     | 
| 
      
 93 
     | 
    
         
            +
                    by :distance, :_geo_distance, location: "test", unit: 'mi'
         
     | 
| 
      
 94 
     | 
    
         
            +
                  end
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
                  expect(search.to_hash[:sort]).to eq  [{_geo_distance: {location: "test", unit: "mi", order: :asc}}]
         
     | 
| 
      
 97 
     | 
    
         
            +
                end
         
     | 
| 
      
 98 
     | 
    
         
            +
              end
         
     | 
| 
      
 99 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'bundler'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "codeclimate-test-reporter"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ENV['CODECLIMATE_REPO_TOKEN'] = '9db5a2e5847018b781c2d42d12ea9b05c4662b2cfad232b356731700da5cc418'
         
     | 
| 
      
 6 
     | 
    
         
            +
            CodeClimate::TestReporter.start
         
     | 
| 
      
 7 
     | 
    
         
            +
            require "#{File.dirname(__FILE__)}/../lib/tire-multisort"
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            begin
         
     | 
| 
      
 10 
     | 
    
         
            +
              Bundler.setup(:default, :development)
         
     | 
| 
      
 11 
     | 
    
         
            +
            rescue Bundler::BundlerError => e
         
     | 
| 
      
 12 
     | 
    
         
            +
              $stderr.puts e.message
         
     | 
| 
      
 13 
     | 
    
         
            +
              $stderr.puts "Run `bundle install` to install missing gems"
         
     | 
| 
      
 14 
     | 
    
         
            +
              exit e.status_code
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,26 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # coding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            lib = File.expand_path('../lib', __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'tire-multisort/version'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |spec|
         
     | 
| 
      
 7 
     | 
    
         
            +
              spec.name          = "tire-multisort"
         
     | 
| 
      
 8 
     | 
    
         
            +
              spec.version       = Tire::MultiSort::VERSION
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.authors       = ["igor04"]
         
     | 
| 
      
 10 
     | 
    
         
            +
              spec.email         = ["igor.s04g@gmail.com"]
         
     | 
| 
      
 11 
     | 
    
         
            +
              spec.summary       = %q{tire sort extension}
         
     | 
| 
      
 12 
     | 
    
         
            +
              spec.description   = %q{multi_sort extended tire sort with some abilities}
         
     | 
| 
      
 13 
     | 
    
         
            +
              spec.homepage      = "https://github.com/igor04/tire-multisort"
         
     | 
| 
      
 14 
     | 
    
         
            +
              spec.license       = "MIT"
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              spec.files         = `git ls-files -z`.split("\x0")
         
     | 
| 
      
 17 
     | 
    
         
            +
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         
     | 
| 
      
 18 
     | 
    
         
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         
     | 
| 
      
 19 
     | 
    
         
            +
              spec.require_paths = ["lib"]
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              spec.add_development_dependency "bundler", "~> 1.5"
         
     | 
| 
      
 22 
     | 
    
         
            +
              spec.add_development_dependency "rake"
         
     | 
| 
      
 23 
     | 
    
         
            +
              spec.add_development_dependency "rspec"
         
     | 
| 
      
 24 
     | 
    
         
            +
              spec.add_development_dependency "tire"
         
     | 
| 
      
 25 
     | 
    
         
            +
              spec.add_development_dependency "codeclimate-test-reporter"
         
     | 
| 
      
 26 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,134 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: tire-multisort
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - igor04
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-01-26 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: bundler
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '1.5'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '1.5'
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 41 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 42 
     | 
    
         
            +
              name: rspec
         
     | 
| 
      
 43 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 44 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 45 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 46 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 47 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 48 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 49 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 50 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 51 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 52 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 53 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 54 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 55 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 56 
     | 
    
         
            +
              name: tire
         
     | 
| 
      
 57 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 58 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 59 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 60 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 61 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 62 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 63 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 64 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 65 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 66 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 67 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 68 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 69 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 70 
     | 
    
         
            +
              name: codeclimate-test-reporter
         
     | 
| 
      
 71 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 72 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 73 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 74 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 75 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 76 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 77 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 78 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 79 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 80 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 81 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 82 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 83 
     | 
    
         
            +
            description: multi_sort extended tire sort with some abilities
         
     | 
| 
      
 84 
     | 
    
         
            +
            email:
         
     | 
| 
      
 85 
     | 
    
         
            +
            - igor.s04g@gmail.com
         
     | 
| 
      
 86 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 87 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 88 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 89 
     | 
    
         
            +
            files:
         
     | 
| 
      
 90 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 91 
     | 
    
         
            +
            - ".travis.yml"
         
     | 
| 
      
 92 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 93 
     | 
    
         
            +
            - LICENSE.txt
         
     | 
| 
      
 94 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 95 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 96 
     | 
    
         
            +
            - lib/tire-multisort.rb
         
     | 
| 
      
 97 
     | 
    
         
            +
            - lib/tire-multisort/tire/search.rb
         
     | 
| 
      
 98 
     | 
    
         
            +
            - lib/tire-multisort/tire/search/multi_sort.rb
         
     | 
| 
      
 99 
     | 
    
         
            +
            - lib/tire-multisort/version.rb
         
     | 
| 
      
 100 
     | 
    
         
            +
            - spec/by_collection_method_spec.rb
         
     | 
| 
      
 101 
     | 
    
         
            +
            - spec/by_default_method_spec.rb
         
     | 
| 
      
 102 
     | 
    
         
            +
            - spec/by_method_spec.rb
         
     | 
| 
      
 103 
     | 
    
         
            +
            - spec/helper.rb
         
     | 
| 
      
 104 
     | 
    
         
            +
            - tire-multisort.gemspec
         
     | 
| 
      
 105 
     | 
    
         
            +
            homepage: https://github.com/igor04/tire-multisort
         
     | 
| 
      
 106 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 107 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 108 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 109 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 110 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 111 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 112 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 113 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 114 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 115 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 116 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 117 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 118 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 119 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 120 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 121 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 122 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 123 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 124 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 125 
     | 
    
         
            +
            rubygems_version: 2.2.2
         
     | 
| 
      
 126 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 127 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 128 
     | 
    
         
            +
            summary: tire sort extension
         
     | 
| 
      
 129 
     | 
    
         
            +
            test_files:
         
     | 
| 
      
 130 
     | 
    
         
            +
            - spec/by_collection_method_spec.rb
         
     | 
| 
      
 131 
     | 
    
         
            +
            - spec/by_default_method_spec.rb
         
     | 
| 
      
 132 
     | 
    
         
            +
            - spec/by_method_spec.rb
         
     | 
| 
      
 133 
     | 
    
         
            +
            - spec/helper.rb
         
     | 
| 
      
 134 
     | 
    
         
            +
            has_rdoc: 
         
     |