Module: Stree::Parser
Instance Method Summary collapse
- #parse_copy_object_result(xml) ⇒ Object
- #parse_error(xml) ⇒ Object
- #parse_list_all_my_buckets_result(xml) ⇒ Object
- #parse_list_bucket_result(xml) ⇒ Object
- #parse_location_constraint(xml) ⇒ Object
- #rexml_document(xml) ⇒ Object
Instance Method Details
#parse_copy_object_result(xml) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/stree/parser.rb', line 33 def parse_copy_object_result(xml) object_attributes = {} document = rexml_document(xml) object_attributes[:etag] = document.elements["CopyObjectResult/ETag"].text object_attributes[:last_modified] = document.elements["CopyObjectResult/LastModified"].text object_attributes end |
#parse_error(xml) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/stree/parser.rb', line 41 def parse_error(xml) document = rexml_document(xml) code = document.elements["Error/Code"].text = document.elements["Error/Message"].text [code, ] end |
#parse_list_all_my_buckets_result(xml) ⇒ Object
10 11 12 13 14 |
# File 'lib/stree/parser.rb', line 10 def parse_list_all_my_buckets_result(xml) names = [] rexml_document(xml).elements.each("ListAllMyBucketsResult/Buckets/Bucket/Name") { |e| names << e.text } names end |
#parse_list_bucket_result(xml) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/stree/parser.rb', line 20 def parse_list_bucket_result(xml) objects_attributes = [] rexml_document(xml).elements.each("ListBucketResult/Contents") do |e| object_attributes = {} object_attributes[:key] = e.elements["Key"].text object_attributes[:etag] = e.elements["ETag"].text object_attributes[:last_modified] = e.elements["LastModified"].text object_attributes[:size] = e.elements["Size"].text objects_attributes << object_attributes end objects_attributes end |
#parse_location_constraint(xml) ⇒ Object
16 17 18 |
# File 'lib/stree/parser.rb', line 16 def parse_location_constraint(xml) rexml_document(xml).elements["LocationConstraint"].text end |
#rexml_document(xml) ⇒ Object
5 6 7 8 |
# File 'lib/stree/parser.rb', line 5 def rexml_document(xml) xml.force_encoding(Encoding::UTF_8) if xml.respond_to? :force_encoding Document.new(xml) end |