Class: RightAws::AcfInterface::AcfDistributionListParser

Inherits:
RightAWSParser
  • Object
show all
Defined in:
lib/acf/right_acf_interface.rb

Overview


PARSERS:

Constant Summary

Constants inherited from RightAWSParser

RightAWSParser::DEFAULT_XML_LIBRARY

Instance Attribute Summary

Attributes inherited from RightAWSParser

#full_tag_name, #result, #tag, #xml_lib, #xmlpath

Instance Method Summary collapse

Methods inherited from RightAWSParser

#initialize, #method_missing, #parse, #tag_end, #tag_start, #tagtext, #text, xml_lib, xml_lib=

Constructor Details

This class inherits a constructor from RightAws::RightAWSParser

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RightAws::RightAWSParser

Instance Method Details

#resetObject

:nodoc:



493
494
495
# File 'lib/acf/right_acf_interface.rb', line 493

def reset
  @result = { :distributions => [] }
end

#tagend(name) ⇒ Object



508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
# File 'lib/acf/right_acf_interface.rb', line 508

def tagend(name)
  case name
  when 'Marker'           then @result[:marker]       = @text
  when 'NextMarker'       then @result[:next_marker]  = @text
  when 'MaxItems'         then @result[:max_items]    = @text.to_i
  when 'IsTruncated'      then @result[:is_truncated] = (@text == 'true')
  when 'Id'               then @distribution[:aws_id]                    = @text
  when 'Status'           then @distribution[:status]                    = @text
  when 'LastModifiedTime' then @distribution[:last_modified_time]        = @text
  when 'DomainName'       then @distribution[:domain_name]               = @text
  when 'Comment'          then @distribution[:comment]                   = AwsUtils::xml_unescape(@text)
  when 'CallerReference'  then @distribution[:caller_reference]          = @text
  when 'CNAME'            then (@distribution[:cnames] ||= [])          << @text
  when 'Enabled'          then @distribution[:enabled]                   = (@text == 'true')
  when 'Bucket'           then (@distribution[:logging] ||= {})[:bucket] = @text
  when 'Prefix'           then (@distribution[:logging] ||= {})[:prefix] = @text
  when 'Protocol'         then (@distribution[:required_protocols] ||= {})[:protocol]        = @text
  when 'InProgressInvalidationBatches' then @distribution[:in_progress_invalidation_batches] = @text.to_i
  when 'DefaultRootObject'             then @distribution[:default_root_object]              = @text
  else
    case full_tag_name
    when %r{/S3Origin/DNSName$}                  then @distribution[:s3_origin][:dns_name]                   = @text
    when %r{/S3Origin/OriginAccessIdentity$}     then @distribution[:s3_origin][:origin_access_identity]     = @text
    when %r{/CustomOrigin/DNSName$}              then @distribution[:custom_origin][:dns_name]               = @text
    when %r{/CustomOrigin/HTTPPort}              then @distribution[:custom_origin][:http_port]              = @text
    when %r{/CustomOrigin/HTTPSPort$}            then @distribution[:custom_origin][:https_port]             = @text
    when %r{/CustomOrigin/OriginProtocolPolicy$} then @distribution[:custom_origin][:origin_protocol_policy] = @text
    when %r{/TrustedSigners/Self$}               then (@distribution[:trusted_signers] ||= [])              << 'self'
    when %r{/TrustedSigners/AwsAccountNumber$}   then (@distribution[:trusted_signers] ||= [])              << @text
    when %r{/Signer/Self$}                       then @active_signer[:aws_account_number]                    = 'self'
    when %r{/Signer/AwsAccountNumber$}           then @active_signer[:aws_account_number]                    = @text
    when %r{/Signer/KeyPairId$}                  then (@active_signer[:key_pair_ids] ||= [])                << @text
    when %r{/Signer$}                            then (@distribution[:active_trusted_signers] ||= [])       << @active_signer
    when %r{(Streaming)?DistributionSummary$},
         %r{^(Streaming)?Distribution$},
         %r{^(Streaming)?DistributionConfig$}
      @result[:distributions] << @distribution
    end
  end
end

#tagstart(name, attributes) ⇒ Object



496
497
498
499
500
501
502
503
504
505
506
507
# File 'lib/acf/right_acf_interface.rb', line 496

def tagstart(name, attributes)
  case full_tag_name
  when %r{/Signer$}
    @active_signer = {}
  when %r{(Streaming)?DistributionSummary$},
       %r{^(Streaming)?Distribution$},
       %r{^(Streaming)?DistributionConfig$}
    @distribution = { }
  when %r{/S3Origin$}     then @distribution[:s3_origin] = {}
  when %r{/CustomOrigin$} then @distribution[:custom_origin] = {}
  end
end