upgrade to mongoid 5.0 (locomotivecms/heroku-instant-deploy#4)
did
committed Oct 10, 2015
commit b4aa09aa66029bb4d2467401e6e92b324099345d
Showing 9
changed files with
31 additions
and 28 deletions
Gemfile.lock
+3
-7
| @@ | @@ -36,7 +36,7 @@ GEM |
| tzinfo (~> 1.1) | |
| addressable (2.3.8) | |
| attr_extras (4.4.0) | |
| - | bson (3.1.0) |
| + | bson (3.2.6) |
| byebug (4.0.5) | |
| columnize (= 0.9.0) | |
| chronic (0.10.2) | |
| @@ | @@ -63,7 +63,6 @@ GEM |
| sass (>= 3.3.0, < 3.5) | |
| compass-import-once (1.0.5) | |
| sass (>= 3.2, < 3.5) | |
| - | connection_pool (2.2.0) |
| coveralls (0.8.1) | |
| json (~> 1.8) | |
| rest-client (>= 1.6.8, < 2) | |
| @@ | @@ -121,10 +120,8 @@ GEM |
| mini_portile (0.6.2) | |
| minitest (5.8.0) | |
| moneta (0.8.0) | |
| - | moped (2.0.6) |
| + | mongo (2.1.1) |
| bson (~> 3.0) | |
| - | connection_pool (~> 2.0) |
| - | optionable (~> 0.2.0) |
| morphine (0.1.1) | |
| multi_json (1.11.1) | |
| multi_xml (0.5.5) | |
| @@ | @@ -133,7 +130,6 @@ GEM |
| mini_portile (~> 0.6.0) | |
| nokogumbo (1.4.1) | |
| nokogiri | |
| - | optionable (0.2.0) |
| origin (2.1.1) | |
| pry (0.10.1) | |
| coderay (~> 1.1.0) | |
| @@ | @@ -226,7 +222,7 @@ DEPENDENCIES |
| json_spec (~> 1.1.4) | |
| locomotivecms_steam! | |
| memory_profiler | |
| - | moped (~> 2.0.6) |
| + | mongo (~> 2.1.0) |
| origin (~> 2.1.1) | |
| pry-byebug (~> 3.1.0) | |
| puma | |
locomotive/steam/adapters/mongodb.rb b/lib/locomotive/steam/adapters/mongodb.rb
+8
-6
| @@ | @@ -1,4 +1,4 @@ |
| - | require 'moped' |
| + | require 'mongo' |
| require 'origin' | |
| require_relative 'mongodb/origin' | |
| @@ | @@ -82,13 +82,15 @@ module Locomotive::Steam |
| end | |
| def session | |
| - | Thread.current[:moped_session] ||= if uri |
| - | Moped::Session.connect(uri) |
| + | Thread.current[:mongo_session] ||= if uri |
| + | Mongo::Client.new(uri) |
| else | |
| - | Moped::Session.new([*hosts]).tap do |session| |
| - | session.use database |
| - | session.login(username, password) if username && password |
| + | options = { database: database } |
| + | if username && password |
| + | options[:user] = username |
| + | options[:password] = password |
| end | |
| + | Mongo::Client.new([*hosts], options) |
| end | |
| end | |
locomotive/steam/adapters/mongodb/command.rb b/lib/locomotive/steam/adapters/mongodb/command.rb
+2
-2
| @@ | @@ -15,13 +15,13 @@ module Locomotive::Steam |
| serialized_entity = @mapper.serialize(entity) | |
| - | @collection.insert(serialized_entity) |
| + | @collection.insert_one(serialized_entity) |
| entity | |
| end | |
| def delete(entity) | |
| - | @collection.find(_id: entity._id).remove if entity._id |
| + | @collection.find(_id: entity._id).delete_one if entity._id |
| end | |
| end | |
locomotive/steam/adapters/mongodb/query.rb b/lib/locomotive/steam/adapters/mongodb/query.rb
+8
-6
| @@ | @@ -47,12 +47,14 @@ module Locomotive::Steam |
| _query = to_origin | |
| selector, fields, sort = _query.selector, _query.options[:fields], _query.options[:sort] | |
| - | collection.find(selector).tap do |results| |
| - | results.sort(sort) if sort |
| - | results.select(fields) if fields |
| - | results.skip(@skip) if @skip |
| - | results.limit(@limit) if @limit |
| - | end |
| + | # FIXME: not very elegant (a proxy class would be better) |
| + | chainable = collection.find(selector) |
| + | chainable = chainable.sort(sort) if sort |
| + | chainable = chainable.projection(fields) if fields |
| + | chainable = chainable.skip(@skip) if @skip |
| + | chainable = chainable.limit(@limit) if @limit |
| + | |
| + | chainable |
| end | |
| def to_origin | |
locomotive/steam/server.rb b/lib/locomotive/steam/server.rb
+1
-1
| @@ | @@ -13,7 +13,7 @@ require 'dragonfly/middleware' |
| require_relative 'middlewares' | |
| if ENV['PROFILER'] | |
| - | require 'moped' |
| + | require 'mongo' |
| require 'rack-mini-profiler' | |
| end | |
locomotivecms_steam.gemspec
+1
-1
| @@ | @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| |
| spec.add_development_dependency 'bundler', '~> 1.7' | |
| spec.add_development_dependency 'rake', '~> 10.4.2' | |
| - | spec.add_development_dependency 'moped', '~> 2.0.6' |
| + | spec.add_development_dependency 'mongo', '~> 2.1.0' |
| spec.add_development_dependency 'origin', '~> 2.1.1' | |
| spec.add_dependency 'sanitize', '~> 4.0.0' | |
spec/integration/repositories/page_repository_spec.rb
+0
-5
| @@ | @@ -5,11 +5,6 @@ require_relative '../../../lib/locomotive/steam/adapters/mongodb.rb' |
| describe Locomotive::Steam::PageRepository do | |
| - | # before(:all) do |
| - | # Moped.logger = Logger.new($stdout) |
| - | # Moped.logger.level = Logger::DEBUG |
| - | # end |
| - | |
| shared_examples_for 'a repository' do | |
| let(:site) { Locomotive::Steam::Site.new(_id: site_id, locales: %w(en fr nb)) } | |
spec/support.rb
+1
-0
| @@ | @@ -1,4 +1,5 @@ |
| require_relative 'support/helpers' | |
| + | require_relative 'support/mongo' |
| require_relative 'support/cache_store' | |
| require_relative 'support/liquid' | |
| require_relative 'support/matchers/hash' | |
spec/support/mongo.rb
+7
-0
| @@ | @@ -0,0 +1,7 @@ |
| + | require 'mongo' |
| + | |
| + | Mongo::Logger.logger.level = Logger::INFO |
| + | |
| + | # DEBUG |
| + | # Mongo::Logger.logger = Logger.new($stdout) |
| + | # Mongo::Logger.logger.level = Logger::DEBUG |