serverless_redirector 0.3.4 → 0.4

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: bf291d3b67b875bd2ae70c723af751bc58748e9b
4
- data.tar.gz: 963c2e15b3c3da833ac69d89e02f3430d324b519
3
+ metadata.gz: 8cec9e1e0836d7ba52eb371437e619193e7c7072
4
+ data.tar.gz: 888f20f1b64eb22675e8dfb577a6996992da6dd7
5
5
  SHA512:
6
- metadata.gz: e812bf4d35308dcbe8b6007a0d9a21cb255c2ff537e4fdde4e5765a0a3492a7fe9cafe7e18a64dd244f87756a3412455d039be741c91d4b0ae62e09f5bb9ce70
7
- data.tar.gz: 59e22ec192a07c783dd365c6f61a5ff0131f160ec25dccd8068eb52b65efe4e41530566c3b0f317e2a882f8b21993bc4a073d4fa5318af0a1bc615b22ab6556d
6
+ metadata.gz: bf4a20525b30514f0200ded81d9388b949f0f8b3be8b47023f476b6b24a0f0abe56321c095c011d15e0e0e75ab17dd2fb052d063ee095dade066a776d0a4ab5b
7
+ data.tar.gz: f2d691bf8169a3616b911972a24de11d88af8fddbfce2dcda0c05087b20092927868636cdd7f750354e3e97581b36077682f0b01dcc7f50fbaf8d0f52d5a76f6
@@ -15,7 +15,7 @@ module ServerlessRedirector
15
15
  case operation
16
16
  when ServerlessRedirector::Operations::RemoveRedirect
17
17
  destination.remove_key operation.redirect.path
18
- when ServerlessRedirector::Operations::CreateRedirect, ServerlessRedirector::Operations::UpdateRedirect
18
+ when ServerlessRedirector::Operations::CreateRedirect, ServerlessRedirector::Operations::UpdateDestination
19
19
  rendered = ServerlessRedirector::Renderer.new('redirect.erb').render(url: operation.redirect.url)
20
20
  destination.write_key operation.redirect.path, operation.redirect.url, rendered
21
21
  end
@@ -102,7 +102,13 @@ module ServerlessRedirector
102
102
  def bucket
103
103
  @bucket ||= begin
104
104
  client = Aws::S3::Client.new
105
- region = @options['client'] || client.get_bucket_location(bucket: bucket_name).location_constraint
105
+ region = @options['region'] || begin
106
+ constraint = ( || client).get_bucket_location(
107
+ bucket: bucket_name,
108
+ ).location_constraint
109
+
110
+ normalise_constraint_to_region(constraint)
111
+ end
106
112
 
107
113
  accelerate = @options['accelerate'] == "true"
108
114
 
@@ -115,6 +121,17 @@ module ServerlessRedirector
115
121
  end
116
122
  end
117
123
 
124
+ def normalise_constraint_to_region(constraint)
125
+ case constraint
126
+ when '', nil
127
+ 'us-east-1'
128
+ when 'EU'
129
+ 'eu-west-1'
130
+ else
131
+ constraint
132
+ end
133
+ end
134
+
118
135
  def build_path(path)
119
136
  if prefix
120
137
  ::File.join prefix, path
@@ -1,3 +1,3 @@
1
1
  module ServerlessRedirector
2
- VERSION = "0.3.4"
2
+ VERSION = "0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverless_redirector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darcy Laycock