Sha256: 104b427400eae13c7427d2f20652ca948ff35d2cf1d7310079e533f50c3bc2b8

Contents?: true

Size: 1.05 KB

Versions: 36

Compression:

Stored size: 1.05 KB

Contents

module Fog
  module Storage
    class InternetArchive
      require 'fog/internet_archive/parsers/storage/cors_configuration'

      private

        def self.hash_to_cors(cors)
          data =  "<CORSConfiguration>\n"

          [cors['CORSConfiguration']].flatten.compact.each do |rule|
            data << "  <CORSRule>\n"

            ['ID', 'MaxAgeSeconds'].each do |key|
              data << "    <#{key}>#{rule[key]}</#{key}>\n" if rule[key]
            end

            ['AllowedOrigin', 'AllowedMethod', 'AllowedHeader', 'ExposeHeader'].each do |key|
              [rule[key]].flatten.compact.each do |value|
                data << "    <#{key}>#{value}</#{key}>\n"
              end
            end

            data << "  </CORSRule>\n"
          end

          data << "</CORSConfiguration>"

          data
        end

        def self.cors_to_hash(cors_xml)
          parser = Fog::Parsers::Storage::InternetArchive::CorsConfiguration.new
          Nokogiri::XML::SAX::Parser.new(parser).parse(cors_xml)
          parser.response
        end
    end
  end
end

Version data entries

36 entries across 34 versions & 6 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-internet-archive-0.0.1/lib/fog/internet_archive/requests/storage/cors_utils.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-internet-archive-0.0.1/lib/fog/internet_archive/requests/storage/cors_utils.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-internet-archive-0.0.1/lib/fog/internet_archive/requests/storage/cors_utils.rb
fog-1.40.0 lib/fog/internet_archive/requests/storage/cors_utils.rb
fog-1.39.0 lib/fog/internet_archive/requests/storage/cors_utils.rb
fog-internet-archive-0.0.1 lib/fog/internet_archive/requests/storage/cors_utils.rb
fog-1.38.0 lib/fog/internet_archive/requests/storage/cors_utils.rb
fog-1.37.0 lib/fog/internet_archive/requests/storage/cors_utils.rb
fog-1.36.0 lib/fog/internet_archive/requests/storage/cors_utils.rb
fog-1.35.0 lib/fog/internet_archive/requests/storage/cors_utils.rb
fog-2.0.0.pre.0 lib/fog/internet_archive/requests/storage/cors_utils.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/internet_archive/requests/storage/cors_utils.rb
fog-1.34.0 lib/fog/internet_archive/requests/storage/cors_utils.rb
fog-1.33.0 lib/fog/internet_archive/requests/storage/cors_utils.rb
fog-1.32.0 lib/fog/internet_archive/requests/storage/cors_utils.rb
fog-1.31.0 lib/fog/internet_archive/requests/storage/cors_utils.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/internet_archive/requests/storage/cors_utils.rb
fog-1.30.0 lib/fog/internet_archive/requests/storage/cors_utils.rb
fog-1.29.0 lib/fog/internet_archive/requests/storage/cors_utils.rb
fog-1.28.0 lib/fog/internet_archive/requests/storage/cors_utils.rb