heirloom 0.7.4 → 0.8.0

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 (40) hide show
  1. data/CHANGELOG +18 -0
  2. data/lib/heirloom/archive/builder.rb +13 -13
  3. data/lib/heirloom/archive/downloader.rb +8 -8
  4. data/lib/heirloom/archive/writer.rb +4 -4
  5. data/lib/heirloom/catalog.rb +2 -2
  6. data/lib/heirloom/catalog/add.rb +4 -3
  7. data/lib/heirloom/catalog/show.rb +2 -2
  8. data/lib/heirloom/cipher/data.rb +3 -3
  9. data/lib/heirloom/cli.rb +1 -0
  10. data/lib/heirloom/cli/catalog.rb +6 -3
  11. data/lib/heirloom/cli/download.rb +9 -9
  12. data/lib/heirloom/cli/formatter.rb +2 -0
  13. data/lib/heirloom/cli/formatter/catalog.rb +42 -0
  14. data/lib/heirloom/cli/formatter/show.rb +55 -0
  15. data/lib/heirloom/cli/list.rb +8 -2
  16. data/lib/heirloom/cli/setup.rb +15 -17
  17. data/lib/heirloom/cli/shared.rb +20 -7
  18. data/lib/heirloom/cli/show.rb +10 -1
  19. data/lib/heirloom/cli/teardown.rb +2 -2
  20. data/lib/heirloom/cli/upload.rb +11 -11
  21. data/lib/heirloom/version.rb +1 -1
  22. data/spec/archive/downloader_spec.rb +15 -15
  23. data/spec/archive/setup_spec.rb +6 -6
  24. data/spec/archive/teardowner_spec.rb +3 -3
  25. data/spec/archive/writer_spec.rb +1 -1
  26. data/spec/catalog/add_spec.rb +8 -7
  27. data/spec/catalog/show_spec.rb +6 -4
  28. data/spec/catalog_spec.rb +12 -12
  29. data/spec/cipher/data_spec.rb +1 -1
  30. data/spec/cli/catalog_spec.rb +46 -15
  31. data/spec/cli/download_spec.rb +13 -13
  32. data/spec/cli/formatter/catalog_spec.rb +39 -0
  33. data/spec/cli/formatter/show_spec.rb +29 -0
  34. data/spec/cli/list_spec.rb +31 -11
  35. data/spec/cli/setup_spec.rb +5 -4
  36. data/spec/cli/shared_spec.rb +9 -1
  37. data/spec/cli/show_spec.rb +45 -12
  38. data/spec/cli/teardown_spec.rb +2 -1
  39. data/spec/cli/upload_spec.rb +12 -12
  40. metadata +19 -12
@@ -21,11 +21,11 @@ describe Heirloom do
21
21
  and_return @archive_mock
22
22
  end
23
23
 
24
- context "with id, region and base specified" do
24
+ context "with id, region and bucket_prefix specified" do
25
25
  before do
26
26
  options = { :name => 'archive_name',
27
27
  :id => '1.0.0',
28
- :base => 'base',
28
+ :bucket_prefix => 'bp',
29
29
  :region => 'us-east-1',
30
30
  :level => 'info',
31
31
  :output => '/tmp/test123',
@@ -40,9 +40,9 @@ describe Heirloom do
40
40
  end
41
41
 
42
42
  it "should download an archive" do
43
- @archive_mock.should_receive(:download).with(:output => '/tmp/test123',
44
- :region => 'us-east-1',
45
- :base_prefix => 'base',
43
+ @archive_mock.should_receive(:download).with(:output => '/tmp/test123',
44
+ :region => 'us-east-1',
45
+ :bucket_prefix => 'bp',
46
46
  :extract => false,
47
47
  :secret => nil).
48
48
  and_return '/tmp/test123'
@@ -54,10 +54,10 @@ describe Heirloom do
54
54
  end
55
55
  end
56
56
 
57
- context "id, region and base not specified" do
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
- :base => 'base'
59
+ @catalog_stub = stub 'catalog', :regions => ['us-east-1', 'us-west-1'],
60
+ :bucket_prefix => 'bp'
61
61
  options = { :name => 'archive_name',
62
62
  :level => 'info',
63
63
  :output => '/tmp/test123',
@@ -82,11 +82,11 @@ describe Heirloom do
82
82
  end
83
83
 
84
84
  it "should download the latest archive from the first region" do
85
- @archive_mock.should_receive(:download).with(:output => '/tmp/test123',
86
- :region => 'us-east-1',
87
- :base_prefix => 'base',
88
- :extract => false,
89
- :secret => nil).
85
+ @archive_mock.should_receive(:download).with(:output => '/tmp/test123',
86
+ :region => 'us-east-1',
87
+ :bucket_prefix => 'bp',
88
+ :extract => false,
89
+ :secret => nil).
90
90
  and_return '/tmp/test123'
91
91
  @cli_download.should_receive(:ensure_directory).
92
92
  with(:config => @config_mock,
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+ require 'heirloom/cli'
3
+
4
+ describe Heirloom do
5
+
6
+ before do
7
+ @catalog = { 'test1' =>
8
+ { 'regions' => ['us-west-1', 'us-east-1'],
9
+ 'bucket_prefix' => ['bp1'] },
10
+ 'test2' =>
11
+ { 'regions' => ['us-west-2'],
12
+ 'bucket_prefix' => ['bp2'] }
13
+ }
14
+ @formatter = Heirloom::CLI::Formatter::Catalog.new
15
+ end
16
+
17
+ context "unfiltered" do
18
+ it "should return the formated list" do
19
+ @formatter.format(:catalog => @catalog,
20
+ :details => nil,
21
+ :name => nil ).should == "test1\ntest2"
22
+ end
23
+ end
24
+
25
+ context "filtered" do
26
+ it "should return the name with details" do
27
+ format = "test1\n Regions : us-west-1, us-east-1\n Bucket Prefix : bp1"
28
+ @formatter.format(:catalog => @catalog,
29
+ :name => 'test1').should == format
30
+ end
31
+
32
+ it "should return not found if name does not exist in catalog" do
33
+ format = "Heirloom not_here not found in catalog."
34
+ @formatter.format(:catalog => @catalog,
35
+ :name => 'not_here').should == format
36
+ end
37
+ end
38
+
39
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+ require 'heirloom/cli'
3
+
4
+ describe Heirloom do
5
+
6
+ before do
7
+ @attributes = { 'id' => '123',
8
+ 'another_data' => 'more_data',
9
+ 'built_at' => 'today',
10
+ 'built_by' => 'me',
11
+ 'bucket_prefix' => 'bp',
12
+ 'us-west-1-s3-url' => 's3',
13
+ 'us-west-1-http-url' => 'http',
14
+ 'us-west-1-https-url' => 'https' }
15
+ end
16
+
17
+ it "should remove reserved / endpoint attribs" do
18
+ formatter = Heirloom::CLI::Formatter::Show.new
19
+ formatter.format(:attributes => @attributes).
20
+ should_not match 'bucket_prefix|us-west-1-s3-url'
21
+ end
22
+
23
+ it "should format the id output correctly" do
24
+ formatter = Heirloom::CLI::Formatter::Show.new
25
+ formatter.format(:attributes => @attributes).
26
+ should == "id : 123\nanother_data : more_data"
27
+ end
28
+
29
+ end
@@ -4,10 +4,10 @@ require 'heirloom/cli'
4
4
  describe Heirloom do
5
5
 
6
6
  before do
7
- options = { :name => 'archive_name',
8
- :level => 'info',
9
- :metadata_region => 'us-west-1',
10
- :count => 100 }
7
+ @options = { :name => 'archive_name',
8
+ :level => 'info',
9
+ :metadata_region => 'us-west-1',
10
+ :count => 100 }
11
11
  @logger_stub = stub :debug => true
12
12
  @config_mock = mock 'config'
13
13
  @archive_mock = mock 'archive'
@@ -15,12 +15,11 @@ describe Heirloom do
15
15
  :access_key => 'key',
16
16
  :secret_key => 'secret',
17
17
  :metadata_region => 'us-west-1'
18
- Trollop.stub(:options).and_return options
19
18
  Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
20
19
  and_return @logger_stub
21
20
  Heirloom::CLI::List.any_instance.should_receive(:load_config).
22
21
  with(:logger => @logger_stub,
23
- :opts => options).
22
+ :opts => @options).
24
23
  and_return @config_mock
25
24
  Heirloom::Archive.should_receive(:new).
26
25
  with(:name => 'archive_name',
@@ -32,13 +31,34 @@ describe Heirloom do
32
31
  and_return @archive_mock
33
32
  @archive_mock.should_receive(:domain_exists?).and_return true
34
33
  @archive_mock.should_receive(:count)
35
- @cli_list = Heirloom::CLI::List.new
36
34
  end
37
35
 
38
- it "should list ids for given archive" do
39
- @archive_mock.should_receive(:list).with(100).and_return(['1','2'])
40
- @cli_list.should_receive(:jj).with ['1','2']
41
- @cli_list.list
36
+ context "as json" do
37
+ before do
38
+ @options[:json] = true
39
+ Trollop.stub :options => @options
40
+ end
41
+
42
+ it "should list ids for given archive" do
43
+ @cli_list = Heirloom::CLI::List.new
44
+ @archive_mock.should_receive(:list).with(100).and_return(['1','2'])
45
+ @cli_list.should_receive(:jj).with ['1','2']
46
+ @cli_list.list
47
+ end
48
+ end
49
+
50
+ context "as human readable" do
51
+ before do
52
+ @options[:json] = nil
53
+ Trollop.stub :options => @options
54
+ end
55
+
56
+ it "should list ids for given archive" do
57
+ @cli_list = Heirloom::CLI::List.new
58
+ @archive_mock.should_receive(:list).with(100).and_return(['1','2'])
59
+ @cli_list.should_receive(:puts).with "1\n2"
60
+ @cli_list.list
61
+ end
42
62
  end
43
63
 
44
64
  end
@@ -6,7 +6,7 @@ describe Heirloom do
6
6
  before do
7
7
  @regions = ['us-west-1', 'us-west-2']
8
8
  options = { :level => 'info',
9
- :base => 'base',
9
+ :bucket_prefix => 'bp',
10
10
  :region => @regions,
11
11
  :name => 'archive_name',
12
12
  :metadata_region => 'us-west-1' }
@@ -39,13 +39,14 @@ describe Heirloom do
39
39
 
40
40
  it "should setup s3 buckets, catalog and simpledb domain" do
41
41
  @catalog_mock.should_receive(:create_catalog_domain)
42
+ @catalog_mock.stub :entry_exists_in_catalog? => false
42
43
  @catalog_mock.should_receive(:add_to_catalog).
43
- with(:regions => @regions,
44
- :base => 'base').
44
+ with(:regions => @regions,
45
+ :bucket_prefix => 'bp').
45
46
  and_return true
46
47
  @archive_mock.should_receive(:setup).
47
48
  with(:regions => @regions,
48
- :bucket_prefix => 'base')
49
+ :bucket_prefix => 'bp')
49
50
  @setup.setup
50
51
  end
51
52
 
@@ -237,7 +237,7 @@ describe Heirloom do
237
237
  end
238
238
  end
239
239
 
240
- context "testing ensure entry exists in catalog" do
240
+ context "testing ensure entry (does not) exists in catalog" do
241
241
  before do
242
242
  @catalog_mock = mock 'catalog'
243
243
  @logger_stub = stub 'logger', :error => true
@@ -257,6 +257,14 @@ describe Heirloom do
257
257
  lambda { @object.ensure_entry_exists_in_catalog @options }.
258
258
  should raise_error SystemExit
259
259
  end
260
+
261
+ it "should exit if the entry exists in catalog" do
262
+ @catalog_mock.should_receive(:entry_exists_in_catalog?).
263
+ with('entry').
264
+ and_return true
265
+ lambda { @object.ensure_entry_does_not_exist_in_catalog @options }.
266
+ should raise_error SystemExit
267
+ end
260
268
  end
261
269
 
262
270
  context "testing latest id" do
@@ -4,10 +4,11 @@ require 'heirloom/cli'
4
4
  describe Heirloom do
5
5
 
6
6
  before do
7
- options = { :name => 'archive_name',
8
- :id => '1.0.0',
9
- :level => 'info',
10
- :metadata_region => 'us-west-1' }
7
+ @options = { :name => 'archive_name',
8
+ :json => true,
9
+ :id => '1.0.0',
10
+ :level => 'info',
11
+ :metadata_region => 'us-west-1' }
11
12
  @logger_stub = stub :debug => true
12
13
  @config_mock = mock 'config'
13
14
  @archive_mock = mock 'archive'
@@ -15,12 +16,11 @@ describe Heirloom do
15
16
  :access_key => 'key',
16
17
  :secret_key => 'secret',
17
18
  :metadata_region => 'us-west-1'
18
- Trollop.stub(:options).and_return options
19
19
  Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
20
20
  and_return @logger_stub
21
21
  Heirloom::CLI::Show.any_instance.should_receive(:load_config).
22
22
  with(:logger => @logger_stub,
23
- :opts => options).
23
+ :opts => @options).
24
24
  and_return @config_mock
25
25
  Heirloom::Archive.should_receive(:new).
26
26
  with(:name => 'archive_name',
@@ -33,13 +33,46 @@ describe Heirloom do
33
33
  and_return @archive_mock
34
34
  @archive_mock.stub :exists? => true
35
35
  @archive_mock.stub :domain_exists? => true
36
- @cli_show = Heirloom::CLI::Show.new
37
36
  end
38
37
 
39
- it "should show a given id" do
40
- @archive_mock.should_receive(:show).and_return( { 'id' => '1.0.0' } )
41
- @cli_show.should_receive(:jj).with 'id' => '1.0.0'
42
- @cli_show.show
43
- end
38
+ context "returning base attributes" do
39
+ before do
40
+ @attributes = { 'id' => '1.0.0' }
41
+ end
42
+
43
+ context "as json" do
44
+ before do
45
+ @options[:json] = true
46
+ Trollop.stub(:options).and_return @options
47
+ end
48
+
49
+ it "should show a given id as json" do
50
+ @cli_show = Heirloom::CLI::Show.new
51
+ @archive_mock.stub :show => @attributes
52
+ @cli_show.should_receive(:jj).with @attributes
53
+ @cli_show.show
54
+ end
55
+ end
44
56
 
57
+ context "as human readable" do
58
+ before do
59
+ @options[:json] = false
60
+ @options[:all] = true
61
+ Trollop.stub(:options).and_return @options
62
+ end
63
+
64
+ it "should show a given id using the show formatter" do
65
+ @cli_show = Heirloom::CLI::Show.new
66
+ @archive_mock.stub :show => @attributes
67
+ formatter_mock = mock 'format'
68
+ Heirloom::CLI::Formatter::Show.stub :new => formatter_mock
69
+ formatter_mock.should_receive(:format).
70
+ with(:attributes => @attributes,
71
+ :all => true).
72
+ and_return 'the attribs'
73
+ @cli_show.should_receive(:puts).with 'the attribs'
74
+ @cli_show.show
75
+ end
76
+ end
77
+ end
45
78
  end
@@ -17,7 +17,8 @@ describe Heirloom do
17
17
  @archive_mock = mock 'archive'
18
18
  @catalog_mock = mock 'catalog'
19
19
  @catalog_mock.stub :regions => ['us-west-1', 'us-west-2']
20
- @catalog_mock.stub :base => 'base', :catalog_domain_exists? => true
20
+ @catalog_mock.stub :bucket_prefix => 'bp',
21
+ :catalog_domain_exists? => true
21
22
  @catalog_mock.should_receive(:entry_exists_in_catalog?).
22
23
  with('archive_name').
23
24
  and_return true
@@ -23,8 +23,8 @@ describe Heirloom do
23
23
  :metadata_region => 'us-west-1'
24
24
  @archive_mock = mock 'archive'
25
25
  @catalog_mock = mock 'catalog'
26
- @catalog_mock.stub :regions => @regions,
27
- :base => 'base',
26
+ @catalog_mock.stub :regions => @regions,
27
+ :bucket_prefix => 'bp',
28
28
  :catalog_domain_exists? => true
29
29
  Trollop.stub(:options).and_return options
30
30
  Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
@@ -53,10 +53,10 @@ describe Heirloom do
53
53
  with(:name => 'archive_name',
54
54
  :config => @config_mock)
55
55
  @upload.should_receive(:ensure_buckets_exist).
56
- with(:base => 'base',
57
- :name => 'archive_name',
58
- :regions => @regions,
59
- :config => @config_mock)
56
+ with(:bucket_prefix => 'bp',
57
+ :name => 'archive_name',
58
+ :regions => @regions,
59
+ :config => @config_mock)
60
60
  @upload.should_receive(:ensure_directory).
61
61
  with(:path => '/buildme',
62
62
  :config => @config_mock)
@@ -65,14 +65,14 @@ describe Heirloom do
65
65
  :config => @config_mock)
66
66
  @archive_mock.stub :exists? => false
67
67
  @archive_mock.should_receive(:build).
68
- with(:base => 'base',
69
- :directory => '/buildme',
70
- :exclude => ["exclude1", "exclude2"],
71
- :git => false,
72
- :secret => 'secret12').
68
+ with(:bucket_prefix => 'bp',
69
+ :directory => '/buildme',
70
+ :exclude => ["exclude1", "exclude2"],
71
+ :git => false,
72
+ :secret => 'secret12').
73
73
  and_return '/tmp/build123.tar.gz'
74
74
  @archive_mock.should_receive(:upload).
75
- with(:bucket_prefix => 'base',
75
+ with(:bucket_prefix => 'bp',
76
76
  :regions => @regions,
77
77
  :public_readable => false,
78
78
  :file => '/tmp/build123.tar.gz')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heirloom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.8.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-12 00:00:00.000000000 Z
12
+ date: 2012-09-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70113954151760 !ruby/object:Gem::Requirement
16
+ requirement: &70260713581820 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70113954151760
24
+ version_requirements: *70260713581820
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: fog
27
- requirement: &70113954150340 !ruby/object:Gem::Requirement
27
+ requirement: &70260713581300 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.5.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70113954150340
35
+ version_requirements: *70260713581300
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: grit
38
- requirement: &70113954149460 !ruby/object:Gem::Requirement
38
+ requirement: &70260713580800 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.5.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70113954149460
46
+ version_requirements: *70260713580800
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: trollop
49
- requirement: &70113954148360 !ruby/object:Gem::Requirement
49
+ requirement: &70260713580320 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - =
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '2.0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70113954148360
57
+ version_requirements: *70260713580320
58
58
  description: I help build and manage building tar.gz files and deploying them into
59
59
  the cloud
60
60
  email:
@@ -107,6 +107,9 @@ files:
107
107
  - lib/heirloom/cli/catalog.rb
108
108
  - lib/heirloom/cli/destroy.rb
109
109
  - lib/heirloom/cli/download.rb
110
+ - lib/heirloom/cli/formatter.rb
111
+ - lib/heirloom/cli/formatter/catalog.rb
112
+ - lib/heirloom/cli/formatter/show.rb
110
113
  - lib/heirloom/cli/list.rb
111
114
  - lib/heirloom/cli/setup.rb
112
115
  - lib/heirloom/cli/shared.rb
@@ -156,6 +159,8 @@ files:
156
159
  - spec/cli/catalog_spec.rb
157
160
  - spec/cli/destroy_spec.rb
158
161
  - spec/cli/download_spec.rb
162
+ - spec/cli/formatter/catalog_spec.rb
163
+ - spec/cli/formatter/show_spec.rb
159
164
  - spec/cli/list_spec.rb
160
165
  - spec/cli/setup_spec.rb
161
166
  - spec/cli/shared_spec.rb
@@ -184,7 +189,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
184
189
  version: '0'
185
190
  segments:
186
191
  - 0
187
- hash: 719472930190387548
192
+ hash: -176871004567933972
188
193
  required_rubygems_version: !ruby/object:Gem::Requirement
189
194
  none: false
190
195
  requirements:
@@ -193,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
198
  version: '0'
194
199
  segments:
195
200
  - 0
196
- hash: 719472930190387548
201
+ hash: -176871004567933972
197
202
  requirements: []
198
203
  rubyforge_project: heirloom
199
204
  rubygems_version: 1.8.16
@@ -230,6 +235,8 @@ test_files:
230
235
  - spec/cli/catalog_spec.rb
231
236
  - spec/cli/destroy_spec.rb
232
237
  - spec/cli/download_spec.rb
238
+ - spec/cli/formatter/catalog_spec.rb
239
+ - spec/cli/formatter/show_spec.rb
233
240
  - spec/cli/list_spec.rb
234
241
  - spec/cli/setup_spec.rb
235
242
  - spec/cli/shared_spec.rb