bson 2.0.0.beta → 2.0.0.rc

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bson might be problematic. Click here for more details.

Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/CHANGELOG.md +80 -0
  5. data/CONTRIBUTING.md +42 -0
  6. data/LICENSE +190 -0
  7. data/NOTICE +2 -0
  8. data/README.md +6 -1
  9. data/Rakefile +15 -1
  10. data/ext/bson/native.c +16 -0
  11. data/lib/bson.rb +12 -50
  12. data/lib/bson/array.rb +14 -1
  13. data/lib/bson/binary.rb +14 -1
  14. data/lib/bson/boolean.rb +14 -1
  15. data/lib/bson/code.rb +14 -1
  16. data/lib/bson/code_with_scope.rb +14 -1
  17. data/lib/bson/document.rb +15 -2
  18. data/lib/bson/encodable.rb +14 -1
  19. data/lib/bson/environment.rb +98 -0
  20. data/lib/bson/false_class.rb +14 -1
  21. data/lib/bson/float.rb +14 -1
  22. data/lib/bson/hash.rb +14 -1
  23. data/lib/bson/int32.rb +15 -2
  24. data/lib/bson/int64.rb +15 -2
  25. data/lib/bson/integer.rb +14 -1
  26. data/lib/bson/json.rb +14 -1
  27. data/lib/bson/max_key.rb +14 -1
  28. data/lib/bson/min_key.rb +14 -1
  29. data/lib/bson/nil_class.rb +14 -1
  30. data/lib/bson/object_id.rb +15 -2
  31. data/lib/bson/regexp.rb +14 -1
  32. data/lib/bson/registry.rb +14 -1
  33. data/lib/bson/specialized.rb +14 -1
  34. data/lib/bson/string.rb +14 -1
  35. data/lib/bson/symbol.rb +14 -1
  36. data/lib/bson/time.rb +14 -1
  37. data/lib/bson/timestamp.rb +14 -1
  38. data/lib/bson/true_class.rb +14 -1
  39. data/lib/bson/undefined.rb +15 -2
  40. data/lib/bson/version.rb +15 -2
  41. data/lib/native.bundle +0 -0
  42. data/spec/bson/array_spec.rb +31 -0
  43. data/spec/bson/binary_spec.rb +103 -0
  44. data/spec/bson/boolean_spec.rb +48 -0
  45. data/spec/bson/code_spec.rb +42 -0
  46. data/spec/bson/code_with_scope_spec.rb +70 -0
  47. data/spec/bson/document_spec.rb +778 -0
  48. data/spec/bson/false_class_spec.rb +28 -0
  49. data/spec/bson/float_spec.rb +29 -0
  50. data/spec/bson/hash_spec.rb +56 -0
  51. data/spec/bson/int32_spec.rb +28 -0
  52. data/spec/bson/int64_spec.rb +28 -0
  53. data/spec/bson/integer_spec.rb +76 -0
  54. data/spec/bson/json_spec.rb +53 -0
  55. data/spec/bson/max_key_spec.rb +75 -0
  56. data/spec/bson/min_key_spec.rb +75 -0
  57. data/spec/bson/nil_class_spec.rb +29 -0
  58. data/spec/bson/object_id_spec.rb +418 -0
  59. data/spec/bson/regexp_spec.rb +89 -0
  60. data/spec/bson/registry_spec.rb +55 -0
  61. data/spec/bson/string_spec.rb +271 -0
  62. data/spec/bson/symbol_spec.rb +45 -0
  63. data/spec/bson/time_spec.rb +43 -0
  64. data/spec/bson/timestamp_spec.rb +74 -0
  65. data/spec/bson/true_class_spec.rb +28 -0
  66. data/spec/bson/undefined_spec.rb +29 -0
  67. data/spec/bson_spec.rb +46 -0
  68. data/spec/spec_helper.rb +31 -0
  69. data/spec/support/shared_examples.rb +95 -0
  70. metadata +85 -5
  71. metadata.gz.sig +1 -0
  72. data/LICENSE.md +0 -13
@@ -0,0 +1,28 @@
1
+ # Copyright (C) 2013 10gen 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 "spec_helper"
16
+
17
+ describe TrueClass do
18
+
19
+ describe "#to_bson" do
20
+
21
+ let(:obj) { true }
22
+ let(:bson) { 1.chr }
23
+ let(:type) { 8.chr }
24
+
25
+ it_behaves_like "a bson element"
26
+ it_behaves_like "a serializable bson element"
27
+ end
28
+ end
@@ -0,0 +1,29 @@
1
+ # Copyright (C) 2013 10gen 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 "spec_helper"
16
+
17
+ describe BSON::Undefined do
18
+
19
+ describe "#to_bson/#from_bson" do
20
+
21
+ let(:type) { 6.chr }
22
+ let(:obj) { described_class.new }
23
+ let(:bson) { BSON::NO_VALUE }
24
+
25
+ it_behaves_like "a bson element"
26
+ it_behaves_like "a serializable bson element"
27
+ it_behaves_like "a deserializable bson element"
28
+ end
29
+ end
@@ -0,0 +1,46 @@
1
+ # Copyright (C) 2013 10gen 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 "spec_helper"
16
+
17
+ describe BSON do
18
+
19
+ describe "::BINARY" do
20
+
21
+ it "returns BINARY" do
22
+ expect(BSON::BINARY).to eq("BINARY")
23
+ end
24
+ end
25
+
26
+ describe "::NO_VAUE" do
27
+
28
+ it "returns an empty string" do
29
+ expect(BSON::NO_VALUE).to be_empty
30
+ end
31
+ end
32
+
33
+ describe "::NULL_BYTE" do
34
+
35
+ it "returns the char 0x00" do
36
+ expect(BSON::NULL_BYTE).to eq(0.chr)
37
+ end
38
+ end
39
+
40
+ describe "::UTF8" do
41
+
42
+ it "returns UTF-8" do
43
+ expect(BSON::UTF8).to eq("UTF-8")
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,31 @@
1
+ # Copyright (C) 2013 10gen 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
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
16
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
17
+
18
+ if ENV["CI"]
19
+ require "simplecov"
20
+ require "coveralls"
21
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
22
+ SimpleCov.start do
23
+ add_filter "spec"
24
+ end
25
+ end
26
+
27
+ require "bson"
28
+ require "rspec"
29
+ require "yaml"
30
+
31
+ Dir["./spec/support/**/*.rb"].each { |file| require file }
@@ -0,0 +1,95 @@
1
+ # Copyright (C) 2013 10gen 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
+ shared_examples_for "a binary encoded string" do
16
+
17
+ let(:binary_encoding) do
18
+ Encoding.find(BSON::BINARY)
19
+ end
20
+
21
+ unless RUBY_VERSION < "1.9"
22
+ it "returns the string with binary encoding" do
23
+ expect(encoded.encoding).to eq(binary_encoding)
24
+ end
25
+ end
26
+ end
27
+
28
+ shared_examples_for "a bson element" do
29
+
30
+ let(:element) do
31
+ defined?(obj) ? obj : described_class.new
32
+ end
33
+
34
+ it "has the correct single byte BSON type" do
35
+ expect(element.bson_type).to eq(type)
36
+ end
37
+ end
38
+
39
+ shared_examples_for "a serializable bson element" do
40
+
41
+ let(:previous_content) do
42
+ 'previous_content'.force_encoding(BSON::BINARY)
43
+ end
44
+
45
+ it "serializes to bson" do
46
+ expect(obj.to_bson).to eq(bson)
47
+ end
48
+
49
+ it "serializes to bson by appending" do
50
+ expect(obj.to_bson(previous_content)).to eq(previous_content << bson)
51
+ end
52
+ end
53
+
54
+ shared_examples_for "a deserializable bson element" do
55
+
56
+ let(:io) do
57
+ StringIO.new(bson)
58
+ end
59
+
60
+ it "deserializes from bson" do
61
+ expect(described_class.from_bson(io)).to eq(obj)
62
+ end
63
+ end
64
+
65
+ shared_examples_for "a JSON serializable object" do
66
+
67
+ it "serializes the JSON from #as_json" do
68
+ expect(object.to_json).to eq(object.as_json.to_json)
69
+ end
70
+ end
71
+
72
+ shared_examples_for "immutable when frozen" do |block|
73
+
74
+ context "when the document is frozen" do
75
+
76
+ before do
77
+ doc.freeze
78
+ end
79
+
80
+ it "raises a runtime error" do
81
+ expect {
82
+ block.call(doc)
83
+ }.to raise_error(RuntimeError)
84
+ end
85
+ end
86
+ end
87
+
88
+ shared_examples_for "a document able to handle utf-8" do
89
+
90
+ it "serializes and deserializes properly" do
91
+ expect(
92
+ BSON::Document.from_bson(StringIO.new(document.to_bson))
93
+ ).to eq(document)
94
+ end
95
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bson
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta
4
+ version: 2.0.0.rc
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Brock
@@ -11,8 +11,29 @@ authors:
11
11
  - Gary Murakami
12
12
  autorequire:
13
13
  bindir: bin
14
- cert_chain: []
15
- date: 2013-05-09 00:00:00.000000000 Z
14
+ cert_chain:
15
+ - |
16
+ -----BEGIN CERTIFICATE-----
17
+ MIIDODCCAiCgAwIBAgIBADANBgkqhkiG9w0BAQUFADBCMRQwEgYDVQQDDAtkcml2
18
+ ZXItcnVieTEVMBMGCgmSJomT8ixkARkWBTEwZ2VuMRMwEQYKCZImiZPyLGQBGRYD
19
+ Y29tMB4XDTEzMDIwMTE0MTEzN1oXDTE0MDIwMTE0MTEzN1owQjEUMBIGA1UEAwwL
20
+ ZHJpdmVyLXJ1YnkxFTATBgoJkiaJk/IsZAEZFgUxMGdlbjETMBEGCgmSJomT8ixk
21
+ ARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANFdSAa8fRm1
22
+ bAM9za6Z0fAH4g02bqM1NGnw8zJQrE/PFrFfY6IFCT2AsLfOwr1maVm7iU1+kdVI
23
+ IQ+iI/9+E+ArJ+rbGV3dDPQ+SLl3mLT+vXjfjcxMqI2IW6UuVtt2U3Rxd4QU0kdT
24
+ JxmcPYs5fDN6BgYc6XXgUjy3m+Kwha2pGctdciUOwEfOZ4RmNRlEZKCMLRHdFP8j
25
+ 4WTnJSGfXDiuoXICJb5yOPOZPuaapPSNXp93QkUdsqdKC32I+KMpKKYGBQ6yisfA
26
+ 5MyVPPCzLR1lP5qXVGJPnOqUAkvEUfCahg7EP9tI20qxiXrR6TSEraYhIFXL0EGY
27
+ u8KAcPHm5KkCAwEAAaM5MDcwCQYDVR0TBAIwADAdBgNVHQ4EFgQUW3dZsX70mlSM
28
+ CiPrZxAGA1vwfNcwCwYDVR0PBAQDAgSwMA0GCSqGSIb3DQEBBQUAA4IBAQCIa/Y6
29
+ xS7YWBxkn9WP0EMnJ3pY9vef9DTmLSi/2jz8PzwlKQ89zNTrqSUD8LoQZmBqCJBt
30
+ dKSQ/RUnaHJuxh8HWvWubP8EBYTuf+I1DFnRv648IF3MR1tCQumVL0XcYMvZcxBj
31
+ a/p+8DomWTQqUdNbNoGywwjtVBWfDdwFV8Po1XcN/AtpILOJQd9J77INIGGCHxZo
32
+ 6SOHHaNknlE9H0w6q0SVxZKZI8/+2c447V0NrHIw1Qhe0tAGJ9V1u3ky8gyxe0SM
33
+ 8v7zLF2XliYbfurYIwkcXs8yPn8ggApBIy9bX6VJxRs/l2+UvqzaHIFaFy/F8/GP
34
+ RNTuXsVG5NDACo7Q
35
+ -----END CERTIFICATE-----
36
+ date: 2013-06-12 00:00:00.000000000 Z
16
37
  dependencies: []
17
38
  description: A full featured BSON specification implementation, in Ruby
18
39
  email:
@@ -24,7 +45,8 @@ extra_rdoc_files: []
24
45
  files:
25
46
  - CONTRIBUTING.md
26
47
  - CHANGELOG.md
27
- - LICENSE.md
48
+ - LICENSE
49
+ - NOTICE
28
50
  - README.md
29
51
  - Rakefile
30
52
  - lib/bson/array.rb
@@ -34,6 +56,7 @@ files:
34
56
  - lib/bson/code_with_scope.rb
35
57
  - lib/bson/document.rb
36
58
  - lib/bson/encodable.rb
59
+ - lib/bson/environment.rb
37
60
  - lib/bson/false_class.rb
38
61
  - lib/bson/float.rb
39
62
  - lib/bson/hash.rb
@@ -57,8 +80,37 @@ files:
57
80
  - lib/bson/version.rb
58
81
  - lib/bson-ruby.jar
59
82
  - lib/bson.rb
83
+ - lib/native.bundle
60
84
  - ext/bson/native.c
61
85
  - ext/bson/extconf.rb
86
+ - spec/bson/array_spec.rb
87
+ - spec/bson/binary_spec.rb
88
+ - spec/bson/boolean_spec.rb
89
+ - spec/bson/code_spec.rb
90
+ - spec/bson/code_with_scope_spec.rb
91
+ - spec/bson/document_spec.rb
92
+ - spec/bson/false_class_spec.rb
93
+ - spec/bson/float_spec.rb
94
+ - spec/bson/hash_spec.rb
95
+ - spec/bson/int32_spec.rb
96
+ - spec/bson/int64_spec.rb
97
+ - spec/bson/integer_spec.rb
98
+ - spec/bson/json_spec.rb
99
+ - spec/bson/max_key_spec.rb
100
+ - spec/bson/min_key_spec.rb
101
+ - spec/bson/nil_class_spec.rb
102
+ - spec/bson/object_id_spec.rb
103
+ - spec/bson/regexp_spec.rb
104
+ - spec/bson/registry_spec.rb
105
+ - spec/bson/string_spec.rb
106
+ - spec/bson/symbol_spec.rb
107
+ - spec/bson/time_spec.rb
108
+ - spec/bson/timestamp_spec.rb
109
+ - spec/bson/true_class_spec.rb
110
+ - spec/bson/undefined_spec.rb
111
+ - spec/bson_spec.rb
112
+ - spec/spec_helper.rb
113
+ - spec/support/shared_examples.rb
62
114
  homepage: http://bsonspec.org
63
115
  licenses:
64
116
  - Apache License Version 2.0
@@ -83,4 +135,32 @@ rubygems_version: 2.0.3
83
135
  signing_key:
84
136
  specification_version: 4
85
137
  summary: Ruby Implementation of the BSON specification
86
- test_files: []
138
+ test_files:
139
+ - spec/bson/array_spec.rb
140
+ - spec/bson/binary_spec.rb
141
+ - spec/bson/boolean_spec.rb
142
+ - spec/bson/code_spec.rb
143
+ - spec/bson/code_with_scope_spec.rb
144
+ - spec/bson/document_spec.rb
145
+ - spec/bson/false_class_spec.rb
146
+ - spec/bson/float_spec.rb
147
+ - spec/bson/hash_spec.rb
148
+ - spec/bson/int32_spec.rb
149
+ - spec/bson/int64_spec.rb
150
+ - spec/bson/integer_spec.rb
151
+ - spec/bson/json_spec.rb
152
+ - spec/bson/max_key_spec.rb
153
+ - spec/bson/min_key_spec.rb
154
+ - spec/bson/nil_class_spec.rb
155
+ - spec/bson/object_id_spec.rb
156
+ - spec/bson/regexp_spec.rb
157
+ - spec/bson/registry_spec.rb
158
+ - spec/bson/string_spec.rb
159
+ - spec/bson/symbol_spec.rb
160
+ - spec/bson/time_spec.rb
161
+ - spec/bson/timestamp_spec.rb
162
+ - spec/bson/true_class_spec.rb
163
+ - spec/bson/undefined_spec.rb
164
+ - spec/bson_spec.rb
165
+ - spec/spec_helper.rb
166
+ - spec/support/shared_examples.rb
@@ -0,0 +1 @@
1
+ �h���-�!Y�U' ��cLm �I��T����aF���� �#[Ȥ��{����O^ ��K�P炇���P���QU�JI����P� =��{�υ�AqS��y��-fD�hNb���-���AFKH�v���%�C���C �y(b��#ay����K��EQ��lH�W-� �T��NX�-ujϹa��x��6���������?��ɭ�����v�U1?N[�d�g���b��_�@��l'�<�׶��
data/LICENSE.md DELETED
@@ -1,13 +0,0 @@
1
- Copyright (C) 2013 10gen 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](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.