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
fog-1.27.0 lib/fog/internet_archive/requests/storage/cors_utils.rb
fog-1.26.0 lib/fog/internet_archive/requests/storage/cors_utils.rb
fog-1.25.0 lib/fog/internet_archive/requests/storage/cors_utils.rb
nsidc-fog-1.24.1 lib/fog/internet_archive/requests/storage/cors_utils.rb
fog-1.24.0 lib/fog/internet_archive/requests/storage/cors_utils.rb
ns-fog-1.22.11 lib/fog/internet_archive/requests/storage/cors_utils.rb
ns-fog-1.22.10 lib/fog/internet_archive/requests/storage/cors_utils.rb
ns-fog-1.22.9 lib/fog/internet_archive/requests/storage/cors_utils.rb
ns-fog-1.22.8 lib/fog/internet_archive/requests/storage/cors_utils.rb
ns-fog-1.22.7 lib/fog/internet_archive/requests/storage/cors_utils.rb
ns-fog-1.22.6 lib/fog/internet_archive/requests/storage/cors_utils.rb
fog-1.23.0 lib/fog/internet_archive/requests/storage/cors_utils.rb
ns-fog-1.22.4 lib/fog/internet_archive/requests/storage/cors_utils.rb
ns-fog-1.22.3 lib/fog/internet_archive/requests/storage/cors_utils.rb
ns-fog-1.22.2 lib/fog/internet_archive/requests/storage/cors_utils.rb
fog-1.22.1 lib/fog/internet_archive/requests/storage/cors_utils.rb