heirloom 0.12.1 → 0.12.2

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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +1 -0
  4. data/CHANGELOG.md +6 -0
  5. data/README.md +12 -6
  6. data/heirloom.gemspec +3 -5
  7. data/lib/heirloom/catalog/verify.rb +2 -2
  8. data/lib/heirloom/cli/authorize.rb +1 -2
  9. data/lib/heirloom/cli/catalog.rb +62 -19
  10. data/lib/heirloom/cli/cleanup.rb +1 -2
  11. data/lib/heirloom/cli/destroy.rb +1 -2
  12. data/lib/heirloom/cli/download.rb +2 -3
  13. data/lib/heirloom/cli/formatter/catalog.rb +25 -11
  14. data/lib/heirloom/cli/list.rb +1 -3
  15. data/lib/heirloom/cli/rotate.rb +1 -2
  16. data/lib/heirloom/cli/setup.rb +1 -2
  17. data/lib/heirloom/cli/shared.rb +3 -0
  18. data/lib/heirloom/cli/show.rb +1 -3
  19. data/lib/heirloom/cli/tag.rb +1 -2
  20. data/lib/heirloom/cli/teardown.rb +1 -2
  21. data/lib/heirloom/cli/upload.rb +1 -2
  22. data/lib/heirloom/version.rb +1 -1
  23. data/spec/acl/s3_spec.rb +11 -11
  24. data/spec/archive/authorizer_spec.rb +20 -20
  25. data/spec/archive/builder_spec.rb +13 -13
  26. data/spec/archive/checker_spec.rb +24 -24
  27. data/spec/archive/destroyer_spec.rb +20 -20
  28. data/spec/archive/downloader_spec.rb +30 -30
  29. data/spec/archive/lister_spec.rb +7 -7
  30. data/spec/archive/reader_spec.rb +65 -65
  31. data/spec/archive/setup_spec.rb +27 -27
  32. data/spec/archive/teardowner_spec.rb +19 -19
  33. data/spec/archive/updater_spec.rb +10 -10
  34. data/spec/archive/uploader_spec.rb +26 -26
  35. data/spec/archive/verifier_spec.rb +25 -25
  36. data/spec/archive/writer_spec.rb +11 -11
  37. data/spec/archive_spec.rb +91 -93
  38. data/spec/aws/s3_spec.rb +102 -102
  39. data/spec/aws/simpledb_spec.rb +33 -63
  40. data/spec/catalog/add_spec.rb +12 -12
  41. data/spec/catalog/delete_spec.rb +14 -14
  42. data/spec/catalog/list_spec.rb +8 -8
  43. data/spec/catalog/setup_spec.rb +11 -11
  44. data/spec/catalog/show_spec.rb +13 -13
  45. data/spec/catalog/verify_spec.rb +16 -16
  46. data/spec/catalog_spec.rb +36 -36
  47. data/spec/cipher/data_spec.rb +19 -19
  48. data/spec/cipher/file_spec.rb +11 -11
  49. data/spec/cli/authorize_spec.rb +16 -16
  50. data/spec/cli/catalog_spec.rb +18 -34
  51. data/spec/cli/destroy_spec.rb +13 -13
  52. data/spec/cli/download_spec.rb +31 -31
  53. data/spec/cli/formatter/catalog_spec.rb +19 -17
  54. data/spec/cli/list_spec.rb +14 -14
  55. data/spec/cli/rotate_spec.rb +9 -9
  56. data/spec/cli/setup_spec.rb +29 -29
  57. data/spec/cli/shared_spec.rb +119 -119
  58. data/spec/cli/show_spec.rb +20 -20
  59. data/spec/cli/tag_spec.rb +18 -18
  60. data/spec/cli/teardown_spec.rb +28 -28
  61. data/spec/cli/upload_spec.rb +38 -38
  62. data/spec/config_spec.rb +21 -21
  63. data/spec/destroyer/s3_spec.rb +6 -6
  64. data/spec/directory/directory_spec.rb +19 -19
  65. data/spec/downloader/s3_spec.rb +18 -18
  66. data/spec/logger_spec.rb +9 -9
  67. data/spec/spec_helper.rb +4 -80
  68. data/spec/uploader/s3_spec.rb +35 -35
  69. metadata +23 -56
  70. data/spec/integration/authorize_spec.rb +0 -79
  71. data/spec/integration/cleanup_spec.rb +0 -77
  72. data/watchr.rb +0 -101
@@ -2,15 +2,15 @@ require 'spec_helper'
2
2
 
3
3
  describe Heirloom do
4
4
  before do
5
- @logger_mock = mock 'logger', :info => true
6
- @logger_mock.stub :info => true,
7
- :debug => true
8
- @config_mock = mock 'config'
9
- @config_mock.stub :logger => @logger_mock
10
- @tempfile_stub = stub 'tempfile', :path => '/path_to_encrypted_archive',
11
- :close! => true
12
- Tempfile.stub :new => @tempfile_stub
13
- @file = Heirloom::Cipher::File.new :config => @config_mock
5
+ @logger_double = double 'logger', :info => true
6
+ @logger_double.stub :info => true,
7
+ :debug => true
8
+ @config_double = double 'config'
9
+ @config_double.stub :logger => @logger_double
10
+ @tempfile_double = double 'tempfile', :path => '/path_to_encrypted_archive',
11
+ :close! => true
12
+ Tempfile.stub :new => @tempfile_double
13
+ @file = Heirloom::Cipher::File.new :config => @config_double
14
14
  end
15
15
 
16
16
  it "should encrypt the given file" do
@@ -26,14 +26,14 @@ describe Heirloom do
26
26
 
27
27
  it "should return false if gpg is not in the path" do
28
28
  @file.should_receive(:which).with('gpg').and_return false
29
- @logger_mock.should_receive(:error)
29
+ @logger_double.should_receive(:error)
30
30
  @file.encrypt_file(:file => '/file',
31
31
  :secret => 'mysecret').should be_false
32
32
  end
33
33
 
34
34
  it "should return false if gpg returns non zero code" do
35
35
  @file.should_receive(:which).with('gpg').and_return true
36
- @logger_mock.should_receive(:error)
36
+ @logger_double.should_receive(:error)
37
37
  command = 'gpg --batch --yes -c --cipher-algo AES256 --passphrase mysecret --output /path_to_encrypted_archive /file 2>&1'
38
38
  @file.should_receive(:`).with command
39
39
  $?.stub :success? => false
@@ -9,39 +9,39 @@ describe Heirloom do
9
9
  :name => 'archive_name',
10
10
  :id => '1.0.0',
11
11
  :metadata_region => 'us-west-1' }
12
- @logger_stub = stub 'logger', :error => true
13
- @config_mock = mock_config :logger => @logger_stub
14
- @archive_mock = mock 'archive'
12
+ @logger_double = double 'logger', :error => true
13
+ @config_double = double_config :logger => @logger_double
14
+ @archive_double = double 'archive'
15
15
  Trollop.stub(:options).and_return options
16
16
  Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
17
- and_return @logger_stub
17
+ and_return @logger_double
18
18
  Heirloom::CLI::Authorize.any_instance.should_receive(:load_config).
19
- with(:logger => @logger_stub,
19
+ with(:logger => @logger_double,
20
20
  :opts => options).
21
- and_return @config_mock
21
+ and_return @config_double
22
22
  Heirloom::Archive.should_receive(:new).
23
23
  with(:name => 'archive_name',
24
- :config => @config_mock).
25
- and_return @archive_mock
24
+ :config => @config_double).
25
+ and_return @archive_double
26
26
  Heirloom::Archive.should_receive(:new).
27
27
  with(:id => '1.0.0',
28
28
  :name => 'archive_name',
29
- :config => @config_mock).
30
- and_return @archive_mock
31
- @archive_mock.stub :exists? => true
32
- @archive_mock.should_receive(:domain_exists?).and_return true
29
+ :config => @config_double).
30
+ and_return @archive_double
31
+ @archive_double.stub :exists? => true
32
+ @archive_double.should_receive(:domain_exists?).and_return true
33
33
  @cli_authorize = Heirloom::CLI::Authorize.new
34
34
  end
35
35
 
36
36
  it "should authorize an account" do
37
- @archive_mock.should_receive(:authorize).with(['test@test.com']).
38
- and_return true
37
+ @archive_double.should_receive(:authorize).with(['test@test.com']).
38
+ and_return true
39
39
  @cli_authorize.authorize
40
40
  end
41
41
 
42
42
  it "should exit if authorize returns false" do
43
- @archive_mock.should_receive(:authorize).with(['test@test.com']).
44
- and_return false
43
+ @archive_double.should_receive(:authorize).with(['test@test.com']).
44
+ and_return false
45
45
  lambda { @cli_authorize.authorize }.should raise_error SystemExit
46
46
  end
47
47
 
@@ -6,53 +6,37 @@ describe Heirloom do
6
6
  before do
7
7
  @options = { :level => 'info',
8
8
  :metadata_region => 'us-west-1' }
9
- @result = { 'heirloom_test' =>
9
+
10
+ @result = { 'heirloom_test' =>
10
11
  { 'regions' => ['us-west-1'],
11
12
  'bucket_prefix' => ['bp'] } }
12
- @logger_stub = stub :debug => true
13
- @config_mock = mock_config :logger => @logger_stub
14
- @catalog_mock = mock 'catalog'
15
- @catalog_mock.stub :catalog_domain_exists? => true
13
+ @logger_double = double :debug => true
14
+ @config_double = double_config :logger => @logger_double
15
+ @catalog_double = double 'catalog'
16
+ @catalog_double.stub :catalog_domain_exists? => true
16
17
  Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
17
- and_return @logger_stub
18
+ and_return @logger_double
18
19
  Heirloom::CLI::Catalog.any_instance.should_receive(:load_config).
19
- with(:logger => @logger_stub,
20
+ with(:logger => @logger_double,
20
21
  :opts => @options).
21
- and_return @config_mock
22
+ and_return @config_double
22
23
  Heirloom::Catalog.should_receive(:new).
23
- with(:config => @config_mock).
24
- and_return @catalog_mock
25
- end
26
-
27
- context "as json" do
28
- before do
29
- @options[:json] = true
30
- Trollop.stub :options => @options
31
- end
32
-
33
- it "should list the details about all heirlooms in the catalog" do
34
- @cli_catalog = Heirloom::CLI::Catalog.new
35
- @catalog_mock.stub :all => @result
36
- formated_result = { 'test' =>
37
- { 'regions' => ['us-west-1'],
38
- 'bucket_prefix' => ['bp'] } }
39
- @cli_catalog.should_receive(:jj).with formated_result
40
- @cli_catalog.all
41
- end
24
+ with(:config => @config_double).
25
+ and_return @catalog_double
42
26
  end
43
27
 
44
28
  context "as human readable" do
45
29
  before do
46
- @options[:json] = nil
47
30
  Trollop.stub :options => @options
48
31
  end
49
32
 
50
33
  it "should list all heirlooms in the catalog" do
51
34
  @cli_catalog = Heirloom::CLI::Catalog.new
52
- @catalog_mock.stub :all => @result
53
- formatter_mock = mock 'formatter'
54
- catalog = { :catalog =>
55
- { "test" =>
35
+ @catalog_double.stub :all => @result
36
+ formatter_double = double 'formatter'
37
+ catalog = { :region => "us-west-1",
38
+ :catalog =>
39
+ { "heirloom_test" =>
56
40
  {
57
41
  "regions" => ["us-west-1"],
58
42
  "bucket_prefix" => ["bp"]
@@ -60,8 +44,8 @@ describe Heirloom do
60
44
  },
61
45
  :name => nil
62
46
  }
63
- Heirloom::CLI::Formatter::Catalog.stub :new => formatter_mock
64
- formatter_mock.should_receive(:format).with(catalog).and_return 'theoutput'
47
+ Heirloom::CLI::Formatter::Catalog.stub :new => formatter_double
48
+ formatter_double.should_receive(:summary_format).with(:region=>"us-west-1").and_return('theoutput')
65
49
  @cli_catalog.should_receive(:puts).with 'theoutput'
66
50
  @cli_catalog.all
67
51
  end
@@ -8,32 +8,32 @@ describe Heirloom do
8
8
  :id => '1.0.0',
9
9
  :level => 'info',
10
10
  :metadata_region => 'us-west-1' }
11
- @logger_stub = stub 'logger'
12
- @config_mock = mock_config :logger => @logger_stub
13
- @archive_mock = mock 'archive'
11
+ @logger_double = double 'logger'
12
+ @config_double = double_config :logger => @logger_double
13
+ @archive_double = double 'archive'
14
14
  Trollop.stub(:options).and_return options
15
15
  Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
16
- and_return @logger_stub
16
+ and_return @logger_double
17
17
  Heirloom::CLI::Destroy.any_instance.should_receive(:load_config).
18
- with(:logger => @logger_stub,
18
+ with(:logger => @logger_double,
19
19
  :opts => options).
20
- and_return @config_mock
20
+ and_return @config_double
21
21
  Heirloom::Archive.should_receive(:new).
22
22
  with(:name => 'archive_name',
23
- :config => @config_mock).
24
- and_return @archive_mock
23
+ :config => @config_double).
24
+ and_return @archive_double
25
25
  Heirloom::Archive.should_receive(:new).
26
26
  with(:id => '1.0.0',
27
27
  :name => 'archive_name',
28
- :config => @config_mock).
29
- and_return @archive_mock
30
- @archive_mock.stub :exists? => true
31
- @archive_mock.should_receive(:domain_exists?).and_return true
28
+ :config => @config_double).
29
+ and_return @archive_double
30
+ @archive_double.stub :exists? => true
31
+ @archive_double.should_receive(:domain_exists?).and_return true
32
32
  @cli_destroy = Heirloom::CLI::Destroy.new
33
33
  end
34
34
 
35
35
  it "should destroy an archive" do
36
- @archive_mock.should_receive(:destroy)
36
+ @archive_double.should_receive(:destroy)
37
37
  @cli_destroy.destroy
38
38
  end
39
39
 
@@ -4,17 +4,17 @@ require 'heirloom/cli'
4
4
  describe Heirloom do
5
5
 
6
6
  before do
7
- @logger_stub = stub 'logger'
8
- @config_mock = mock_config :logger => @logger_stub
9
- @archive_mock = mock 'archive'
7
+ @logger_double = double 'logger'
8
+ @config_double = double_config :logger => @logger_double
9
+ @archive_double = double 'archive'
10
10
  Heirloom::HeirloomLogger.should_receive(:new).
11
11
  with(:log_level => 'info').
12
- and_return @logger_stub
12
+ and_return @logger_double
13
13
  Heirloom::Archive.should_receive(:new).
14
- with(:id => '1.0.0',
15
- :name => 'archive_name',
16
- :config => @config_mock).
17
- and_return @archive_mock
14
+ with(:id => '1.0.0',
15
+ :name => 'archive_name',
16
+ :config => @config_double).
17
+ and_return @archive_double
18
18
  end
19
19
 
20
20
  context "with id, region and bucket_prefix specified" do
@@ -29,25 +29,25 @@ describe Heirloom do
29
29
  :metadata_region => 'us-west-1' }
30
30
  Trollop.stub(:options).and_return options
31
31
  Heirloom::CLI::Download.any_instance.should_receive(:load_config).
32
- with(:logger => @logger_stub,
32
+ with(:logger => @logger_double,
33
33
  :opts => options).
34
- and_return @config_mock
34
+ and_return @config_double
35
35
  @cli_download = Heirloom::CLI::Download.new
36
36
  end
37
37
 
38
38
  it "should download an archive" do
39
- @archive_mock.should_receive(:download).with(:output => '/tmp/test123',
40
- :region => 'us-east-1',
41
- :bucket_prefix => 'bp',
42
- :extract => false,
43
- :secret => nil).
39
+ @archive_double.should_receive(:download).with(:output => '/tmp/test123',
40
+ :region => 'us-east-1',
41
+ :bucket_prefix => 'bp',
42
+ :extract => false,
43
+ :secret => nil).
44
44
  and_return '/tmp/test123'
45
45
  @cli_download.should_receive(:ensure_path_is_directory).
46
- with(:config => @config_mock,
46
+ with(:config => @config_double,
47
47
  :path => '/tmp/test123').
48
48
  and_return true
49
49
  @cli_download.should_receive(:ensure_directory_is_writable).
50
- with(:config => @config_mock,
50
+ with(:config => @config_double,
51
51
  :path => '/tmp/test123').
52
52
  and_return true
53
53
  @cli_download.download
@@ -56,9 +56,9 @@ describe Heirloom do
56
56
 
57
57
  context "id, region and bucket prefix not specified" do
58
58
  before do
59
- @catalog_stub = stub 'catalog', :regions => ['us-east-1', 'us-west-1'],
60
- :bucket_prefix => 'bp'
61
- @archive_mock.stub :exists? => true
59
+ @catalog_double = double 'catalog', :regions => ['us-east-1', 'us-west-1'],
60
+ :bucket_prefix => 'bp'
61
+ @archive_double.stub :exists? => true
62
62
  options = { :name => 'archive_name',
63
63
  :level => 'info',
64
64
  :output => '/tmp/test123',
@@ -67,34 +67,34 @@ describe Heirloom do
67
67
  :metadata_region => 'us-west-1' }
68
68
  Trollop.stub(:options).and_return options
69
69
  Heirloom::CLI::Download.any_instance.should_receive(:load_config).
70
- with(:logger => @logger_stub,
70
+ with(:logger => @logger_double,
71
71
  :opts => options).
72
- and_return @config_mock
72
+ and_return @config_double
73
73
  Heirloom::Catalog.should_receive(:new).
74
74
  with(:name => 'archive_name',
75
- :config => @config_mock).
76
- and_return @catalog_stub
77
- archive_stub_to_lookup_latest = stub 'latest', :list => ['1.0.0']
75
+ :config => @config_double).
76
+ and_return @catalog_double
77
+ archive_double_to_lookup_latest = double 'latest', :list => ['1.0.0']
78
78
  Heirloom::Archive.should_receive(:new).
79
79
  with(:name => 'archive_name',
80
- :config => @config_mock).
81
- and_return archive_stub_to_lookup_latest
80
+ :config => @config_double).
81
+ and_return archive_double_to_lookup_latest
82
82
  @cli_download = Heirloom::CLI::Download.new
83
83
  end
84
84
 
85
85
  it "should download the latest archive from the first region" do
86
- @archive_mock.should_receive(:download).with(:output => '/tmp/test123',
86
+ @archive_double.should_receive(:download).with(:output => '/tmp/test123',
87
87
  :region => 'us-east-1',
88
88
  :bucket_prefix => 'bp',
89
89
  :extract => false,
90
90
  :secret => nil).
91
- and_return '/tmp/test123'
91
+ and_return '/tmp/test123'
92
92
  @cli_download.should_receive(:ensure_path_is_directory).
93
- with(:config => @config_mock,
93
+ with(:config => @config_double,
94
94
  :path => '/tmp/test123').
95
95
  and_return true
96
96
  @cli_download.should_receive(:ensure_directory_is_writable).
97
- with(:config => @config_mock,
97
+ with(:config => @config_double,
98
98
  :path => '/tmp/test123').
99
99
  and_return true
100
100
  @cli_download.download
@@ -4,39 +4,41 @@ require 'heirloom/cli'
4
4
  describe Heirloom do
5
5
 
6
6
  before do
7
- @catalog = { 'test1' =>
7
+
8
+ @catalog = { 'heirloom_test1' =>
8
9
  { 'regions' => ['us-west-1', 'us-east-1'],
9
10
  'bucket_prefix' => ['bp1'] },
10
- 'test2' =>
11
+ 'heirloom_test2' =>
11
12
  { 'regions' => ['us-west-2'],
12
13
  'bucket_prefix' => ['bp2'] }
13
14
  }
14
- @formatter = Heirloom::CLI::Formatter::Catalog.new
15
+ @formatter = Heirloom::CLI::Formatter::Catalog.new :catalog => @catalog
16
+
17
+
15
18
  end
16
19
 
17
20
  context "unfiltered" do
18
- it "should return the formated list" do
19
- @formatter.format(:catalog => @catalog,
21
+ it "should return the summary formatted list" do
22
+
23
+ @formatter.summary_format(:region => 'us-west-1',
20
24
  :details => nil,
21
- :name => nil ).should == "test1\ntest2"
25
+ :name => nil ).should == "us-west-1\n test1\n test2"
22
26
  end
23
27
  end
24
28
 
25
29
  context "filtered" do
26
- it "should return the name with details" do
30
+ it "should return the name with details when passed in the name and region" do
27
31
  format = "test1\n" +
28
- " regions : us-west-1, us-east-1\n" +
29
- " bucket_prefix : bp1\n" +
30
- " us-west-1-s3-url : s3://bp1-us-west-1/test1\n" +
31
- " us-east-1-s3-url : s3://bp1-us-east-1/test1"
32
- @formatter.format(:catalog => @catalog,
32
+ " metadata_region : us-west-1\n" +
33
+ " regions : us-east-1, us-west-1\n" +
34
+ " bucket_prefix : bp1\n" +
35
+ " us-east-1-s3-url : s3://bp1-us-east-1/test1\n" +
36
+ " us-west-1-s3-url : s3://bp1-us-west-1/test1"
37
+
38
+ @formatter.detailed_format(:region => 'us-west-1',
39
+ :details => nil,
33
40
  :name => 'test1').should == format
34
- end
35
41
 
36
- it "should return not found if name does not exist in catalog" do
37
- format = "Heirloom not_here not found in catalog."
38
- @formatter.format(:catalog => @catalog,
39
- :name => 'not_here').should == format
40
42
  end
41
43
  end
42
44
 
@@ -8,25 +8,25 @@ describe Heirloom do
8
8
  :level => 'info',
9
9
  :metadata_region => 'us-west-1',
10
10
  :count => 100 }
11
- @logger_stub = stub :debug => true
12
- @config_mock = mock_config :logger => @logger_stub
13
- @archive_mock = mock 'archive'
11
+ @logger_double = double :debug => true
12
+ @config_double = double_config :logger => @logger_double
13
+ @archive_double = double 'archive'
14
14
  Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
15
- and_return @logger_stub
15
+ and_return @logger_double
16
16
  Heirloom::CLI::List.any_instance.should_receive(:load_config).
17
- with(:logger => @logger_stub,
17
+ with(:logger => @logger_double,
18
18
  :opts => @options).
19
- and_return @config_mock
19
+ and_return @config_double
20
20
  Heirloom::Archive.should_receive(:new).
21
21
  with(:name => 'archive_name',
22
- :config => @config_mock).
23
- and_return @archive_mock
22
+ :config => @config_double).
23
+ and_return @archive_double
24
24
  Heirloom::Archive.should_receive(:new).
25
25
  with(:name => 'archive_name',
26
- :config => @config_mock).
27
- and_return @archive_mock
28
- @archive_mock.should_receive(:domain_exists?).and_return true
29
- @archive_mock.should_receive(:count)
26
+ :config => @config_double).
27
+ and_return @archive_double
28
+ @archive_double.should_receive(:domain_exists?).and_return true
29
+ @archive_double.should_receive(:count)
30
30
  end
31
31
 
32
32
  context "as json" do
@@ -37,7 +37,7 @@ describe Heirloom do
37
37
 
38
38
  it "should list ids for given archive" do
39
39
  @cli_list = Heirloom::CLI::List.new
40
- @archive_mock.should_receive(:list).with(100).and_return(['1','2'])
40
+ @archive_double.should_receive(:list).with(100).and_return(['1','2'])
41
41
  @cli_list.should_receive(:jj).with ['1','2']
42
42
  @cli_list.list
43
43
  end
@@ -51,7 +51,7 @@ describe Heirloom do
51
51
 
52
52
  it "should list ids for given archive" do
53
53
  @cli_list = Heirloom::CLI::List.new
54
- @archive_mock.should_receive(:list).with(100).and_return(['1','2'])
54
+ @archive_double.should_receive(:list).with(100).and_return(['1','2'])
55
55
  @cli_list.should_receive(:puts).with "1\n2"
56
56
  @cli_list.list
57
57
  end