mongo 2.0.0.rc → 2.0.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.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +2 -1
  4. data/README.md +1 -4
  5. data/lib/mongo/client.rb +1 -1
  6. data/lib/mongo/collection.rb +1 -1
  7. data/lib/mongo/collection/view.rb +1 -1
  8. data/lib/mongo/collection/view/writable.rb +26 -10
  9. data/lib/mongo/database.rb +1 -1
  10. data/lib/mongo/grid/file.rb +12 -0
  11. data/lib/mongo/grid/file/chunk.rb +1 -1
  12. data/lib/mongo/grid/file/metadata.rb +13 -0
  13. data/lib/mongo/operation/aggregate.rb +1 -1
  14. data/lib/mongo/operation/write.rb +1 -5
  15. data/lib/mongo/operation/write/bulk.rb +17 -0
  16. data/lib/mongo/operation/write/{bulk_delete.rb → bulk/bulk_delete.rb} +1 -1
  17. data/lib/mongo/operation/{bulk_delete → write/bulk/bulk_delete}/result.rb +3 -0
  18. data/lib/mongo/operation/write/{bulk_insert.rb → bulk/bulk_insert.rb} +1 -1
  19. data/lib/mongo/operation/{bulk_insert → write/bulk/bulk_insert}/result.rb +3 -0
  20. data/lib/mongo/operation/write/{bulk_mergable.rb → bulk/bulk_mergable.rb} +0 -0
  21. data/lib/mongo/operation/write/{bulk_update.rb → bulk/bulk_update.rb} +1 -1
  22. data/lib/mongo/operation/{bulk_update → write/bulk/bulk_update}/result.rb +8 -1
  23. data/lib/mongo/operation/write/{legacy_bulk_mergable.rb → bulk/legacy_bulk_mergable.rb} +0 -0
  24. data/lib/mongo/operation/write/delete.rb +2 -0
  25. data/lib/mongo/operation/write/delete/result.rb +40 -0
  26. data/lib/mongo/operation/write/insert.rb +2 -0
  27. data/lib/mongo/operation/write/insert/result.rb +32 -0
  28. data/lib/mongo/operation/write/update.rb +9 -4
  29. data/lib/mongo/operation/write/update/result.rb +160 -0
  30. data/lib/mongo/server/connectable.rb +11 -0
  31. data/lib/mongo/server/connection.rb +1 -0
  32. data/lib/mongo/server/connection_pool.rb +1 -1
  33. data/lib/mongo/server/connection_pool/queue.rb +1 -1
  34. data/lib/mongo/server/monitor.rb +16 -0
  35. data/lib/mongo/server/monitor/connection.rb +1 -0
  36. data/lib/mongo/socket/ssl.rb +30 -8
  37. data/lib/mongo/version.rb +1 -1
  38. data/lib/mongo/write_concern/acknowledged.rb +1 -1
  39. data/lib/mongo/write_concern/unacknowledged.rb +1 -1
  40. data/spec/certificates/ca.pem +17 -0
  41. data/spec/certificates/client.pem +101 -0
  42. data/spec/certificates/crl.pem +10 -0
  43. data/spec/certificates/crl_client_revoked.pem +12 -0
  44. data/spec/certificates/password_protected.pem +51 -0
  45. data/spec/certificates/server.pem +34 -0
  46. data/spec/mongo/collection/view/writable_spec.rb +175 -0
  47. data/spec/mongo/crud_spec.rb +42 -0
  48. data/spec/mongo/grid/file/metadata_spec.rb +23 -0
  49. data/spec/mongo/grid/file_spec.rb +34 -0
  50. data/spec/mongo/operation/write/delete_spec.rb +8 -0
  51. data/spec/mongo/operation/write/insert_spec.rb +21 -8
  52. data/spec/mongo/operation/write/update_spec.rb +52 -1
  53. data/spec/mongo/server/connection_spec.rb +33 -10
  54. data/spec/mongo/server/monitor_spec.rb +14 -0
  55. data/spec/spec_helper.rb +2 -17
  56. data/spec/support/crud.rb +203 -0
  57. data/spec/support/crud/read.rb +144 -0
  58. data/spec/support/crud/write.rb +214 -0
  59. data/spec/support/crud_tests/read/aggregate.yml +43 -0
  60. data/spec/support/crud_tests/read/count.yml +37 -0
  61. data/spec/support/crud_tests/read/distinct.yml +33 -0
  62. data/spec/support/crud_tests/read/find.yml +50 -0
  63. data/spec/support/crud_tests/write/deleteMany.yml +36 -0
  64. data/spec/support/crud_tests/write/deleteOne.yml +49 -0
  65. data/spec/support/crud_tests/write/findOneAndDelete.yml +54 -0
  66. data/spec/support/crud_tests/write/findOneAndReplace.yml +153 -0
  67. data/spec/support/crud_tests/write/findOneAndUpdate.yml +161 -0
  68. data/spec/support/crud_tests/write/insertMany.yml +24 -0
  69. data/spec/support/crud_tests/write/insertOne.yml +19 -0
  70. data/spec/support/crud_tests/write/replaceOne.yml +96 -0
  71. data/spec/support/crud_tests/write/updateMany.yml +83 -0
  72. data/spec/support/crud_tests/write/updateOne.yml +80 -0
  73. metadata +64 -20
  74. metadata.gz.sig +0 -0
  75. data/spec/mongo_orchestration_spec.rb +0 -70
  76. data/spec/support/mongo_orchestration.rb +0 -61
  77. data/spec/support/mongo_orchestration/requestable.rb +0 -109
  78. data/spec/support/mongo_orchestration/standalone.rb +0 -57
@@ -1,109 +0,0 @@
1
- # Copyright (C) 2009-2014 MongoDB, Inc.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- require 'httparty'
16
-
17
- module MongoOrchestration
18
-
19
- # Encapsulates behavior of a Mongo Orchestration resource.
20
- #
21
- # @since 2.0.0
22
- module Requestable
23
- include HTTParty
24
-
25
- # @return [ String ] base_path The path used to connect to the MO service.
26
- attr_reader :base_path
27
- alias_method :path, :base_path
28
-
29
- # Initialize a Mongo Orchestration resource.
30
- #
31
- # @example Initialize a Mongo Orchestration resource.
32
- # MongoOrchestration::Standalone.new
33
- #
34
- # @param [ Hash ] options Options for creating the resource.
35
- #
36
- # @option options [ String ] :path The path to use for Mongo Orchestration.
37
- #
38
- # @since 2.0.0
39
- def initialize(options = {})
40
- @base_path = options[:path] || MongoOrchestration::DEFAULT_BASE_URI
41
- create(options)
42
- end
43
-
44
- # Is the Mongo Orchestration resource still available?
45
- #
46
- # @example Check if the Mongo Orchestration resource is available.
47
- # standalone.alive?
48
- #
49
- # @return [ true, false ] If the resource is available.
50
- #
51
- # @since 2.0.0
52
- def alive?
53
- begin
54
- get("servers/#{id}")
55
- rescue ServiceNotAvailable
56
- return false
57
- end
58
- !!(@config = @response if @response &&
59
- @response['procInfo'] &&
60
- @response['procInfo']['alive'])
61
- end
62
-
63
- # Send a request to Mongo Orchestration, specifying the request type.
64
- #
65
- # @example Get a list of servers.
66
- # standalone.request('GET', 'servers')
67
- #
68
- # @param [ String ] method The request type.
69
- # @param [ String ] path The path for the request.
70
- # @param [ Hash ] options Options for the request.
71
- #
72
- # @return [ HTTParty::Response ] The response from the request.
73
- #
74
- # @since 2.0.0
75
- def request(method, path, options = {})
76
- http_request(method, path, options)
77
- end
78
-
79
- private
80
-
81
- def http_request(method, path = nil, options = {})
82
- dispatch do
83
- method = method.downcase.to_sym unless method.class == Symbol
84
- options[:body] = options[:body].to_json if options.has_key?(:body)
85
- HTTParty.send(method, [@base_path, path].compact.join('/'), options)
86
- end
87
- end
88
-
89
- def get(path = nil, options = {})
90
- http_request(__method__, path, options)
91
- end
92
-
93
- def post(path = nil, options = {})
94
- http_request(__method__, path, options)
95
- end
96
-
97
- def dispatch
98
- begin
99
- @response = yield
100
- rescue ArgumentError, Errno::ECONNREFUSED
101
- raise ServiceNotAvailable.new unless ok?
102
- end
103
- end
104
-
105
- def ok?
106
- @response && @response.code/100 == 2
107
- end
108
- end
109
- end
@@ -1,57 +0,0 @@
1
- # Copyright (C) 2009-2014 MongoDB, Inc.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- module MongoOrchestration
16
- class Standalone
17
- include Requestable
18
-
19
- attr_reader :client
20
- attr_reader :id
21
-
22
- # Stop this resource.
23
- #
24
- # @since 2.0.0
25
- def stop
26
- request_content = { body: { action: 'stop' } }
27
- @config = post("#{orchestration}/#{id}", request_content)
28
- self
29
- end
30
-
31
- private
32
-
33
- def create(options = {})
34
- unless alive?
35
- @config = post(orchestration,
36
- { body: initialize_config[:request_content] })
37
- @id = @config['id']
38
- @client = Mongo::Client.new("#{@config['mongodb_uri']}")
39
- end
40
- self
41
- end
42
-
43
- def orchestration
44
- initialize_config[:orchestration]
45
- end
46
-
47
- def initialize_config
48
- {
49
- orchestration: 'servers',
50
- request_content: {
51
- name: 'mongod',
52
- procParams: { journal: true }
53
- }
54
- }
55
- end
56
- end
57
- end