Module: BBK::Utils::Xml
- Defined in:
- lib/bbk/utils/xml.rb
Constant Summary collapse
- MTOM_ID_FIRST_LETTERS =
%w[a b c d e f].freeze
Class Method Summary collapse
-
.build_substitution_id(id) ⇒ Object
Generate identifier to future substitution in XML body.
-
.generate_mtom_attachment_id ⇒ Object
Generate uuid compatible with SOAP AttachmentContent identifier.
-
.normalize_slug(name, href) ⇒ Object
Normalize XML href to be predictible and constant in various cases.
Class Method Details
.build_substitution_id(id) ⇒ Object
Generate identifier to future substitution in XML body. Ex.: real attachment identifier when uploading to FTP
14 15 16 |
# File 'lib/bbk/utils/xml.rb', line 14 def self.build_substitution_id(id) "@{#{id}}" end |
.generate_mtom_attachment_id ⇒ Object
Generate uuid compatible with SOAP AttachmentContent identifier
20 21 22 23 24 |
# File 'lib/bbk/utils/xml.rb', line 20 def self. id = SecureRandom.uuid id[0] = MTOM_ID_FIRST_LETTERS.sample id end |
.normalize_slug(name, href) ⇒ Object
Normalize XML href to be predictible and constant in various cases
28 29 30 31 32 33 34 35 36 |
# File 'lib/bbk/utils/xml.rb', line 28 def self.normalize_slug(name, href) href_uri = URI.parse(href) href_slug = [href_uri.scheme, href_uri.host, *href_uri.path.split('/'), href_uri.query].select do |item| item.present? end.join('-').gsub( /[.&]/, '-' ) Russian.translit "#{name}_#{href_slug}" end |