continuum-stager-api 0.1.0 → 0.1.1

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,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MWRiOTA4YWU1ZGNlZDA4YzI4MTMwMjRmYjA2ZjlmYTZiYjMxOTZlMg==
5
- data.tar.gz: !binary |-
6
- ZDE3NWEwODI5MGIyNjMyODcyYTNmNDU4NjZmNmI5ZmM4NWY2ODkzOA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- MjUwY2Q0YzVkYzc4MTYxYTVmMTMwNGUxYzIxNGIzMzZiZjQ4MzVmM2JmMjAw
10
- ODFhNTJmOTE2Yzc4YmMzNjMyMGRmOTUzZjlkYTY2NjIxYWVlZjJiOWIxZjRk
11
- ZGRlODlmZDJmZDVmOTU0YjlhZmQ3ODU4YzQwZDlhMWQzYjUzNzM=
12
- data.tar.gz: !binary |-
13
- MjQwMzdkODU0YzI3NGQxNTIwMzgxZmRmYWM5NzcyMDY2Mjk4ZTk1MDNkODgx
14
- OGM0MjBlYzI5Y2NlYzdkZTA5ZTI5NmM0ODNkODczMTVmNjVkM2RmYWU2OGYy
15
- ZWUwMjk0NTI2OTZjY2VhZjVkOTExMWQ2OTc5NGU2MjUwYzUwOGU=
2
+ SHA1:
3
+ metadata.gz: 87c3aa31c2d8599ca0d727e99ebb0672fc81963f
4
+ data.tar.gz: 152f10e919cb7426d1e7f95a8bab1c379df3bded
5
+ SHA512:
6
+ metadata.gz: 72a8ab538de1f47d1ab5d2b380682c71e0f00eebd2f5e3b259df9deb2b996643827128613f40d349e7497cdf7b7d02c4231b84bc6f3d7206f06e0f52cf3736d2
7
+ data.tar.gz: 6e2dd9ebe4c5751b97b331489a72d5f2db2f9fa46ec9344311c603633b2e50fb3cc3dfdb8cb97c574142739c67a98d7653f534bc6a269a9a9d30f7ec74e57d79
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.test_files = `git ls-files -- {spec}/*`.split("\n")
16
16
  gem.name = "continuum-stager-api"
17
17
  gem.require_paths = ["lib"]
18
- gem.version = "0.1.0"
18
+ gem.version = "0.1.1"
19
19
 
20
20
  gem.add_development_dependency 'rspec', '~> 2.6.0'
21
21
  gem.add_development_dependency 'rake'
@@ -67,7 +67,7 @@ module Apcera
67
67
 
68
68
  # Upload the new package to the staging coordinator
69
69
  def upload
70
- execute_app("tar czf #{@updated_pkg_path} .")
70
+ execute_app("tar czf #{@updated_pkg_path} #{@app_path}")
71
71
 
72
72
  sha1 = Digest::SHA1.file(@updated_pkg_path)
73
73
  File.open(@updated_pkg_path, "rb") do |f|
@@ -249,16 +249,18 @@ module Apcera
249
249
  exit code
250
250
  end
251
251
 
252
- private
253
-
252
+ # Output to stderr
254
253
  def output_error(text)
255
254
  $stderr.puts text
256
255
  end
257
256
 
257
+ # Output to stdout
258
258
  def output(text)
259
259
  $stdout.puts text
260
260
  end
261
261
 
262
+ private
263
+
262
264
  def setup_environment
263
265
  # When staging we use the root path. These are overridden in tests.
264
266
  @root_path = "/"
@@ -3,29 +3,29 @@ require 'spec_helper'
3
3
  describe Apcera::Stager do
4
4
  before do
5
5
  @appdir = "site"
6
-
7
- # See mock server directory for setup!
8
6
  @stager_url = "http://example.com"
9
7
  end
10
8
 
11
- it "should raise an exception when initialized without a stager url" do
12
- expect { Apcera::Stager.new }.to raise_error(Apcera::Error::StagerURLRequired)
13
- end
14
-
15
- it "should initialize with the stager url passed as an argument" do
16
- stager = Apcera::Stager.new({:stager_url => @stager_url})
17
- stager.class.should == Apcera::Stager
18
- stager.stager_url.should == @stager_url
19
- end
9
+ describe "initialize" do
10
+ it "should raise an exception when initialized without a stager url" do
11
+ expect { Apcera::Stager.new }.to raise_error(Apcera::Error::StagerURLRequired)
12
+ end
20
13
 
21
- it "should initialize when the ENV variable STAGER_URL is present" do
22
- begin
23
- ENV["STAGER_URL"] = @stager_url
24
- stager = Apcera::Stager.new
14
+ it "should initialize with the stager url passed as an argument" do
15
+ stager = Apcera::Stager.new({:stager_url => @stager_url})
25
16
  stager.class.should == Apcera::Stager
26
17
  stager.stager_url.should == @stager_url
27
- ensure
28
- ENV["STAGER_URL"] = nil
18
+ end
19
+
20
+ it "should initialize when the ENV variable STAGER_URL is present" do
21
+ begin
22
+ ENV["STAGER_URL"] = @stager_url
23
+ stager = Apcera::Stager.new
24
+ stager.class.should == Apcera::Stager
25
+ stager.stager_url.should == @stager_url
26
+ ensure
27
+ ENV["STAGER_URL"] = nil
28
+ end
29
29
  end
30
30
  end
31
31
 
@@ -76,38 +76,40 @@ describe Apcera::Stager do
76
76
  end
77
77
 
78
78
  context "extract" do
79
- it "should decompress the package to a supplied path" do
79
+ before do
80
80
  VCR.use_cassette('download') do
81
81
  @stager.download
82
82
  end
83
+ end
83
84
 
85
+ it "should decompress the package to a supplied path" do
84
86
  @stager.extract(@appdir)
85
- File.exists?(File.join(@stager.root_path, @appdir)).should == true
87
+ expected_path = File.join(@stager.root_path, @appdir)
88
+ File.exists?(expected_path).should == true
89
+ @stager.app_path.should == expected_path
86
90
  end
87
91
 
88
92
  it "should bubble errors to fail" do
89
93
  @stager.should_receive(:exit0r).with(1) { raise }
90
94
 
91
95
  err = Apcera::Error::ExecuteError.new
92
- @stager.should_receive(:execute_app).and_raise(err)
96
+ @stager.should_receive(:execute_app).with("tar -zxf #{@stager.pkg_path}").and_raise(err)
93
97
 
94
- VCR.use_cassette('download') do
95
- @stager.download
96
- end
97
-
98
- expect { @stager.extract(@appdir) }.to raise_error(err)
98
+ expect { @stager.extract(@appdir) }.to raise_error(err.class)
99
99
  end
100
100
  end
101
101
 
102
102
  context "execute" do
103
- it "should execute commands with clean bundler environment" do
104
- Bundler.should_receive(:with_clean_env).at_least(:once).and_yield
105
-
103
+ before do
106
104
  VCR.use_cassette('download') do
107
105
  @stager.download
108
106
  end
109
107
 
110
108
  @stager.extract(@appdir)
109
+ end
110
+
111
+ it "should execute commands with clean bundler environment" do
112
+ Bundler.should_receive(:with_clean_env).at_least(:once).and_yield
111
113
 
112
114
  @stager.execute("cat thing").should == nil
113
115
  @stager.execute("cat #{File.join(@stager.app_path, "app", "Gemfile")}").should == true
@@ -116,26 +118,22 @@ describe Apcera::Stager do
116
118
  it "should bubble errors to fail" do
117
119
  @stager.should_receive(:exit0r).with(1) { raise }
118
120
 
119
- VCR.use_cassette('download') do
120
- @stager.download
121
- end
122
-
123
- @stager.extract(@appdir)
124
-
125
121
  cmd = "cat thing"
126
122
  expect {@stager.execute(cmd) }.to raise_error(Apcera::Error::ExecuteError, "failed to execute: #{cmd}.\n")
127
123
  end
128
124
  end
129
125
 
130
126
  context "execute_app" do
131
- it "should execute commands in app dir with clean bundler environment" do
132
- Bundler.should_receive(:with_clean_env).at_least(:once).and_yield
133
-
127
+ before do
134
128
  VCR.use_cassette('download') do
135
129
  @stager.download
136
130
  end
137
131
 
138
132
  @stager.extract(@appdir)
133
+ end
134
+
135
+ it "should execute commands in app dir with clean bundler environment" do
136
+ Bundler.should_receive(:with_clean_env).at_least(:once).and_yield
139
137
 
140
138
  @stager.execute_app("cat thing").should == nil
141
139
  @stager.execute_app("cat #{File.join("app", "Gemfile")}").should == true
@@ -144,40 +142,36 @@ describe Apcera::Stager do
144
142
  it "should bubble errors to fail" do
145
143
  @stager.should_receive(:exit0r).with(1) { raise }
146
144
 
147
- VCR.use_cassette('download') do
148
- @stager.download
149
- end
150
-
151
- @stager.extract(@appdir)
152
-
153
145
  cmd = "cat thing"
154
146
  expect {@stager.execute_app(cmd) }.to raise_error(Apcera::Error::ExecuteError, "failed to execute: #{cmd}.\n")
155
147
  end
156
148
  end
157
149
 
158
150
  context "upload" do
159
- it "should compress a new package and send to the staging coordinator" do
151
+ before do
160
152
  VCR.use_cassette('download') do
161
153
  @stager.download
162
154
  end
163
155
 
164
156
  @stager.extract(@appdir)
157
+ end
165
158
 
159
+ it "should compress a new package and send to the staging coordinator" do
166
160
  VCR.use_cassette('upload') do
167
161
  @stager.upload
168
162
  end
169
163
 
170
- File.exists?(File.join(@stager.root_path, "#{@appdir}.tar.gz"))
164
+ File.exists?(@stager.updated_pkg_path).should == true
171
165
  end
172
166
 
173
- it "should bubble errors to fail" do
174
- @stager.should_receive(:exit0r).with(1) { raise }
167
+ it "should compress using tar czf" do
168
+ @stager.should_receive(:execute_app).with("tar czf #{@stager.updated_pkg_path} #{@stager.app_path}").and_return
175
169
 
176
- VCR.use_cassette('download') do
177
- @stager.download
178
- end
170
+ @stager.upload
171
+ end
179
172
 
180
- @stager.extract(@appdir)
173
+ it "should bubble errors to fail" do
174
+ @stager.should_receive(:exit0r).with(1) { raise }
181
175
 
182
176
  VCR.use_cassette('invalid/upload') do
183
177
  expect { @stager.upload }.to raise_error(RestClient::ResourceNotFound, "404 Resource Not Found")
@@ -186,13 +180,15 @@ describe Apcera::Stager do
186
180
  end
187
181
 
188
182
  context "complete" do
189
- it "should compress a new package and send to the staging coordinator then be done" do
183
+ before do
190
184
  VCR.use_cassette('download') do
191
185
  @stager.download
192
186
  end
193
187
 
194
188
  @stager.extract(@appdir)
189
+ end
195
190
 
191
+ it "should compress a new package and send to the staging coordinator then be done" do
196
192
  VCR.use_cassette('complete') do
197
193
  @stager.complete
198
194
  end
@@ -203,12 +199,6 @@ describe Apcera::Stager do
203
199
  it "should bubble errors to fail" do
204
200
  @stager.should_receive(:exit0r).with(1) { raise }
205
201
 
206
- VCR.use_cassette('download') do
207
- @stager.download
208
- end
209
-
210
- @stager.extract(@appdir)
211
-
212
202
  VCR.use_cassette('invalid/complete') do
213
203
  expect { @stager.complete }.to raise_error(RestClient::ResourceNotFound, "404 Resource Not Found")
214
204
  end
@@ -234,11 +224,16 @@ describe Apcera::Stager do
234
224
  end
235
225
 
236
226
  context "snapshot" do
237
- it "should send a snapshot request to the staging coordinator" do
227
+ before do
238
228
  VCR.use_cassette('download') do
239
229
  @stager.download
240
230
  end
231
+
241
232
  @stager.extract(@appdir)
233
+ end
234
+
235
+ it "should send a snapshot request to the staging coordinator" do
236
+
242
237
  VCR.use_cassette('snapshot') do
243
238
  @stager.snapshot
244
239
  end
@@ -250,10 +245,6 @@ describe Apcera::Stager do
250
245
  it "should bubble errors to fail" do
251
246
  @stager.should_receive(:exit0r).with(1) { raise }
252
247
 
253
- VCR.use_cassette('download') do
254
- @stager.download
255
- end
256
- @stager.extract(@appdir)
257
248
  VCR.use_cassette('invalid/snapshot') do
258
249
  expect { @stager.snapshot }.to raise_error(RestClient::ResourceNotFound, "404 Resource Not Found")
259
250
  end
@@ -471,6 +462,28 @@ describe Apcera::Stager do
471
462
  end
472
463
  end
473
464
 
465
+ context "output" do
466
+ before do
467
+ @stager.unstub(:output)
468
+ end
469
+
470
+ it "should print to stdout" do
471
+ $stdout.should_receive(:puts).with("test")
472
+ @stager.output("test")
473
+ end
474
+ end
475
+
476
+ context "output_error" do
477
+ before do
478
+ @stager.unstub(:output_error)
479
+ end
480
+
481
+ it "should print to stderr" do
482
+ $stderr.should_receive(:puts).with("test")
483
+ @stager.output_error("test")
484
+ end
485
+ end
486
+
474
487
  context "exit0r" do
475
488
  before do
476
489
  @stager.unstub(:exit0r)
@@ -52,4 +52,67 @@ http_interactions:
52
52
  string: OK
53
53
  http_version:
54
54
  recorded_at: Mon, 25 Aug 2014 02:37:56 GMT
55
+ - request:
56
+ method: post
57
+ uri: http://example.com/failed
58
+ body:
59
+ encoding: ASCII-8BIT
60
+ string: ''
61
+ headers:
62
+ Accept:
63
+ - "*/*; q=0.5, application/xml"
64
+ Accept-Encoding:
65
+ - gzip, deflate
66
+ Content-Length:
67
+ - '0'
68
+ Content-Type:
69
+ - application/x-www-form-urlencoded
70
+ User-Agent:
71
+ - Ruby
72
+ response:
73
+ status:
74
+ code: 404
75
+ message: Not Found
76
+ headers:
77
+ Accept-Ranges:
78
+ - bytes
79
+ Cache-Control:
80
+ - max-age=604800
81
+ Content-Type:
82
+ - text/html
83
+ Date:
84
+ - Tue, 26 Aug 2014 08:19:48 GMT
85
+ Etag:
86
+ - '"359670651"'
87
+ Expires:
88
+ - Tue, 02 Sep 2014 08:19:48 GMT
89
+ Last-Modified:
90
+ - Fri, 09 Aug 2013 23:54:35 GMT
91
+ Server:
92
+ - EOS (lax004/45BF)
93
+ X-Ec-Custom-Error:
94
+ - '1'
95
+ Content-Length:
96
+ - '1270'
97
+ body:
98
+ encoding: UTF-8
99
+ string: "<!doctype html>\n<html>\n<head>\n <title>Example Domain</title>\n\n
100
+ \ <meta charset=\"utf-8\" />\n <meta http-equiv=\"Content-type\" content=\"text/html;
101
+ charset=utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width,
102
+ initial-scale=1\" />\n <style type=\"text/css\">\n body {\n background-color:
103
+ #f0f0f2;\n margin: 0;\n padding: 0;\n font-family: \"Open
104
+ Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n \n }\n
105
+ \ div {\n width: 600px;\n margin: 5em auto;\n padding:
106
+ 50px;\n background-color: #fff;\n border-radius: 1em;\n }\n
107
+ \ a:link, a:visited {\n color: #38488f;\n text-decoration:
108
+ none;\n }\n @media (max-width: 700px) {\n body {\n background-color:
109
+ #fff;\n }\n div {\n width: auto;\n margin:
110
+ 0 auto;\n border-radius: 0;\n padding: 1em;\n }\n
111
+ \ }\n </style> \n</head>\n\n<body>\n<div>\n <h1>Example Domain</h1>\n
112
+ \ <p>This domain is established to be used for illustrative examples in
113
+ documents. You may use this\n domain in examples without prior coordination
114
+ or asking for permission.</p>\n <p><a href=\"http://www.iana.org/domains/example\">More
115
+ information...</a></p>\n</div>\n</body>\n</html>\n"
116
+ http_version:
117
+ recorded_at: Tue, 26 Aug 2014 08:19:48 GMT
55
118
  recorded_with: VCR 2.9.2
@@ -27,4 +27,29 @@ http_interactions:
27
27
  string: OK
28
28
  http_version:
29
29
  recorded_at: Mon, 25 Aug 2014 02:37:56 GMT
30
+ - request:
31
+ method: post
32
+ uri: http://example.com/done
33
+ body:
34
+ encoding: US-ASCII
35
+ string: ''
36
+ headers: {}
37
+ response:
38
+ status:
39
+ code: 200
40
+ message: OK
41
+ headers:
42
+ Content-Type:
43
+ - text/html; charset=ISO-8859-1
44
+ Date:
45
+ - Mon, 25 Aug 2014 02:00:56 GMT
46
+ Content-Length:
47
+ - '2'
48
+ Connection:
49
+ - close
50
+ body:
51
+ encoding: US-ASCII
52
+ string: OK
53
+ http_version:
54
+ recorded_at: Mon, 25 Aug 2014 02:00:56 GMT
30
55
  recorded_with: VCR 2.9.2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: continuum-stager-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Ellithorpe
@@ -14,56 +14,56 @@ dependencies:
14
14
  name: rest-client
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 2.6.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 2.6.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
@@ -84,28 +84,28 @@ dependencies:
84
84
  name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ! '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: vcr
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ! '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ! '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  description: Continuum Stager api library
@@ -115,8 +115,8 @@ executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
- - .gitignore
119
- - .travis.yml
118
+ - ".gitignore"
119
+ - ".travis.yml"
120
120
  - CHANGELOG.md
121
121
  - Gemfile
122
122
  - LICENSE
@@ -171,17 +171,17 @@ require_paths:
171
171
  - lib
172
172
  required_ruby_version: !ruby/object:Gem::Requirement
173
173
  requirements:
174
- - - ! '>='
174
+ - - ">="
175
175
  - !ruby/object:Gem::Version
176
176
  version: '0'
177
177
  required_rubygems_version: !ruby/object:Gem::Requirement
178
178
  requirements:
179
- - - ! '>='
179
+ - - ">="
180
180
  - !ruby/object:Gem::Version
181
181
  version: '0'
182
182
  requirements: []
183
183
  rubyforge_project:
184
- rubygems_version: 2.0.7
184
+ rubygems_version: 2.2.2
185
185
  signing_key:
186
186
  specification_version: 4
187
187
  summary: Continuum Stager api library which makes it super easy to write stagers for