lib/fog/ninefold/compute.rb in fog-1.3.1 vs lib/fog/ninefold/compute.rb in fog-1.4.0

- old
+ new

@@ -1,6 +1,6 @@ -require File.expand_path(File.join(File.dirname(__FILE__), '..', 'ninefold')) +require 'fog/ninefold' require 'fog/compute' module Fog module Compute class Ninefold < Fog::Service @@ -61,12 +61,10 @@ request :list_ip_forwarding_rules class Mock def initialize(options) - require 'multi_json' - @api_url = options[:ninefold_api_url] || Fog.credentials[:ninefold_api_url] || API_URL @ninefold_compute_key = options[:ninefold_compute_key] || Fog.credentials[:ninefold_compute_key] @ninefold_compute_secret = options[:ninefold_compute_secret] || Fog.credentials[:ninefold_compute_secret] end @@ -76,25 +74,23 @@ end class Real def initialize(options) - require 'multi_json' - @api_url = options[:ninefold_api_url] || Fog.credentials[:ninefold_api_url] || API_URL @ninefold_compute_key = options[:ninefold_compute_key] || Fog.credentials[:ninefold_compute_key] @ninefold_compute_secret = options[:ninefold_compute_secret] || Fog.credentials[:ninefold_compute_secret] @connection_options = options[:connection_options] || {} @persistent = options[:persistent] || false @connection = Fog::Connection.new(@api_url, @persistent, @connection_options) end def request(command, params, options) params['response'] = "json" - req = "apiKey=#{@ninefold_compute_key}&command=#{command}&" # convert params to strings for sort - req += URI.escape(params.sort_by{|k,v| k.to_s }.collect{|e| "#{e[0].to_s}=#{e[1].to_s}"}.join('&')) + req_params = params.merge('apiKey' => @ninefold_compute_key, 'command' => command) + req = URI.escape(req_params.sort_by{|k,v| k.to_s }.collect{|e| "#{e[0].to_s}=#{e[1].to_s}"}.join('&')) encoded_signature = url_escape(encode_signature(req)) options = { :expects => 200, :method => 'GET', @@ -106,10 +102,10 @@ end unless response.body.empty? # Because the response is some weird xml-json thing, we need to try and mung # the values out with a prefix, and if there is an empty data entry return an # empty version of the expected type (if provided) - response = MultiJson.decode(response.body) + response = Fog::JSON.decode(response.body) if options.has_key? :response_prefix keys = options[:response_prefix].split('/') keys.each do |k| if response[k] response = response[k]