aws-sdk 1.7.1 → 1.8.0
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.
- data/README.rdoc +4 -4
- data/lib/aws-sdk.rb +60 -1
- data/lib/aws.rb +1 -50
- data/lib/aws/api_config/CloudFront-2012-05-05.yml +864 -899
- data/lib/aws/api_config/DataPipeline-2012-10-29.yml +422 -0
- data/lib/aws/api_config/EC2-2012-07-20.yml +0 -2
- data/lib/aws/api_config/Glacier-2012-06-01.yml +622 -0
- data/lib/aws/api_config/ImportExport-2010-06-01.yml +109 -0
- data/lib/aws/api_config/{SQS-2011-10-01.yml → SQS-2012-11-05.yml} +3 -1
- data/lib/aws/api_config/StorageGateway-2012-06-30.yml +748 -0
- data/lib/aws/cloud_front.rb +71 -0
- data/lib/aws/cloud_front/client.rb +1307 -0
- data/lib/aws/cloud_front/config.rb +18 -0
- data/lib/aws/cloud_front/errors.rb +22 -0
- data/lib/aws/cloud_front/request.rb +44 -0
- data/lib/aws/core.rb +19 -1
- data/lib/aws/core/client.rb +7 -0
- data/lib/aws/core/collection.rb +1 -1
- data/lib/aws/core/configuration.rb +12 -0
- data/lib/aws/core/data.rb +13 -8
- data/lib/aws/core/json_client.rb +3 -4
- data/lib/aws/core/json_parser.rb +76 -0
- data/lib/aws/core/json_request_builder.rb +4 -3
- data/lib/aws/core/json_response_parser.rb +1 -3
- data/lib/aws/core/managed_file.rb +32 -0
- data/lib/aws/core/options/json_serializer.rb +82 -0
- data/lib/aws/core/options/validator.rb +5 -1
- data/lib/aws/core/options/xml_serializer.rb +18 -4
- data/lib/aws/core/{rest_client.rb → rest_json_client.rb} +5 -6
- data/lib/aws/core/rest_request_builder.rb +59 -35
- data/lib/aws/core/rest_response_parser.rb +13 -4
- data/lib/aws/core/rest_xml_client.rb +47 -0
- data/lib/aws/core/signature/version_4.rb +22 -8
- data/lib/aws/data_pipeline.rb +30 -0
- data/lib/aws/data_pipeline/client.rb +392 -0
- data/lib/aws/data_pipeline/config.rb +18 -0
- data/lib/aws/data_pipeline/errors.rb +20 -0
- data/lib/aws/data_pipeline/request.rb +26 -0
- data/lib/aws/ec2/instance_collection.rb +11 -3
- data/lib/aws/ec2/security_group.rb +5 -5
- data/lib/aws/ec2/security_group/{egress_ip_permission_collection.rb → ip_permission_collection.rb} +33 -14
- data/lib/aws/glacier.rb +50 -0
- data/lib/aws/glacier/archive.rb +54 -0
- data/lib/aws/glacier/archive_collection.rb +141 -0
- data/lib/aws/glacier/client.rb +286 -0
- data/lib/aws/glacier/config.rb +19 -0
- data/lib/aws/glacier/errors.rb +22 -0
- data/lib/aws/glacier/request.rb +34 -0
- data/lib/aws/glacier/resource.rb +30 -0
- data/lib/aws/glacier/vault.rb +137 -0
- data/lib/aws/glacier/vault_collection.rb +75 -0
- data/lib/aws/glacier/vault_notification_configuration.rb +27 -0
- data/lib/aws/import_export.rb +71 -0
- data/lib/aws/import_export/client.rb +109 -0
- data/lib/aws/import_export/config.rb +19 -0
- data/lib/aws/import_export/errors.rb +22 -0
- data/lib/aws/import_export/request.rb +23 -0
- data/lib/aws/route_53/client.rb +1 -1
- data/lib/aws/s3/bucket_lifecycle_configuration.rb +160 -63
- data/lib/aws/s3/client.rb +43 -0
- data/lib/aws/s3/client/xml.rb +6 -0
- data/lib/aws/s3/cors_rule_collection.rb +1 -1
- data/lib/aws/s3/data_options.rb +1 -3
- data/lib/aws/s3/request.rb +1 -1
- data/lib/aws/s3/s3_object.rb +52 -10
- data/lib/aws/sqs/client.rb +9 -3
- data/lib/aws/sqs/queue.rb +44 -5
- data/lib/aws/storage_gateway.rb +71 -0
- data/lib/aws/storage_gateway/client.rb +472 -0
- data/lib/aws/storage_gateway/config.rb +18 -0
- data/lib/aws/storage_gateway/errors.rb +22 -0
- data/lib/aws/storage_gateway/request.rb +28 -0
- data/lib/aws/version.rb +1 -1
- metadata +45 -10
- data/lib/aws/ec2/security_group/ingress_ip_permission_collection.rb +0 -61
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
AWS::Core::Configuration.module_eval do
|
15
|
+
|
16
|
+
add_service 'DataPipeline', 'data_pipeline', 'datapipeline.us-east-1.amazonaws.com'
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
module AWS
|
15
|
+
class DataPipeline
|
16
|
+
module Errors
|
17
|
+
extend Core::LazyErrorClasses
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
module AWS
|
15
|
+
class DataPipeline
|
16
|
+
# @private
|
17
|
+
class Request < Core::Http::Request
|
18
|
+
include Core::Signature::Version4
|
19
|
+
|
20
|
+
def service
|
21
|
+
'datapipeline'
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -192,6 +192,16 @@ module AWS
|
|
192
192
|
# valid for instances launched outside a VPC (e.g. those
|
193
193
|
# launched without the :subnet option).
|
194
194
|
#
|
195
|
+
# @option options [Boolean] :ebs_optimized (false) EBS-Optimized instances
|
196
|
+
# enable Amazon EC2 instances to fully utilize the IOPS provisioned on
|
197
|
+
# an EBS volume. EBS-optimized instances deliver dedicated throughput
|
198
|
+
# between Amazon EC2 and Amazon EBS, with options between 500 Mbps and
|
199
|
+
# 1000 Mbps depending on the instance type used. When attached to
|
200
|
+
# EBS-Optimized instances, Provisioned IOPS volumes are designed
|
201
|
+
# to deliver within 10% of their provisioned performance 99.9% of the time.
|
202
|
+
# *NOTE:* EBS Optimized instances incur an additional service charge. This
|
203
|
+
# optional is only valid for certain instance types.
|
204
|
+
#
|
195
205
|
# @return [Instance or Array] If a single instance is being created,
|
196
206
|
# this returns an {EC2::Instance} to represent the newly
|
197
207
|
# created instance. Otherwise it returns an array of instance
|
@@ -268,9 +278,7 @@ module AWS
|
|
268
278
|
options[:min_count] == 1
|
269
279
|
self[resp.instances_set.first.instance_id]
|
270
280
|
else
|
271
|
-
resp
|
272
|
-
self[i.instance_id]
|
273
|
-
end
|
281
|
+
resp[:instances_set].map {|i| self[i[:instance_id]] }
|
274
282
|
end
|
275
283
|
end
|
276
284
|
|
@@ -31,9 +31,9 @@ module AWS
|
|
31
31
|
|
32
32
|
AWS.register_autoloads(self, 'aws/ec2/security_group') do
|
33
33
|
autoload :IpPermission, 'ip_permission'
|
34
|
-
autoload :IpPermissionCollection, '
|
35
|
-
autoload :IngressIpPermissionCollection, '
|
36
|
-
autoload :EgressIpPermissionCollection, '
|
34
|
+
autoload :IpPermissionCollection, 'ip_permission_collection'
|
35
|
+
autoload :IngressIpPermissionCollection, 'ip_permission_collection'
|
36
|
+
autoload :EgressIpPermissionCollection, 'ip_permission_collection'
|
37
37
|
end
|
38
38
|
|
39
39
|
include TaggedItem
|
@@ -63,7 +63,7 @@ module AWS
|
|
63
63
|
attribute :ip_permissions_list_egress, :from => :ip_permissions_egress
|
64
64
|
|
65
65
|
populates_from(:describe_security_groups) do |resp|
|
66
|
-
resp
|
66
|
+
resp[:security_group_index][id]
|
67
67
|
end
|
68
68
|
|
69
69
|
# @return [Boolean] True if the security group exists.
|
@@ -347,7 +347,7 @@ module AWS
|
|
347
347
|
def ingress_opts protocol, ports, sources
|
348
348
|
|
349
349
|
opts = {}
|
350
|
-
opts[:ip_protocol] = protocol.to_s.downcase
|
350
|
+
opts[:ip_protocol] = protocol == :any ? '-1' : protocol.to_s.downcase
|
351
351
|
opts[:from_port] = Array(ports).first.to_i
|
352
352
|
opts[:to_port] = Array(ports).last.to_i
|
353
353
|
|
data/lib/aws/ec2/security_group/{egress_ip_permission_collection.rb → ip_permission_collection.rb}
RENAMED
@@ -14,42 +14,50 @@
|
|
14
14
|
module AWS
|
15
15
|
class EC2
|
16
16
|
class SecurityGroup < Resource
|
17
|
-
class EgressIpPermissionCollection
|
18
17
|
|
19
|
-
|
20
|
-
|
18
|
+
class IpPermissionCollection
|
19
|
+
|
20
|
+
include Core::Collection::Simple
|
21
21
|
|
22
22
|
def initialize security_group, options = {}
|
23
23
|
@security_group = security_group
|
24
|
+
@egress = !!options[:egress]
|
24
25
|
super
|
25
26
|
end
|
26
27
|
|
27
28
|
# @return [SecurityGroup]
|
28
29
|
attr_reader :security_group
|
29
30
|
|
30
|
-
|
31
|
-
|
31
|
+
# @return [Boolean]
|
32
|
+
attr_reader :egress
|
33
|
+
|
34
|
+
alias_method :egress?, :egress
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def _each_item options = {}
|
39
|
+
|
40
|
+
list_method = 'ip_permissions_list'
|
41
|
+
list_method += '_egress' if egress?
|
42
|
+
|
43
|
+
security_group.send(list_method).each do |p|
|
32
44
|
|
33
45
|
# egress permissions don't always have ports
|
34
|
-
|
35
|
-
ports = [p[:from_port], p[:to_port]]
|
36
|
-
else
|
37
|
-
ports = nil
|
38
|
-
end
|
46
|
+
ports = p[:from_port] ? [p[:from_port], p[:to_port]] : nil
|
39
47
|
|
40
|
-
ip_ranges = p
|
48
|
+
ip_ranges = p[:ip_ranges].collect{|ip| ip[:cidr_ip] }
|
41
49
|
|
42
|
-
groups = p
|
50
|
+
groups = p[:groups].collect do |group|
|
43
51
|
SecurityGroup.new(group[:group_id],
|
44
52
|
:owner_id => group[:user_id],
|
45
53
|
:vpc_id => security_group.vpc_id,
|
46
54
|
:config => config)
|
47
55
|
end
|
48
56
|
|
49
|
-
permission = IpPermission.new(security_group, p
|
57
|
+
permission = IpPermission.new(security_group, p[:ip_protocol], ports,
|
50
58
|
:ip_ranges => ip_ranges,
|
51
59
|
:groups => groups,
|
52
|
-
:egress =>
|
60
|
+
:egress => egress?,
|
53
61
|
:config => config)
|
54
62
|
|
55
63
|
yield(permission)
|
@@ -58,6 +66,17 @@ module AWS
|
|
58
66
|
end
|
59
67
|
|
60
68
|
end
|
69
|
+
|
70
|
+
class IngressIpPermissionCollection < IpPermissionCollection; end
|
71
|
+
|
72
|
+
class EgressIpPermissionCollection < IpPermissionCollection
|
73
|
+
|
74
|
+
def initialize security_group, options = {}
|
75
|
+
super(security_group, options.merge(:egress => true))
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
61
80
|
end
|
62
81
|
end
|
63
82
|
end
|
data/lib/aws/glacier.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
require 'aws/core'
|
15
|
+
require 'aws/glacier/config'
|
16
|
+
|
17
|
+
module AWS
|
18
|
+
class Glacier
|
19
|
+
|
20
|
+
AWS.register_autoloads(self, 'aws/glacier') do
|
21
|
+
autoload :Archive, 'archive'
|
22
|
+
autoload :ArchiveCollection, 'archive_collection'
|
23
|
+
autoload :Client, 'client'
|
24
|
+
autoload :Errors, 'errors'
|
25
|
+
autoload :Request, 'request'
|
26
|
+
autoload :Resource, 'resource'
|
27
|
+
autoload :Vault, 'vault'
|
28
|
+
autoload :VaultCollection, 'vault_collection'
|
29
|
+
autoload :VaultNotificationConfiguration, 'vault_notification_configuration'
|
30
|
+
end
|
31
|
+
|
32
|
+
include Core::ServiceInterface
|
33
|
+
|
34
|
+
# @option options[String] :account_id ('-')
|
35
|
+
def intialize options = {}
|
36
|
+
@account_id = options[:account_id] || '-'
|
37
|
+
super
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [String]
|
41
|
+
attr_accessor :account_id
|
42
|
+
|
43
|
+
# @return [VaultCollection] Returns a collection for working with
|
44
|
+
# vaults that belong to this account.
|
45
|
+
def vaults
|
46
|
+
VaultCollection.new(:config => config, :account_id => account_id)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
module AWS
|
15
|
+
class Glacier
|
16
|
+
|
17
|
+
class Archive < Resource
|
18
|
+
|
19
|
+
# @param [Vault] vault
|
20
|
+
# @param [String] archive_id
|
21
|
+
# @param [Hash] options
|
22
|
+
# @option options [String] :account_id
|
23
|
+
def initialize vault, archive_id, options = {}
|
24
|
+
@vault = vault
|
25
|
+
@archive_id = archive_id
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [Vault]
|
30
|
+
attr_reader :vault
|
31
|
+
|
32
|
+
# @return [String]
|
33
|
+
attr_reader :archive_id
|
34
|
+
|
35
|
+
# Deletes the current archive.
|
36
|
+
# @return [nil]
|
37
|
+
def delete
|
38
|
+
client.delete_archive(resource_options)
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
|
42
|
+
protected
|
43
|
+
|
44
|
+
def resource_identifiers
|
45
|
+
[
|
46
|
+
[:vault_name, vault.name],
|
47
|
+
[:archive_id, archive_id],
|
48
|
+
[:account_id, account_id],
|
49
|
+
]
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
require 'openssl'
|
15
|
+
|
16
|
+
module AWS
|
17
|
+
class Glacier
|
18
|
+
|
19
|
+
class ArchiveCollection
|
20
|
+
|
21
|
+
include Core::Model
|
22
|
+
|
23
|
+
# @param [Vault] vault
|
24
|
+
# @param [Hash] options
|
25
|
+
# @option options [String] :account_id
|
26
|
+
def initialize vault, options = {}
|
27
|
+
@vault = vault
|
28
|
+
@account_id = options[:account_id] || '-'
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [Vault]
|
33
|
+
attr_reader :vault
|
34
|
+
|
35
|
+
# @return [String]
|
36
|
+
attr_reader :account_id
|
37
|
+
|
38
|
+
# Creates an archive by uploading a file to a vault.
|
39
|
+
# @param [File,Pathname,IO,String] data The data to upload.
|
40
|
+
# If +data+ is a string, this is treated as a path to a file
|
41
|
+
# on disk.
|
42
|
+
# @param [Hash] options
|
43
|
+
# @option options [String] description
|
44
|
+
# @return [Archive]
|
45
|
+
def create data, options = {}
|
46
|
+
|
47
|
+
data = convert_to_io(data)
|
48
|
+
|
49
|
+
hash, tree_hash = compute_checksums(data)
|
50
|
+
|
51
|
+
options = {}
|
52
|
+
options[:vault_name] = vault.name
|
53
|
+
options[:account_id] = account_id
|
54
|
+
options[:body] = data
|
55
|
+
options[:checksum] = tree_hash
|
56
|
+
options[:content_sha256] = hash
|
57
|
+
options[:archive_description] = options[:description] if
|
58
|
+
options[:description]
|
59
|
+
|
60
|
+
resp = client.upload_archive(options)
|
61
|
+
|
62
|
+
self[resp[:archive_id]]
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
# @param [String] archive_id
|
67
|
+
# @return [Archive]
|
68
|
+
def [] archive_id
|
69
|
+
Archive.new(vault, archive_id, :config => config, :account_id => account_id)
|
70
|
+
end
|
71
|
+
|
72
|
+
protected
|
73
|
+
|
74
|
+
def convert_to_io data
|
75
|
+
return Core::ManagedFile.open(data) if
|
76
|
+
data.is_a?(Pathname) or data.is_a?(String)
|
77
|
+
|
78
|
+
return data if io_like?(data)
|
79
|
+
|
80
|
+
msg = "expected data to be IO-like or a file path (String/Pathanme)."
|
81
|
+
raise ArgumentError, msg
|
82
|
+
end
|
83
|
+
|
84
|
+
# @return [Boolean] Returns +tue+ if data acts like a file.
|
85
|
+
def io_like? data
|
86
|
+
data.respond_to?(:read) and
|
87
|
+
data.respond_to?(:eof?) and
|
88
|
+
data.respond_to?(:rewind) and
|
89
|
+
data.respond_to?(:size)
|
90
|
+
end
|
91
|
+
|
92
|
+
# Computes two checksums in a single pass of the data:
|
93
|
+
# * a hash of the entire payload
|
94
|
+
# * a tree hash of the entire payload
|
95
|
+
#
|
96
|
+
# The tree hash is required by the streaming operations,
|
97
|
+
# the simple hash is required for generating the signature
|
98
|
+
# (via sigv4).
|
99
|
+
#
|
100
|
+
# The sigv4 module will compute the hash of the payload for us,
|
101
|
+
# but that requires reading the data a 2nd time. :(
|
102
|
+
def compute_checksums data
|
103
|
+
|
104
|
+
digest = OpenSSL::Digest::Digest.new('sha256')
|
105
|
+
tree_digest = OpenSSL::Digest::Digest.new('sha256')
|
106
|
+
tree_parts = []
|
107
|
+
|
108
|
+
until data.eof?
|
109
|
+
|
110
|
+
chunk = data.read(1024 * 1024) # read 1MB
|
111
|
+
tree_parts << tree_digest.update(chunk).to_s
|
112
|
+
tree_digest.reset
|
113
|
+
|
114
|
+
digest.update(chunk)
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
data.rewind
|
119
|
+
|
120
|
+
[digest.to_s, compute_tree_hash(tree_parts)]
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
def compute_tree_hash hashes
|
125
|
+
|
126
|
+
digest = OpenSSL::Digest::Digest.new('sha256')
|
127
|
+
|
128
|
+
until hashes.count == 1
|
129
|
+
hashes = hashes.each_slice(2).map do |h1,h2|
|
130
|
+
h2 ? digest.update(h1 + h2).to_s : h1
|
131
|
+
end
|
132
|
+
digest.reset
|
133
|
+
end
|
134
|
+
|
135
|
+
hashes.first
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|