configure-s3-website 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 57823af5f276b1d5990767f66c1d091c7e3aab2f
4
+ data.tar.gz: 7b5328afc20f3d96a0c8519be1a7d1d984cd8e64
5
+ SHA512:
6
+ metadata.gz: 267418558c77dc6705503ed76a8dfee2367918793ce82efcdd6963bba5e9958b36725927cabf0628b8a34bfa3387049bf472ca09a1dc07c743724d7ceba666c9
7
+ data.tar.gz: c12bcb19386baf65c246833154046a6b56534a96cccb2cf907b89421654cfabe9c93c7228bf7b367d3af8f2eab4e49b4990fe17c63d861421bcd5151de4ecc53
@@ -1,5 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.2
4
3
  - 1.9.3
5
4
  - 2.0.0
data/README.md CHANGED
@@ -9,6 +9,8 @@ command-line interface.
9
9
  The bucket may or may not exist. If the bucket does not exist,
10
10
  `configure-s3-website` will create it.
11
11
 
12
+ For deploying websites to S3, consider using [s3_website](https://github.com/laurilehmijoki/s3_website).
13
+
12
14
  ## Install
13
15
 
14
16
  gem install configure-s3-website
@@ -69,7 +71,10 @@ file. For example:
69
71
  cloudfront_distribution_config:
70
72
  default_cache_behavior:
71
73
  min_TTL: 600
72
- default_root_object: index.json
74
+ aliases:
75
+ quantity: 1
76
+ items:
77
+ CNAME: your.domain.net
73
78
  ```
74
79
 
75
80
  See the section below for more information about the valid values of the
@@ -168,6 +173,19 @@ configuration file a row like this:
168
173
  The valid *s3_endpoint* values consist of the [S3 location constraint
169
174
  values](http://docs.amazonwebservices.com/general/latest/gr/rande.html#s3_region).
170
175
 
176
+
177
+ ### Specifying non-standard index or error documents
178
+
179
+ By default, `configure-s3-website` uses `index.html` for the index document and `error.html` for the error document.
180
+
181
+ You can override either or both of these defaults like this:
182
+
183
+ index_document: default.html
184
+ error_document: 404.html
185
+
186
+ You can specify the name of any document in the bucket.
187
+
188
+
171
189
  ### Configuring redirects
172
190
 
173
191
  You can configure redirects on your S3 website by adding `routing_rules` into
@@ -223,10 +241,13 @@ Big thanks to the following contributors (in alphabetical order):
223
241
 
224
242
  * SlawD
225
243
  * Steve Schwartz
244
+ * Toby Marsden
226
245
 
227
246
  ## Supported Ruby versions
228
247
 
229
- The file `.travis.yml` defines the supported Ruby versions.
248
+ The file `.travis.yml` defines the officially supported Ruby versions. This gem
249
+ might work on other versions as well, but they are not covered with continuous
250
+ integration.
230
251
 
231
252
  ## License
232
253
 
@@ -2,6 +2,10 @@
2
2
 
3
3
  This project uses [Semantic Versioning](http://semver.org).
4
4
 
5
+ ## 1.5.0
6
+
7
+ * Add support for custom index and error documents
8
+
5
9
  ## 1.4.0
6
10
 
7
11
  * Allow the user to store his CloudFront settings in the config file
@@ -18,6 +18,7 @@ spec = Gem::Specification.new do |s|
18
18
  s.add_development_dependency 'rake', '~> 0.9.0'
19
19
  s.add_development_dependency 'vcr', '~> 2.3.0'
20
20
  s.add_development_dependency 'webmock', '~> 1.8.0'
21
+ s.add_development_dependency 'json', '~> 1.7.7'
21
22
 
22
23
  s.files = `git ls-files`.split("\n")
23
24
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -32,6 +32,14 @@ module ConfigureS3Website
32
32
  @config['routing_rules']
33
33
  end
34
34
 
35
+ def index_document
36
+ @config['index_document']
37
+ end
38
+
39
+ def error_document
40
+ @config['error_document']
41
+ end
42
+
35
43
  def cloudfront_distribution_config
36
44
  @config['cloudfront_distribution_config']
37
45
  end
@@ -24,10 +24,10 @@ module ConfigureS3Website
24
24
  body = %|
25
25
  <WebsiteConfiguration xmlns='http://s3.amazonaws.com/doc/2006-03-01/'>
26
26
  <IndexDocument>
27
- <Suffix>index.html</Suffix>
27
+ <Suffix>#{config_source.index_document || "index.html"}</Suffix>
28
28
  </IndexDocument>
29
29
  <ErrorDocument>
30
- <Key>error.html</Key>
30
+ <Key>#{config_source.error_document || "error.html"}</Key>
31
31
  </ErrorDocument>
32
32
  </WebsiteConfiguration>
33
33
  |
@@ -66,10 +66,10 @@ module ConfigureS3Website
66
66
  body = %|
67
67
  <WebsiteConfiguration xmlns='http://s3.amazonaws.com/doc/2006-03-01/'>
68
68
  <IndexDocument>
69
- <Suffix>index.html</Suffix>
69
+ <Suffix>#{config_source.index_document || "index.html"}</Suffix>
70
70
  </IndexDocument>
71
71
  <ErrorDocument>
72
- <Key>error.html</Key>
72
+ <Key>#{config_source.error_document || "error.html"}</Key>
73
73
  </ErrorDocument>
74
74
  <RoutingRules>
75
75
  |
@@ -1,3 +1,3 @@
1
1
  module ConfigureS3Website
2
- VERSION = '1.4.0'
2
+ VERSION = '1.5.0'
3
3
  end
@@ -2,51 +2,116 @@ require 'rspec'
2
2
  require 'configure-s3-website'
3
3
 
4
4
  describe ConfigureS3Website::S3Client do
5
- context '#create_bucket with invalid s3_endpoint value' do
6
- let(:config_source) {
7
- mock = double('config_source')
8
- mock.stub(:s3_endpoint).and_return('invalid-location-constraint')
9
- mock
10
- }
11
-
12
- it 'throws an error' do
13
- expect {
14
- extractor = ConfigureS3Website::S3Client.
15
- send(:create_bucket, config_source)
16
- }.to raise_error(InvalidS3LocationConstraintError)
5
+ describe '#enable_website_configuration' do
6
+ context 'custom index and error documents' do
7
+ let(:config_source) {
8
+ ConfigureS3Website::FileConfigSource.new('spec/sample_files/_custom_index_and_error_docs.yml')
9
+ }
10
+
11
+ it 'calls the S3 API with the custom index document' do
12
+ expect_api_call(
13
+ :enable_website_configuration,
14
+ /<IndexDocument>\s*<Suffix>default.html<\/Suffix>\s*<\/IndexDocument>/,
15
+ config_source
16
+ )
17
+ end
18
+
19
+ it 'calls the S3 API with the custom error document' do
20
+ expect_api_call(
21
+ :enable_website_configuration,
22
+ /<ErrorDocument>\s*<Key>404.html<\/Key>\s*<\/ErrorDocument>/,
23
+ config_source
24
+ )
25
+ end
17
26
  end
18
27
  end
19
28
 
20
- context '#create_bucket with no s3_endpoint value' do
21
- let(:config_source) {
22
- ConfigureS3Website::FileConfigSource.new('spec/sample_files/_config_file.yml')
23
- }
29
+ describe '#configure_bucket_redirects' do
30
+ context 'custom index and error documents' do
31
+ let(:config_source) {
32
+ ConfigureS3Website::FileConfigSource.new('spec/sample_files/_custom_index_and_error_docs_with_routing_rules.yml')
33
+ }
34
+
35
+ it 'calls the S3 API with the custom index document' do
36
+ expect_api_call(
37
+ :configure_bucket_redirects,
38
+ /<IndexDocument>\s*<Suffix>default.html<\/Suffix>\s*<\/IndexDocument>/,
39
+ config_source
40
+ )
41
+ end
24
42
 
25
- it 'calls the S3 api without request body' do
26
- ConfigureS3Website::HttpHelper.should_receive(:call_s3_api).
27
- with(anything(), anything(), '', anything())
28
- ConfigureS3Website::S3Client.send(:create_bucket,
29
- config_source)
43
+ it 'calls the S3 API with the custom error document' do
44
+ expect_api_call(
45
+ :configure_bucket_redirects,
46
+ /<ErrorDocument>\s*<Key>missing.html<\/Key>\s*<\/ErrorDocument>/,
47
+ config_source
48
+ )
49
+ end
30
50
  end
31
51
  end
32
52
 
33
- context '#create_bucket with s3_endpoint value' do
34
- let(:config_source) {
35
- ConfigureS3Website::FileConfigSource.new(
36
- 'spec/sample_files/_config_file_oregon.yml'
53
+ describe '#create_bucket' do
54
+ context 'invalid s3_endpoint value' do
55
+ let(:config_source) {
56
+ mock = double('config_source')
57
+ mock.stub(:s3_endpoint).and_return('invalid-location-constraint')
58
+ mock
59
+ }
60
+
61
+ it 'throws an error' do
62
+ expect {
63
+ extractor = ConfigureS3Website::S3Client.
64
+ send(:create_bucket, config_source)
65
+ }.to raise_error(InvalidS3LocationConstraintError)
66
+ end
67
+ end
68
+
69
+ context 'no s3_endpoint value' do
70
+ let(:config_source) {
71
+ ConfigureS3Website::FileConfigSource.new('spec/sample_files/_config_file.yml')
72
+ }
73
+
74
+ it 'calls the S3 api without request body' do
75
+ ConfigureS3Website::HttpHelper.should_receive(:call_s3_api).
76
+ with(anything(), anything(), '', anything())
77
+ ConfigureS3Website::S3Client.send(:create_bucket,
78
+ config_source)
79
+ end
80
+ end
81
+
82
+ context 'valid s3_endpoint value' do
83
+ let(:config_source) {
84
+ ConfigureS3Website::FileConfigSource.new(
85
+ 'spec/sample_files/_config_file_oregon.yml'
37
86
  )
38
- }
87
+ }
39
88
 
40
- it 'calls the S3 api with location constraint XML' do
41
- ConfigureS3Website::HttpHelper.should_receive(:call_s3_api).
42
- with(anything(), anything(),
89
+ it 'calls the S3 api with location constraint XML' do
90
+ ConfigureS3Website::HttpHelper.should_receive(:call_s3_api).
91
+ with(anything(), anything(),
43
92
  %|
44
93
  <CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
45
94
  <LocationConstraint>us-west-2</LocationConstraint>
46
95
  </CreateBucketConfiguration >
47
96
  |, anything())
48
- ConfigureS3Website::S3Client.send(:create_bucket,
49
- config_source)
97
+ ConfigureS3Website::S3Client.send(:create_bucket,
98
+ config_source)
99
+ end
50
100
  end
51
101
  end
102
+
103
+ def expect_api_call(operation, body, config_source)
104
+ ConfigureS3Website::HttpHelper.
105
+ should_receive(:call_s3_api).
106
+ with(
107
+ anything(),
108
+ anything(),
109
+ body,
110
+ anything()
111
+ )
112
+ ConfigureS3Website::S3Client.send(
113
+ operation,
114
+ config_source
115
+ )
116
+ end
52
117
  end
@@ -0,0 +1,5 @@
1
+ s3_id: <%= 'hello world' %>
2
+ s3_secret: <%= 'secret world' %>
3
+ s3_bucket: my-bucket
4
+ index_document: default.html
5
+ error_document: 404.html
@@ -0,0 +1,12 @@
1
+ s3_id: <%= 'hello world' %>
2
+ s3_secret: <%= 'secret world' %>
3
+ s3_bucket: my-bucket
4
+ index_document: default.html
5
+ error_document: missing.html
6
+ routing_rules:
7
+ - condition:
8
+ key_prefix_equals: blog/some_path
9
+ redirect:
10
+ host_name: blog.example.com
11
+ replace_key_prefix_with: some_new_path/
12
+ http_redirect_code: 301
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configure-s3-website
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
5
- prerelease:
4
+ version: 1.5.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Lauri Lehmijoki
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-21 00:00:00.000000000 Z
11
+ date: 2013-10-11 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: deep_merge
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - '='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - '='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec-expectations
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: cucumber
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: aruba
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -94,7 +83,6 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rake
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ~>
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ~>
108
95
  - !ruby/object:Gem::Version
@@ -110,7 +97,6 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: vcr
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ~>
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ~>
124
109
  - !ruby/object:Gem::Version
@@ -126,7 +111,6 @@ dependencies:
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: webmock
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
115
  - - ~>
132
116
  - !ruby/object:Gem::Version
@@ -134,11 +118,24 @@ dependencies:
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
122
  - - ~>
140
123
  - !ruby/object:Gem::Version
141
124
  version: 1.8.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: json
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: 1.7.7
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ version: 1.7.7
142
139
  description:
143
140
  email: lauri.lehmijoki@iki.fi
144
141
  executables:
@@ -192,36 +189,31 @@ files:
192
189
  - spec/sample_files/_config_file.yml
193
190
  - spec/sample_files/_config_file_oregon.yml
194
191
  - spec/sample_files/_config_file_with_eruby.yml
192
+ - spec/sample_files/_custom_index_and_error_docs.yml
193
+ - spec/sample_files/_custom_index_and_error_docs_with_routing_rules.yml
195
194
  - spec/xml_helper_spec.rb
196
195
  homepage: https://github.com/laurilehmijoki/configure-s3-website
197
196
  licenses: []
197
+ metadata: {}
198
198
  post_install_message:
199
199
  rdoc_options: []
200
200
  require_paths:
201
201
  - lib
202
202
  required_ruby_version: !ruby/object:Gem::Requirement
203
- none: false
204
203
  requirements:
205
- - - ! '>='
204
+ - - '>='
206
205
  - !ruby/object:Gem::Version
207
206
  version: '0'
208
- segments:
209
- - 0
210
- hash: 2506779264415997513
211
207
  required_rubygems_version: !ruby/object:Gem::Requirement
212
- none: false
213
208
  requirements:
214
- - - ! '>='
209
+ - - '>='
215
210
  - !ruby/object:Gem::Version
216
211
  version: '0'
217
- segments:
218
- - 0
219
- hash: 2506779264415997513
220
212
  requirements: []
221
213
  rubyforge_project:
222
- rubygems_version: 1.8.25
214
+ rubygems_version: 2.0.3
223
215
  signing_key:
224
- specification_version: 3
216
+ specification_version: 4
225
217
  summary: Configure your AWS S3 bucket to function as a web site
226
218
  test_files:
227
219
  - features/cassettes/cucumber_tags/apply-configs-on-cf-dist.yml
@@ -251,4 +243,6 @@ test_files:
251
243
  - spec/sample_files/_config_file.yml
252
244
  - spec/sample_files/_config_file_oregon.yml
253
245
  - spec/sample_files/_config_file_with_eruby.yml
246
+ - spec/sample_files/_custom_index_and_error_docs.yml
247
+ - spec/sample_files/_custom_index_and_error_docs_with_routing_rules.yml
254
248
  - spec/xml_helper_spec.rb