blobby-s3 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 815ee79119fea852e7da5b17a52a0da336e0be7d
4
- data.tar.gz: 8e1817e54d7ac8c92e7fe752e14cb1ffb11fdb88
3
+ metadata.gz: 98d9ddbd196d5fc309808c44ce1eacf5af1f94b6
4
+ data.tar.gz: 17d9a7c734176bc8fe5091c10952806f7361a367
5
5
  SHA512:
6
- metadata.gz: 43ba0af1954d399a279969035cfc8480f998cd74e74cd71125cacdfe131e929113d16ff2516cb073abe39603a0d3fefc03f65549e7d676c64bb37ec0a7f216ad
7
- data.tar.gz: 4504c6c2ba203320779a0374088c3dd00544a7ea73bdea31fa84d874b93ac548a7142112cd5423d3da4db1a3a547d08be72a6ef669f91d9238ecb7164bb49492
6
+ metadata.gz: b21edc01cccaf07db902b179a1f197864599565f8d21984cf68737166b3d8a8b237fb6ab8e419309a341c2477eea2f559d10d2069c10c13918519ae46f2b48b2
7
+ data.tar.gz: 28aac839a3753f4f1ea89633b8fbfd173f42e1ba1977ba3f935d9fa636e5bfdf370e08753569c2d8841623ce4f4a5765493ffd4da52ae52c0493e7564408d5c4
@@ -3,7 +3,7 @@ rvm:
3
3
  - 2.2.2
4
4
  env:
5
5
  global:
6
+ - BLOBBY_S3_TEST_BUCKET=blobby-s3-test-ap-southeast-1
6
7
  - AWS_DEFAULT_REGION=us-east-1
7
- - BLOBBY_S3_TEST_BUCKET=fake-aws-sdk-s3-test
8
- - AWS_ACCESS_KEY_ID=AKIAJ6LW4DFV3RH4Z6OQ
9
- - secure: RozEwNe8txMO8jqo/hFWnusfiUSpvz2yN6bDe1G/8bW3pOmjYT319qL5jAIHBxQFohHpUsJMxwsjS07yNq1rlBDuiDJsNnZW6RGzOuVTztaxgjeauo8X4vV3PkZU6Ln0qoYPQiCsIwQfczBpno2Eor0E1BuOXcZGtHsFoQQxWiBG9RkCelGx+Ze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ORwgbF+x9D6TtedphWtpNy62aZFYMmMxud0dX+LfZKm3xi+AlSdZZ5fw/Un5jFKAe1MqNsinkh7+OVyreoZD8MqTUvK3YDOZXHLb5S0FRcqtkN/Dj2PVWzDnhO1hTHK/dhF5EF+axCgcpYNjdgJfhjx28="
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
8
8
  gem.homepage = "https://github.com/realestate-com.au/blobby-s3"
9
9
 
10
10
  gem.name = "blobby-s3"
11
- gem.version = "1.1.0"
11
+ gem.version = "1.1.1"
12
12
 
13
13
  gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
14
14
  gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
@@ -22,6 +22,12 @@ module Blobby
22
22
  store
23
23
  end
24
24
 
25
+ def self.bucket_region(bucket_name, s3_options = {})
26
+ s3_client = Aws::S3::Client.new(s3_options)
27
+ result = s3_client.get_bucket_location(:bucket => bucket_name)
28
+ result ? result.location_constraint : "us-east-1"
29
+ end
30
+
25
31
  # Create a new instance.
26
32
  #
27
33
  # bucket_name - name of the bucket to store things in
@@ -29,8 +35,7 @@ module Blobby
29
35
  #
30
36
  def initialize(bucket_name, s3_options = {})
31
37
  @bucket_name = bucket_name.to_str
32
- @s3_options = s3_options.dup
33
- @s3_options[:endpoint] = s3_endpoint_for_bucket
38
+ @s3_options = s3_options
34
39
  end
35
40
 
36
41
  attr_reader :bucket_name
@@ -96,26 +101,12 @@ module Blobby
96
101
 
97
102
  private
98
103
 
99
- def s3_client
100
- ::Aws::S3::Client.new(s3_options)
101
- end
102
-
103
- def s3_endpoint_for_bucket
104
- location = s3_client.get_bucket_location(:bucket => bucket_name).location_constraint
105
- case location
106
- when ""
107
- "https://s3.amazonaws.com"
108
- when "EU"
109
- "https://s3-eu-west-1.amazonaws.com"
110
- else
111
- "https://s3-#{location}.amazonaws.com"
112
- end
113
- rescue ::Aws::Errors::ServiceError
114
- "https://s3.amazonaws.com"
104
+ def bucket_region
105
+ @bucket_region ||= S3Store.bucket_region(bucket_name, s3_options)
115
106
  end
116
107
 
117
108
  def s3_resource
118
- ::Aws::S3::Resource.new(s3_options)
109
+ ::Aws::S3::Resource.new(s3_options.merge(:region => bucket_region))
119
110
  end
120
111
 
121
112
  def bucket
@@ -9,6 +9,10 @@ require "blobby/store_behaviour"
9
9
 
10
10
  describe Blobby::S3Store do
11
11
 
12
+ before do
13
+ allow(Blobby::S3Store).to receive(:bucket_region).and_return("us-east-1")
14
+ end
15
+
12
16
  describe ".from_uri" do
13
17
 
14
18
  context "with s3://bucket" do
@@ -73,9 +77,13 @@ describe Blobby::S3Store, :integration => true do
73
77
 
74
78
  context "with a writable bucket" do
75
79
 
76
- EXISTING_BUCKET_NAME = ENV.fetch("BLOBBY_S3_TEST_BUCKET", "fake-aws-sdk-s3-test")
80
+ EXISTING_BUCKET_NAME = ENV.fetch("BLOBBY_S3_TEST_BUCKET", "blobby-s3-test-ap-southeast-1")
81
+
82
+ let(:bucket_region) do
83
+ Blobby::S3Store.bucket_region(EXISTING_BUCKET_NAME)
84
+ end
77
85
 
78
- let(:s3_resource) { Aws::S3::Resource.new(:region => "us-east-1")}
86
+ let(:s3_resource) { Aws::S3::Resource.new(:region => bucket_region) }
79
87
  let(:bucket) { s3_resource.bucket(EXISTING_BUCKET_NAME) }
80
88
 
81
89
  before do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blobby-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-22 00:00:00.000000000 Z
11
+ date: 2017-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-resources
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  version: '0'
77
77
  requirements: []
78
78
  rubyforge_project:
79
- rubygems_version: 2.5.1
79
+ rubygems_version: 2.5.2
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: Store BLOBs in S3