stacker_bee 2.1.0.pre180 → 2.1.0.pre181

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjM2MmUzMTI4NjMzMTkxMjUxOTAzYzk0NzBlN2ZmNGJlNDQ3NjFjYw==
4
+ NDBlNGIwYTAxNmY5Yjk5ZDVkZGZhNmQzMzc3NTlhMWZhN2Y2MDViMQ==
5
5
  data.tar.gz: !binary |-
6
- Yjg3ZGM0M2E3MTU2Yzg1M2Q4YmY3NDZhZjMzNjRiYzIyOWY2ZjhmOQ==
6
+ ZTc3ZDY2NmRkNGJhMWJlMmUyOTJjMGEwOWYwOGMwMzMzNjAzN2RmMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- N2I1ODhiMTY2NWVhYmUxNzE4OWViNTVmZDY4MjgzM2QyOGI0MTkyZDdiNzY1
10
- OTk1YjJiMGIzMDUyYmZlZDQ5NGY4OTQzYzNhMjExZjg5MDk4MDc3ZmZiNzg0
11
- ZTEzZDAxNzdiOTcxMDM0OWM2ZmI1NGRkN2JmNzUxZWZhOGFmYjE=
9
+ ODQwYTg0ODAxNzBiZDFkODQyMzVhMjU1YTcyY2YwOGI0OGNjZTFlOGFlOTRj
10
+ MjQxN2M2N2U2ZDY4YmVhMDgxZWY1YmI4OTc4MWJlYWMyYjI4N2UxZjRlZGEw
11
+ MmIwMzlmOGJkMTE1ZWQ2Nzc1YmZmYTQzNGQzMzQ1OGMyMDg1ZGM=
12
12
  data.tar.gz: !binary |-
13
- ZGIzOWIyYWM0MjZhYTBjOTNiZjVhOWUxZGJiNDg2NDA0MTE3NTM5NDUyN2Jl
14
- ZGU1NzFjMzRhOTUzOTRmNTg4NjQ5NmE0MDBjYWU0NDZlYmExYjk0NDdlZTQ3
15
- MmM0OGZmNTY1MmJlMWRjNzEwOGNjNjc5OGU4OTM4ODViZTUyYzA=
13
+ MDM2NTkxMWY4NDg0ZDQ0MzczYjBkYWMwZmYzODE5MDNjZTRkNTViMmM3MDQz
14
+ NTFjNzA5NzdiZjNjZmVlZmY2ZDQ4NGVmYTRkNWZjOTIwZjU2NTQwYjg1ZjNi
15
+ MzVkYjU1OTQ4ZGYwMWIyNzUxNThlNTVmMjZjNDdkZGJmNTRmYjg=
@@ -17,8 +17,11 @@ module StackerBee
17
17
  uri.path = ''
18
18
  fail ConnectionError, "no protocol specified" unless uri.scheme
19
19
 
20
- ssl_verify = !configuration.ssl_verify.nil? ?
21
- configuration.ssl_verify : true
20
+ ssl_verify = if !configuration.ssl_verify.nil?
21
+ configuration.ssl_verify
22
+ else
23
+ true
24
+ end
22
25
 
23
26
  initialize_faraday(url: uri.to_s,
24
27
  ssl: { verify: ssl_verify })
@@ -31,14 +34,14 @@ module StackerBee
31
34
 
32
35
  configuration.faraday_middlewares.call faraday
33
36
 
34
- unless has_adapter?(faraday.builder.handlers)
37
+ unless using_adapter?(faraday.builder.handlers)
35
38
  faraday.adapter Faraday.default_adapter # Net::HTTP
36
39
  end
37
40
  end
38
41
  end
39
42
 
40
- def has_adapter?(handlers)
41
- handlers.detect do |handler|
43
+ def using_adapter?(handlers)
44
+ handlers.find do |handler|
42
45
  handler.klass.ancestors.include?(Faraday::Adapter)
43
46
  end
44
47
  end
@@ -47,7 +50,7 @@ module StackerBee
47
50
  @faraday.get(path, params)
48
51
  rescue Faraday::Error::ConnectionFailed => error
49
52
  raise ConnectionError,
50
- "Failed to connect to #{configuration.url}, #{error}"
53
+ "Failed to connect to #{configuration.url}, #{error}"
51
54
  end
52
55
  end
53
56
  end
@@ -4,20 +4,20 @@ module StackerBee
4
4
  def after(env)
5
5
  body = env.response.body
6
6
 
7
- return if !is_hash?(body)
7
+ return unless hash?(body)
8
8
 
9
- if has_count?(body)
10
- env.response.body =remove_count(body)
9
+ if contains_count?(body)
10
+ env.response.body = remove_count(body)
11
11
  elsif single_hash?(body)
12
12
  env.response.body = first_hash(body)
13
13
  end
14
14
  end
15
15
 
16
- def is_hash?(body)
16
+ def hash?(body)
17
17
  body.respond_to?(:keys)
18
18
  end
19
19
 
20
- def has_count?(body)
20
+ def contains_count?(body)
21
21
  body.size == 2 && body.key?("count")
22
22
  end
23
23
 
@@ -39,4 +39,3 @@ module StackerBee
39
39
  end
40
40
  end
41
41
  end
42
-
@@ -27,7 +27,9 @@ module StackerBee
27
27
  hashes.each do |hash_name, hash|
28
28
  remove_empties(hash).each_with_index do |(key, value), index|
29
29
  hash_url_key = self.class.tokenize("#{hash_name}[#{index}]")
30
- params["#{hash_url_key}.key"] = params["#{hash_url_key}.name"] = key
30
+
31
+ params["#{hash_url_key}.key"] = key
32
+ params["#{hash_url_key}.name"] = key
31
33
  params["#{hash_url_key}.value"] = value
32
34
  end
33
35
  params.delete hash_name
@@ -39,6 +41,5 @@ module StackerBee
39
41
  hash.reject { |_, v| v.nil? || v == "" }
40
42
  end
41
43
  end
42
-
43
44
  end
44
45
  end
@@ -3,9 +3,7 @@ module StackerBee
3
3
  class EndpointNormalizer < Base
4
4
  def before(env)
5
5
  new_endpoint_name = endpoint_name_for(env.request.endpoint_name)
6
- if new_endpoint_name
7
- env.request.endpoint_name = new_endpoint_name
8
- end
6
+ env.request.endpoint_name = new_endpoint_name if new_endpoint_name
9
7
  end
10
8
 
11
9
  def endpoint_name_for(name)
@@ -16,6 +16,6 @@ describe "A request sent to CloudStack for console access", :vcr do
16
16
  subject(:console_access) { client.console_access(vm: vm) }
17
17
 
18
18
  it "returns html for console access" do
19
- expect(console_access).to match %r{<html>.*<frame src=.*</html>}
19
+ expect(console_access).to match(/<html>.*<frame src=.*<\/html>/)
20
20
  end
21
21
  end
@@ -12,7 +12,7 @@ describe "A response to a request sent to the CloudStack API", :vcr do
12
12
  middlewares: middlewares
13
13
  }
14
14
  end
15
- let(:middlewares) { proc { } }
15
+ let(:middlewares) { proc {} }
16
16
 
17
17
  let(:client) do
18
18
  StackerBee::Client.new(config_hash)
@@ -16,11 +16,11 @@ describe StackerBee::Client, "calling endpoint" do
16
16
  let(:client) do
17
17
  StackerBee::Client.new(
18
18
  url: "http://example.com",
19
- middlewares: ->(builder) do
19
+ middlewares: lambda do |builder|
20
20
  builder.before middleware_class,
21
- expected_endpoint_name: endpoint_name,
22
- expected_params: params,
23
- response_body: response_body
21
+ expected_endpoint_name: endpoint_name,
22
+ expected_params: params,
23
+ response_body: response_body
24
24
  end
25
25
  )
26
26
  end
@@ -28,8 +28,8 @@ describe StackerBee::Client, "calling endpoint" do
28
28
  let(:middleware_class) do
29
29
  Class.new StackerBee::Middleware::Base do
30
30
  def call(env)
31
- raise unless env.request.endpoint_name == expected_endpoint_name
32
- raise unless env.request.params == expected_params
31
+ fail unless env.request.endpoint_name == expected_endpoint_name
32
+ fail unless env.request.params == expected_params
33
33
 
34
34
  env.response.body = response_body
35
35
  end
@@ -60,7 +60,6 @@ describe StackerBee::Client, "calling endpoint" do
60
60
  end
61
61
  end
62
62
 
63
-
64
63
  describe StackerBee::Client, "configuration" do
65
64
  let(:default_url) { "default_cloud-stack.com" }
66
65
  let(:default_api_key) { "default-cloud-stack-api-key" }
@@ -17,7 +17,7 @@ describe StackerBee::Middleware::Adapter do
17
17
  let(:middleware) { described_class.new(app: app, connection: connection) }
18
18
 
19
19
  let(:raw_response) do
20
- double(env: { response_headers: response_headers}, body: response_body)
20
+ double(env: { response_headers: response_headers }, body: response_body)
21
21
  end
22
22
  let(:response_headers) { { "content-type" => content_type } }
23
23
  let(:content_type) { "text/javascript; charset=UTF-8" }
@@ -43,7 +43,7 @@ describe StackerBee::Middleware::Adapter do
43
43
  end
44
44
 
45
45
  it "sorts the paramers" do
46
- connection.should have_received(:get).with([["a", "a"], ["z", "z"]], path)
46
+ connection.should have_received(:get).with([%w(a a), %w(z z)], path)
47
47
  end
48
48
  end
49
49
 
@@ -11,7 +11,7 @@ describe StackerBee::Middleware::Base do
11
11
  let(:middleware) { subclass.new(app: app) }
12
12
 
13
13
  let(:subclass) { Class.new(StackerBee::Middleware::Base, &subclass_body) }
14
- let(:subclass_body) { proc { } }
14
+ let(:subclass_body) { proc {} }
15
15
 
16
16
  describe "#call" do
17
17
  before do
@@ -34,4 +34,3 @@ describe StackerBee::Middleware::CloudStackAPI do
34
34
  its([:command]) { should eq "endpoint-name" }
35
35
  end
36
36
  end
37
-
@@ -42,9 +42,8 @@ describe StackerBee::Middleware::ConsoleAccess do
42
42
  describe "#endpoint_name_for" do
43
43
  context "given names it reponds to" do
44
44
  %w[consoleAccess console_access CONSOLEACCESS].each do |name|
45
- it "returns consoleAccess for '#{name}'" do
46
- middleware.endpoint_name_for(name).should == described_class::ENDPOINT
47
- end
45
+ subject { middleware.endpoint_name_for(name) }
46
+ it { should eq described_class::ENDPOINT }
48
47
  end
49
48
  end
50
49
 
@@ -6,7 +6,7 @@ describe StackerBee::Middleware::FormatValues do
6
6
  let(:params) do
7
7
  {
8
8
  single: 1,
9
- list: [1,2,3]
9
+ list: [1, 2, 3]
10
10
  }
11
11
  end
12
12
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stacker_bee
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0.pre180
4
+ version: 2.1.0.pre181
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Sterndale
@@ -226,7 +226,6 @@ files:
226
226
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/space_character_in_a_request_parameter/properly_signs_the_request.yml
227
227
  - spec/fixtures/4.2.json
228
228
  - spec/fixtures/simple.json
229
- - spec/integration/check_spec.rb
230
229
  - spec/integration/configure_middleware_spec.rb
231
230
  - spec/integration/console_spec.rb
232
231
  - spec/integration/request_spec.rb
@@ -300,7 +299,6 @@ test_files:
300
299
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/space_character_in_a_request_parameter/properly_signs_the_request.yml
301
300
  - spec/fixtures/4.2.json
302
301
  - spec/fixtures/simple.json
303
- - spec/integration/check_spec.rb
304
302
  - spec/integration/configure_middleware_spec.rb
305
303
  - spec/integration/console_spec.rb
306
304
  - spec/integration/request_spec.rb
@@ -1,48 +0,0 @@
1
- if false
2
- require 'spec_helper'
3
-
4
- describe "Client initialization configures the middleware" do
5
- context "pass a new middleware to the client" do
6
- subject { StackerBee::Client.new(config_hash) }
7
-
8
- let(:url) { CONFIG["url"] }
9
- let(:config_hash) do
10
- {
11
- url: url,
12
- api_key: api_key,
13
- secret_key: secret_key,
14
- apis_path: File.join(File.dirname(__FILE__), '../fixtures/4.2.json'),
15
- faraday_middlewares: ->(faraday) { faraday.use middleware_class }
16
- }
17
- end
18
-
19
- let(:middleware_class) do
20
- Class.new(Faraday::Middleware) do
21
- def call(env)
22
- $query = env[:url].query
23
- fail "MiddlewareUsed"
24
- end
25
- end
26
- end
27
-
28
- before do
29
- $query = nil
30
- end
31
-
32
- data = JSON.parse(File.read("/Users/mike/Desktop/stuff.json"))
33
- data.each do |request|
34
- context "something" do
35
- let(:api_key) { request["config"]["api_key"] }
36
- let(:secret_key) { request["config"]["secret_key"] }
37
- it do
38
- expect {
39
- subject.request(*request["input"])
40
- }.to raise_exception "MiddlewareUsed"
41
-
42
- $query.should == request["query"]
43
- end
44
- end
45
- end
46
- end
47
- end
48
- end