mongo_mapper_ext 0.2.2 → 0.2.3
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.
- data/Rakefile +5 -5
- data/lib/mongo_db_ext/micelaneous.rb +12 -0
- data/lib/mongo_mapper_ext/gems.rb +17 -2
- data/lib/mongo_mapper_ext/hacks/active_model.rb +16 -0
- data/lib/mongo_mapper_ext/hacks/fixes.rb +37 -0
- data/lib/mongo_mapper_ext/{micelaneous.rb → logging.rb} +30 -8
- data/lib/mongo_mapper_ext/migration.rb +1 -1
- data/lib/mongo_mapper_ext/mongo_mapper.rb +0 -25
- data/lib/mongo_mapper_ext/plugins/{attributes_cache.rb → attribute_cache.rb} +2 -1
- data/lib/mongo_mapper_ext/plugins/attribute_convertors.rb +79 -0
- data/lib/mongo_mapper_ext/plugins/belongs_to_with_counter_cache.rb +45 -0
- data/lib/mongo_mapper_ext/plugins/carrierwave.rb +60 -0
- data/lib/mongo_mapper_ext/plugins/{default_scope.rb → custom_scope.rb} +3 -2
- data/lib/mongo_mapper_ext/plugins/db_config.rb +84 -46
- data/lib/mongo_mapper_ext/plugins/micelaneous.rb +24 -68
- data/lib/mongo_mapper_ext/rad/file_uploader.rb +28 -0
- data/lib/mongo_mapper_ext/rad.rb +2 -0
- data/lib/mongo_mapper_ext/spec.rb +103 -0
- data/lib/mongo_mapper_ext/{migrate.rake → tasks.rb} +3 -15
- data/lib/mongo_mapper_ext.rb +41 -24
- data/readme.md +74 -2
- data/spec/attribute_convertors_spec.rb +71 -0
- data/spec/carrierwave_spec/plane.jpg +0 -0
- data/spec/carrierwave_spec.rb +42 -0
- data/spec/{scope_spec.rb → custom_scope_spec.rb} +26 -32
- data/spec/micelaneous_plugin_spec.rb +34 -20
- data/spec/micelaneous_spec.rb +105 -24
- data/spec/migration_spec.rb +8 -17
- data/spec/{mm_spec.rb → mongo_mapper_spec.rb} +0 -0
- data/spec/spec_helper.rb +2 -5
- data/spec/uploading_spec/ship.jpg +0 -0
- data/spec/uploading_spec//321/204/320/260/320/270/314/206/320/273 /321/201 /320/277/321/200/320/276/320/261/320/265/320/273/320/260/320/274/320/270.txt" +1 -0
- data/spec/uploading_spec.rb +49 -0
- metadata +164 -72
- data/lib/mongo_mapper_ext/db_config.rb +0 -67
- data/lib/mongo_mapper_ext/hacks/time_measuring.rb +0 -44
- data/lib/mongo_mapper_ext/spec/helper.rb +0 -61
    
        data/spec/micelaneous_spec.rb
    CHANGED
    
    | @@ -1,53 +1,134 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 | 
            -
            require "mongo_mapper_ext/micelaneous"
         | 
| 4 | 
            -
            require "mongo_mapper_ext/plugins/micelaneous"
         | 
| 5 | 
            -
             | 
| 6 3 | 
             
            describe "MongoMapper micelaneous" do
         | 
| 7 | 
            -
               | 
| 8 | 
            -
                @db = Mongo::Connection.new.db('test')
         | 
| 9 | 
            -
                MongoMapper.database = 'test'
         | 
| 10 | 
            -
              end
         | 
| 4 | 
            +
              with_mongo_mapper
         | 
| 11 5 |  | 
| 12 | 
            -
               | 
| 13 | 
            -
                @db.collection('test').drop
         | 
| 14 | 
            -
                @coll = @db.collection('test')
         | 
| 15 | 
            -
              end
         | 
| 6 | 
            +
              after(:all){remove_constants %w(UpsertSample AsStringSample TranslationCheck)}    
         | 
| 16 7 |  | 
| 17 | 
            -
               | 
| 18 | 
            -
                 | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 8 | 
            +
              describe "Collection extensions" do
         | 
| 9 | 
            +
                before do
         | 
| 10 | 
            +
                  connection = Mongo::Connection.new.db('test')
         | 
| 11 | 
            +
                  @collection = connection.collection('test')
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
                
         | 
| 14 | 
            +
                it "upsert should update" do
         | 
| 15 | 
            +
                  id = @collection.save count: 2
         | 
| 16 | 
            +
                  @collection.upsert!({_id: id}, :$inc => {count: 1})
         | 
| 17 | 
            +
                  @collection.find(_id: id).first['count'].should == 3
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
              
         | 
| 20 | 
            +
                it "upsert should set" do
         | 
| 21 | 
            +
                  id = @collection.save({})
         | 
| 22 | 
            +
                  @collection.upsert!({_id: id}, :$inc => {count: 1})
         | 
| 23 | 
            +
                  @collection.find(_id: id).first['count'].should == 1
         | 
| 24 | 
            +
                end
         | 
| 21 25 | 
             
              end
         | 
| 22 26 |  | 
| 23 | 
            -
               | 
| 24 | 
            -
                 | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            +
              describe "i18n" do
         | 
| 28 | 
            +
                it "should translate error messages" do
         | 
| 29 | 
            +
                  class ::TranslationCheck
         | 
| 30 | 
            +
                    include MongoMapper::Document
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                    key :name, String
         | 
| 33 | 
            +
                    validates_uniqueness_of :name
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  TranslationCheck.destroy_all
         | 
| 37 | 
            +
                  TranslationCheck.create! name: 'a'
         | 
| 38 | 
            +
                  t = TranslationCheck.new name: 'a'
         | 
| 39 | 
            +
                  t.should_not be_valid
         | 
| 40 | 
            +
                  t.errors[:name].first.should =~ /already been taken/
         | 
| 41 | 
            +
                end
         | 
| 27 42 | 
             
              end
         | 
| 28 43 |  | 
| 29 44 | 
             
              describe "handy upsert" do
         | 
| 30 45 | 
             
                class ::UpsertSample
         | 
| 31 46 | 
             
                  include MongoMapper::Document
         | 
| 32 | 
            -
                   | 
| 47 | 
            +
                  include MongoMapper::Plugins::Micelaneous
         | 
| 33 48 |  | 
| 34 | 
            -
                  key :counter, Integer, : | 
| 49 | 
            +
                  key :counter, Integer, default: 1
         | 
| 35 50 | 
             
                end  
         | 
| 36 51 |  | 
| 37 | 
            -
                before  | 
| 52 | 
            +
                before do 
         | 
| 38 53 | 
             
                  @model = UpsertSample.create!
         | 
| 39 54 | 
             
                end
         | 
| 40 55 |  | 
| 41 56 | 
             
                it "class upsert" do
         | 
| 42 | 
            -
                  UpsertSample.upsert @model.id, :$inc => {: | 
| 57 | 
            +
                  UpsertSample.upsert!({id: @model.id}, :$inc => {counter: 1})
         | 
| 43 58 | 
             
                  @model.reload
         | 
| 44 59 | 
             
                  @model.counter.should == 2
         | 
| 45 60 | 
             
                end
         | 
| 46 61 |  | 
| 47 62 | 
             
                it "model upsert" do
         | 
| 48 | 
            -
                  @model.upsert :$inc => {: | 
| 63 | 
            +
                  @model.upsert! :$inc => {counter: 1}
         | 
| 49 64 | 
             
                  @model.reload
         | 
| 50 65 | 
             
                  @model.counter.should == 2
         | 
| 51 66 | 
             
                end
         | 
| 52 67 | 
             
              end
         | 
| 68 | 
            +
              
         | 
| 69 | 
            +
              describe "as_string" do
         | 
| 70 | 
            +
                before do
         | 
| 71 | 
            +
                  @convertors = MongoMapper::Plugins::AttributeConvertors::ClassMethods::ATTRIBUTE_CONVERTORS
         | 
| 72 | 
            +
                  @convertors[:test_convertor] = {
         | 
| 73 | 
            +
                    from_string: -> s {"from_string: #{s}"},
         | 
| 74 | 
            +
                    to_string:   -> v {"to_string: #{v}"}
         | 
| 75 | 
            +
                  }
         | 
| 76 | 
            +
                end
         | 
| 77 | 
            +
                
         | 
| 78 | 
            +
                it ":line convertor" do      
         | 
| 79 | 
            +
                  v = ['a', 'b']
         | 
| 80 | 
            +
                  str_v = 'a, b'
         | 
| 81 | 
            +
                  @convertors[:line][:from_string].call(str_v).should == v
         | 
| 82 | 
            +
                  @convertors[:line][:to_string].call(v).should == str_v
         | 
| 83 | 
            +
                end
         | 
| 84 | 
            +
                
         | 
| 85 | 
            +
                it ":yaml convertor" do
         | 
| 86 | 
            +
                  v = {'a' => 'b'}
         | 
| 87 | 
            +
                  str_v = v.to_yaml.strip
         | 
| 88 | 
            +
                  
         | 
| 89 | 
            +
                  @convertors[:yaml][:from_string].call(str_v).should == v
         | 
| 90 | 
            +
                  @convertors[:yaml][:to_string].call(v).should == str_v
         | 
| 91 | 
            +
                end
         | 
| 92 | 
            +
                
         | 
| 93 | 
            +
                it ":json convertor" do
         | 
| 94 | 
            +
                  v = {'a' => 'b'}
         | 
| 95 | 
            +
                  str_v = v.to_json.strip
         | 
| 96 | 
            +
                  @convertors[:json][:from_string].call(str_v).should == v
         | 
| 97 | 
            +
                  @convertors[:json][:to_string].call(v).should == str_v
         | 
| 98 | 
            +
                end
         | 
| 99 | 
            +
                
         | 
| 100 | 
            +
                it ":key extension" do
         | 
| 101 | 
            +
                  class ::AsStringSample
         | 
| 102 | 
            +
                    include MongoMapper::Document
         | 
| 103 | 
            +
                    include MongoMapper::Plugins::Micelaneous
         | 
| 104 | 
            +
                    
         | 
| 105 | 
            +
                    key :key, String, as_string: :test_convertor
         | 
| 106 | 
            +
                    key :protected_key, String, as_string: :test_convertor, protected: true
         | 
| 107 | 
            +
                  end
         | 
| 108 | 
            +
                
         | 
| 109 | 
            +
                  o = AsStringSample.new
         | 
| 110 | 
            +
                  
         | 
| 111 | 
            +
                  # get
         | 
| 112 | 
            +
                  o.key_as_string.should == 'to_string: '
         | 
| 113 | 
            +
                  o.key = 'value'
         | 
| 114 | 
            +
                  o.clear_cache
         | 
| 115 | 
            +
                  o.key_as_string.should == 'to_string: value'
         | 
| 116 | 
            +
                  
         | 
| 117 | 
            +
                  # set
         | 
| 118 | 
            +
                  o.key_as_string = ''
         | 
| 119 | 
            +
                  o.key.should == 'from_string: '
         | 
| 120 | 
            +
                  o.key_as_string = 'value'
         | 
| 121 | 
            +
                  o.key.should == 'from_string: value'
         | 
| 122 | 
            +
                  
         | 
| 123 | 
            +
                  # mass assignment
         | 
| 124 | 
            +
                  o.key = ''
         | 
| 125 | 
            +
                  o.update_attributes key_as_string: 'value'
         | 
| 126 | 
            +
                  o.key.should == 'from_string: value'
         | 
| 127 | 
            +
                  
         | 
| 128 | 
            +
                  # protection
         | 
| 129 | 
            +
                  o.protected_key = ''
         | 
| 130 | 
            +
                  o.update_attributes protected_key_as_string: 'value'
         | 
| 131 | 
            +
                  o.protected_key.should == ''
         | 
| 132 | 
            +
                end
         | 
| 133 | 
            +
              end
         | 
| 53 134 | 
             
            end
         | 
    
        data/spec/migration_spec.rb
    CHANGED
    
    | @@ -1,8 +1,5 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 | 
            -
            require "mongo_mapper_ext"
         | 
| 4 | 
            -
            require "mongo_mapper_ext/spec/helper"
         | 
| 5 | 
            -
             | 
| 6 3 | 
             
            describe "MongoMapper Migration" do
         | 
| 7 4 | 
             
              with_mongo_mapper
         | 
| 8 5 |  | 
| @@ -11,28 +8,22 @@ describe "MongoMapper Migration" do | |
| 11 8 | 
             
              before :all do
         | 
| 12 9 | 
             
                MongoMapper.logger = Logger.new(nil)
         | 
| 13 10 | 
             
                MongoMapper.db_config = {
         | 
| 14 | 
            -
                  ' | 
| 15 | 
            -
                  ' | 
| 11 | 
            +
                  'default' => {'name' => "default_test"},
         | 
| 12 | 
            +
                  'global' => {'name' => 'global_test'}
         | 
| 16 13 | 
             
                }
         | 
| 17 14 |  | 
| 18 15 | 
             
                class ::Sample
         | 
| 19 16 | 
             
                  include MongoMapper::Document
         | 
| 20 | 
            -
                   | 
| 17 | 
            +
                  _use_database :global
         | 
| 21 18 |  | 
| 22 19 | 
             
                  key :name, String
         | 
| 23 20 | 
             
                end
         | 
| 24 21 |  | 
| 25 | 
            -
                # MongoMapper.call_deferred
         | 
| 26 22 | 
             
                Migration.logger = nil        
         | 
| 27 23 | 
             
              end
         | 
| 28 | 
            -
             | 
| 29 | 
            -
              after :all do
         | 
| 30 | 
            -
                Object.send :remove_const, :Sample if Object.const_defined? :Sample    
         | 
| 31 | 
            -
              end
         | 
| 24 | 
            +
              after(:all){remove_constants :Sample}
         | 
| 32 25 |  | 
| 33 | 
            -
              before | 
| 34 | 
            -
                Migration.definitions.clear
         | 
| 35 | 
            -
              end
         | 
| 26 | 
            +
              before{Migration.definitions.clear}
         | 
| 36 27 |  | 
| 37 28 | 
             
              it "Shouldn't update if versions are the same" do
         | 
| 38 29 | 
             
                Migration.update(:global, 0).should be_false
         | 
| @@ -42,7 +33,7 @@ describe "MongoMapper Migration" do | |
| 42 33 | 
             
                Sample.count.should == 0    
         | 
| 43 34 | 
             
                Migration.define :global, 1 do |m|
         | 
| 44 35 | 
             
                  m.up do |db|
         | 
| 45 | 
            -
                    Sample.create : | 
| 36 | 
            +
                    Sample.create name: 'name'
         | 
| 46 37 | 
             
                    coll = db.collection 'samples'
         | 
| 47 38 | 
             
                    coll.find.count.should == 1
         | 
| 48 39 | 
             
                  end
         | 
| @@ -55,7 +46,7 @@ describe "MongoMapper Migration" do | |
| 55 46 | 
             
              it "increase_db_version" do
         | 
| 56 47 | 
             
                Sample.count.should == 0
         | 
| 57 48 | 
             
                Migration.define :global, 1 do |m|
         | 
| 58 | 
            -
                  m.up{Sample.create : | 
| 49 | 
            +
                  m.up{Sample.create name: 'name'}
         | 
| 59 50 | 
             
                end
         | 
| 60 51 |  | 
| 61 52 | 
             
                Migration.update(:global, 1).should be_true    
         | 
| @@ -65,7 +56,7 @@ describe "MongoMapper Migration" do | |
| 65 56 |  | 
| 66 57 | 
             
              it "decrease_db_version" do    
         | 
| 67 58 | 
             
                Migration.define :global, 1 do |m|
         | 
| 68 | 
            -
                  m.up{Sample.create : | 
| 59 | 
            +
                  m.up{Sample.create name: 'name'}
         | 
| 69 60 | 
             
                  m.down{Sample.destroy_all}
         | 
| 70 61 | 
             
                end
         | 
| 71 62 | 
             
                Migration.update(:global, 1).should be_true
         | 
| 
            File without changes
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -1,9 +1,6 @@ | |
| 1 1 | 
             
            require 'rspec_ext'
         | 
| 2 2 |  | 
| 3 | 
            -
            lib_dir = "#{__FILE__.parent_dirname}/lib"
         | 
| 4 | 
            -
            $LOAD_PATH << lib_dir unless $LOAD_PATH.include? lib_dir
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            gem 'mongo_mapper', '>=0.8'
         | 
| 7 3 | 
             
            require "mongo_mapper"
         | 
| 8 4 |  | 
| 9 | 
            -
            require  | 
| 5 | 
            +
            require "mongo_mapper_ext"
         | 
| 6 | 
            +
            require "mongo_mapper_ext/spec"
         | 
| Binary file | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            1
         | 
| @@ -0,0 +1,49 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
            require "mongo_mapper_ext/rad"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe "Uploading" do  
         | 
| 5 | 
            +
              with_tmp_spec_dir
         | 
| 6 | 
            +
              with_mongo_mapper
         | 
| 7 | 
            +
              with_files  
         | 
| 8 | 
            +
              
         | 
| 9 | 
            +
              before :all do
         | 
| 10 | 
            +
                class ShipUploader < Models::FileUploader      
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
                
         | 
| 13 | 
            +
                class Ship
         | 
| 14 | 
            +
                  include MongoMapper::Document
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  key :name
         | 
| 17 | 
            +
                  validates_uniqueness_of :name
         | 
| 18 | 
            +
                  
         | 
| 19 | 
            +
                  mount_uploader :image, ShipUploader
         | 
| 20 | 
            +
                end                
         | 
| 21 | 
            +
              end  
         | 
| 22 | 
            +
              after(:all){remove_constants :Ship, :ShipUploader}  
         | 
| 23 | 
            +
              
         | 
| 24 | 
            +
              it "should upload images" do    
         | 
| 25 | 
            +
                ship = nil
         | 
| 26 | 
            +
                File.open "#{spec_dir}/ship.jpg" do |f|
         | 
| 27 | 
            +
                  ship = Ship.new image: f
         | 
| 28 | 
            +
                  ship.save!
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
                ship.image.url.should =~ /\/ship\.jpg/
         | 
| 31 | 
            +
                ship.image_filename.should =~ /ship\.jpg/
         | 
| 32 | 
            +
                ship.image.path.should =~ /\/ship\.jpg/
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
              
         | 
| 35 | 
            +
              it "should preserve spaces and unicode characters in filename" do
         | 
| 36 | 
            +
                File.open "#{spec_dir}/файл с пробелами.txt" do |f|
         | 
| 37 | 
            +
                  ship = Ship.new image: f
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                  ship.image.url.should =~ /\/файл с пробелами\.txt/
         | 
| 40 | 
            +
                  ship.image.filename =~ /файл с пробелами\.txt/
         | 
| 41 | 
            +
                  ship.image.path =~ /\/файл с пробелами\.txt/
         | 
| 42 | 
            +
                
         | 
| 43 | 
            +
                  # ship.smart_url.should =~ /files\/file with spaces\/file with spaces\.txt\?\d/
         | 
| 44 | 
            +
                  # f.smart_url.should =~ /files\/data\/ship\?\d+/
         | 
| 45 | 
            +
                  # f.smart_url(:icon).should =~ /images\/mime\/dat_icon\.png/
         | 
| 46 | 
            +
                  # f.smart_url(:thumb).should =~ /images\/mime\/dat_thumb\.png/
         | 
| 47 | 
            +
                end
         | 
| 48 | 
            +
              end
         | 
| 49 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,120 +1,212 @@ | |
| 1 | 
            -
            --- !ruby/object:Gem::Specification | 
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: mongo_mapper_ext
         | 
| 3 | 
            -
            version: !ruby/object:Gem::Version | 
| 4 | 
            -
               | 
| 5 | 
            -
              prerelease:  | 
| 6 | 
            -
              segments: 
         | 
| 7 | 
            -
              - 0
         | 
| 8 | 
            -
              - 2
         | 
| 9 | 
            -
              - 2
         | 
| 10 | 
            -
              version: 0.2.2
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.2.3
         | 
| 5 | 
            +
              prerelease: 
         | 
| 11 6 | 
             
            platform: ruby
         | 
| 12 | 
            -
            authors: | 
| 7 | 
            +
            authors:
         | 
| 13 8 | 
             
            - Alexey Petrushin
         | 
| 14 9 | 
             
            autorequire: 
         | 
| 15 10 | 
             
            bindir: bin
         | 
| 16 11 | 
             
            cert_chain: []
         | 
| 17 | 
            -
             | 
| 18 | 
            -
            date: 2010-10-15 00:00:00 +04:00
         | 
| 12 | 
            +
            date: 2011-05-19 00:00:00.000000000 +04:00
         | 
| 19 13 | 
             
            default_executable: 
         | 
| 20 | 
            -
            dependencies: | 
| 21 | 
            -
            - !ruby/object:Gem::Dependency | 
| 14 | 
            +
            dependencies:
         | 
| 15 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 22 16 | 
             
              name: mongo_mapper
         | 
| 17 | 
            +
              requirement: &2795830 !ruby/object:Gem::Requirement
         | 
| 18 | 
            +
                none: false
         | 
| 19 | 
            +
                requirements:
         | 
| 20 | 
            +
                - - =
         | 
| 21 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 22 | 
            +
                    version: 0.9.0
         | 
| 23 | 
            +
              type: :runtime
         | 
| 24 | 
            +
              prerelease: false
         | 
| 25 | 
            +
              version_requirements: *2795830
         | 
| 26 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 27 | 
            +
              name: carrierwave
         | 
| 28 | 
            +
              requirement: &2795590 !ruby/object:Gem::Requirement
         | 
| 29 | 
            +
                none: false
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - =
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: 0.5.3
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: *2795590
         | 
| 37 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 38 | 
            +
              name: i18n
         | 
| 39 | 
            +
              requirement: &2795370 !ruby/object:Gem::Requirement
         | 
| 40 | 
            +
                none: false
         | 
| 41 | 
            +
                requirements:
         | 
| 42 | 
            +
                - - =
         | 
| 43 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 44 | 
            +
                    version: 0.5.0
         | 
| 45 | 
            +
              type: :runtime
         | 
| 46 | 
            +
              prerelease: false
         | 
| 47 | 
            +
              version_requirements: *2795370
         | 
| 48 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 49 | 
            +
              name: activesupport
         | 
| 50 | 
            +
              requirement: &2795150 !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                none: false
         | 
| 52 | 
            +
                requirements:
         | 
| 53 | 
            +
                - - =
         | 
| 54 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 55 | 
            +
                    version: 3.0.7
         | 
| 56 | 
            +
              type: :runtime
         | 
| 23 57 | 
             
              prerelease: false
         | 
| 24 | 
            -
               | 
| 58 | 
            +
              version_requirements: *2795150
         | 
| 59 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 60 | 
            +
              name: activemodel
         | 
| 61 | 
            +
              requirement: &2794920 !ruby/object:Gem::Requirement
         | 
| 25 62 | 
             
                none: false
         | 
| 26 | 
            -
                requirements: | 
| 27 | 
            -
                - -  | 
| 28 | 
            -
                  - !ruby/object:Gem::Version | 
| 29 | 
            -
                     | 
| 30 | 
            -
                    segments: 
         | 
| 31 | 
            -
                    - 0
         | 
| 32 | 
            -
                    - 8
         | 
| 33 | 
            -
                    - 6
         | 
| 34 | 
            -
                    version: 0.8.6
         | 
| 63 | 
            +
                requirements:
         | 
| 64 | 
            +
                - - =
         | 
| 65 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 66 | 
            +
                    version: 3.0.7
         | 
| 35 67 | 
             
              type: :runtime
         | 
| 36 | 
            -
               | 
| 37 | 
            -
             | 
| 68 | 
            +
              prerelease: false
         | 
| 69 | 
            +
              version_requirements: *2794920
         | 
| 70 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 71 | 
            +
              name: bson
         | 
| 72 | 
            +
              requirement: &2794680 !ruby/object:Gem::Requirement
         | 
| 73 | 
            +
                none: false
         | 
| 74 | 
            +
                requirements:
         | 
| 75 | 
            +
                - - =
         | 
| 76 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 77 | 
            +
                    version: 1.3.0
         | 
| 78 | 
            +
              type: :runtime
         | 
| 79 | 
            +
              prerelease: false
         | 
| 80 | 
            +
              version_requirements: *2794680
         | 
| 81 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 38 82 | 
             
              name: bson_ext
         | 
| 83 | 
            +
              requirement: &2794460 !ruby/object:Gem::Requirement
         | 
| 84 | 
            +
                none: false
         | 
| 85 | 
            +
                requirements:
         | 
| 86 | 
            +
                - - =
         | 
| 87 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 88 | 
            +
                    version: 1.3.0
         | 
| 89 | 
            +
              type: :runtime
         | 
| 90 | 
            +
              prerelease: false
         | 
| 91 | 
            +
              version_requirements: *2794460
         | 
| 92 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 93 | 
            +
              name: mongo
         | 
| 94 | 
            +
              requirement: &2794250 !ruby/object:Gem::Requirement
         | 
| 95 | 
            +
                none: false
         | 
| 96 | 
            +
                requirements:
         | 
| 97 | 
            +
                - - =
         | 
| 98 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 99 | 
            +
                    version: 1.3.0
         | 
| 100 | 
            +
              type: :runtime
         | 
| 101 | 
            +
              prerelease: false
         | 
| 102 | 
            +
              version_requirements: *2794250
         | 
| 103 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 104 | 
            +
              name: plucky
         | 
| 105 | 
            +
              requirement: &2794030 !ruby/object:Gem::Requirement
         | 
| 106 | 
            +
                none: false
         | 
| 107 | 
            +
                requirements:
         | 
| 108 | 
            +
                - - =
         | 
| 109 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                    version: 0.3.6
         | 
| 111 | 
            +
              type: :runtime
         | 
| 39 112 | 
             
              prerelease: false
         | 
| 40 | 
            -
               | 
| 113 | 
            +
              version_requirements: *2794030
         | 
| 114 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 115 | 
            +
              name: jnunemaker-validatable
         | 
| 116 | 
            +
              requirement: &2793810 !ruby/object:Gem::Requirement
         | 
| 41 117 | 
             
                none: false
         | 
| 42 | 
            -
                requirements: | 
| 43 | 
            -
                - -  | 
| 44 | 
            -
                  - !ruby/object:Gem::Version | 
| 45 | 
            -
                     | 
| 46 | 
            -
                    segments: 
         | 
| 47 | 
            -
                    - 1
         | 
| 48 | 
            -
                    - 1
         | 
| 49 | 
            -
                    - 1
         | 
| 50 | 
            -
                    version: 1.1.1
         | 
| 118 | 
            +
                requirements:
         | 
| 119 | 
            +
                - - =
         | 
| 120 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 121 | 
            +
                    version: 1.8.4
         | 
| 51 122 | 
             
              type: :runtime
         | 
| 52 | 
            -
               | 
| 123 | 
            +
              prerelease: false
         | 
| 124 | 
            +
              version_requirements: *2793810
         | 
| 125 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 126 | 
            +
              name: mini_magick
         | 
| 127 | 
            +
              requirement: &2793600 !ruby/object:Gem::Requirement
         | 
| 128 | 
            +
                none: false
         | 
| 129 | 
            +
                requirements:
         | 
| 130 | 
            +
                - - =
         | 
| 131 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 132 | 
            +
                    version: 3.2.1
         | 
| 133 | 
            +
              type: :runtime
         | 
| 134 | 
            +
              prerelease: false
         | 
| 135 | 
            +
              version_requirements: *2793600
         | 
| 136 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 137 | 
            +
              name: subexec
         | 
| 138 | 
            +
              requirement: &2793390 !ruby/object:Gem::Requirement
         | 
| 139 | 
            +
                none: false
         | 
| 140 | 
            +
                requirements:
         | 
| 141 | 
            +
                - - =
         | 
| 142 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 143 | 
            +
                    version: 0.0.4
         | 
| 144 | 
            +
              type: :runtime
         | 
| 145 | 
            +
              prerelease: false
         | 
| 146 | 
            +
              version_requirements: *2793390
         | 
| 53 147 | 
             
            description: 
         | 
| 54 148 | 
             
            email: 
         | 
| 55 149 | 
             
            executables: []
         | 
| 56 | 
            -
             | 
| 57 150 | 
             
            extensions: []
         | 
| 58 | 
            -
             | 
| 59 151 | 
             
            extra_rdoc_files: []
         | 
| 60 | 
            -
             | 
| 61 | 
            -
            files: 
         | 
| 152 | 
            +
            files:
         | 
| 62 153 | 
             
            - Rakefile
         | 
| 63 154 | 
             
            - readme.md
         | 
| 64 | 
            -
            - lib/ | 
| 155 | 
            +
            - lib/mongo_db_ext/micelaneous.rb
         | 
| 65 156 | 
             
            - lib/mongo_mapper_ext/gems.rb
         | 
| 157 | 
            +
            - lib/mongo_mapper_ext/hacks/active_model.rb
         | 
| 66 158 | 
             
            - lib/mongo_mapper_ext/hacks/fixes.rb
         | 
| 67 | 
            -
            - lib/mongo_mapper_ext/ | 
| 68 | 
            -
            - lib/mongo_mapper_ext/micelaneous.rb
         | 
| 69 | 
            -
            - lib/mongo_mapper_ext/migrate.rake
         | 
| 159 | 
            +
            - lib/mongo_mapper_ext/logging.rb
         | 
| 70 160 | 
             
            - lib/mongo_mapper_ext/migration.rb
         | 
| 71 161 | 
             
            - lib/mongo_mapper_ext/mongo_mapper.rb
         | 
| 72 | 
            -
            - lib/mongo_mapper_ext/plugins/ | 
| 162 | 
            +
            - lib/mongo_mapper_ext/plugins/attribute_cache.rb
         | 
| 163 | 
            +
            - lib/mongo_mapper_ext/plugins/attribute_convertors.rb
         | 
| 164 | 
            +
            - lib/mongo_mapper_ext/plugins/belongs_to_with_counter_cache.rb
         | 
| 165 | 
            +
            - lib/mongo_mapper_ext/plugins/carrierwave.rb
         | 
| 166 | 
            +
            - lib/mongo_mapper_ext/plugins/custom_scope.rb
         | 
| 73 167 | 
             
            - lib/mongo_mapper_ext/plugins/db_config.rb
         | 
| 74 | 
            -
            - lib/mongo_mapper_ext/plugins/default_scope.rb
         | 
| 75 168 | 
             
            - lib/mongo_mapper_ext/plugins/micelaneous.rb
         | 
| 76 | 
            -
            - lib/mongo_mapper_ext/ | 
| 169 | 
            +
            - lib/mongo_mapper_ext/rad/file_uploader.rb
         | 
| 170 | 
            +
            - lib/mongo_mapper_ext/rad.rb
         | 
| 171 | 
            +
            - lib/mongo_mapper_ext/spec.rb
         | 
| 172 | 
            +
            - lib/mongo_mapper_ext/tasks.rb
         | 
| 77 173 | 
             
            - lib/mongo_mapper_ext/view_helpers.rb
         | 
| 78 174 | 
             
            - lib/mongo_mapper_ext.rb
         | 
| 175 | 
            +
            - spec/attribute_convertors_spec.rb
         | 
| 176 | 
            +
            - spec/carrierwave_spec/plane.jpg
         | 
| 177 | 
            +
            - spec/carrierwave_spec.rb
         | 
| 178 | 
            +
            - spec/custom_scope_spec.rb
         | 
| 79 179 | 
             
            - spec/micelaneous_plugin_spec.rb
         | 
| 80 180 | 
             
            - spec/micelaneous_spec.rb
         | 
| 81 181 | 
             
            - spec/migration_spec.rb
         | 
| 82 | 
            -
            - spec/ | 
| 83 | 
            -
            - spec/scope_spec.rb
         | 
| 182 | 
            +
            - spec/mongo_mapper_spec.rb
         | 
| 84 183 | 
             
            - spec/spec_helper.rb
         | 
| 184 | 
            +
            - spec/uploading_spec/ship.jpg
         | 
| 185 | 
            +
            - spec/uploading_spec/файл с пробелами.txt
         | 
| 186 | 
            +
            - spec/uploading_spec.rb
         | 
| 85 187 | 
             
            has_rdoc: true
         | 
| 86 188 | 
             
            homepage: http://github.com/alexeypetrushin/mongo_mapper
         | 
| 87 189 | 
             
            licenses: []
         | 
| 88 | 
            -
             | 
| 89 190 | 
             
            post_install_message: 
         | 
| 90 191 | 
             
            rdoc_options: []
         | 
| 91 | 
            -
             | 
| 92 | 
            -
            require_paths: 
         | 
| 192 | 
            +
            require_paths:
         | 
| 93 193 | 
             
            - lib
         | 
| 94 | 
            -
            required_ruby_version: !ruby/object:Gem::Requirement | 
| 194 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 95 195 | 
             
              none: false
         | 
| 96 | 
            -
              requirements: | 
| 97 | 
            -
              - -  | 
| 98 | 
            -
                - !ruby/object:Gem::Version | 
| 99 | 
            -
                   | 
| 100 | 
            -
             | 
| 101 | 
            -
                  - 0
         | 
| 102 | 
            -
                  version: "0"
         | 
| 103 | 
            -
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 196 | 
            +
              requirements:
         | 
| 197 | 
            +
              - - ! '>='
         | 
| 198 | 
            +
                - !ruby/object:Gem::Version
         | 
| 199 | 
            +
                  version: '0'
         | 
| 200 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 104 201 | 
             
              none: false
         | 
| 105 | 
            -
              requirements: | 
| 106 | 
            -
              - -  | 
| 107 | 
            -
                - !ruby/object:Gem::Version | 
| 108 | 
            -
                   | 
| 109 | 
            -
                  segments: 
         | 
| 110 | 
            -
                  - 0
         | 
| 111 | 
            -
                  version: "0"
         | 
| 202 | 
            +
              requirements:
         | 
| 203 | 
            +
              - - ! '>='
         | 
| 204 | 
            +
                - !ruby/object:Gem::Version
         | 
| 205 | 
            +
                  version: '0'
         | 
| 112 206 | 
             
            requirements: []
         | 
| 113 | 
            -
             | 
| 114 207 | 
             
            rubyforge_project: 
         | 
| 115 | 
            -
            rubygems_version: 1. | 
| 208 | 
            +
            rubygems_version: 1.5.1
         | 
| 116 209 | 
             
            signing_key: 
         | 
| 117 210 | 
             
            specification_version: 3
         | 
| 118 211 | 
             
            summary: Extensions for MongoMapper
         | 
| 119 212 | 
             
            test_files: []
         | 
| 120 | 
            -
             | 
| @@ -1,67 +0,0 @@ | |
| 1 | 
            -
            module MongoMapper
         | 
| 2 | 
            -
              class ConnectionsPool < Hash
         | 
| 3 | 
            -
                def [](database_alias)
         | 
| 4 | 
            -
                  database_alias = database_alias.to_s
         | 
| 5 | 
            -
                  unless connection = super(database_alias)            
         | 
| 6 | 
            -
                    MongoMapper.db_config.must.include database_alias
         | 
| 7 | 
            -
                    db_options = MongoMapper.db_config[database_alias]        
         | 
| 8 | 
            -
                    connection = Mongo::Connection.new(db_options['host'], db_options['port'], :logger => MongoMapper.logger)
         | 
| 9 | 
            -
                  
         | 
| 10 | 
            -
                    if defined?(PhusionPassenger)
         | 
| 11 | 
            -
                      PhusionPassenger.on_event(:starting_worker_process) do |forked|
         | 
| 12 | 
            -
                        connection.connect_to_master if forked
         | 
| 13 | 
            -
                      end
         | 
| 14 | 
            -
                    end
         | 
| 15 | 
            -
                    
         | 
| 16 | 
            -
                    self[database_alias] = connection
         | 
| 17 | 
            -
                  end            
         | 
| 18 | 
            -
                  return connection
         | 
| 19 | 
            -
                end
         | 
| 20 | 
            -
              end
         | 
| 21 | 
            -
              
         | 
| 22 | 
            -
              class DatabasesPool < Hash
         | 
| 23 | 
            -
                def [](database_alias)
         | 
| 24 | 
            -
                  database_alias = database_alias.to_s
         | 
| 25 | 
            -
                  unless db = super(database_alias)
         | 
| 26 | 
            -
                    MongoMapper.db_config.must.include database_alias
         | 
| 27 | 
            -
                    db_options = MongoMapper.db_config[database_alias]
         | 
| 28 | 
            -
                    db = MongoMapper.connections[database_alias].db db_options['name'].must_be.a(String)
         | 
| 29 | 
            -
                    self[database_alias] = db
         | 
| 30 | 
            -
                  end
         | 
| 31 | 
            -
                  return db
         | 
| 32 | 
            -
                end
         | 
| 33 | 
            -
              end
         | 
| 34 | 
            -
              
         | 
| 35 | 
            -
              class << self
         | 
| 36 | 
            -
                attr_accessor :db_config
         | 
| 37 | 
            -
                
         | 
| 38 | 
            -
                def db_config      
         | 
| 39 | 
            -
                  # unless @db_config
         | 
| 40 | 
            -
                  #   
         | 
| 41 | 
            -
                  #   if defined?(::Rails) and defined?(DATABASE)              
         | 
| 42 | 
            -
                  #     @db_config = {}
         | 
| 43 | 
            -
                  #     DATABASE["#{::Rails.env}!"].to_h.each do |db_alias, options|
         | 
| 44 | 
            -
                  #       @db_config[db_alias.to_s] = {
         | 
| 45 | 
            -
                  #         'name' => options.name!,
         | 
| 46 | 
            -
                  #         'host' => options.host(nil),
         | 
| 47 | 
            -
                  #         'port' => options.port(nil)
         | 
| 48 | 
            -
                  #       }
         | 
| 49 | 
            -
                  #     end
         | 
| 50 | 
            -
                  #   else
         | 
| 51 | 
            -
                  #     @db_config = {}
         | 
| 52 | 
            -
                  #     # raise "If you don't using Rails you must override this method and provide your own config!"
         | 
| 53 | 
            -
                  #   end          
         | 
| 54 | 
            -
                  # end
         | 
| 55 | 
            -
                  @db_config ||= {}
         | 
| 56 | 
            -
                end
         | 
| 57 | 
            -
                
         | 
| 58 | 
            -
                def connections
         | 
| 59 | 
            -
                  @connections ||= ConnectionsPool.new
         | 
| 60 | 
            -
                end
         | 
| 61 | 
            -
                
         | 
| 62 | 
            -
                def databases
         | 
| 63 | 
            -
                  @databases ||= DatabasesPool.new
         | 
| 64 | 
            -
                end
         | 
| 65 | 
            -
              end
         | 
| 66 | 
            -
                          
         | 
| 67 | 
            -
            end
         | 
| @@ -1,44 +0,0 @@ | |
| 1 | 
            -
            # Measures MongoDB requests time and adds it to log
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            if defined?(Rails) and RAILS_ENV == 'development'
         | 
| 4 | 
            -
              Mongo::Connection.class_eval do  
         | 
| 5 | 
            -
                def send_message_with_time operation, message, log_message=nil
         | 
| 6 | 
            -
                  begin
         | 
| 7 | 
            -
                    logger = @logger
         | 
| 8 | 
            -
                    @logger = nil      
         | 
| 9 | 
            -
                    t = Time.now
         | 
| 10 | 
            -
                    send_message_without_time operation, message, log_message
         | 
| 11 | 
            -
                  ensure
         | 
| 12 | 
            -
                    logger.debug("  MONGODB (#{Time.now - t}) #{log_message || message}") if logger
         | 
| 13 | 
            -
                    @logger = logger
         | 
| 14 | 
            -
                  end
         | 
| 15 | 
            -
                end
         | 
| 16 | 
            -
                alias_method_chain :send_message, :time
         | 
| 17 | 
            -
              
         | 
| 18 | 
            -
                def send_message_with_safe_check_with_time operation, message, db_name, log_message=nil    
         | 
| 19 | 
            -
                  begin
         | 
| 20 | 
            -
                    logger = @logger
         | 
| 21 | 
            -
                    @logger = nil      
         | 
| 22 | 
            -
                    t = Time.now
         | 
| 23 | 
            -
                    send_message_with_safe_check_without_time operation, message, db_name, log_message
         | 
| 24 | 
            -
                  ensure
         | 
| 25 | 
            -
                    logger.debug("  MONGODB (#{Time.now - t}) #{log_message || message}") if logger
         | 
| 26 | 
            -
                    @logger = logger
         | 
| 27 | 
            -
                  end
         | 
| 28 | 
            -
                end
         | 
| 29 | 
            -
                alias_method_chain :send_message_with_safe_check, :time
         | 
| 30 | 
            -
              
         | 
| 31 | 
            -
                def receive_message_with_time operation, message, log_message=nil, socket=nil
         | 
| 32 | 
            -
                  begin
         | 
| 33 | 
            -
                    logger = @logger
         | 
| 34 | 
            -
                    @logger = nil      
         | 
| 35 | 
            -
                    t = Time.now
         | 
| 36 | 
            -
                    receive_message_without_time operation, message, log_message, socket
         | 
| 37 | 
            -
                  ensure
         | 
| 38 | 
            -
                    logger.debug("  MONGODB (#{Time.now - t}) #{log_message || message}") if logger
         | 
| 39 | 
            -
                    @logger = logger
         | 
| 40 | 
            -
                  end
         | 
| 41 | 
            -
                end
         | 
| 42 | 
            -
                alias_method_chain :receive_message, :time
         | 
| 43 | 
            -
              end
         | 
| 44 | 
            -
            end
         |