Class: Awsum::Ec2::SecurityGroupParser
- Defined in:
- lib/ec2/security_group.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(ec2) ⇒ SecurityGroupParser
constructor
A new instance of SecurityGroupParser.
- #result ⇒ Object
- #tag_end(tag) ⇒ Object
- #tag_start(tag, attributes) ⇒ Object
- #text(text) ⇒ Object
Methods inherited from Parser
Constructor Details
#initialize(ec2) ⇒ SecurityGroupParser
Returns a new instance of SecurityGroupParser.
73 74 75 76 77 78 79 80 |
# File 'lib/ec2/security_group.rb', line 73 def initialize(ec2) @ec2 = ec2 @security_groups = [] @text = nil @stack = [] = [] = [] end |
Instance Method Details
#result ⇒ Object
170 171 172 |
# File 'lib/ec2/security_group.rb', line 170 def result @security_groups end |
#tag_end(tag) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/ec2/security_group.rb', line 116 def tag_end(tag) case tag when 'DescribeSecurityGroupsResponse', 'requestId' #no-op when 'securityGroupInfo', 'ipPermissions', 'groups', 'ipRanges' @stack.pop when 'item' case @stack[-1] when 'securityGroupInfo' @security_groups << SecurityGroup.new( @ec2, @current['groupName'], @current['groupDescription'], @current['ownerId'], , ) @text = '' when 'groups' << SecurityGroup::GroupPermission.new( ['ipProtocol'], ['fromPort'], ['toPort'], @group_info['groupName'], @group_info['userId'] ) when 'ipRanges' << SecurityGroup::IpPermission.new( ['ipProtocol'], ['fromPort'], ['toPort'], @ip_info['cidrIp'] ) end else unless @text.nil? text = @text.strip text = (text == '' ? nil : text) case @stack[-1] when 'securityGroupInfo' @current[tag] = text when 'ipPermissions' [tag] = text when 'groups' @group_info[tag] = text when 'ipRanges' @ip_info[tag] = text end @text = '' end end end |
#tag_start(tag, attributes) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/ec2/security_group.rb', line 82 def tag_start(tag, attributes) case tag when 'securityGroupInfo' @stack << 'securityGroupInfo' when 'ipPermissions' @stack << 'ipPermissions' when 'groups' @stack << 'groups' when 'ipRanges' @stack << 'ipRanges' when 'item' case @stack[-1] when 'securityGroupInfo' @current = {} = [] = [] @text = '' when 'ipPermissions' = {} @text = '' when 'groups' @group_info = {} @text = '' when 'ipRanges' @ip_info = {} @text = '' end end end |
#text(text) ⇒ Object
112 113 114 |
# File 'lib/ec2/security_group.rb', line 112 def text(text) @text << text unless @text.nil? end |