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