Class: Awsum::Ec2::SecurityGroupParser
- Defined in:
- lib/awsum/ec2/parsers/security_group_parser.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.
4 5 6 7 8 9 10 11 |
# File 'lib/awsum/ec2/parsers/security_group_parser.rb', line 4 def initialize(ec2) @ec2 = ec2 @security_groups = [] @text = nil @stack = [] @group_permissions = [] @ip_permissions = [] end |
Instance Method Details
#result ⇒ Object
101 102 103 |
# File 'lib/awsum/ec2/parsers/security_group_parser.rb', line 101 def result @security_groups end |
#tag_end(tag) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/awsum/ec2/parsers/security_group_parser.rb', line 47 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'], @ip_permissions, @group_permissions ) @text = '' when 'groups' @group_permissions << SecurityGroup::GroupPermission.new( @permissions['ipProtocol'], @permissions['fromPort'], @permissions['toPort'], @group_info['groupName'], @group_info['userId'] ) when 'ipRanges' @ip_permissions << SecurityGroup::IpPermission.new( @permissions['ipProtocol'], @permissions['fromPort'], @permissions['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' @permissions[tag] = text when 'groups' @group_info[tag] = text when 'ipRanges' @ip_info[tag] = text end @text = '' end end end |
#tag_start(tag, attributes) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/awsum/ec2/parsers/security_group_parser.rb', line 13 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 = {} @group_permissions = [] @ip_permissions = [] @text = '' when 'ipPermissions' @permissions = {} @text = '' when 'groups' @group_info = {} @text = '' when 'ipRanges' @ip_info = {} @text = '' end end end |
#text(text) ⇒ Object
43 44 45 |
# File 'lib/awsum/ec2/parsers/security_group_parser.rb', line 43 def text(text) @text << text unless @text.nil? end |