ridley 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -34,6 +34,8 @@ module Ridley
34
34
  def_delegator :conn, :port
35
35
  def_delegator :conn, :path_prefix
36
36
 
37
+ def_delegator :conn, :url_prefix=
38
+
37
39
  def_delegator :conn, :get
38
40
  def_delegator :conn, :put
39
41
  def_delegator :conn, :post
@@ -79,6 +81,10 @@ module Ridley
79
81
  @organization = options.fetch(:organization, nil)
80
82
  @thread_count = options.fetch(:thread_count, DEFAULT_THREAD_COUNT)
81
83
 
84
+ unless @client_key.present? && File.exist?(@client_key)
85
+ raise Errors::ClientKeyFileNotFound, "client key not found at: '#{@client_key}'"
86
+ end
87
+
82
88
  faraday_options = options.slice(:params, :headers, :request, :ssl, :proxy)
83
89
  uri_hash = Addressable::URI.parse(options[:server_url]).to_hash.slice(:scheme, :host, :port)
84
90
 
data/lib/ridley/errors.rb CHANGED
@@ -17,6 +17,8 @@ module Ridley
17
17
  alias_method :to_s, :message
18
18
  end
19
19
 
20
+ class ClientKeyFileNotFound < RidleyError; end
21
+
20
22
  class HTTPError < RidleyError
21
23
  class << self
22
24
  def fabricate(env)
@@ -75,11 +75,23 @@ module Ridley
75
75
  }
76
76
  contents = File.open(path, 'rb') { |f| f.read }
77
77
 
78
- if connection.hosted?
79
- Faraday.put(checksum[:url], contents, headers)
80
- else
81
- connection.put(URI(checksum[:url]).path, contents, headers)
82
- end
78
+ # Hosted Chef returns Amazon S3 URLs for where to upload
79
+ # checksums to. OSS Chef Server and Hosted Chef return URLs
80
+ # to the same Chef API that the Sandbox creation request was
81
+ # sent to.
82
+ #
83
+ # The connection object is duplicated to ensure all of our connection
84
+ # settings persist, but the scheme, host, and port are set to the
85
+ # value of the given checksum.
86
+ conn = connection.send(:conn).dup
87
+
88
+ url = URI(checksum[:url])
89
+ upload_path = url.path
90
+ url.path = ""
91
+
92
+ conn.url_prefix = url.to_s
93
+
94
+ conn.put(upload_path, contents, headers)
83
95
  end
84
96
 
85
97
  def commit
@@ -1,3 +1,3 @@
1
1
  module Ridley
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -88,6 +88,14 @@ describe Ridley::Connection do
88
88
  )
89
89
  }.should raise_error(ArgumentError, "Missing required option(s): 'client_key'")
90
90
  end
91
+
92
+ it "raises a ClientKeyFileNotFound if the filepath for client_key is not found" do
93
+ config[:client_key] = "/tmp/nofile.xxsa"
94
+
95
+ lambda {
96
+ subject.new(config)
97
+ }.should raise_error(Ridley::Errors::ClientKeyFileNotFound)
98
+ end
91
99
  end
92
100
 
93
101
  describe "::sync" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ridley
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-20 00:00:00.000000000 Z
12
+ date: 2012-09-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yajl-ruby
@@ -418,7 +418,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
418
418
  version: '0'
419
419
  segments:
420
420
  - 0
421
- hash: -2069225012835502679
421
+ hash: 3051717703450695836
422
422
  requirements: []
423
423
  rubyforge_project:
424
424
  rubygems_version: 1.8.23