bson 1.9.2-java → 1.10.0-java

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.

@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bcefde7a056a56bcee5f360d2919ced4a7ae809a
4
+ data.tar.gz: e6bafce576e3e0e12a47d3473160383ff29da65f
5
+ SHA512:
6
+ metadata.gz: 56e2cad5dc2aeb4c9f3f826813922fc11f7a2a1f606e854903398ccc39c21ac03872b518b9845db8b71ed0ef07da29256d8aa3acaaa3720ba69f5b8aa77d2622
7
+ data.tar.gz: 8ff97ceded56759addf309cffe0aa7bf9f68b612816778c5a624f0ea2352ab6f0dd18abfbb03978b607ad5e984cbdc89ccc1c4cca0e945fe98713b1ff0ccac4d
Binary file
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 10gen, Inc.
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.9.2
1
+ 1.10.0
data/bin/b2json CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: UTF-8
3
3
 
4
- # Copyright (C) 2013 10gen Inc.
4
+ # Copyright (C) 2009-2013 MongoDB, Inc.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
data/bin/j2bson CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: UTF-8
3
3
 
4
- # Copyright (C) 2013 10gen Inc.
4
+ # Copyright (C) 2009-2013 MongoDB, Inc.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
Binary file
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
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'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
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
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
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.
@@ -16,7 +16,7 @@ require 'jruby'
16
16
 
17
17
  include Java
18
18
 
19
- jar_dir = File.join(File.dirname(__FILE__), '../../ext/jbson')
19
+ jar_dir = File.expand_path(File.join(File.dirname(__FILE__), '../../ext/jbson'))
20
20
  require File.join(jar_dir, 'lib/java-bson.jar')
21
21
  require File.join(jar_dir, 'target/jbson.jar')
22
22
 
@@ -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
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
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
- opts = 0
341
- opts |= Regexp::IGNORECASE if options_str.include?('i')
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
- options_str << 'i' if ((options & Regexp::IGNORECASE) != 0)
501
- if ((options & Regexp::MULTILINE) != 0)
502
- options_str << 'm'
503
- options_str << 's'
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
- options_str << 'x' if ((options & Regexp::EXTENDED) != 0)
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
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
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
 
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
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.
@@ -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
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
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.
@@ -41,6 +41,16 @@ module BSON
41
41
  instance_of?(BSON::OrderedHash)
42
42
  end
43
43
 
44
+ def reject
45
+ return to_enum(:reject) unless block_given?
46
+ dup.tap {|hash| hash.reject!{|k, v| yield k, v}}
47
+ end
48
+
49
+ def select
50
+ return to_enum(:select) unless block_given?
51
+ dup.tap {|hash| hash.reject!{|k, v| ! yield k, v}}
52
+ end
53
+
44
54
  # We only need the body of this class if the RUBY_VERSION is before 1.9
45
55
  if RUBY_VERSION < '1.9'
46
56
  attr_accessor :ordered_keys
@@ -142,21 +152,16 @@ module BSON
142
152
  self
143
153
  end
144
154
 
145
- def reject(&block)
146
- clone = self.clone
147
- return clone unless block_given?
148
- clone.delete_if(&block)
149
- end
150
-
151
- def reject!(&block)
152
- changed = false
153
- self.each do |k,v|
154
- if yield k, v
155
- changed = true
156
- delete(k)
155
+ def reject!
156
+ return to_enum(:reject!) unless block_given?
157
+ raise "can't modify frozen BSON::OrderedHash" if frozen?
158
+ keys = @ordered_keys.dup
159
+ @ordered_keys.each do |k|
160
+ if yield k, self[k]
161
+ keys.delete(k)
157
162
  end
158
163
  end
159
- changed ? self : nil
164
+ keys == @ordered_keys ? nil : @ordered_keys = keys
160
165
  end
161
166
 
162
167
  def clear
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
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.
@@ -49,6 +49,16 @@ module ActiveSupport
49
49
  end
50
50
  end
51
51
 
52
+ def reject
53
+ return to_enum(:reject) unless block_given?
54
+ dup.tap {|hash| hash.reject!{|k, v| yield k, v}}
55
+ end
56
+
57
+ def select
58
+ return to_enum(:select) unless block_given?
59
+ dup.tap {|hash| hash.reject!{|k, v| ! yield k, v}}
60
+ end
61
+
52
62
  alias_method :regular_writer, :[]= unless method_defined?(:regular_writer)
53
63
  alias_method :regular_update, :update unless method_defined?(:regular_update)
54
64
 
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
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.
@@ -35,7 +35,7 @@ module BSON
35
35
  #
36
36
  # @param [Array, String] data to story as BSON binary. If a string is given, the on
37
37
  # Ruby 1.9 it will be forced to the binary encoding.
38
- # @param [Fixnum] one of four values specifying a BSON binary subtype. Possible values are
38
+ # @param [Fixnum] subtype one of four values specifying a BSON binary subtype. Possible values are
39
39
  # SUBTYPE_BYTES, SUBTYPE_UUID, SUBTYPE_MD5, and SUBTYPE_USER_DEFINED.
40
40
  #
41
41
  # @see http://www.mongodb.org/display/DOCS/BSON#BSON-noteondatabinary BSON binary subtypes.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
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,7 +23,7 @@ module BSON
23
23
  # Wrap code to be evaluated by MongoDB.
24
24
  #
25
25
  # @param [String] code the JavaScript code.
26
- # @param [Hash] a document mapping identifiers to values, which
26
+ # @param [Hash] scope a document mapping identifiers to values, which
27
27
  # represent the scope in which the code is to be executed.
28
28
  def initialize(code, scope={})
29
29
  @code = code
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
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.
@@ -21,10 +21,8 @@ module BSON
21
21
 
22
22
  # Create a DBRef. Use this class in conjunction with DB#dereference.
23
23
  #
24
- # @param [String] a collection name
25
- # @param [ObjectId] an object id
26
- #
27
- # @core dbrefs constructor_details
24
+ # @param [String] namespace a collection name.
25
+ # @param [ObjectId] object_id an object id.
28
26
  def initialize(namespace, object_id)
29
27
  @namespace = namespace
30
28
  @object_id = object_id
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
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 opts [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
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
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.
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bson
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.2
5
- prerelease:
4
+ version: 1.10.0
6
5
  platform: java
7
6
  authors:
8
7
  - Tyler Brock
@@ -15,9 +14,9 @@ bindir: bin
15
14
  cert_chain:
16
15
  - |
17
16
  -----BEGIN CERTIFICATE-----
18
- MIIDODCCAiCgAwIBAgIBADANBgkqhkiG9w0BAQUFADBCMRQwEgYDVQQDDAtkcml2
17
+ MIIDfDCCAmSgAwIBAgIBATANBgkqhkiG9w0BAQUFADBCMRQwEgYDVQQDDAtkcml2
19
18
  ZXItcnVieTEVMBMGCgmSJomT8ixkARkWBTEwZ2VuMRMwEQYKCZImiZPyLGQBGRYD
20
- Y29tMB4XDTEzMDIwMTE0MTEzN1oXDTE0MDIwMTE0MTEzN1owQjEUMBIGA1UEAwwL
19
+ Y29tMB4XDTE0MDIxOTE1MTEyNloXDTE1MDIxOTE1MTEyNlowQjEUMBIGA1UEAwwL
21
20
  ZHJpdmVyLXJ1YnkxFTATBgoJkiaJk/IsZAEZFgUxMGdlbjETMBEGCgmSJomT8ixk
22
21
  ARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANFdSAa8fRm1
23
22
  bAM9za6Z0fAH4g02bqM1NGnw8zJQrE/PFrFfY6IFCT2AsLfOwr1maVm7iU1+kdVI
@@ -25,16 +24,17 @@ cert_chain:
25
24
  JxmcPYs5fDN6BgYc6XXgUjy3m+Kwha2pGctdciUOwEfOZ4RmNRlEZKCMLRHdFP8j
26
25
  4WTnJSGfXDiuoXICJb5yOPOZPuaapPSNXp93QkUdsqdKC32I+KMpKKYGBQ6yisfA
27
26
  5MyVPPCzLR1lP5qXVGJPnOqUAkvEUfCahg7EP9tI20qxiXrR6TSEraYhIFXL0EGY
28
- u8KAcPHm5KkCAwEAAaM5MDcwCQYDVR0TBAIwADAdBgNVHQ4EFgQUW3dZsX70mlSM
29
- CiPrZxAGA1vwfNcwCwYDVR0PBAQDAgSwMA0GCSqGSIb3DQEBBQUAA4IBAQCIa/Y6
30
- xS7YWBxkn9WP0EMnJ3pY9vef9DTmLSi/2jz8PzwlKQ89zNTrqSUD8LoQZmBqCJBt
31
- dKSQ/RUnaHJuxh8HWvWubP8EBYTuf+I1DFnRv648IF3MR1tCQumVL0XcYMvZcxBj
32
- a/p+8DomWTQqUdNbNoGywwjtVBWfDdwFV8Po1XcN/AtpILOJQd9J77INIGGCHxZo
33
- 6SOHHaNknlE9H0w6q0SVxZKZI8/+2c447V0NrHIw1Qhe0tAGJ9V1u3ky8gyxe0SM
34
- 8v7zLF2XliYbfurYIwkcXs8yPn8ggApBIy9bX6VJxRs/l2+UvqzaHIFaFy/F8/GP
35
- RNTuXsVG5NDACo7Q
27
+ u8KAcPHm5KkCAwEAAaN9MHswCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
28
+ BBYEFFt3WbF+9JpUjAoj62cQBgNb8HzXMCAGA1UdEQQZMBeBFWRyaXZlci1ydWJ5
29
+ QDEwZ2VuLmNvbTAgBgNVHRIEGTAXgRVkcml2ZXItcnVieUAxMGdlbi5jb20wDQYJ
30
+ KoZIhvcNAQEFBQADggEBALGvdxHF+CnH6QO4PeIce3S8EHuHsYiGLk4sWgNGZkjD
31
+ V3C4XjlI8rQZxalwQwcauacOGj9x94flWUXruEF7+rjUtig7OIrQK2+uVg86vl8r
32
+ xy1n2s1d31KsuazEVExe5o19tnVbI9+30P9qPkS+NgaellXpj5c5qnJUGn5BJtzo
33
+ 3D001zXpVnuZvCcE/A4fQ+BEM0zm0oOmA/gWIAFrufOL9oYg1881dRZ+kQytF/9c
34
+ JrZM8w8wGbIOeLtoQqa7HB/jOYbTahH7KMNh2LHAbOR93hNIJxVRa4iwxiMQ75tN
35
+ 9WUIAJ4AEtjwRg1Bz0OwDo3aucPCBpx77+/FWhv7JYY=
36
36
  -----END CERTIFICATE-----
37
- date: 2013-08-21 00:00:00.000000000 Z
37
+ date: 2014-04-03 00:00:00.000000000 Z
38
38
  dependencies: []
39
39
  description: A Ruby BSON implementation for MongoDB. For more information about Mongo, see http://www.mongodb.org. For more information on BSON, see http://www.bsonspec.org.
40
40
  email: mongodb-dev@googlegroups.com
@@ -44,17 +44,20 @@ executables:
44
44
  extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
- - bson.gemspec
48
47
  - LICENSE
49
48
  - VERSION
50
49
  - bin/b2json
51
50
  - bin/j2bson
51
+ - bson.gemspec
52
+ - ext/jbson/lib/java-bson.jar
53
+ - ext/jbson/target/jbson.jar
52
54
  - lib/bson.rb
53
55
  - lib/bson/bson_c.rb
54
56
  - lib/bson/bson_java.rb
55
57
  - lib/bson/bson_ruby.rb
56
58
  - lib/bson/byte_buffer.rb
57
59
  - lib/bson/exceptions.rb
60
+ - lib/bson/grow.rb
58
61
  - lib/bson/ordered_hash.rb
59
62
  - lib/bson/support/hash_with_indifferent_access.rb
60
63
  - lib/bson/types/binary.rb
@@ -62,12 +65,12 @@ files:
62
65
  - lib/bson/types/dbref.rb
63
66
  - lib/bson/types/min_max_keys.rb
64
67
  - lib/bson/types/object_id.rb
68
+ - lib/bson/types/regex.rb
65
69
  - lib/bson/types/timestamp.rb
66
- - ext/jbson/target/jbson.jar
67
- - ext/jbson/lib/java-bson.jar
68
70
  homepage: http://www.mongodb.org
69
71
  licenses:
70
72
  - Apache License Version 2.0
73
+ metadata: {}
71
74
  post_install_message:
72
75
  rdoc_options: []
73
76
  require_paths:
@@ -77,18 +80,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
80
  - - '>='
78
81
  - !ruby/object:Gem::Version
79
82
  version: '0'
80
- none: false
81
83
  required_rubygems_version: !ruby/object:Gem::Requirement
82
84
  requirements:
83
85
  - - '>='
84
86
  - !ruby/object:Gem::Version
85
87
  version: '0'
86
- none: false
87
88
  requirements: []
88
89
  rubyforge_project: bson
89
- rubygems_version: 1.8.24
90
+ rubygems_version: 2.2.2
90
91
  signing_key:
91
- specification_version: 3
92
+ specification_version: 4
92
93
  summary: Ruby implementation of BSON
93
94
  test_files: []
94
95
  has_rdoc: yard
metadata.gz.sig CHANGED
Binary file