volt-mongo 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 43063074686dca2266c780c50fcbe0433b8e406e
4
- data.tar.gz: c2ebd5819f1fbd43d7143c59c058ecd008681084
3
+ metadata.gz: 35999987c336d195411aff33270e830fbf129104
4
+ data.tar.gz: e5d7bf3eaa0e4006162b86df417bdea4f11e0518
5
5
  SHA512:
6
- metadata.gz: 9b90bb5875a5693e6f9ad5009eff4d6456ef728c859690874c4a0c1219bcc07870772bf7933876bc3e2ef55b57eb43b2735d3c2bc3807bb1a1e19ad6cb042ed0
7
- data.tar.gz: 9bee73448f9b6b923e880f0cc05fd93aa99a55d30e35e77ef80ca9fc250c4ef30a912268be161e9f2878d2043893220ebfb40f1529e6682ceca49dae97af0bf6
6
+ metadata.gz: 54f56cca889487743ac44c319a3ff67d1dbcbdfbe8c5bdf2381dcbd96de4425711ed1aad68137a40bf871a0eb8897c41ca62ed524df565baa9d04cca849fe128
7
+ data.tar.gz: b2dac7862c22a3f1aee4e6befff3234967a67622dc9cc495786c8b74f1c3df8a823510b3efc062378deb33366d5a4e4e98d73f426b55c70494a5cee0c61362ed
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -25,7 +25,7 @@ module Volt
25
25
  db
26
26
 
27
27
  true
28
- rescue ::Mongo::ConnectionFailure => e
28
+ rescue ::Mongo::Error => e
29
29
  false
30
30
  end
31
31
  end
@@ -34,18 +34,18 @@ module Volt
34
34
  return @db if @db
35
35
 
36
36
  if Volt.config.db_uri.present?
37
- @mongo_db ||= ::Mongo::MongoClient.from_uri(Volt.config.db_uri)
38
- @db ||= @mongo_db.db(Volt.config.db_uri.split('/').last || Volt.config.db_name)
37
+ db_name = Volt.config.db_uri.split('/').last || Volt.config.db_name
38
+ @db ||= ::Mongo::Client.new(Volt.config.db_uri, database: db_name, :monitoring => false)
39
39
  else
40
- @mongo_db ||= ::Mongo::MongoClient.new(Volt.config.db_host, Volt.config.db_port)
41
- @db ||= @mongo_db.db(Volt.config.db_name)
40
+ db_name = Volt.config.db_name
41
+ @db ||= ::Mongo::Client.new("mongodb://#{Volt.config.db_host}:#{Volt.config.db_port}", database: db_name, :monitoring => false)
42
42
  end
43
43
 
44
44
  @db
45
45
  end
46
46
 
47
47
  def insert(collection, values)
48
- db[collection].insert(values)
48
+ db[collection].insert_one(values)
49
49
  end
50
50
 
51
51
  def update(collection, values)
@@ -54,14 +54,14 @@ module Volt
54
54
  to_mongo_id!(values)
55
55
  # TODO: Seems mongo is dumb and doesn't let you upsert with custom id's
56
56
  begin
57
- db[collection].insert(values)
58
- rescue ::Mongo::OperationFailure => error
57
+ db[collection].insert_one(values)
58
+ rescue => error
59
59
  # Really mongo client?
60
- if error.message[/^11000[:]/]
60
+ if error.message[/^E11000/] && error.message['$_id_']
61
61
  # Update because the id already exists
62
62
  update_values = values.dup
63
63
  id = update_values.delete('_id')
64
- db[collection].update({ '_id' => id }, update_values)
64
+ db[collection].update_one({ '_id' => id }, update_values)
65
65
  else
66
66
  return { error: error.message }
67
67
  end
@@ -101,7 +101,7 @@ module Volt
101
101
  result = result.send(method_name, *args)
102
102
  end
103
103
 
104
- if result.is_a?(::Mongo::Cursor)
104
+ if result.is_a?(::Mongo::Collection::View)
105
105
  result = result.to_a.map do |hash|
106
106
  # Return id instead of _id
107
107
  to_volt_id!(hash)
@@ -119,18 +119,21 @@ module Volt
119
119
  query['_id'] = query.delete('id')
120
120
  end
121
121
 
122
- db[collection].remove(query)
122
+ db[collection].delete_one(query)
123
123
  end
124
124
 
125
125
  # remove the collection entirely
126
126
  def drop_collection(collection)
127
- db.drop_collection(collection)
127
+ db[collection].drop
128
128
  end
129
129
 
130
130
  def drop_database
131
- db.connection.drop_database(Volt.config.db_name)
131
+ db.database.drop
132
132
  end
133
133
 
134
+ def adapter_version
135
+ ::Mongo::VERSION
136
+ end
134
137
 
135
138
  private
136
139
  # Mutate a hash to use id instead of _id
data/volt-mongo.gemspec CHANGED
@@ -19,6 +19,6 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency 'mongo', '~> 1.12.0'
22
+ spec.add_dependency 'mongo', '~> 2.1.2'
23
23
  spec.add_development_dependency "rake"
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: volt-mongo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Stout
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-16 00:00:00.000000000 Z
11
+ date: 2015-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongo
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.12.0
19
+ version: 2.1.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.12.0
26
+ version: 2.1.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement