bson 3.2.4 → 3.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +14 -0
- data/Rakefile +7 -5
- data/ext/bson/native.c +25 -0
- data/lib/bson/document.rb +1 -1
- data/lib/bson/regexp.rb +32 -7
- data/lib/bson/version.rb +1 -1
- data/spec/bson/document_spec.rb +12 -2
- metadata +2 -2
- 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: 2f5fedb8e90899170ca4e67704d80a6b63f10303
|
4
|
+
data.tar.gz: 20eef028f83b52a330aa392b41ef189f3822c12b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd23def4d8d0efe7279aeb96b0ca02f565c36fc974b53362887033a4b4b3d54a08499d5c78d8914f0bbe3845c511ab4f95a09e98092e33c1f1548073e88cd414
|
7
|
+
data.tar.gz: 98a8be8ca884939c734f388f412fdd236ce10c4470697ac289fab7acc777d61126b5f25ae144f320a18ecef697da92b25ebfb50cfaadc797eaabc6064bd468f7
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
BSON Changelog
|
2
2
|
==============
|
3
3
|
|
4
|
+
## 3.2.6
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* [#44](https://github.com/mongodb/bson-ruby/pull/44) Fixed regexp deserialization in
|
9
|
+
conjunction with SSL io. (Niels Ganser)
|
10
|
+
|
11
|
+
## 3.2.5
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
|
15
|
+
* [RUBY-1024](https://jira.mongodb.org/browse/RUBY-1024) Fixed Hash#merge only to yield when keys
|
16
|
+
exist in both hashes. (Agis Anastasopoulos)
|
17
|
+
|
4
18
|
## 3.2.4
|
5
19
|
|
6
20
|
### Bug Fixes
|
data/Rakefile
CHANGED
@@ -47,11 +47,7 @@ def extension
|
|
47
47
|
RUBY_PLATFORM =~ /darwin/ ? "bundle" : "so"
|
48
48
|
end
|
49
49
|
|
50
|
-
|
51
|
-
require "perf/bench"
|
52
|
-
else
|
53
|
-
require_relative "perf/bench"
|
54
|
-
end
|
50
|
+
require_relative "perf/bench" unless jruby?
|
55
51
|
|
56
52
|
RSpec::Core::RakeTask.new(:spec)
|
57
53
|
RSpec::Core::RakeTask.new(:rspec)
|
@@ -114,6 +110,12 @@ namespace :benchmark do
|
|
114
110
|
require "bson"
|
115
111
|
benchmark!
|
116
112
|
end
|
113
|
+
|
114
|
+
task :profile => :compile do
|
115
|
+
puts "Profiling with native extensions..."
|
116
|
+
require "bson"
|
117
|
+
profile!
|
118
|
+
end
|
117
119
|
end
|
118
120
|
|
119
121
|
task :default => [ :clean_all, :spec, :ext_spec ]
|
data/ext/bson/native.c
CHANGED
@@ -635,6 +635,28 @@ static VALUE rb_true_class_to_bson(int argc, VALUE *argv, VALUE self)
|
|
635
635
|
return encoded;
|
636
636
|
}
|
637
637
|
|
638
|
+
/**
|
639
|
+
* Decode a string from bson.
|
640
|
+
*
|
641
|
+
* @example Decode a string.
|
642
|
+
* rb_bson_string_from_bson(string, io);
|
643
|
+
*
|
644
|
+
* @param [ String ] self The string class.
|
645
|
+
* @param [ IO ] bson The io stream of BSON.
|
646
|
+
*
|
647
|
+
* @return [ String ] The decoded string.
|
648
|
+
*
|
649
|
+
* @since 3.2.5
|
650
|
+
*/
|
651
|
+
static VALUE rb_bson_string_from_bson(VALUE self, VALUE bson)
|
652
|
+
{
|
653
|
+
ID read_method = rb_intern("read");
|
654
|
+
VALUE int_bytes = rb_funcall(bson, read_method, 1, 4);
|
655
|
+
VALUE size = rb_integer_from_bson_int32(self, int_bytes);
|
656
|
+
VALUE string_bytes = rb_funcall(bson, read_method, 1, size - 1);
|
657
|
+
return rb_bson_from_bson_string(string_bytes);
|
658
|
+
}
|
659
|
+
|
638
660
|
/**
|
639
661
|
* Initialize the bson c extension.
|
640
662
|
*
|
@@ -656,6 +678,7 @@ void Init_native()
|
|
656
678
|
VALUE object_id = rb_const_get(bson, rb_intern("ObjectId"));
|
657
679
|
VALUE generator = rb_const_get(object_id, rb_intern("Generator"));
|
658
680
|
VALUE string = rb_const_get(bson, rb_intern("String"));
|
681
|
+
VALUE string_class = rb_singleton_class(string);
|
659
682
|
VALUE true_class = rb_const_get(bson, rb_intern("TrueClass"));
|
660
683
|
VALUE false_class = rb_const_get(bson, rb_intern("FalseClass"));
|
661
684
|
// needed to hash the machine id
|
@@ -711,6 +734,8 @@ void Init_native()
|
|
711
734
|
rb_define_method(string, "set_int32", rb_string_set_int32, 2);
|
712
735
|
rb_undef_method(string, "from_bson_string");
|
713
736
|
rb_define_method(string, "from_bson_string", rb_bson_from_bson_string, 0);
|
737
|
+
rb_undef_method(string_class, "from_bson");
|
738
|
+
rb_define_method(string_class, "from_bson", rb_bson_string_from_bson, 1);
|
714
739
|
rb_undef_method(string, "check_for_illegal_characters!");
|
715
740
|
rb_define_private_method(string, "check_for_illegal_characters!", rb_string_check_for_illegal_characters, 0);
|
716
741
|
|
data/lib/bson/document.rb
CHANGED
@@ -110,7 +110,7 @@ module BSON
|
|
110
110
|
# @since 3.0.0
|
111
111
|
def merge!(other)
|
112
112
|
other.each_pair do |key, value|
|
113
|
-
value = yield(convert_key(key), self[key], convert_value(value)) if block_given?
|
113
|
+
value = yield(convert_key(key), self[key], convert_value(value)) if block_given? && self[key]
|
114
114
|
self[key] = value
|
115
115
|
end
|
116
116
|
self
|
data/lib/bson/regexp.rb
CHANGED
@@ -28,6 +28,31 @@ module BSON
|
|
28
28
|
# @since 2.0.0
|
29
29
|
BSON_TYPE = 11.chr.force_encoding(BINARY).freeze
|
30
30
|
|
31
|
+
# Extended value constant.
|
32
|
+
#
|
33
|
+
# @since 3.2.6
|
34
|
+
EXTENDED_VALUE = 'x'.freeze
|
35
|
+
|
36
|
+
# Ignore case constant.
|
37
|
+
#
|
38
|
+
# @since 3.2.6
|
39
|
+
IGNORECASE_VALUE = 'i'.freeze
|
40
|
+
|
41
|
+
# Multiline constant.
|
42
|
+
#
|
43
|
+
# @since 3.2.6
|
44
|
+
MULTILINE_VALUE = 'm'.freeze
|
45
|
+
|
46
|
+
# Newline constant.
|
47
|
+
#
|
48
|
+
# @since 3.2.6
|
49
|
+
NEWLINE_VALUE = 's'.freeze
|
50
|
+
|
51
|
+
# Ruby multiline constant.
|
52
|
+
#
|
53
|
+
# @since 3.2.6
|
54
|
+
RUBY_MULTILINE_VALUE = 'ms'.freeze
|
55
|
+
|
31
56
|
# Get the regexp as JSON hash data.
|
32
57
|
#
|
33
58
|
# @example Get the regexp as a JSON hash.
|
@@ -71,15 +96,15 @@ module BSON
|
|
71
96
|
end
|
72
97
|
|
73
98
|
def bson_extended
|
74
|
-
(options & ::Regexp::EXTENDED != 0) ?
|
99
|
+
(options & ::Regexp::EXTENDED != 0) ? EXTENDED_VALUE : NO_VALUE
|
75
100
|
end
|
76
101
|
|
77
102
|
def bson_ignorecase
|
78
|
-
(options & ::Regexp::IGNORECASE != 0) ?
|
103
|
+
(options & ::Regexp::IGNORECASE != 0) ? IGNORECASE_VALUE : NO_VALUE
|
79
104
|
end
|
80
105
|
|
81
106
|
def bson_multiline
|
82
|
-
(options & ::Regexp::MULTILINE != 0) ?
|
107
|
+
(options & ::Regexp::MULTILINE != 0) ? RUBY_MULTILINE_VALUE : NO_VALUE
|
83
108
|
end
|
84
109
|
|
85
110
|
# Represents the raw values for the regular expression.
|
@@ -153,13 +178,13 @@ module BSON
|
|
153
178
|
def from_bson(bson)
|
154
179
|
pattern = bson.gets(NULL_BYTE).from_bson_string.chop!
|
155
180
|
options = 0
|
156
|
-
while (option = bson.readbyte) !=
|
181
|
+
while (option = bson.readbyte.chr) != NULL_BYTE
|
157
182
|
case option
|
158
|
-
when
|
183
|
+
when IGNORECASE_VALUE
|
159
184
|
options |= ::Regexp::IGNORECASE
|
160
|
-
when
|
185
|
+
when MULTILINE_VALUE, NEWLINE_VALUE
|
161
186
|
options |= ::Regexp::MULTILINE
|
162
|
-
when
|
187
|
+
when EXTENDED_VALUE
|
163
188
|
options |= ::Regexp::EXTENDED
|
164
189
|
end
|
165
190
|
end
|
data/lib/bson/version.rb
CHANGED
data/spec/bson/document_spec.rb
CHANGED
@@ -439,7 +439,7 @@ describe BSON::Document do
|
|
439
439
|
it "executes the block on each merged element" do
|
440
440
|
expect(merged[:a]).to eq(0)
|
441
441
|
expect(merged[:b]).to eq(3)
|
442
|
-
expect(merged[:c]).to eq(
|
442
|
+
expect(merged[:c]).to eq(7)
|
443
443
|
end
|
444
444
|
end
|
445
445
|
end
|
@@ -488,7 +488,17 @@ describe BSON::Document do
|
|
488
488
|
it "executes the block on each merged element" do
|
489
489
|
expect(other[:a]).to eq(0)
|
490
490
|
expect(other[:b]).to eq(3)
|
491
|
-
expect(other[:c]).to eq(
|
491
|
+
expect(other[:c]).to eq(7)
|
492
|
+
end
|
493
|
+
end
|
494
|
+
|
495
|
+
context "and the documents have no common keys" do
|
496
|
+
before { other[:a] = 1 }
|
497
|
+
|
498
|
+
it "does not execute the block" do
|
499
|
+
expect(other.merge(b: 1) { |key, old, new| old + new }).to eq(
|
500
|
+
BSON::Document.new(a: 1, b: 1)
|
501
|
+
)
|
492
502
|
end
|
493
503
|
end
|
494
504
|
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: 3.2.
|
4
|
+
version: 3.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Brock
|
@@ -34,7 +34,7 @@ cert_chain:
|
|
34
34
|
XZOS48LlWh15EG4yZo/gRzqNAW2LUIkYA5eMS2Kp6r+KV8IBUO/LaHdrXbdilpa8
|
35
35
|
BRsuCo7UZDbFVRns04HLyjVvkj+K/ywIcdKdS0csz5M=
|
36
36
|
-----END CERTIFICATE-----
|
37
|
-
date: 2015-
|
37
|
+
date: 2015-10-08 00:00:00.000000000 Z
|
38
38
|
dependencies: []
|
39
39
|
description: A full featured BSON specification implementation, in Ruby
|
40
40
|
email:
|
metadata.gz.sig
CHANGED
Binary file
|