moped_mapping 0.0.1 → 0.0.2
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 +6 -14
 - data/lib/moped_mapping/node_ext.rb +7 -0
 - data/lib/moped_mapping/version.rb +1 -1
 - data/spec/moped_mapping_get_more_spec.rb +44 -0
 - metadata +10 -8
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,15 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              metadata.gz: !binary |-
         
     | 
| 
       9 
     | 
    
         
            -
                NGU5MTRhZGUzZjQwZGQ3NzUxYmE3Yjk1MTgwYzU0MTVhM2RkYmY3YjljYzdm
         
     | 
| 
       10 
     | 
    
         
            -
                NDUwYzdmNWVmZTZlYjNjMGVhZjA2ODY4MDgyMzQyMDAwZGNmNjI5NWVhMzhm
         
     | 
| 
       11 
     | 
    
         
            -
                YzRmZjAxNDc3MDQxMDhmODg3M2E2MTEzYTAxNGM1NGE1OTM4NDA=
         
     | 
| 
       12 
     | 
    
         
            -
              data.tar.gz: !binary |-
         
     | 
| 
       13 
     | 
    
         
            -
                NmE3OTk4MzZiOWMzZGU5YTdlZGI1ZDkwN2M1NDQwMGNiOTZhYWIxN2ZhMTU3
         
     | 
| 
       14 
     | 
    
         
            -
                MmYwZDYzYzBjYzQ1MjU5ZmE5NDczNDViNDQ2YjkyYWJhODE3NTdiMTQxMzU0
         
     | 
| 
       15 
     | 
    
         
            -
                ZDRlMWUwODRhYzY0NWY0NmIzZWE2ZTQ4MzU2ODY3ZjgxZmI5ZjM=
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 9914d0817e9fd1c72047906175ef4c94ee22d21e
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: ebe492719c88fcfa2e3994701e661adb1a95ef72
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 193749ea662a6afac1cdc44bcc5cd1f3236f559f9438afc9eb5f7b7fb6d16690126066117721f18dc0764c916e83f6c8542d5e193d9dbe19decdacca0ead329e
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 067a2b33d1f6d28b72fd8ea7567206b82907e741a8c387530ff9e1b21d52515c396396ea13cbb64a2b1642bbdea37b329d334c92d07175ff06e5cec2dc9ac510
         
     | 
| 
         @@ -7,6 +7,8 @@ module MopedMapping 
     | 
|
| 
       7 
7 
     | 
    
         
             
                  klass.module_eval do
         
     | 
| 
       8 
8 
     | 
    
         
             
                    alias_method :query_without_mapping, :query
         
     | 
| 
       9 
9 
     | 
    
         
             
                    alias_method :query, :query_with_mapping
         
     | 
| 
      
 10 
     | 
    
         
            +
                    alias_method :get_more_without_mapping, :get_more
         
     | 
| 
      
 11 
     | 
    
         
            +
                    alias_method :get_more, :get_more_with_mapping
         
     | 
| 
       10 
12 
     | 
    
         
             
                  end
         
     | 
| 
       11 
13 
     | 
    
         
             
                end
         
     | 
| 
       12 
14 
     | 
    
         | 
| 
         @@ -14,5 +16,10 @@ module MopedMapping 
     | 
|
| 
       14 
16 
     | 
    
         
             
                  collection = MopedMapping.mapped_name(database, collection)
         
     | 
| 
       15 
17 
     | 
    
         
             
                  return query_without_mapping(database, collection, selector, options, &block)
         
     | 
| 
       16 
18 
     | 
    
         
             
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                def get_more_with_mapping(database, collection, selector, options = {}, &block)
         
     | 
| 
      
 21 
     | 
    
         
            +
                  collection = MopedMapping.mapped_name(database, collection)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  return get_more_without_mapping(database, collection, selector, options, &block)
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
       17 
24 
     | 
    
         
             
              end
         
     | 
| 
       18 
25 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,44 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            require 'tengine/support/yaml_with_erb'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'active_support/core_ext/hash/indifferent_access'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            describe MopedMapping do
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              let(:config) do
         
     | 
| 
      
 10 
     | 
    
         
            +
                YAML.load_file(File.expand_path("../moped.config.yml", __FILE__))["test"].with_indifferent_access
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              before do
         
     | 
| 
      
 14 
     | 
    
         
            +
                MopedMapping.disable
         
     | 
| 
      
 15 
     | 
    
         
            +
                @session = Moped::Session.new(config[:sessions][:default][:hosts])
         
     | 
| 
      
 16 
     | 
    
         
            +
                @database_name = config[:sessions][:default][:database]
         
     | 
| 
      
 17 
     | 
    
         
            +
                @session.use(@database_name)
         
     | 
| 
      
 18 
     | 
    
         
            +
                @session.tap do |s|
         
     | 
| 
      
 19 
     | 
    
         
            +
                  # コレクションの削除
         
     | 
| 
      
 20 
     | 
    
         
            +
                  s.collection_names.each{|col| s[col].drop }
         
     | 
| 
      
 21 
     | 
    
         
            +
                  # テスト用のデータの追加
         
     | 
| 
      
 22 
     | 
    
         
            +
                  s["items"].tap do |c|
         
     | 
| 
      
 23 
     | 
    
         
            +
                    c.insert(name: "foo", price: 100)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
                  s["items@1"].tap do |c|
         
     | 
| 
      
 26 
     | 
    
         
            +
                    200.times do |i|
         
     | 
| 
      
 27 
     | 
    
         
            +
                      c.insert(name: "item1-#{'%04d' % [i]}", price: (100 * rand).ceil)
         
     | 
| 
      
 28 
     | 
    
         
            +
                    end
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
                end
         
     | 
| 
      
 31 
     | 
    
         
            +
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              describe :find_with_cursor do
         
     | 
| 
      
 35 
     | 
    
         
            +
                it do
         
     | 
| 
      
 36 
     | 
    
         
            +
                  MopedMapping.enable
         
     | 
| 
      
 37 
     | 
    
         
            +
                  col = @session["items"]
         
     | 
| 
      
 38 
     | 
    
         
            +
                  MopedMapping.collection_map(@database_name, {"items" => "items@1" }) do
         
     | 
| 
      
 39 
     | 
    
         
            +
                    col.find().to_a.should have(200).items
         
     | 
| 
      
 40 
     | 
    
         
            +
                  end
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: moped_mapping
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - akima
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2013- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2013-11-05 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: moped
         
     | 
| 
         @@ -42,28 +42,28 @@ dependencies: 
     | 
|
| 
       42 
42 
     | 
    
         
             
              name: rake
         
     | 
| 
       43 
43 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       44 
44 
     | 
    
         
             
                requirements:
         
     | 
| 
       45 
     | 
    
         
            -
                - -  
     | 
| 
      
 45 
     | 
    
         
            +
                - - '>='
         
     | 
| 
       46 
46 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       47 
47 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       48 
48 
     | 
    
         
             
              type: :development
         
     | 
| 
       49 
49 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       50 
50 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       51 
51 
     | 
    
         
             
                requirements:
         
     | 
| 
       52 
     | 
    
         
            -
                - -  
     | 
| 
      
 52 
     | 
    
         
            +
                - - '>='
         
     | 
| 
       53 
53 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       54 
54 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       55 
55 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       56 
56 
     | 
    
         
             
              name: tengine_support
         
     | 
| 
       57 
57 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       58 
58 
     | 
    
         
             
                requirements:
         
     | 
| 
       59 
     | 
    
         
            -
                - -  
     | 
| 
      
 59 
     | 
    
         
            +
                - - '>='
         
     | 
| 
       60 
60 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       61 
61 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       62 
62 
     | 
    
         
             
              type: :development
         
     | 
| 
       63 
63 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       64 
64 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       65 
65 
     | 
    
         
             
                requirements:
         
     | 
| 
       66 
     | 
    
         
            -
                - -  
     | 
| 
      
 66 
     | 
    
         
            +
                - - '>='
         
     | 
| 
       67 
67 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       68 
68 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       69 
69 
     | 
    
         
             
            description: make mapping from moped collection object to MongoDB actual collection
         
     | 
| 
         @@ -88,6 +88,7 @@ files: 
     | 
|
| 
       88 
88 
     | 
    
         
             
            - spec/moped.config.yml
         
     | 
| 
       89 
89 
     | 
    
         
             
            - spec/moped_mapping/geospatial_spec.rb
         
     | 
| 
       90 
90 
     | 
    
         
             
            - spec/moped_mapping/thread_safe_spec.rb
         
     | 
| 
      
 91 
     | 
    
         
            +
            - spec/moped_mapping_get_more_spec.rb
         
     | 
| 
       91 
92 
     | 
    
         
             
            - spec/moped_mapping_spec.rb
         
     | 
| 
       92 
93 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       93 
94 
     | 
    
         
             
            homepage: ''
         
     | 
| 
         @@ -100,12 +101,12 @@ require_paths: 
     | 
|
| 
       100 
101 
     | 
    
         
             
            - lib
         
     | 
| 
       101 
102 
     | 
    
         
             
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
       102 
103 
     | 
    
         
             
              requirements:
         
     | 
| 
       103 
     | 
    
         
            -
              - -  
     | 
| 
      
 104 
     | 
    
         
            +
              - - '>='
         
     | 
| 
       104 
105 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       105 
106 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       106 
107 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       107 
108 
     | 
    
         
             
              requirements:
         
     | 
| 
       108 
     | 
    
         
            -
              - -  
     | 
| 
      
 109 
     | 
    
         
            +
              - - '>='
         
     | 
| 
       109 
110 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       110 
111 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       111 
112 
     | 
    
         
             
            requirements: []
         
     | 
| 
         @@ -119,6 +120,7 @@ test_files: 
     | 
|
| 
       119 
120 
     | 
    
         
             
            - spec/moped.config.yml
         
     | 
| 
       120 
121 
     | 
    
         
             
            - spec/moped_mapping/geospatial_spec.rb
         
     | 
| 
       121 
122 
     | 
    
         
             
            - spec/moped_mapping/thread_safe_spec.rb
         
     | 
| 
      
 123 
     | 
    
         
            +
            - spec/moped_mapping_get_more_spec.rb
         
     | 
| 
       122 
124 
     | 
    
         
             
            - spec/moped_mapping_spec.rb
         
     | 
| 
       123 
125 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       124 
126 
     | 
    
         
             
            has_rdoc: 
         
     |