Sha256: 65827639582989343cfea7214f46e7058dd87182f2038f46ae2ab93b496e9120
Contents?: true
Size: 1.23 KB
Versions: 15
Compression:
Stored size: 1.23 KB
Contents
module Vzaar class SignatureExtractor < Struct.new(:data, :format) include Vzaar::Helper def extract _format == :xml ? from_xml : symb_keys(data) end private def _format blank?(format) ? :xml : format.to_sym end def from_xml { https: xml_extractor('//vzaar-api/https'), signature: xml_extractor('//vzaar-api/signature'), expiration_date: xml_extractor('//vzaar-api/expirationdate'), acl: xml_extractor('//vzaar-api/acl'), success_action_redirect: xml_extractor('//vzaar-api/success_action_redirect'), profile: xml_extractor('//vzaar-api/profile'), access_key_id: xml_extractor('//vzaar-api/accesskeyid'), aws_access_key: xml_extractor('//vzaar-api/accesskeyid'), policy: xml_extractor('//vzaar-api/policy'), title: xml_extractor('//vzaar-api/title'), guid: xml_extractor('//vzaar-api/guid'), key: xml_extractor('//vzaar-api/key'), bucket: xml_extractor('//vzaar-api/bucket') } end def xml_extractor(xpath) return '' if xml_data.to_s == '' xml_data.at_xpath(xpath) ? xml_data.at_xpath(xpath).text : '' end def xml_data @xml_data ||= Nokogiri::XML(data) end end end
Version data entries
15 entries across 15 versions & 1 rubygems