open-uri-s3 1.3.0 → 1.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 09063274ea954a0ee89c5c5098a6aa44d37363df
4
- data.tar.gz: ab68e9475b54fad4b8d59920d60fa1bed0e53bb3
3
+ metadata.gz: 173a6d9e73fff6d19915a376e1afa06cf1ca3104
4
+ data.tar.gz: ac7354c002aaa90e3df0fb3b1094f521a3514c9f
5
5
  SHA512:
6
- metadata.gz: 7d21c8b67879998d6f2685176af30be8e0ad4a64f98881f67c23a04e3cf23467fc9725c629d49bb551c89da5c0ee633c8fa268276611e94077c7a1d6cdd2d7ec
7
- data.tar.gz: 2b26b1df53977fefc9f496545ba2d97c3c08ae75ff3b2796d26e8494dca26c28772f590f443095ba7553fc3ca6af55b1bbd425999200bcf1a036c98f63eb1146
6
+ metadata.gz: 019e2867e6e0929cba03330e18d3150f5f10fac051c4bf4733c7d5fbbe4a312154333ea5ab5f2d3058d2ff55274d0b0b295fc17e52332fe4747d9478ae2b29de
7
+ data.tar.gz: 905c19d72cd9199c8f766bdd20d0083c606f1d030f508f144723d83b040a5dac3b443f410bf5ac682b7be07b9af292eb1c467c240ff0d5016c2dda71c563a584
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0
1
+ 1.4.0
@@ -7,15 +7,16 @@ module URI
7
7
 
8
8
  # @return [Aws::S3::Object] S3 object (quacks like IO)
9
9
  def open(*args)
10
- s3 = ::Aws::S3.new
11
- bucket = s3.buckets[self.hostname]
12
- if bucket.location_constraint
13
- s3 = ::Aws::S3.new(s3_endpoint: "s3-#{bucket.location_constraint}.amazonaws.com")
14
- bucket = s3.buckets[self.hostname]
10
+ client = Aws::S3::Client.new
11
+ bucket_location = client.get_bucket_location(bucket: self.hostname)
12
+ location_constraint = bucket_location.data.location_constraint
13
+
14
+ if !location_constraint.empty?
15
+ client = Aws::S3::Client.new(region: location_constraint)
15
16
  end
16
17
 
17
18
  path = self.path[1..-1]
18
- object = bucket.objects[path]
19
+ object = client.get_object(bucket: self.hostname, key: path).body
19
20
 
20
21
  if block_given?
21
22
  yield object
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "open-uri-s3"
8
- s.version = "1.3.0"
8
+ s.version = "1.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Erik Terpstra"]
12
- s.date = "2015-11-16"
12
+ s.date = "2015-11-24"
13
13
  s.description = "AWS S3 protocol support for open-uri"
14
14
  s.email = "erterpstra@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -10,7 +10,7 @@ describe URI::S3 do
10
10
  let(:object) { double('object', read: 'contents') }
11
11
 
12
12
  before do
13
- allow(Aws::S3).to receive(:new).and_return(s3)
13
+ allow(Aws::S3::Client).to receive(:new).and_return(s3)
14
14
  end
15
15
 
16
16
  describe "open" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open-uri-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-16 00:00:00.000000000 Z
11
+ date: 2015-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk