bson 1.9.2 → 1.10.0.rc0
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +4 -1
- data.tar.gz.sig +0 -0
- data/LICENSE +1 -1
- data/VERSION +1 -1
- data/bin/b2json +1 -1
- data/bin/j2bson +1 -1
- data/lib/bson.rb +4 -3
- data/lib/bson/bson_c.rb +3 -3
- data/lib/bson/bson_java.rb +3 -2
- data/lib/bson/bson_ruby.rb +34 -26
- data/lib/bson/byte_buffer.rb +4 -1
- data/lib/bson/exceptions.rb +1 -1
- data/lib/bson/grow.rb +173 -0
- data/lib/bson/ordered_hash.rb +1 -1
- data/lib/bson/support/hash_with_indifferent_access.rb +1 -1
- data/lib/bson/types/binary.rb +1 -1
- data/lib/bson/types/code.rb +1 -1
- data/lib/bson/types/dbref.rb +1 -3
- data/lib/bson/types/min_max_keys.rb +1 -1
- data/lib/bson/types/object_id.rb +2 -5
- data/lib/bson/types/regex.rb +116 -0
- data/lib/bson/types/timestamp.rb +1 -1
- metadata +26 -23
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01a93a47b6068729e800f31aa186e7f0376e68f0
|
4
|
+
data.tar.gz: 7fbfcb5c5c8939827bed1faaffc8b2dc5d19474b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 255aa03c670411751e2c7fc2de06b0f5b3139fe0747570134c3047e39d0b3b12669a639aae63a1e0542639a26f88371cf918eab8be9271f62de85b58d85930f6
|
7
|
+
data.tar.gz: b22500b45e67475f64e5aee27953b037986dac621749db0a8fda5e3c70a4e0a7754b3de9b3fec9329a98bd06fc22781c8ff453ab3e4fa33d4cd6f767ca02f762
|
checksums.yaml.gz.sig
CHANGED
@@ -1 +1,4 @@
|
|
1
|
-
|
1
|
+
v������qօ�<�^8� >�r%�P���O�I<c�Q�ۥ礮�t�ީW}Q'����q�X�=�3���J
|
2
|
+
��F�Cb{8f��ԕ�ǯ����B�&XTL���O�#�u=Il ���V��%����(����^��DT��
|
3
|
+
��V���\�| oQ��� ���
|
4
|
+
��CjFF���.(|2�;���F���4�i�,�Gh[y�ԣ��)e��e(v�V�������h��˰X
|
data.tar.gz.sig
CHANGED
Binary file
|
data/LICENSE
CHANGED
@@ -175,7 +175,7 @@
|
|
175
175
|
|
176
176
|
END OF TERMS AND CONDITIONS
|
177
177
|
|
178
|
-
Copyright (C) 2008-2013
|
178
|
+
Copyright (C) 2008-2013 MongoDB, Inc.
|
179
179
|
|
180
180
|
Licensed under the Apache License, Version 2.0 (the "License");
|
181
181
|
you may not use this file except in compliance with the License.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.10.0.rc0
|
data/bin/b2json
CHANGED
data/bin/j2bson
CHANGED
data/lib/bson.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013
|
1
|
+
# Copyright (C) 2009-2013 MongoDB, Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -19,8 +19,8 @@ module BSON
|
|
19
19
|
BSON_CODER.serialize(obj, check_keys, move_id)
|
20
20
|
end
|
21
21
|
|
22
|
-
def self.deserialize(buf=nil)
|
23
|
-
BSON_CODER.deserialize(buf)
|
22
|
+
def self.deserialize(buf=nil, opts={})
|
23
|
+
BSON_CODER.deserialize(buf, opts)
|
24
24
|
end
|
25
25
|
|
26
26
|
# Reads a single BSON document from an IO object.
|
@@ -108,5 +108,6 @@ require 'bson/types/binary'
|
|
108
108
|
require 'bson/types/code'
|
109
109
|
require 'bson/types/dbref'
|
110
110
|
require 'bson/types/min_max_keys'
|
111
|
+
require 'bson/types/regex'
|
111
112
|
require 'bson/types/object_id'
|
112
113
|
require 'bson/types/timestamp'
|
data/lib/bson/bson_c.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013
|
1
|
+
# Copyright (C) 2009-2013 MongoDB, Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -20,8 +20,8 @@ module BSON
|
|
20
20
|
ByteBuffer.new(CBson.serialize(obj, check_keys, move_id, max_bson_size))
|
21
21
|
end
|
22
22
|
|
23
|
-
def self.deserialize(buf=nil)
|
24
|
-
CBson.deserialize(ByteBuffer.new(buf).to_s)
|
23
|
+
def self.deserialize(buf=nil, opts={})
|
24
|
+
CBson.deserialize(ByteBuffer.new(buf).to_s, opts)
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.max_bson_size
|
data/lib/bson/bson_java.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013
|
1
|
+
# Copyright (C) 2009-2013 MongoDB, Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -28,9 +28,10 @@ module BSON
|
|
28
28
|
ByteBuffer.new(enc.encode(obj))
|
29
29
|
end
|
30
30
|
|
31
|
-
def self.deserialize(buf)
|
31
|
+
def self.deserialize(buf, opts={})
|
32
32
|
dec = Java::OrgJbson::RubyBSONDecoder.new
|
33
33
|
callback = Java::OrgJbson::RubyBSONCallback.new(JRuby.runtime)
|
34
|
+
callback.set_opts(opts);
|
34
35
|
dec.decode(buf.to_s.to_java_bytes, callback)
|
35
36
|
callback.get
|
36
37
|
end
|
data/lib/bson/bson_ruby.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013
|
1
|
+
# Copyright (C) 2009-2013 MongoDB, Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -108,8 +108,8 @@ module BSON
|
|
108
108
|
new(max_bson_size).serialize(obj, check_keys, move_id)
|
109
109
|
end
|
110
110
|
|
111
|
-
def self.deserialize(buf=nil)
|
112
|
-
new.deserialize(buf)
|
111
|
+
def self.deserialize(buf=nil, opts={})
|
112
|
+
new.deserialize(buf, opts)
|
113
113
|
end
|
114
114
|
|
115
115
|
def serialize(obj, check_keys=false, move_id=false)
|
@@ -199,7 +199,7 @@ module BSON
|
|
199
199
|
end
|
200
200
|
end
|
201
201
|
|
202
|
-
def deserialize(buf=nil)
|
202
|
+
def deserialize(buf=nil, opts={})
|
203
203
|
# If buf is nil, use @buf, assumed to contain already-serialized BSON.
|
204
204
|
# This is only true during testing.
|
205
205
|
if buf.is_a? String
|
@@ -233,13 +233,13 @@ module BSON
|
|
233
233
|
doc[key] = deserialize_oid_data(@buf)
|
234
234
|
when ARRAY
|
235
235
|
key = deserialize_cstr(@buf)
|
236
|
-
doc[key] = deserialize_array_data(@buf)
|
236
|
+
doc[key] = deserialize_array_data(@buf, opts)
|
237
237
|
when REGEX
|
238
238
|
key = deserialize_cstr(@buf)
|
239
|
-
doc[key] = deserialize_regex_data(@buf)
|
239
|
+
doc[key] = deserialize_regex_data(@buf, opts)
|
240
240
|
when OBJECT
|
241
241
|
key = deserialize_cstr(@buf)
|
242
|
-
doc[key] = deserialize_object_data(@buf)
|
242
|
+
doc[key] = deserialize_object_data(@buf, opts)
|
243
243
|
when BOOLEAN
|
244
244
|
key = deserialize_cstr(@buf)
|
245
245
|
doc[key] = deserialize_boolean_data(@buf)
|
@@ -316,10 +316,10 @@ module BSON
|
|
316
316
|
buf.get_long
|
317
317
|
end
|
318
318
|
|
319
|
-
def deserialize_object_data(buf)
|
319
|
+
def deserialize_object_data(buf, opts={})
|
320
320
|
size = buf.get_int
|
321
321
|
buf.position -= 4
|
322
|
-
object = @encoder.new.deserialize(buf.get(size))
|
322
|
+
object = @encoder.new.deserialize(buf.get(size), opts)
|
323
323
|
if object.has_key? "$ref"
|
324
324
|
DBRef.new(object["$ref"], object["$id"])
|
325
325
|
else
|
@@ -327,22 +327,20 @@ module BSON
|
|
327
327
|
end
|
328
328
|
end
|
329
329
|
|
330
|
-
def deserialize_array_data(buf)
|
331
|
-
h = deserialize_object_data(buf)
|
330
|
+
def deserialize_array_data(buf, opts={})
|
331
|
+
h = deserialize_object_data(buf, opts)
|
332
332
|
a = []
|
333
333
|
h.each { |k, v| a[k.to_i] = v }
|
334
334
|
a
|
335
335
|
end
|
336
336
|
|
337
|
-
def deserialize_regex_data(buf)
|
337
|
+
def deserialize_regex_data(buf, opts={})
|
338
|
+
compile = opts.key?(:compile_regex) ? opts[:compile_regex] : true
|
339
|
+
compile = true if compile.nil?
|
338
340
|
str = deserialize_cstr(buf)
|
339
341
|
options_str = deserialize_cstr(buf)
|
340
|
-
|
341
|
-
|
342
|
-
opts |= Regexp::MULTILINE if options_str.include?('m')
|
343
|
-
opts |= Regexp::MULTILINE if options_str.include?('s')
|
344
|
-
opts |= Regexp::EXTENDED if options_str.include?('x')
|
345
|
-
Regexp.new(str, opts)
|
342
|
+
bson_regex = BSON::Regex.new(str, options_str)
|
343
|
+
compile ? bson_regex.try_compile : bson_regex
|
346
344
|
end
|
347
345
|
|
348
346
|
def deserialize_timestamp_data(buf)
|
@@ -371,7 +369,7 @@ module BSON
|
|
371
369
|
encoded_str(str)
|
372
370
|
end
|
373
371
|
|
374
|
-
def deserialize_code_w_scope_data(buf)
|
372
|
+
def deserialize_code_w_scope_data(buf, opts={})
|
375
373
|
buf.get_int
|
376
374
|
len = buf.get_int
|
377
375
|
code = buf.get(len)[0..-2]
|
@@ -381,7 +379,7 @@ module BSON
|
|
381
379
|
|
382
380
|
scope_size = buf.get_int
|
383
381
|
buf.position -= 4
|
384
|
-
scope = @encoder.new.deserialize(buf.get(scope_size))
|
382
|
+
scope = @encoder.new.deserialize(buf.get(scope_size), opts)
|
385
383
|
|
386
384
|
Code.new(encoded_str(code), scope)
|
387
385
|
end
|
@@ -497,12 +495,22 @@ module BSON
|
|
497
495
|
|
498
496
|
options = val.options
|
499
497
|
options_str = ''
|
500
|
-
|
501
|
-
if (
|
502
|
-
options_str << '
|
503
|
-
options_str << '
|
498
|
+
|
499
|
+
if val.is_a?(BSON::Regex)
|
500
|
+
options_str << 'i' if ((options & BSON::Regex::IGNORECASE) != 0)
|
501
|
+
options_str << 'l' if ((options & BSON::Regex::LOCALE_DEPENDENT) != 0)
|
502
|
+
options_str << 'm' if ((options & BSON::Regex::MULTILINE) != 0)
|
503
|
+
options_str << 's' if ((options & BSON::Regex::DOTALL) != 0)
|
504
|
+
options_str << 'u' if ((options & BSON::Regex::UNICODE) != 0)
|
505
|
+
options_str << 'x' if ((options & BSON::Regex::EXTENDED) != 0)
|
506
|
+
else
|
507
|
+
options_str << 'm' # Ruby regular expressions always use multiline mode
|
508
|
+
options_str << 'i' if ((options & Regexp::IGNORECASE) != 0)
|
509
|
+
# dotall on the server is multiline in Ruby
|
510
|
+
options_str << 's' if ((options & Regexp::MULTILINE) != 0)
|
511
|
+
options_str << 'x' if ((options & Regexp::EXTENDED) != 0)
|
504
512
|
end
|
505
|
-
|
513
|
+
|
506
514
|
options_str << val.extra_options_str if val.respond_to?(:extra_options_str)
|
507
515
|
# Must store option chars in alphabetical order
|
508
516
|
self.class.serialize_cstr(buf, options_str.split(//).sort.uniq.join)
|
@@ -596,7 +604,7 @@ module BSON
|
|
596
604
|
STRING
|
597
605
|
when Array
|
598
606
|
ARRAY
|
599
|
-
when Regexp
|
607
|
+
when Regexp, BSON::Regex
|
600
608
|
REGEX
|
601
609
|
when ObjectId
|
602
610
|
OID
|
data/lib/bson/byte_buffer.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013
|
1
|
+
# Copyright (C) 2009-2013 MongoDB, Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,8 +12,11 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
+
require 'bson/grow'
|
16
|
+
|
15
17
|
module BSON
|
16
18
|
class ByteBuffer
|
19
|
+
include BSON::Grow
|
17
20
|
|
18
21
|
attr_reader :order, :max_size
|
19
22
|
|
data/lib/bson/exceptions.rb
CHANGED
data/lib/bson/grow.rb
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Copyright (C) 2009-2013 MongoDB, Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
module BSON
|
18
|
+
module Grow
|
19
|
+
# module with methods to grow BSON docs/objects/arrays
|
20
|
+
# this module is intended for internal use and is subject to change
|
21
|
+
# proper usage is essential as minimal overhead is preferred over usage checks
|
22
|
+
# unfinish! returns unfinished BSON for faster growing with bang! methods
|
23
|
+
# bang! methods work on unfinished BSON with neither terminating nulls nor proper sizes
|
24
|
+
# finish! must be called to finish BSON after using bang! methods
|
25
|
+
# corresponding non-bang methods work on finished BSON
|
26
|
+
# object/array methods should be paired, ex., array!/b_end! and array/b_end
|
27
|
+
# push!/push and push_doc!/push_doc append to arrays with correct keys
|
28
|
+
# b_end needs a better name
|
29
|
+
|
30
|
+
def to_e # Extract bytes for elements from BSON
|
31
|
+
@str[4...-1]
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_t # Extract type from (single-element) BSON
|
35
|
+
@str[4,1]
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_v # Extract value from (single-element) BSON
|
39
|
+
@str[(@str.index(NULL_BYTE,5)+1)...-1]
|
40
|
+
end
|
41
|
+
|
42
|
+
def finish_one!(offset = 0) # Appends terminating null byte and sets size
|
43
|
+
put(0)
|
44
|
+
put_int(@str.size - offset, offset)
|
45
|
+
@cursor = @str.size
|
46
|
+
self
|
47
|
+
end
|
48
|
+
|
49
|
+
def unfinish! # Backup past terminating null bytes
|
50
|
+
@b_pos ||= [0]
|
51
|
+
@cursor = @str.size - @b_pos.size # BSON::BSON_CODER.serialize may not restore @cursor
|
52
|
+
self
|
53
|
+
end
|
54
|
+
|
55
|
+
def finish! # Append all terminating null bytes and set all sizes
|
56
|
+
@b_pos ||= [0]
|
57
|
+
(@b_pos.size-1).downto(0){|i| finish_one!(@b_pos[i])}
|
58
|
+
self
|
59
|
+
end
|
60
|
+
|
61
|
+
def grow!(bson) # Appends BSON elements unfinished
|
62
|
+
put_binary(bson.to_e)
|
63
|
+
self
|
64
|
+
end
|
65
|
+
|
66
|
+
def grow(bson) # Appends BSON elements finished
|
67
|
+
@b_pos ||= [0]
|
68
|
+
put_binary(bson.to_e, @str.size - @b_pos.size)
|
69
|
+
finish!
|
70
|
+
end
|
71
|
+
|
72
|
+
def push!(bson) # Appends BSON element value with correct key unfinished
|
73
|
+
@a_index ||= [0]
|
74
|
+
@b_pos ||= [0]
|
75
|
+
put_binary(bson.to_t)
|
76
|
+
put_binary(@a_index[-1].to_s)
|
77
|
+
put_binary(NULL_BYTE)
|
78
|
+
@a_index[-1] += 1
|
79
|
+
put_binary(bson.to_v)
|
80
|
+
self
|
81
|
+
end
|
82
|
+
|
83
|
+
def push(bson) # Appends BSON element value with correct key finished
|
84
|
+
@a_index ||= [0]
|
85
|
+
@b_pos ||= [0]
|
86
|
+
put_binary(bson.to_t, @str.size - @b_pos.size)
|
87
|
+
put_binary(@a_index[-1].to_s)
|
88
|
+
put_binary(NULL_BYTE)
|
89
|
+
@a_index[-1] += 1
|
90
|
+
put_binary(bson.to_v)
|
91
|
+
finish!
|
92
|
+
end
|
93
|
+
|
94
|
+
def push_doc!(bson) # Appends BSON doc with correct key unfinished
|
95
|
+
@a_index ||= [0]
|
96
|
+
@b_pos ||= [0]
|
97
|
+
put(BSON::BSON_RUBY::OBJECT)
|
98
|
+
put_binary(@a_index[-1].to_s)
|
99
|
+
put(0)
|
100
|
+
@a_index[-1] += 1
|
101
|
+
put_binary(bson.to_s)
|
102
|
+
self
|
103
|
+
end
|
104
|
+
|
105
|
+
def push_doc(bson) # Appends BSON doc with correct key finished
|
106
|
+
@a_index ||= [0]
|
107
|
+
@b_pos ||= [0]
|
108
|
+
put(BSON::BSON_RUBY::OBJECT, @str.size - @b_pos.size)
|
109
|
+
put_binary(@a_index[-1].to_s)
|
110
|
+
put(0)
|
111
|
+
@a_index[-1] += 1
|
112
|
+
put_binary(bson.to_s)
|
113
|
+
finish!
|
114
|
+
end
|
115
|
+
|
116
|
+
def b_do!(key, type = BSON::BSON_RUBY::OBJECT) # Append object/array element unfinished
|
117
|
+
put(type)
|
118
|
+
BSON::BSON_RUBY.serialize_cstr(self, key)
|
119
|
+
@b_pos ||= [0]
|
120
|
+
@a_index ||= [0]
|
121
|
+
@b_pos << @cursor # mark position of size
|
122
|
+
@a_index << 0
|
123
|
+
put_int(0)
|
124
|
+
self
|
125
|
+
end
|
126
|
+
|
127
|
+
def b_do(key, type = BSON::BSON_RUBY::OBJECT) # Append object/array element finished
|
128
|
+
@b_pos ||= [0]
|
129
|
+
@cursor = @str.size - @b_pos.size
|
130
|
+
b_do!(key, type)
|
131
|
+
finish!
|
132
|
+
end
|
133
|
+
|
134
|
+
def doc!(key) # Append object element unfinished
|
135
|
+
b_do!(key, BSON::BSON_RUBY::OBJECT)
|
136
|
+
end
|
137
|
+
|
138
|
+
def doc(key) # Append object element finished
|
139
|
+
b_do(key, BSON::BSON_RUBY::OBJECT)
|
140
|
+
end
|
141
|
+
|
142
|
+
def array!(key) # Append array element unfinished
|
143
|
+
b_do!(key, BSON::BSON_RUBY::ARRAY)
|
144
|
+
end
|
145
|
+
|
146
|
+
def array(key) # Append array element finished
|
147
|
+
b_do(key, BSON::BSON_RUBY::ARRAY)
|
148
|
+
end
|
149
|
+
|
150
|
+
def b_end! # End object/array unfinished - next operation will be up one level
|
151
|
+
@b_pos ||= [0]
|
152
|
+
finish_one!(@b_pos[-1])
|
153
|
+
@b_pos.pop
|
154
|
+
@a_index ||= [0]
|
155
|
+
@a_index.pop
|
156
|
+
self
|
157
|
+
end
|
158
|
+
|
159
|
+
def b_end # End object/array finished - next operation will be up one level
|
160
|
+
@b_pos ||= [0]
|
161
|
+
@b_pos.pop
|
162
|
+
@a_index ||= [0]
|
163
|
+
@a_index.pop
|
164
|
+
self
|
165
|
+
end
|
166
|
+
|
167
|
+
def clear! # Clear internal state for reuse
|
168
|
+
@b_pos = @a_index = nil
|
169
|
+
self
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
end
|
data/lib/bson/ordered_hash.rb
CHANGED
data/lib/bson/types/binary.rb
CHANGED
data/lib/bson/types/code.rb
CHANGED
data/lib/bson/types/dbref.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013
|
1
|
+
# Copyright (C) 2009-2013 MongoDB, Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -23,8 +23,6 @@ module BSON
|
|
23
23
|
#
|
24
24
|
# @param [String] a collection name
|
25
25
|
# @param [ObjectId] an object id
|
26
|
-
#
|
27
|
-
# @core dbrefs constructor_details
|
28
26
|
def initialize(namespace, object_id)
|
29
27
|
@namespace = namespace
|
30
28
|
@object_id = object_id
|
data/lib/bson/types/object_id.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013
|
1
|
+
# Copyright (C) 2009-2013 MongoDB, Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,9 +12,8 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require 'thread'
|
16
|
-
require 'socket'
|
17
15
|
require 'digest/md5'
|
16
|
+
require 'socket'
|
18
17
|
|
19
18
|
module BSON
|
20
19
|
|
@@ -23,8 +22,6 @@ module BSON
|
|
23
22
|
end
|
24
23
|
|
25
24
|
# Generates MongoDB object ids.
|
26
|
-
#
|
27
|
-
# @core objectids
|
28
25
|
class ObjectId
|
29
26
|
attr_accessor :data
|
30
27
|
|
@@ -0,0 +1,116 @@
|
|
1
|
+
# Copyright (C) 2009-2013 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 BSON
|
16
|
+
|
17
|
+
# generates a wrapped Regexp with lazy compilation.
|
18
|
+
# can represent flags not supported in Ruby's core Regexp class before compilation.
|
19
|
+
class Regex
|
20
|
+
|
21
|
+
IGNORECASE = 0x01
|
22
|
+
LOCALE_DEPENDENT = 0x02
|
23
|
+
MULTILINE = 0x04
|
24
|
+
DOTALL = 0x08
|
25
|
+
UNICODE = 0x10
|
26
|
+
EXTENDED = 0x20
|
27
|
+
|
28
|
+
attr_accessor :pattern
|
29
|
+
alias_method :source, :pattern
|
30
|
+
attr_accessor :options
|
31
|
+
|
32
|
+
# Create a new regexp.
|
33
|
+
#
|
34
|
+
# @param pattern [String]
|
35
|
+
# @param options [Array, String]
|
36
|
+
def initialize(pattern, *opts)
|
37
|
+
@pattern = pattern
|
38
|
+
@options = opts.first.is_a?(Fixnum) ? opts.first : str_opts_to_int(opts.join)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Check equality of this wrapped Regexp with another.
|
42
|
+
#
|
43
|
+
# @param [BSON::Regex] regexp
|
44
|
+
def eql?(regexp)
|
45
|
+
regexp.kind_of?(BSON::Regex) &&
|
46
|
+
self.pattern == regexp.pattern &&
|
47
|
+
self.options == regexp.options
|
48
|
+
end
|
49
|
+
alias_method :==, :eql?
|
50
|
+
|
51
|
+
# Get a human-readable representation of this BSON Regex.
|
52
|
+
def inspect
|
53
|
+
"#<BSON::Regex:0x#{self.object_id} " <<
|
54
|
+
"@pattern=#{@pattern}>, @options=#{@options}>"
|
55
|
+
end
|
56
|
+
|
57
|
+
# Clone or dup the current BSON::Regex.
|
58
|
+
def initialize_copy
|
59
|
+
a_copy = self.dup
|
60
|
+
a_copy.pattern = self.pattern.dup
|
61
|
+
a_copy.options = self.options.dup
|
62
|
+
a_copy
|
63
|
+
end
|
64
|
+
|
65
|
+
# Attempt to convert a native Ruby Regexp to a BSON::Regex.
|
66
|
+
#
|
67
|
+
# @note Warning: Ruby regular expressions use a different syntax and different
|
68
|
+
# set of flags than BSON regular expressions. A regular expression matches different
|
69
|
+
# strings when executed in Ruby than it matches when used in a MongoDB query,
|
70
|
+
# if it can be used in a query at all.
|
71
|
+
#
|
72
|
+
# @param regexp [Regexp] The native Ruby regexp object to convert to BSON::Regex.
|
73
|
+
#
|
74
|
+
# @return [BSON::Regex]
|
75
|
+
def self.from_native(regexp)
|
76
|
+
pattern = regexp.source
|
77
|
+
opts = 0
|
78
|
+
opts |= MULTILINE # multiline mode is always on for Ruby regular expressions
|
79
|
+
opts |= IGNORECASE if (Regexp::IGNORECASE & regexp.options != 0)
|
80
|
+
opts |= DOTALL if (Regexp::MULTILINE & regexp.options != 0)
|
81
|
+
opts |= EXTENDED if (Regexp::EXTENDED & regexp.options != 0)
|
82
|
+
self.new(pattern, opts)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Compile the BSON::Regex.
|
86
|
+
#
|
87
|
+
# @note Warning: regular expressions retrieved from the server may include a pattern
|
88
|
+
# that cannot be compiled into a Ruby regular expression, or which matches a
|
89
|
+
# different set of strings in Ruby than it does when used in a MongoDB query,
|
90
|
+
# or it may have flags that are not supported by Ruby regular expressions.
|
91
|
+
#
|
92
|
+
# @return [Regexp] A ruby core Regexp object.
|
93
|
+
def try_compile
|
94
|
+
regexp_opts = 0
|
95
|
+
regexp_opts |= Regexp::IGNORECASE if (options & IGNORECASE != 0)
|
96
|
+
regexp_opts |= Regexp::MULTILINE if (options & DOTALL != 0)
|
97
|
+
regexp_opts |= Regexp::EXTENDED if (options & EXTENDED != 0)
|
98
|
+
Regexp.new(pattern, regexp_opts)
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
# Convert the string options to an integer.
|
103
|
+
#
|
104
|
+
# @return [Fixnum] The Integer representation of the options.
|
105
|
+
def str_opts_to_int(str_opts="")
|
106
|
+
opts = 0
|
107
|
+
opts |= IGNORECASE if str_opts.include?('i')
|
108
|
+
opts |= LOCALE_DEPENDENT if str_opts.include?('l')
|
109
|
+
opts |= MULTILINE if str_opts.include?('m')
|
110
|
+
opts |= DOTALL if str_opts.include?('s')
|
111
|
+
opts |= UNICODE if str_opts.include?('u')
|
112
|
+
opts |= EXTENDED if str_opts.include?('x')
|
113
|
+
opts
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
data/lib/bson/types/timestamp.rb
CHANGED
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: 1.
|
4
|
+
version: 1.10.0.rc0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Brock
|
@@ -14,26 +14,27 @@ bindir: bin
|
|
14
14
|
cert_chain:
|
15
15
|
- |
|
16
16
|
-----BEGIN CERTIFICATE-----
|
17
|
-
|
17
|
+
MIIDfDCCAmSgAwIBAgIBATANBgkqhkiG9w0BAQUFADBCMRQwEgYDVQQDDAtkcml2
|
18
18
|
ZXItcnVieTEVMBMGCgmSJomT8ixkARkWBTEwZ2VuMRMwEQYKCZImiZPyLGQBGRYD
|
19
|
-
|
19
|
+
Y29tMB4XDTE0MDIxODIyMDQwMVoXDTE1MDIxODIyMDQwMVowQjEUMBIGA1UEAwwL
|
20
20
|
ZHJpdmVyLXJ1YnkxFTATBgoJkiaJk/IsZAEZFgUxMGdlbjETMBEGCgmSJomT8ixk
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
21
|
+
ARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANdoZILE3alL
|
22
|
+
V5OGgh2hkgVTd79nRV3akueIZgu9qXhNHixXsyxBnaSPbrK7s1bWurgVT/Klp//3
|
23
|
+
ASnU78R5ChmCX5/xMRp+E9FO69nCt33njUKyYU0+SwiEID02At+bUb3iS7S5CIMO
|
24
|
+
tLSybh/DhH9Hi5g+FqwpRQy/RQcTJ6Uz/75+Ng2J0oz6eVvXAuEz75apE3qJcLb3
|
25
|
+
w699mm0e4qqpfHcSkgJbOGpmbrb+XimNy+AXdagkKYk2tUjYiCwkLop0hf/XBEWu
|
26
|
+
ap8vwBNdAn+ox1eNQUSdowBf4dJvIJWepRjqeFRcLPUrF5JES7qyHbnyi7nqtaCS
|
27
|
+
GwLBeSsgxdECAwEAAaN9MHswCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
|
28
|
+
BBYEFEfmGN56RK0OIRqm4XYACgI7AXbsMCAGA1UdEQQZMBeBFWRyaXZlci1ydWJ5
|
29
|
+
QDEwZ2VuLmNvbTAgBgNVHRIEGTAXgRVkcml2ZXItcnVieUAxMGdlbi5jb20wDQYJ
|
30
|
+
KoZIhvcNAQEFBQADggEBAFcxu5xBsPg6szjBrkej2P+Qa9LK22rdIZtECnK8TLsQ
|
31
|
+
tmNdYMraNgiYf96U1zZKvjgzI04BRYmIeCnIDdg2MkpOZO35d/v/Hu0N9tiu08NX
|
32
|
+
aSSw+yzt43hIzEtYgs0WlSxXqnmu0ClA37t+mA0OTzp64pkQSiJfYlMbsCpElk4r
|
33
|
+
vJ5hsT7hMiPKABow5+pXckFwznEuciyBCx3ox9MnEic8qsjdiZgleeAJKDpKb+uX
|
34
|
+
ZLLlRFg7YfmA+N2giYd0oQz670xnBy5ZOvtXZe1wLLfGyeDwXeTrQGUE3oBRpr/t
|
35
|
+
eokvmuSJOtUOXE7dArS2jfgXfYsg1YZt4HttbJ9Z4ZM=
|
35
36
|
-----END CERTIFICATE-----
|
36
|
-
date:
|
37
|
+
date: 2014-02-18 00:00:00.000000000 Z
|
37
38
|
dependencies: []
|
38
39
|
description: A Ruby BSON implementation for MongoDB. For more information about Mongo,
|
39
40
|
see http://www.mongodb.org. For more information on BSON, see http://www.bsonspec.org.
|
@@ -44,17 +45,18 @@ executables:
|
|
44
45
|
extensions: []
|
45
46
|
extra_rdoc_files: []
|
46
47
|
files:
|
47
|
-
- bson.gemspec
|
48
48
|
- LICENSE
|
49
49
|
- VERSION
|
50
50
|
- bin/b2json
|
51
51
|
- bin/j2bson
|
52
|
+
- bson.gemspec
|
52
53
|
- lib/bson.rb
|
53
54
|
- lib/bson/bson_c.rb
|
54
55
|
- lib/bson/bson_java.rb
|
55
56
|
- lib/bson/bson_ruby.rb
|
56
57
|
- lib/bson/byte_buffer.rb
|
57
58
|
- lib/bson/exceptions.rb
|
59
|
+
- lib/bson/grow.rb
|
58
60
|
- lib/bson/ordered_hash.rb
|
59
61
|
- lib/bson/support/hash_with_indifferent_access.rb
|
60
62
|
- lib/bson/types/binary.rb
|
@@ -62,6 +64,7 @@ files:
|
|
62
64
|
- lib/bson/types/dbref.rb
|
63
65
|
- lib/bson/types/min_max_keys.rb
|
64
66
|
- lib/bson/types/object_id.rb
|
67
|
+
- lib/bson/types/regex.rb
|
65
68
|
- lib/bson/types/timestamp.rb
|
66
69
|
homepage: http://www.mongodb.org
|
67
70
|
licenses:
|
@@ -73,17 +76,17 @@ require_paths:
|
|
73
76
|
- lib
|
74
77
|
required_ruby_version: !ruby/object:Gem::Requirement
|
75
78
|
requirements:
|
76
|
-
- -
|
79
|
+
- - ">="
|
77
80
|
- !ruby/object:Gem::Version
|
78
81
|
version: '0'
|
79
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
83
|
requirements:
|
81
|
-
- -
|
84
|
+
- - ">"
|
82
85
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
86
|
+
version: 1.3.1
|
84
87
|
requirements: []
|
85
88
|
rubyforge_project: bson
|
86
|
-
rubygems_version: 2.
|
89
|
+
rubygems_version: 2.2.1
|
87
90
|
signing_key:
|
88
91
|
specification_version: 4
|
89
92
|
summary: Ruby implementation of BSON
|
metadata.gz.sig
CHANGED
Binary file
|