ridley 0.12.3 → 0.12.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -45,5 +45,5 @@ group :test do
45
45
  gem 'fuubar'
46
46
  gem 'json_spec'
47
47
  gem 'webmock'
48
- gem 'chef-zero', '>= 1.0.1'
48
+ gem 'chef-zero', '~> 1.1.1'
49
49
  end
@@ -4,6 +4,7 @@ require 'celluloid'
4
4
  require 'chozo'
5
5
  require 'faraday'
6
6
  require 'forwardable'
7
+ require 'hashie'
7
8
  require 'json'
8
9
  require 'pathname'
9
10
  require 'solve'
@@ -67,10 +67,7 @@ module Ridley
67
67
  include Celluloid
68
68
  include Ridley::Logging
69
69
 
70
- finalizer do
71
- @connection_supervisor.terminate if @connection_supervisor && @connection_supervisor.alive?
72
- @resources_supervisor.terminate if @resources_supervisor && @resources_supervisor.alive?
73
- end
70
+ finalizer :finalize_callback
74
71
 
75
72
  def_delegator :connection, :build_url
76
73
  def_delegator :connection, :scheme
@@ -251,5 +248,10 @@ module Ridley
251
248
  def connection
252
249
  @connection_registry[:connection_pool]
253
250
  end
251
+
252
+ def finalize_callback
253
+ @connection_supervisor.terminate if @connection_supervisor && @connection_supervisor.alive?
254
+ @resources_supervisor.terminate if @resources_supervisor && @resources_supervisor.alive?
255
+ end
254
256
  end
255
257
  end
@@ -48,8 +48,6 @@ module Ridley
48
48
  @retry_interval = options[:retry_interval]
49
49
 
50
50
  options[:builder] = Faraday::Builder.new do |b|
51
- b.response :json
52
- b.response :gzip
53
51
  b.request :retry,
54
52
  max: @retries,
55
53
  interval: @retry_interval,
@@ -58,9 +56,12 @@ module Ridley
58
56
  Errno::ETIMEDOUT,
59
57
  Faraday::Error::TimeoutError
60
58
  ]
61
- b.response :chef_response
62
59
  b.request :chef_auth, client_name, client_key
63
60
 
61
+ b.response :parse_json
62
+ b.response :gzip
63
+ b.response :chef_response
64
+
64
65
  b.adapter :net_http_persistent
65
66
  end
66
67
 
@@ -22,7 +22,7 @@ module Ridley
22
22
  # @return [Array]
23
23
  attr_reader :command_uploaders
24
24
 
25
- finalizer :finalizer
25
+ finalizer :finalize_callback
26
26
 
27
27
  EMBEDDED_RUBY_PATH = 'C:\opscode\chef\embedded\bin\ruby'.freeze
28
28
 
@@ -42,10 +42,6 @@ module Ridley
42
42
  @command_uploaders = Array.new
43
43
  end
44
44
 
45
- def finalizer
46
- command_uploaders.map(&:cleanup)
47
- end
48
-
49
45
  def run(command)
50
46
  response = Ridley::HostConnector::Response.new(host)
51
47
  command_uploaders << command_uploader = CommandUploader.new(winrm)
@@ -151,6 +147,12 @@ module Ridley
151
147
  command = "#{EMBEDDED_RUBY_PATH} -e \"#{command_lines.join(';')}\""
152
148
  run(command)
153
149
  end
150
+
151
+ private
152
+
153
+ def finalize_callback
154
+ command_uploaders.map(&:cleanup)
155
+ end
154
156
  end
155
157
  end
156
158
  end
@@ -96,8 +96,6 @@ module Ridley
96
96
  end
97
97
 
98
98
  def on_complete(env)
99
- log.debug(env)
100
-
101
99
  if self.class.json_response?(env)
102
100
  log.debug { "==> parsing Chef response body as JSON" }
103
101
  env[:body] = self.class.parse(env[:body])
@@ -109,4 +107,4 @@ module Ridley
109
107
  end
110
108
  end
111
109
 
112
- Faraday.register_middleware(:response, json: Ridley::Middleware::ParseJson)
110
+ Faraday.register_middleware(:response, parse_json: Ridley::Middleware::ParseJson)
@@ -8,9 +8,7 @@ module Ridley
8
8
 
9
9
  attr_reader :item_resource
10
10
 
11
- finalizer do
12
- item_resource.terminate if item_resource && item_resource.alive?
13
- end
11
+ finalizer :finalize_callback
14
12
 
15
13
  # @param [Celluloid::Registry] connection_registry
16
14
  # @param [String] data_bag_secret
@@ -30,5 +28,11 @@ module Ridley
30
28
  return nil if ex.cause.is_a?(Errors::HTTPNotFound)
31
29
  abort(ex.cause)
32
30
  end
31
+
32
+ private
33
+
34
+ def finalize_callback
35
+ item_resource.terminate if item_resource && item_resource.alive?
36
+ end
33
37
  end
34
38
  end
@@ -4,9 +4,7 @@ module Ridley
4
4
  set_resource_path "sandboxes"
5
5
  represented_by Ridley::SandboxObject
6
6
 
7
- finalizer do
8
- uploader.terminate if uploader && uploader.alive?
9
- end
7
+ finalizer :finalize_callback
10
8
 
11
9
  def initialize(connection_registry, client_name, client_key, options = {})
12
10
  super(connection_registry)
@@ -99,5 +97,9 @@ module Ridley
99
97
  private
100
98
 
101
99
  attr_reader :uploader
100
+
101
+ def finalize_callback
102
+ uploader.terminate if uploader && uploader.alive?
103
+ end
102
104
  end
103
105
  end
@@ -1,3 +1,3 @@
1
1
  module Ridley
2
- VERSION = "0.12.3"
2
+ VERSION = "0.12.4"
3
3
  end
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.add_runtime_dependency 'celluloid', '~> 0.14.0'
23
23
  s.add_runtime_dependency 'erubis'
24
24
  s.add_runtime_dependency 'faraday', '>= 0.8.4'
25
+ s.add_runtime_dependency 'hashie', '>= 2.0.2'
25
26
  s.add_runtime_dependency 'mixlib-log', '>= 1.3.0'
26
27
  s.add_runtime_dependency 'mixlib-shellout', '>= 1.1.0'
27
28
  s.add_runtime_dependency 'mixlib-config', '>= 1.1.0'
@@ -25,7 +25,7 @@ describe Ridley::Middleware::ChefResponse do
25
25
  end
26
26
  end
27
27
 
28
- it "returns false if response status is in the 400 range" do
28
+ it "returns false if response status is in the 400 range" do
29
29
  (400..499).each do |code|
30
30
  env.should_receive(:[]).with(:status).and_return(code)
31
31
 
@@ -46,7 +46,7 @@ describe Ridley::Middleware::ChefResponse do
46
46
  subject do
47
47
  Faraday.new(server_url) do |conn|
48
48
  conn.response :chef_response
49
- conn.response :json
49
+ conn.response :parse_json
50
50
  conn.adapter Faraday.default_adapter
51
51
  end
52
52
  end
@@ -73,7 +73,7 @@ describe Ridley::Middleware::ChefResponse do
73
73
 
74
74
  let(:chef_unauthorized) do
75
75
  {
76
- status: 401,
76
+ status: 401,
77
77
  body: generate_normalized_json(error: "401 - Unauthorized. You must properly authenticate your API requests!"),
78
78
  headers: {
79
79
  content_type: "application/json; charset=utf8"
@@ -83,7 +83,7 @@ describe Ridley::Middleware::ChefResponse do
83
83
 
84
84
  let(:chef_forbidden) do
85
85
  {
86
- status: 403,
86
+ status: 403,
87
87
  body: generate_normalized_json(error: "403 - Forbidden."),
88
88
  headers: {
89
89
  content_type: "application/json; charset=utf8"
@@ -170,7 +170,7 @@ describe Ridley::Middleware::ChefResponse do
170
170
  stub_request(:get, File.join(server_url, 'not_existant_route')).to_return(chef_not_found)
171
171
  end
172
172
 
173
- it "raises a Ridley::Errors::HTTPNotFound" do
173
+ it "raises a Ridley::Errors::HTTPNotFound" do
174
174
  lambda {
175
175
  subject.get('not_existant_route')
176
176
  }.should raise_error(Ridley::Errors::HTTPNotFound)
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.12.3
4
+ version: 0.12.4
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: 2013-05-25 00:00:00.000000000 Z
12
+ date: 2013-05-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
@@ -91,6 +91,22 @@ dependencies:
91
91
  - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: 0.8.4
94
+ - !ruby/object:Gem::Dependency
95
+ name: hashie
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: 2.0.2
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: 2.0.2
94
110
  - !ruby/object:Gem::Dependency
95
111
  name: mixlib-log
96
112
  requirement: !ruby/object:Gem::Requirement
@@ -409,7 +425,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
409
425
  version: '0'
410
426
  segments:
411
427
  - 0
412
- hash: 3894427319828211488
428
+ hash: 744717169722095875
413
429
  requirements: []
414
430
  rubyforge_project:
415
431
  rubygems_version: 1.8.23