module Azure::Storage::File::Serialization
Public Class Methods
directories_and_files_enumeration_results_from_xml(xml)
click to toggle source
# File lib/azure/storage/file/serialization.rb, line 99 def self.directories_and_files_enumeration_results_from_xml(xml) xml = slopify(xml) expect_node("EnumerationResults", xml) results = enumeration_results_from_xml(xml, Azure::Storage::Common::Service::EnumerationResults.new) return results unless (xml > "Entries").any? if ((xml > "Entries") > "File").any? if xml.Entries.File.count == 0 results.push(file_from_xml(xml.Entries.File)) else xml.Entries.File.each { |file_node| results.push(file_from_xml(file_node)) } end end if ((xml > "Entries") > "Directory").any? if xml.Entries.Directory.count == 0 results.push(directory_from_xml(xml.Entries.Directory)) else xml.Entries.Directory.each { |directory_node| results.push(directory_from_xml(directory_node)) } end end results end
directory_from_headers(headers)
click to toggle source
# File lib/azure/storage/file/serialization.rb, line 158 def self.directory_from_headers(headers) Directory::Directory.new do |directory| directory.properties = directory_properties_from_headers(headers) directory.metadata = metadata_from_headers(headers) end end
directory_from_xml(xml)
click to toggle source
# File lib/azure/storage/file/serialization.rb, line 149 def self.directory_from_xml(xml) xml = slopify(xml) expect_node("Directory", xml) Directory::Directory.new do |directory| directory.name = xml.Name.text if (xml > "Name").any? end end
directory_properties_from_headers(headers)
click to toggle source
# File lib/azure/storage/file/serialization.rb, line 165 def self.directory_properties_from_headers(headers) props = {} props[:last_modified] = headers["Last-Modified"] props[:etag] = headers["ETag"] props end
file_from_headers(headers)
click to toggle source
# File lib/azure/storage/file/serialization.rb, line 172 def self.file_from_headers(headers) File.new do |file| file.properties = file_properties_from_headers(headers) file.metadata = metadata_from_headers(headers) end end
file_from_xml(xml)
click to toggle source
# File lib/azure/storage/file/serialization.rb, line 130 def self.file_from_xml(xml) xml = slopify(xml) expect_node("File", xml) File.new do |file| file.name = xml.Name.text if (xml > "Name").any? file.properties = file_properties_from_xml(xml.Properties) if (xml > "Properties").any? end end
file_properties_from_headers(headers)
click to toggle source
# File lib/azure/storage/file/serialization.rb, line 179 def self.file_properties_from_headers(headers) props = {} props[:last_modified] = headers["Last-Modified"] props[:etag] = headers["ETag"] props[:type] = headers["x-ms-type"] props[:content_length] = headers["Content-Length"].to_i unless headers["Content-Length"].nil? props[:content_length] = headers["x-ms-content-length"].to_i unless headers["x-ms-content-length"].nil? props[:content_type] = headers["Content-Type"] props[:content_encoding] = headers["Content-Encoding"] props[:content_language] = headers["Content-Language"] props[:content_disposition] = headers["Content-Disposition"] props[:content_md5] = headers["x-ms-content-md5"] || headers["Content-MD5"] props[:range_md5] = headers["Content-MD5"] if headers["x-ms-content-md5"] && headers["Content-MD5"] props[:cache_control] = headers["Cache-Control"] props[:copy_id] = headers["x-ms-copy-id"] props[:copy_status] = headers["x-ms-copy-status"] props[:copy_source] = headers["x-ms-copy-source"] props[:copy_progress] = headers["x-ms-copy-progress"] props[:copy_completion_time] = headers["x-ms-copy-completion-time"] props[:copy_status_description] = headers["x-ms-copy-status-description"] props[:accept_ranges] = headers["Accept-Ranges"].to_i if headers["Accept-Ranges"] props end
file_properties_from_xml(xml)
click to toggle source
# File lib/azure/storage/file/serialization.rb, line 140 def self.file_properties_from_xml(xml) xml = slopify(xml) expect_node("Properties", xml) props = {} props[:content_length] = (xml > "Content-Length").text.to_i if (xml > "Content-Length").any? props end
quota_from_headers(headers)
click to toggle source
# File lib/azure/storage/file/serialization.rb, line 89 def self.quota_from_headers(headers) headers["x-ms-share-quota"] ? headers["x-ms-share-quota"].to_i : nil end
range_list_from_xml(xml)
click to toggle source
# File lib/azure/storage/file/serialization.rb, line 209 def self.range_list_from_xml(xml) xml = slopify(xml) expect_node("Ranges", xml) range_list = [] return range_list unless (xml > "Range").any? if xml.Range.count == 0 range_list.push [xml.Range.Start.text.to_i, xml.Range.End.text.to_i] else xml.Range.each { |range| range_list.push [range.Start.text.to_i, range.End.text.to_i] } end range_list end