continuum-stager-api 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 12edd2b8b9c59ea9e1559d0d82a70dcd80974852
4
- data.tar.gz: 4ff0c5b27bcce22bbfceeeb0efbbb42ec58f9156
3
+ metadata.gz: c915dbe247ca720afed7f0c88727537f61422181
4
+ data.tar.gz: b311c1b061e61b7c3bd082cbee449574ad24b1fb
5
5
  SHA512:
6
- metadata.gz: 882efbf11bd13e8d214ab3da90bec6305fd6d77d3bd1bf8e1c02b5b428ebed875a79a1df9d92db6882b08d1fe51c960dcd059fd8a6f84ce04f742f4d30f66621
7
- data.tar.gz: 428d0d08dd667c23809f312c89cbde645d0971b8f4605788faafe4c92e1a3ac3199667972172a16ccfa31b55e524f1b780eaa73d23bac41ada92dacf77290ae9
6
+ metadata.gz: f0e7376958039ab0c30e9b44f128a5985e83f9bf8897a21af5ac1c6b0aac2b2e6c1bb81c657ba4e39dccaf302d0f101617f5520949e499ec48356fd53bde305b
7
+ data.tar.gz: 7044cce662b548f8582f17a4cbb970ea082c14cc5ae9aea41788f1af2487617e2bf9e94ecf72bd0e860578953e7fd54115db485b6862c4efda3be093f46e1989
@@ -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.8"
18
+ gem.version = "0.1.9"
19
19
 
20
20
  gem.add_development_dependency 'rspec', '~> 2.6.0'
21
21
  gem.add_development_dependency 'rake'
@@ -1,5 +1,6 @@
1
1
  module Apcera
2
2
  module Error
3
+ class DownloadError < StandardError; end
3
4
  class StagerURLRequired < StandardError; end
4
5
  class ExecuteError < StandardError; end
5
6
  class AppPathError < StandardError; end
@@ -15,10 +15,24 @@ module Apcera
15
15
  end
16
16
 
17
17
  # Download a package from the staging coordinator.
18
+ # We use Net::HTTP here because it supports streaming downloads.
18
19
  def download
19
- response = RestClient.get(@stager_url + "/data")
20
- File.open(@pkg_path, "wb") do |f|
21
- f.write(response.to_str)
20
+ uri = URI(@stager_url + "/data")
21
+
22
+ Net::HTTP.start(uri.host, uri.port) do |http|
23
+ request = Net::HTTP::Get.new uri
24
+
25
+ http.request request do |response|
26
+ if response.code.to_i == 200
27
+ open @pkg_path, 'wb' do |io|
28
+ response.read_body do |chunk|
29
+ io.write chunk
30
+ end
31
+ end
32
+ else
33
+ raise Apcera::Error::DownloadError.new("package download failed.\n")
34
+ end
35
+ end
22
36
  end
23
37
  rescue => e
24
38
  fail e
@@ -70,7 +70,7 @@ describe Apcera::Stager do
70
70
  @stager.should_receive(:exit0r).with(1) { raise }
71
71
 
72
72
  VCR.use_cassette('invalid/download') do
73
- expect { @stager.download }.to raise_error(RestClient::ResourceNotFound, "404 Resource Not Found")
73
+ expect { @stager.download }.to raise_error(Apcera::Error::DownloadError, "package download failed.\n")
74
74
  end
75
75
  end
76
76
  end
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.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Ellithorpe