Sha256: 317a2f96abcf8b08fae1fd6a9b6f511ae6c515a10c68f858554c79e5cd662627

Contents?: true

Size: 815 Bytes

Versions: 30

Compression:

Stored size: 815 Bytes

Contents

require 'junoser/xsd/complex_type'
require 'junoser/xsd/element'
require 'nokogiri'

module Junoser
  module Xsd
    module Parsable
      def to_config
        rule = "rule(:#{self['name'].underscore}) do\n"

        case name
        when 'complexType'
          rule << Junoser::Xsd::ComplexType.new(self, depth: 1).to_s
        when 'element'
          rule << Junoser::Xsd::Element.new(self, depth: 1).content
        else
          raise "ERROR: unknown element: #{name}"
        end

        rule << "\nend\n\n"
      end

      def remove_unused
        xpath('/xsd:schema/*[self::xsd:import]').remove
        xpath('//xsd:element[@ref="undocumented" or @ref="junos:comment" or @name="apply-advanced"]').remove
        self
      end
    end
  end
end

Nokogiri::XML::Element.include Junoser::Xsd::Parsable

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
junoser-0.3.9 lib/junoser/xsd/parsable.rb
junoser-0.3.8 lib/junoser/xsd/parsable.rb
junoser-0.3.7 lib/junoser/xsd/parsable.rb
junoser-0.3.6 lib/junoser/xsd/parsable.rb
junoser-0.3.5 lib/junoser/xsd/parsable.rb
junoser-0.3.4 lib/junoser/xsd/parsable.rb
junoser-0.3.3 lib/junoser/xsd/parsable.rb
junoser-0.3.2 lib/junoser/xsd/parsable.rb
junoser-0.3.1 lib/junoser/xsd/parsable.rb
junoser-0.3.0 lib/junoser/xsd/parsable.rb