Class: Fog::Parsers::AWS::ElasticBeanstalk::BaseParser
- Inherits:
-
Base
- Object
- Nokogiri::XML::SAX::Document
- Base
- Fog::Parsers::AWS::ElasticBeanstalk::BaseParser
show all
- Defined in:
- lib/fog/aws/parsers/beanstalk/parser.rb
Direct Known Subclasses
CheckDNSAvailability, CreateApplication, CreateApplicationVersion, CreateConfigurationTemplate, CreateEnvironment, CreateStorageLocation, DescribeApplicationVersions, DescribeApplications, DescribeConfigurationOptions, DescribeConfigurationSettings, DescribeEnvironmentResources, DescribeEnvironments, DescribeEvents, ListAvailableSolutionStacks, RetrieveEnvironmentInfo, TerminateEnvironment, UpdateApplication, UpdateApplicationVersion, UpdateConfigurationTemplate, UpdateEnvironment, ValidateConfigurationSettings
Instance Attribute Summary
Attributes inherited from Base
#response
Instance Method Summary
collapse
Methods inherited from Base
#attr_value, #characters, #value
Constructor Details
#initialize(result_name) ⇒ BaseParser
Returns a new instance of BaseParser.
8
9
10
11
12
13
|
# File 'lib/fog/aws/parsers/beanstalk/parser.rb', line 8
def initialize(result_name)
@result_name = result_name super()
@tags = {}
@list_tags = {}
end
|
Instance Method Details
#end_element(name) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/fog/aws/parsers/beanstalk/parser.rb', line 50
def end_element(name)
case name
when 'member'
if @parse_stack.last[:type] != :object
@parse_stack.last[:value] << value
end
when 'RequestId'
@response['ResponseMetadata'][name] = value
else
if @list_tags.has_key?(name) || @tags[name] == :object
@parse_stack.pop()
elsif @tags.has_key?(name)
set_value(name, value, @tags[name])
end
end
end
|
#get_parent ⇒ Object
68
69
70
71
|
# File 'lib/fog/aws/parsers/beanstalk/parser.rb', line 68
def get_parent
parent = @parse_stack.last[:value]
parent.is_a?(Array) ? parent.last : parent
end
|
#reset ⇒ Object
15
16
17
18
19
|
# File 'lib/fog/aws/parsers/beanstalk/parser.rb', line 15
def reset
@response = { @result_name => {}, 'ResponseMetadata' => {} }
@parse_stack = [ { :type => :object, :value => @response[@result_name]} ]
end
|
#set_value(name, value, type) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/fog/aws/parsers/beanstalk/parser.rb', line 73
def set_value(name, value, type)
case type
when :datetime
get_parent[name] = Time.parse value
when :boolean
get_parent[name] = value == "true" when :integer
get_parent[name] = value.to_i
else
get_parent[name] = value
end
end
|
#start_element(name, attrs = []) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/fog/aws/parsers/beanstalk/parser.rb', line 35
def start_element(name, attrs = [])
super
if name == 'member'
if @parse_stack.last[:type] == :object
@parse_stack.last[:value] << {} end
elsif @list_tags.has_key?(name)
set_value(name, [], :array) @parse_stack.push({ :type => @tags[name], :value => get_parent[name] })
elsif @tags[name] == :object
set_value(name, {}, :object)
@parse_stack.push({ :type => @tags[name], :value => get_parent[name] })
end
end
|
#tag(name, *traits) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/fog/aws/parsers/beanstalk/parser.rb', line 22
def tag name, *traits
if traits.delete(:list)
@list_tags[name] = true
end
if traits.length == 1
@tags[name] = traits.last
else
raise "Too many traits specified, only specify :list or a type"
end
end
|