mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #3245 from fcheung/remove_fog_core_parser
[Fog|Core] Move fog/core/parser to fog-xml gem
This commit is contained in:
commit
a29fcd8a53
26 changed files with 7 additions and 136 deletions
|
@ -48,7 +48,7 @@ Gem::Specification.new do |s|
|
|||
## that are needed for an end user to actually USE your code.
|
||||
s.add_dependency("fog-core", "~> 1.24")
|
||||
s.add_dependency("fog-json")
|
||||
s.add_dependency("fog-xml")
|
||||
s.add_dependency("fog-xml", "~> 0.1.1")
|
||||
|
||||
s.add_dependency('nokogiri', '~> 1.5', '>= 1.5.11')
|
||||
s.add_dependency('ipaddress', '~>0.5')
|
||||
|
|
|
@ -10,7 +10,6 @@ require 'fog/core'
|
|||
# data exchange specific (to be extracted and used on a per provider basis)
|
||||
require 'fog/xml'
|
||||
require 'fog/json'
|
||||
require 'fog/core/parser'
|
||||
|
||||
# deprecation wrappers (XML wrapped version)
|
||||
require 'fog/core/deprecated/connection'
|
||||
|
|
|
@ -86,8 +86,6 @@ module Fog
|
|||
# * AutoScaling object with connection to AWS.
|
||||
|
||||
def initialize(options={})
|
||||
require 'fog/core/parser'
|
||||
|
||||
@use_iam_profile = options[:use_iam_profile]
|
||||
|
||||
@connection_options = options[:connection_options] || {}
|
||||
|
|
|
@ -64,7 +64,6 @@ module Fog
|
|||
class Real
|
||||
include Fog::AWS::CredentialFetcher::ConnectionMethods
|
||||
def initialize(options={})
|
||||
require 'fog/core/parser'
|
||||
|
||||
@use_iam_profile = options[:use_iam_profile]
|
||||
|
||||
|
|
|
@ -142,7 +142,6 @@ EOF
|
|||
# ==== Returns
|
||||
# * cdn object with connection to aws.
|
||||
def initialize(options={})
|
||||
require 'fog/core/parser'
|
||||
|
||||
@use_iam_profile = options[:use_iam_profile]
|
||||
setup_credentials(options)
|
||||
|
|
|
@ -46,7 +46,6 @@ module Fog
|
|||
# ==== Returns
|
||||
# * CloudFormation object with connection to AWS.
|
||||
def initialize(options={})
|
||||
require 'fog/core/parser'
|
||||
|
||||
@use_iam_profile = options[:use_iam_profile]
|
||||
|
||||
|
|
|
@ -449,7 +449,6 @@ module Fog
|
|||
attr_accessor :region
|
||||
|
||||
def initialize(options={})
|
||||
require 'fog/core/parser'
|
||||
|
||||
@connection_options = options[:connection_options] || {}
|
||||
@region = options[:region] ||= 'us-east-1'
|
||||
|
|
|
@ -90,7 +90,6 @@ module Fog
|
|||
# ==== Returns
|
||||
# * dns object with connection to aws.
|
||||
def initialize(options={})
|
||||
require 'fog/core/parser'
|
||||
|
||||
@use_iam_profile = options[:use_iam_profile]
|
||||
setup_credentials(options)
|
||||
|
|
|
@ -131,7 +131,6 @@ module Fog
|
|||
# ==== Returns
|
||||
# * ELB object with connection to AWS.
|
||||
def initialize(options={})
|
||||
require 'fog/core/parser'
|
||||
|
||||
@use_iam_profile = options[:use_iam_profile]
|
||||
@connection_options = options[:connection_options] || {}
|
||||
|
|
|
@ -173,7 +173,6 @@ module Fog
|
|||
# ==== Returns
|
||||
# * IAM object with connection to AWS.
|
||||
def initialize(options={})
|
||||
require 'fog/core/parser'
|
||||
|
||||
@use_iam_profile = options[:use_iam_profile]
|
||||
@connection_options = options[:connection_options] || {}
|
||||
|
|
|
@ -48,7 +48,6 @@ module Fog
|
|||
# ==== Returns
|
||||
# * SES object with connection to AWS.
|
||||
def initialize(options={})
|
||||
require 'fog/core/parser'
|
||||
|
||||
@use_iam_profile = options[:use_iam_profile]
|
||||
setup_credentials(options)
|
||||
|
|
|
@ -70,7 +70,6 @@ module Fog
|
|||
# ==== Returns
|
||||
# * SimpleDB object with connection to aws.
|
||||
def initialize(options={})
|
||||
require 'fog/core/parser'
|
||||
|
||||
@use_iam_profile = options[:use_iam_profile]
|
||||
setup_credentials(options)
|
||||
|
|
|
@ -415,7 +415,6 @@ module Fog
|
|||
# ==== Returns
|
||||
# * S3 object with connection to aws.
|
||||
def initialize(options={})
|
||||
require 'fog/core/parser'
|
||||
|
||||
@use_iam_profile = options[:use_iam_profile]
|
||||
@instrumentor = options[:instrumentor]
|
||||
|
|
|
@ -72,7 +72,6 @@ module Fog
|
|||
# ==== Returns
|
||||
# * STS object with connection to AWS.
|
||||
def initialize(options={})
|
||||
require 'fog/core/parser'
|
||||
|
||||
@use_iam_profile = options[:use_iam_profile]
|
||||
setup_credentials(options)
|
||||
|
|
|
@ -45,7 +45,6 @@ module Fog
|
|||
|
||||
class Real
|
||||
def initialize(options={})
|
||||
require 'fog/core/parser'
|
||||
|
||||
@bare_metal_cloud_password = options[:bare_metal_cloud_password]
|
||||
@bare_metal_cloud_username = options[:bare_metal_cloud_username]
|
||||
|
|
|
@ -1,112 +1,2 @@
|
|||
require "nokogiri"
|
||||
|
||||
module Fog
|
||||
module Parsers
|
||||
class Base < Nokogiri::XML::SAX::Document
|
||||
attr_reader :response
|
||||
|
||||
def initialize
|
||||
reset
|
||||
end
|
||||
|
||||
def attr_value(name, attrs)
|
||||
(entry = attrs.find {|a, v| a == name }) && entry.last
|
||||
end
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def characters(string)
|
||||
@value ||= ''
|
||||
@value << string
|
||||
end
|
||||
|
||||
# ###############################################################################
|
||||
# This is a workaround. Original implementation from Nokogiri is overwritten with
|
||||
# one that does not join namespace prefix with local name.
|
||||
def start_element_namespace name, attrs = [], prefix = nil, uri = nil, ns = []
|
||||
start_element name, attrs
|
||||
end
|
||||
|
||||
def end_element_namespace name, prefix = nil, uri = nil
|
||||
end_element name
|
||||
end
|
||||
|
||||
# ###############################################################################
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
@value = nil
|
||||
end
|
||||
|
||||
def value
|
||||
@value && @value.dup
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module Fog
|
||||
class ToHashDocument < Nokogiri::XML::SAX::Document
|
||||
def initialize
|
||||
@stack = []
|
||||
end
|
||||
|
||||
def characters(string)
|
||||
@value ||= ''
|
||||
@value << string.strip
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
last = @stack.pop
|
||||
if last.empty? && @value.empty?
|
||||
@stack.last[name.to_sym] = ''
|
||||
elsif last == {:i_nil=>"true"}
|
||||
@stack.last[name.to_sym] = nil
|
||||
elsif !@value.empty?
|
||||
@stack.last[name.to_sym] = @value
|
||||
end
|
||||
@value = ''
|
||||
end
|
||||
|
||||
def body
|
||||
@stack.first
|
||||
end
|
||||
|
||||
def response
|
||||
body
|
||||
end
|
||||
|
||||
def start_element(name, attributes = [])
|
||||
@value = ''
|
||||
parsed_attributes = {}
|
||||
until attributes.empty?
|
||||
if attributes.first.is_a?(Array)
|
||||
key, value = attributes.shift
|
||||
else
|
||||
key, value = attributes.shift, attributes.shift
|
||||
end
|
||||
parsed_attributes[key.gsub(':','_').to_sym] = value
|
||||
end
|
||||
if @stack.last.is_a?(Array)
|
||||
@stack.last << {name.to_sym => parsed_attributes}
|
||||
else
|
||||
data = if @stack.empty?
|
||||
@stack.push(parsed_attributes)
|
||||
parsed_attributes
|
||||
elsif @stack.last[name.to_sym]
|
||||
unless @stack.last[name.to_sym].is_a?(Array)
|
||||
@stack.last[name.to_sym] = [@stack.last[name.to_sym]]
|
||||
end
|
||||
@stack.last[name.to_sym] << parsed_attributes
|
||||
@stack.last[name.to_sym].last
|
||||
else
|
||||
@stack.last[name.to_sym] = {}
|
||||
@stack.last[name.to_sym].merge!(parsed_attributes)
|
||||
@stack.last[name.to_sym]
|
||||
end
|
||||
@stack.push(data)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Fog::Logger.deprecation("fog/core/parser is deprecated use fog/xml instead [light_black](#{caller.first})[/]")
|
||||
require 'fog/xml'
|
|
@ -76,7 +76,6 @@ module Fog
|
|||
# ==== Returns
|
||||
# * dns object with connection to aws.
|
||||
def initialize(options={})
|
||||
require 'fog/core/parser'
|
||||
|
||||
@dnsmadeeasy_api_key = options[:dnsmadeeasy_api_key]
|
||||
@dnsmadeeasy_secret_key = options[:dnsmadeeasy_secret_key]
|
||||
|
|
|
@ -2,7 +2,6 @@ require 'nokogiri'
|
|||
|
||||
require 'fog/core'
|
||||
require 'fog/xml'
|
||||
require 'fog/core/parser'
|
||||
|
||||
module Fog
|
||||
module Dynect
|
||||
|
|
|
@ -284,7 +284,6 @@ module Fog
|
|||
end
|
||||
|
||||
def initialize(options = {})
|
||||
require 'fog/core/parser'
|
||||
@base_path = options[:base_path] || '/cloudapi/ecloud'
|
||||
@connections = {}
|
||||
@connection_options = options[:connection_options] || {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'fog/core'
|
||||
|
||||
require 'fog/xml'
|
||||
module Fog
|
||||
module Ecloud
|
||||
ECLOUD_OPTIONS = [:ecloud_authentication_method]
|
||||
|
|
|
@ -211,7 +211,6 @@ module Fog
|
|||
# ==== Returns
|
||||
# * Storage object with connection to google.
|
||||
def initialize(options={})
|
||||
require 'fog/core/parser'
|
||||
|
||||
@google_storage_access_key_id = options[:google_storage_access_key_id]
|
||||
@google_storage_secret_access_key = options[:google_storage_secret_access_key]
|
||||
|
|
|
@ -240,7 +240,6 @@ module Fog
|
|||
# ==== Returns
|
||||
# * S3 object with connection to aws.
|
||||
def initialize(options={})
|
||||
require 'fog/core/parser'
|
||||
|
||||
setup_credentials(options)
|
||||
@connection_options = options[:connection_options] || {}
|
||||
|
|
|
@ -179,7 +179,6 @@ module Fog
|
|||
|
||||
def initialize(options = {})
|
||||
require 'builder'
|
||||
require 'fog/core/parser'
|
||||
|
||||
@connections = {}
|
||||
@connection_options = options[:connection_options] || {}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require 'fog/core'
|
||||
require 'fog/xml'
|
||||
|
||||
module Fog
|
||||
module Vcloud
|
||||
|
|
|
@ -67,7 +67,6 @@ module Fog
|
|||
|
||||
class Real
|
||||
def initialize(options={})
|
||||
require 'fog/core/parser'
|
||||
|
||||
@zerigo_email = options[:zerigo_email]
|
||||
@zerigo_token = options[:zerigo_token]
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
Shindo.tests('Fog::Compute[:aws] | tag requests', ['aws']) do
|
||||
Fog::Compute::AWS::Mock.reset if Fog.mocking?
|
||||
|
||||
@tags_format = {
|
||||
'tagSet' => [{
|
||||
'key' => String,
|
||||
|
|
Loading…
Add table
Reference in a new issue