Sha256: 6af4318a62bb0271a0fecd3d9ce064d73551f7275b6ea68377faa5491aac2554

Contents?: true

Size: 599 Bytes

Versions: 2

Compression:

Stored size: 599 Bytes

Contents

require 'nokogiri'
require 'erb'
require 'ostruct'
require 'securerandom'

module Fog
  module Libvirt
    module Util
      def xml_element(xml, path, attribute=nil)
        xml = Nokogiri::XML(xml)
        attribute.nil? ? (xml/path).first.text : (xml/path).first[attribute.to_sym]
      end

      def xml_elements(xml, path, attribute=nil)
        xml = Nokogiri::XML(xml)
        attribute.nil? ? (xml/path).map : (xml/path).map{|element| element[attribute.to_sym]}
      end

      def randomized_name
        "fog-#{(SecureRandom.random_number*10E14).to_i.round}"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-libvirt-0.13.1 lib/fog/libvirt/models/compute/util/util.rb
fog-libvirt-0.13.0 lib/fog/libvirt/models/compute/util/util.rb