s3_website 1.6.3 → 1.6.4

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: 29a254f2801e9e63b44ad767609e498309bf1002
4
- data.tar.gz: e0262bc0a34a7a94ddc0dab19bcaecfc7981ab06
3
+ metadata.gz: 55cbf48ece87058d058773afa873397466a7bb46
4
+ data.tar.gz: 23e1d2f8b50bad5582a3954fff956e5d401a4855
5
5
  SHA512:
6
- metadata.gz: 4a1feb02a3114c23a620152f409d5985759ce518399856ec7324fc09bebc8e2b535f92b76307da15ab3c861db280686b5947bebd94666664ce7564f177526e7c
7
- data.tar.gz: b3aa31a71a4430a2ebb35a713eb9a2d6ff87ebac3d90a7c9b7b875f35037b930c9f8400de955de6c7a430e9ef5905beaf67a6d712739624590ded98ae8adc6a0
6
+ metadata.gz: e23239516c9d32cf5a29bc826a5809635e17e20adfd8aa083a620e6ca9aa2ad8e8da29d467c2aeebe5732ea7516bd1f3a6024551739c85fe59ae13199fa3ad84
7
+ data.tar.gz: f6857264ecd3e9f88b92979c55d89a54800a14d2f07b325dce5871edc8eb5e6aeb4720c50d685dcdacbde379c3a3d3a76e707f2c01145e3539d5ea6ac5fe0f97
data/bin/s3_website CHANGED
@@ -6,6 +6,8 @@ class Cfg < Thor
6
6
  desc 'create', 'Create a config file with placeholder values'
7
7
  def create
8
8
  S3Website::Tasks.config_create Dir.pwd
9
+ rescue Exception => e
10
+ puts S3Website.error_report e
9
11
  end
10
12
 
11
13
  desc 'apply', 'Apply the configuration on the AWS services'
@@ -19,7 +21,13 @@ class Cfg < Thor
19
21
  LONGDESC
20
22
  def apply
21
23
  puts 'Applying the configurations in s3_website.yml on the AWS services ...'
22
- system('configure-s3-website --config-file s3_website.yml')
24
+ require 'configure-s3-website'
25
+ config_source = ConfigureS3Website::FileConfigSource.new 's3_website.yml'
26
+ ConfigureS3Website::Runner.run({
27
+ :config_source => config_source
28
+ })
29
+ rescue Exception => e
30
+ puts S3Website.error_report e
23
31
  end
24
32
  end
25
33
 
@@ -50,6 +58,8 @@ class Cli < Thor
50
58
  def push
51
59
  site_path = S3Website::Paths.infer_site_path options[:site]
52
60
  S3Website::Tasks.push(options[:config_dir], site_path, options[:headless])
61
+ rescue Exception => e
62
+ puts S3Website.error_report e
53
63
  end
54
64
 
55
65
  desc 'cfg SUBCOMMAND ...ARGS', 'Operate on the config file'
data/changelog.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  This project uses [Semantic Versioning](http://semver.org).
4
4
 
5
+ ## 1.6.4
6
+
7
+ * Add systematic error handling
8
+
9
+ Fixes issue https://github.com/laurilehmijoki/s3_website/issues/52.
10
+
5
11
  ## 1.6.3
6
12
 
7
13
  * Invalidate a deleted file on CloudFront
@@ -0,0 +1,17 @@
1
+ Feature: reporting errors to the user
2
+
3
+ Background: we want to show a non-technical error report to the user.
4
+ Consequently, we do not print the stack trace of the error.
5
+
6
+ @starts-new-os-process
7
+ @network-io
8
+ Scenario: The S3 credentials are invalid
9
+ When I run `s3_website push --site ../../features/support/test_site_dirs/my.blog.com --config_dir ../../features/support/test_site_dirs/my.blog.com`
10
+ Then the output should contain:
11
+ """
12
+ The AWS Access Key Id you provided does not exist in our records. (AWS::S3::Errors::InvalidAccessKeyId)
13
+ """
14
+ And the output should not contain:
15
+ """
16
+ throw
17
+ """
@@ -47,17 +47,17 @@ module S3Website
47
47
  @end_msg = end_msg
48
48
  @ordinal_direction = 'n' # start from north
49
49
  print init_msg
50
- print ' '
50
+ print ' '
51
51
  render_next_step
52
52
  end
53
53
 
54
54
  def render_next_step
55
55
  @ordinal_direction = DiffProgressIndicator.next_ordinal_direction @ordinal_direction
56
- print("\b" + DiffProgressIndicator.render_ordinal_direction(@ordinal_direction))
56
+ print("\b\b" + DiffProgressIndicator.render_ordinal_direction(@ordinal_direction) + ' ')
57
57
  end
58
58
 
59
59
  def finish
60
- print "\b"
60
+ print "\b\b"
61
61
  print @end_msg
62
62
  end
63
63
 
@@ -31,4 +31,12 @@ module S3Website
31
31
  super(message)
32
32
  end
33
33
  end
34
+
35
+ def self.error_report(error)
36
+ if error.is_a? S3WebsiteError
37
+ "#{error.message}"
38
+ else
39
+ "#{error.message} (#{error.class})"
40
+ end
41
+ end
34
42
  end
@@ -10,9 +10,6 @@ module S3Website
10
10
  else
11
11
  candidate_path_if_exists candidate_path
12
12
  end
13
- rescue NoWebsiteDirectoryFound => e
14
- puts e.message
15
- exit 1
16
13
  end
17
14
 
18
15
  private
@@ -15,16 +15,10 @@ module S3Website
15
15
  :invalidated_items_count => invalidated_items_count,
16
16
  :changed_redirects_count => changed_redirects.size
17
17
  }
18
- rescue S3WebsiteError => e
19
- puts e.message
20
- exit 1
21
18
  end
22
19
 
23
20
  def self.config_create(dir)
24
21
  ConfigLoader.check_s3_configuration dir
25
- rescue S3WebsiteError => e
26
- puts e.message
27
- exit 1
28
22
  end
29
23
 
30
24
  private
data/s3_website.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "s3_website"
6
- s.version = "1.6.3"
6
+ s.version = "1.6.4"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Lauri Lehmijoki"]
9
9
  s.email = ["lauri.lehmijoki@iki.fi"]
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'error reporting' do
4
+ it 'prints the class name of the error' do
5
+ S3Website::error_report(SocketError.new('network is down')).should include(
6
+ 'SocketError'
7
+ )
8
+ end
9
+
10
+ it 'prints the message of the error' do
11
+ S3Website::error_report(SocketError.new('network is down')).should eq(
12
+ 'network is down (SocketError)'
13
+ )
14
+ end
15
+
16
+ it "only prints the message if the error is an #{S3Website::S3WebsiteError}" do
17
+ S3Website::error_report(S3Website::NoWebsiteDirectoryFound.new()).should eq(
18
+ "I can't find any website. Are you in the right directory?"
19
+ )
20
+ end
21
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3_website
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.3
4
+ version: 1.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lauri Lehmijoki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-02 00:00:00.000000000 Z
11
+ date: 2014-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -239,6 +239,7 @@ files:
239
239
  - features/cloudfront.feature
240
240
  - features/command-line-help.feature
241
241
  - features/delete.feature
242
+ - features/error_reporting.feature
242
243
  - features/instructions-for-new-user.feature
243
244
  - features/jekyll-support.feature
244
245
  - features/nanoc-support.feature
@@ -326,6 +327,7 @@ files:
326
327
  - spec/lib/cloudfront/invalidator_spec.rb
327
328
  - spec/lib/config_loader_spec.rb
328
329
  - spec/lib/endpoint_spec.rb
330
+ - spec/lib/error_spec.rb
329
331
  - spec/lib/keyboard_spec.rb
330
332
  - spec/lib/parallelism_spec.rb
331
333
  - spec/lib/paths_spec.rb
@@ -381,6 +383,7 @@ test_files:
381
383
  - features/cloudfront.feature
382
384
  - features/command-line-help.feature
383
385
  - features/delete.feature
386
+ - features/error_reporting.feature
384
387
  - features/instructions-for-new-user.feature
385
388
  - features/jekyll-support.feature
386
389
  - features/nanoc-support.feature
@@ -451,6 +454,7 @@ test_files:
451
454
  - spec/lib/cloudfront/invalidator_spec.rb
452
455
  - spec/lib/config_loader_spec.rb
453
456
  - spec/lib/endpoint_spec.rb
457
+ - spec/lib/error_spec.rb
454
458
  - spec/lib/keyboard_spec.rb
455
459
  - spec/lib/parallelism_spec.rb
456
460
  - spec/lib/paths_spec.rb