bson 5.0.0 → 5.0.2
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.
- checksums.yaml +4 -4
- data/README.md +91 -7
- data/Rakefile +63 -39
- data/ext/bson/read.c +18 -3
- data/ext/bson/util.c +5 -2
- data/ext/bson/write.c +4 -0
- data/lib/bson/array.rb +1 -1
- data/lib/bson/binary.rb +16 -1
- data/lib/bson/code.rb +1 -1
- data/lib/bson/code_with_scope.rb +1 -1
- data/lib/bson/db_pointer.rb +1 -1
- data/lib/bson/decimal128/builder.rb +1 -1
- data/lib/bson/decimal128.rb +1 -1
- data/lib/bson/ext_json.rb +1 -1
- data/lib/bson/float.rb +1 -1
- data/lib/bson/hash.rb +1 -1
- data/lib/bson/int32.rb +1 -1
- data/lib/bson/int64.rb +1 -1
- data/lib/bson/integer.rb +1 -1
- data/lib/bson/max_key.rb +1 -1
- data/lib/bson/min_key.rb +1 -1
- data/lib/bson/object.rb +2 -2
- data/lib/bson/object_id.rb +12 -2
- data/lib/bson/regexp.rb +1 -1
- data/lib/bson/symbol.rb +2 -2
- data/lib/bson/time.rb +1 -1
- data/lib/bson/timestamp.rb +1 -1
- data/lib/bson/undefined.rb +1 -1
- data/lib/bson/version.rb +2 -1
- data/spec/bson/binary_spec.rb +46 -7
- data/spec/bson/object_id_spec.rb +14 -0
- metadata +7 -80
- checksums.yaml.gz.sig +0 -0
- data/spec/shared/LICENSE +0 -20
- data/spec/shared/bin/get-mongodb-download-url +0 -17
- data/spec/shared/bin/s3-copy +0 -45
- data/spec/shared/bin/s3-upload +0 -69
- data/spec/shared/lib/mrss/child_process_helper.rb +0 -80
- data/spec/shared/lib/mrss/cluster_config.rb +0 -231
- data/spec/shared/lib/mrss/constraints.rb +0 -378
- data/spec/shared/lib/mrss/docker_runner.rb +0 -298
- data/spec/shared/lib/mrss/eg_config_utils.rb +0 -51
- data/spec/shared/lib/mrss/event_subscriber.rb +0 -210
- data/spec/shared/lib/mrss/lite_constraints.rb +0 -238
- data/spec/shared/lib/mrss/server_version_registry.rb +0 -113
- data/spec/shared/lib/mrss/session_registry.rb +0 -69
- data/spec/shared/lib/mrss/session_registry_legacy.rb +0 -60
- data/spec/shared/lib/mrss/spec_organizer.rb +0 -179
- data/spec/shared/lib/mrss/utils.rb +0 -37
- data/spec/shared/share/Dockerfile.erb +0 -321
- data/spec/shared/share/haproxy-1.conf +0 -16
- data/spec/shared/share/haproxy-2.conf +0 -17
- data/spec/shared/shlib/config.sh +0 -27
- data/spec/shared/shlib/distro.sh +0 -74
- data/spec/shared/shlib/server.sh +0 -416
- data/spec/shared/shlib/set_env.sh +0 -169
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -2
data/lib/bson/timestamp.rb
CHANGED
@@ -92,7 +92,7 @@ module BSON
|
|
92
92
|
end
|
93
93
|
|
94
94
|
# Converts this object to a representation directly serializable to
|
95
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
95
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
96
96
|
#
|
97
97
|
# @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
|
98
98
|
# (default is canonical extended JSON)
|
data/lib/bson/undefined.rb
CHANGED
@@ -57,7 +57,7 @@ module BSON
|
|
57
57
|
end
|
58
58
|
|
59
59
|
# Converts this object to a representation directly serializable to
|
60
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
60
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
61
61
|
#
|
62
62
|
# @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
|
63
63
|
# (default is canonical extended JSON)
|
data/lib/bson/version.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
# rubocop:todo all
|
3
|
+
|
3
4
|
# Copyright (C) 2009-2020 MongoDB Inc.
|
4
5
|
#
|
5
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -15,5 +16,5 @@
|
|
15
16
|
# limitations under the License.
|
16
17
|
|
17
18
|
module BSON
|
18
|
-
VERSION = "5.0.
|
19
|
+
VERSION = "5.0.2"
|
19
20
|
end
|
data/spec/bson/binary_spec.rb
CHANGED
@@ -20,17 +20,56 @@ describe BSON::Binary do
|
|
20
20
|
let(:testing1) { described_class.new("testing") }
|
21
21
|
let(:testing2) { described_class.new("testing") }
|
22
22
|
let(:not_testing) { described_class.new("not testing") }
|
23
|
+
let(:testing3) { described_class.new("testing", :user) }
|
23
24
|
|
24
|
-
describe "
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
describe "Comparable" do
|
26
|
+
describe "#eql?" do
|
27
|
+
context "for two equal objects" do
|
28
|
+
it "returns true" do
|
29
|
+
expect(testing1).to eql(testing2)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "for two different objects" do
|
34
|
+
it "returns false" do
|
35
|
+
expect(testing1).not_to eql(not_testing)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'for objects with identical data but different types' do
|
40
|
+
it 'returns false' do
|
41
|
+
expect(testing1).not_to eql(testing3)
|
42
|
+
end
|
28
43
|
end
|
29
44
|
end
|
30
45
|
|
31
|
-
|
32
|
-
|
33
|
-
|
46
|
+
describe '#<=>' do
|
47
|
+
context 'with a non-Binary object' do
|
48
|
+
it 'returns nil' do
|
49
|
+
expect(testing1 <=> 'bogus').to be_nil
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'with identical type and data' do
|
54
|
+
it 'returns 0' do
|
55
|
+
expect(testing1 <=> testing2).to be == 0
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'with mismatched type' do
|
60
|
+
it 'returns nil' do
|
61
|
+
expect(testing1 <=> testing3).to be_nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'with identical type but mismatched data' do
|
66
|
+
it 'returns -1 when a < b' do
|
67
|
+
expect(not_testing <=> testing1).to be == -1
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'returns 1 when a > b' do
|
71
|
+
expect(testing1 <=> not_testing).to be == 1
|
72
|
+
end
|
34
73
|
end
|
35
74
|
end
|
36
75
|
end
|
data/spec/bson/object_id_spec.rb
CHANGED
@@ -622,6 +622,20 @@ describe BSON::ObjectId do
|
|
622
622
|
end
|
623
623
|
end
|
624
624
|
|
625
|
+
context 'when the timestamp is larger than a 32-bit integer' do
|
626
|
+
let(:distant_future) { Time.at(2 ** 32) }
|
627
|
+
|
628
|
+
before do
|
629
|
+
allow(Time).to receive(:now).and_return(distant_future)
|
630
|
+
end
|
631
|
+
|
632
|
+
let(:object_id) { BSON::ObjectId.new }
|
633
|
+
|
634
|
+
it 'wraps the timestamp to 0' do
|
635
|
+
expect(object_id.to_time).to be == Time.at(0)
|
636
|
+
end
|
637
|
+
end
|
638
|
+
|
625
639
|
context 'when fork changes the pid' do
|
626
640
|
before do
|
627
641
|
skip 'requires Process.fork' unless Process.respond_to?(:fork)
|
metadata
CHANGED
@@ -1,41 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The MongoDB Ruby Team
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
-
|
12
|
-
-----BEGIN CERTIFICATE-----
|
13
|
-
MIIEeDCCAuCgAwIBAgIBATANBgkqhkiG9w0BAQsFADBBMREwDwYDVQQDDAhkYngt
|
14
|
-
cnVieTEXMBUGCgmSJomT8ixkARkWB21vbmdvZGIxEzARBgoJkiaJk/IsZAEZFgNj
|
15
|
-
b20wHhcNMjQwMjA5MTc0NzIyWhcNMjUwMjA4MTc0NzIyWjBBMREwDwYDVQQDDAhk
|
16
|
-
YngtcnVieTEXMBUGCgmSJomT8ixkARkWB21vbmdvZGIxEzARBgoJkiaJk/IsZAEZ
|
17
|
-
FgNjb20wggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC0/Veq9l47cTfX
|
18
|
-
tQ+kHq2NOCwJuJGt1iXWQ/vH/yp7pZ/bLej7gPDl2CfIngAXRjM7r1FkR9ya7VAm
|
19
|
-
IneBFcVU3HhpIXWi4ByXGjBOXFD1Dfbz4C4zedIWRk/hNzXa+rQY4KPwpOwG/hZg
|
20
|
-
id+rSXWSbNlkyN97XfonweVh7JsIa9X/2JY9ADYjhCfEZF+b0+Wl7+jgwzLWb46I
|
21
|
-
0WH0bZBIZ0BbKAwUXIgvq5mQf9PzukmMVYCwnkJ/P4wrHO22HuwnbMyvJuGjVwqi
|
22
|
-
j1NRp/2vjmKBFWxIfhlSXEIiqAmeEVNXzhPvTVeyo+rma+7R3Bo+4WHkcnPpXJJZ
|
23
|
-
Jd63qXMvTB0GplEcMJPztWhrJOmcxIOVoQyigEPSQT8JpzFVXby4SGioizv2eT7l
|
24
|
-
VYSiCHuc3yEDyq5M+98WGX2etbj6esYtzI3rDevpIAHPB6HQmtoJIA4dSl3gjFb+
|
25
|
-
D+YQSuB2qYu021FI9zeY9sbZyWysEXBxhwrmTk+XUV0qz+OQZkMCAwEAAaN7MHkw
|
26
|
-
CQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFH4nnr4tYlatU57RbExW
|
27
|
-
jG86YM5nMB8GA1UdEQQYMBaBFGRieC1ydWJ5QG1vbmdvZGIuY29tMB8GA1UdEgQY
|
28
|
-
MBaBFGRieC1ydWJ5QG1vbmdvZGIuY29tMA0GCSqGSIb3DQEBCwUAA4IBgQBKGtHA
|
29
|
-
fpi3N/BL1J5O4CBsAjtF4jHDiw2r5MwK+66NzMh3uedjgPI7MoosemLy++SB+8BR
|
30
|
-
SE8bDkb6gfDQQzrI6KSXXyqH2TbQXpY5Tac7/yqXRiu8G2qOrOj4czB/Hq7j09CV
|
31
|
-
YoH88v6hL11i5jt6jPjFh8hXYG0hDQxhi3atRz5Wwd98tUf2DSbyJXJiRgCBeZjl
|
32
|
-
rP7AnKsWMu0C+zPlL+nXtQr+nTFtkKXRWfUJMqePpBqtriQvgQ+Y1ItqYVTSLuiM
|
33
|
-
iwUMcn/rGhdCMBSaKDXdFkIveCHQE2f2WBo2EdErrcTrgEKYYdNfzcb/43j7L1kx
|
34
|
-
AUwyTtk+HFrviBynQbKN82rjbZE+5gukVea5c7idQPkqacPYsoU37DI+hTlUyJkV
|
35
|
-
dcTtfEg44lLlfNukBslfiQf54r+uWbyB0m0rDUN/py7/Ghyzt5GLBU91uCO3dGoI
|
36
|
-
55uFRHMvEcJMTDeImC/nuucPCAiEGMHggr9+NPC0tqpxjGKTo7lS7GzUFjg=
|
37
|
-
-----END CERTIFICATE-----
|
38
|
-
date: 2024-02-13 00:00:00.000000000 Z
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-11-19 00:00:00.000000000 Z
|
39
12
|
dependencies: []
|
40
13
|
description: A fully featured BSON specification implementation in Ruby
|
41
14
|
email: dbx-ruby@mongodb.com
|
@@ -167,29 +140,6 @@ files:
|
|
167
140
|
- spec/runners/common_driver.rb
|
168
141
|
- spec/runners/corpus.rb
|
169
142
|
- spec/runners/corpus_legacy.rb
|
170
|
-
- spec/shared/LICENSE
|
171
|
-
- spec/shared/bin/get-mongodb-download-url
|
172
|
-
- spec/shared/bin/s3-copy
|
173
|
-
- spec/shared/bin/s3-upload
|
174
|
-
- spec/shared/lib/mrss/child_process_helper.rb
|
175
|
-
- spec/shared/lib/mrss/cluster_config.rb
|
176
|
-
- spec/shared/lib/mrss/constraints.rb
|
177
|
-
- spec/shared/lib/mrss/docker_runner.rb
|
178
|
-
- spec/shared/lib/mrss/eg_config_utils.rb
|
179
|
-
- spec/shared/lib/mrss/event_subscriber.rb
|
180
|
-
- spec/shared/lib/mrss/lite_constraints.rb
|
181
|
-
- spec/shared/lib/mrss/server_version_registry.rb
|
182
|
-
- spec/shared/lib/mrss/session_registry.rb
|
183
|
-
- spec/shared/lib/mrss/session_registry_legacy.rb
|
184
|
-
- spec/shared/lib/mrss/spec_organizer.rb
|
185
|
-
- spec/shared/lib/mrss/utils.rb
|
186
|
-
- spec/shared/share/Dockerfile.erb
|
187
|
-
- spec/shared/share/haproxy-1.conf
|
188
|
-
- spec/shared/share/haproxy-2.conf
|
189
|
-
- spec/shared/shlib/config.sh
|
190
|
-
- spec/shared/shlib/distro.sh
|
191
|
-
- spec/shared/shlib/server.sh
|
192
|
-
- spec/shared/shlib/set_env.sh
|
193
143
|
- spec/spec_helper.rb
|
194
144
|
- spec/spec_tests/common_driver_spec.rb
|
195
145
|
- spec/spec_tests/corpus_legacy_spec.rb
|
@@ -266,7 +216,7 @@ metadata:
|
|
266
216
|
documentation_uri: https://www.mongodb.com/docs/ruby-driver/current/tutorials/bson-v4/
|
267
217
|
homepage_uri: https://www.mongodb.com/docs/ruby-driver/current/tutorials/bson-v4/
|
268
218
|
source_code_uri: https://github.com/mongodb/bson-ruby
|
269
|
-
post_install_message:
|
219
|
+
post_install_message:
|
270
220
|
rdoc_options: []
|
271
221
|
require_paths:
|
272
222
|
- lib
|
@@ -281,8 +231,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
281
231
|
- !ruby/object:Gem::Version
|
282
232
|
version: 1.3.6
|
283
233
|
requirements: []
|
284
|
-
rubygems_version: 3.
|
285
|
-
signing_key:
|
234
|
+
rubygems_version: 3.4.19
|
235
|
+
signing_key:
|
286
236
|
specification_version: 4
|
287
237
|
summary: Ruby implementation of the BSON specification
|
288
238
|
test_files:
|
@@ -335,29 +285,6 @@ test_files:
|
|
335
285
|
- spec/runners/common_driver.rb
|
336
286
|
- spec/runners/corpus.rb
|
337
287
|
- spec/runners/corpus_legacy.rb
|
338
|
-
- spec/shared/LICENSE
|
339
|
-
- spec/shared/bin/get-mongodb-download-url
|
340
|
-
- spec/shared/bin/s3-copy
|
341
|
-
- spec/shared/bin/s3-upload
|
342
|
-
- spec/shared/lib/mrss/child_process_helper.rb
|
343
|
-
- spec/shared/lib/mrss/cluster_config.rb
|
344
|
-
- spec/shared/lib/mrss/constraints.rb
|
345
|
-
- spec/shared/lib/mrss/docker_runner.rb
|
346
|
-
- spec/shared/lib/mrss/eg_config_utils.rb
|
347
|
-
- spec/shared/lib/mrss/event_subscriber.rb
|
348
|
-
- spec/shared/lib/mrss/lite_constraints.rb
|
349
|
-
- spec/shared/lib/mrss/server_version_registry.rb
|
350
|
-
- spec/shared/lib/mrss/session_registry.rb
|
351
|
-
- spec/shared/lib/mrss/session_registry_legacy.rb
|
352
|
-
- spec/shared/lib/mrss/spec_organizer.rb
|
353
|
-
- spec/shared/lib/mrss/utils.rb
|
354
|
-
- spec/shared/share/Dockerfile.erb
|
355
|
-
- spec/shared/share/haproxy-1.conf
|
356
|
-
- spec/shared/share/haproxy-2.conf
|
357
|
-
- spec/shared/shlib/config.sh
|
358
|
-
- spec/shared/shlib/distro.sh
|
359
|
-
- spec/shared/shlib/server.sh
|
360
|
-
- spec/shared/shlib/set_env.sh
|
361
288
|
- spec/spec_helper.rb
|
362
289
|
- spec/spec_tests/common_driver_spec.rb
|
363
290
|
- spec/spec_tests/corpus_legacy_spec.rb
|
checksums.yaml.gz.sig
DELETED
Binary file
|
data/spec/shared/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2020 MongoDB, Inc.
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
desired_version, arch = ARGV
|
4
|
-
if arch.nil?
|
5
|
-
STDERR.puts "Usage: get-mongodb-download-url desired-version arch"
|
6
|
-
exit 1
|
7
|
-
end
|
8
|
-
|
9
|
-
$: << File.join(File.dirname(__FILE__), '../lib')
|
10
|
-
require 'mrss/server_version_registry'
|
11
|
-
|
12
|
-
begin
|
13
|
-
puts Mrss::ServerVersionRegistry.new(desired_version, arch).download_url
|
14
|
-
rescue Mrss::ServerVersionRegistry::Error => exc
|
15
|
-
STDERR.puts "Error: #{exc}"
|
16
|
-
exit 2
|
17
|
-
end
|
data/spec/shared/bin/s3-copy
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'optparse'
|
4
|
-
require 'aws-sdk-s3'
|
5
|
-
|
6
|
-
options = {}
|
7
|
-
OptionParser.new do |opts|
|
8
|
-
opts.banner = "Usage: s3-copy options"
|
9
|
-
|
10
|
-
opts.on("-r", "--region=REGION", "AWS region to use (default us-east-1)") do |v|
|
11
|
-
options[:region] = v
|
12
|
-
end
|
13
|
-
|
14
|
-
opts.on("-p", "--param=KEY=VALUE", "Specify parameter for new files") do |v|
|
15
|
-
options[:params] ||= {}
|
16
|
-
k, v = v.split('=', 2)
|
17
|
-
options[:params][k.to_sym] = v
|
18
|
-
end
|
19
|
-
|
20
|
-
opts.on("-f", "--from=BUCKET:PATH", "Bucket name and key (or path) to copy from") do |v|
|
21
|
-
options[:from] = v
|
22
|
-
end
|
23
|
-
|
24
|
-
opts.on("-t", "--to=BUCKET:PATH", "Bucket name and key (or path) to write to (may be specified more than once)") do |v|
|
25
|
-
options[:to] ||= []
|
26
|
-
options[:to] << v
|
27
|
-
end
|
28
|
-
end.parse!
|
29
|
-
|
30
|
-
ENV['AWS_REGION'] ||= options[:region] || 'us-east-1'
|
31
|
-
|
32
|
-
bucket, key = options.fetch(:from).split(':', 2)
|
33
|
-
|
34
|
-
s3 = Aws::S3::Client.new
|
35
|
-
|
36
|
-
options.fetch(:to).each do |dest|
|
37
|
-
STDERR.puts "Copying to #{dest}"
|
38
|
-
dbucket, dkey = dest.split(':', 2)
|
39
|
-
s3.copy_object(
|
40
|
-
bucket: dbucket,
|
41
|
-
key: dkey,
|
42
|
-
copy_source: "/#{bucket}/#{key}",
|
43
|
-
**options[:params] || {},
|
44
|
-
)
|
45
|
-
end
|
data/spec/shared/bin/s3-upload
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'optparse'
|
4
|
-
require 'aws-sdk-s3'
|
5
|
-
|
6
|
-
options = {}
|
7
|
-
OptionParser.new do |opts|
|
8
|
-
opts.banner = "Usage: s3-upload options"
|
9
|
-
|
10
|
-
opts.on("-r", "--region=REGION", "AWS region to use (default us-east-1)") do |v|
|
11
|
-
options[:region] = v
|
12
|
-
end
|
13
|
-
|
14
|
-
opts.on("-p", "--param=KEY=VALUE", "Specify parameter for S3 upload") do |v|
|
15
|
-
options[:params] ||= {}
|
16
|
-
k, v = v.split('=', 2)
|
17
|
-
options[:params][k.to_sym] = v
|
18
|
-
end
|
19
|
-
|
20
|
-
opts.on("-f", "--file=PATH", "Path to the file to upload, - to upload standard input") do |v|
|
21
|
-
options[:file] = v
|
22
|
-
end
|
23
|
-
|
24
|
-
opts.on("-w", "--write=BUCKET:PATH", "Bucket name and key (or path) to upload to") do |v|
|
25
|
-
options[:write] = v
|
26
|
-
end
|
27
|
-
|
28
|
-
opts.on("-c", "--copy=BUCKET:PATH", "Bucket name and key (or path) to copy to (may be specified more than once)") do |v|
|
29
|
-
options[:copy] ||= []
|
30
|
-
options[:copy] << v
|
31
|
-
end
|
32
|
-
end.parse!
|
33
|
-
|
34
|
-
ENV['AWS_REGION'] ||= options[:region] || 'us-east-1'
|
35
|
-
|
36
|
-
def upload(f, options)
|
37
|
-
s3 = Aws::S3::Client.new
|
38
|
-
write = options.fetch(:write)
|
39
|
-
STDERR.puts "Writing #{write}"
|
40
|
-
bucket, key = write.split(':', 2)
|
41
|
-
s3.put_object(
|
42
|
-
body: f.read,
|
43
|
-
bucket: bucket,
|
44
|
-
key: key,
|
45
|
-
**options[:params] || {},
|
46
|
-
)
|
47
|
-
if copy = options[:copy]
|
48
|
-
copy.each do |dest|
|
49
|
-
STDERR.puts "Copying to #{dest}"
|
50
|
-
dbucket, dkey = dest.split(':', 2)
|
51
|
-
s3.copy_object(
|
52
|
-
bucket: dbucket,
|
53
|
-
key: dkey,
|
54
|
-
copy_source: "/#{bucket}/#{key}",
|
55
|
-
**options[:params] || {},
|
56
|
-
)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
if options[:file] == '-'
|
62
|
-
upload(STDIN, options)
|
63
|
-
elsif options[:file]
|
64
|
-
File.open(options[:file]) do |f|
|
65
|
-
upload(f, options)
|
66
|
-
end
|
67
|
-
else
|
68
|
-
upload(STDIN, options)
|
69
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
autoload :ChildProcess, 'childprocess'
|
5
|
-
autoload :Tempfile, 'tempfile'
|
6
|
-
|
7
|
-
module Mrss
|
8
|
-
module ChildProcessHelper
|
9
|
-
class SpawnError < StandardError; end
|
10
|
-
|
11
|
-
module_function def call(cmd, env: nil, cwd: nil)
|
12
|
-
process = ChildProcess.new(*cmd)
|
13
|
-
process.io.inherit!
|
14
|
-
if cwd
|
15
|
-
process.cwd = cwd
|
16
|
-
end
|
17
|
-
if env
|
18
|
-
env.each do |k, v|
|
19
|
-
process.environment[k.to_s] = v
|
20
|
-
end
|
21
|
-
end
|
22
|
-
process.start
|
23
|
-
process.wait
|
24
|
-
process
|
25
|
-
end
|
26
|
-
|
27
|
-
module_function def check_call(cmd, env: nil, cwd: nil)
|
28
|
-
process = call(cmd, env: env, cwd: cwd)
|
29
|
-
unless process.exit_code == 0
|
30
|
-
raise SpawnError, "Failed to execute: #{cmd}"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
module_function def get_output(cmd, env: nil, cwd: nil)
|
35
|
-
process = ChildProcess.new(*cmd)
|
36
|
-
process.io.inherit!
|
37
|
-
if cwd
|
38
|
-
process.cwd = cwd
|
39
|
-
end
|
40
|
-
if env
|
41
|
-
env.each do |k, v|
|
42
|
-
process.environment[k.to_s] = v
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
output = ''
|
47
|
-
r, w = IO.pipe
|
48
|
-
|
49
|
-
begin
|
50
|
-
process.io.stdout = w
|
51
|
-
process.start
|
52
|
-
w.close
|
53
|
-
|
54
|
-
thread = Thread.new do
|
55
|
-
begin
|
56
|
-
loop do
|
57
|
-
output << r.readpartial(16384)
|
58
|
-
end
|
59
|
-
rescue EOFError
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
process.wait
|
64
|
-
thread.join
|
65
|
-
ensure
|
66
|
-
r.close
|
67
|
-
end
|
68
|
-
|
69
|
-
[process, output]
|
70
|
-
end
|
71
|
-
|
72
|
-
module_function def check_output(*args)
|
73
|
-
process, output = get_output(*args)
|
74
|
-
unless process.exit_code == 0
|
75
|
-
raise SpawnError,"Failed to execute: #{args}"
|
76
|
-
end
|
77
|
-
output
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|