Sha256: f410fc73d195c38bc38ff1a43730b92b45ee48f463220d2096ac63b0f001ce64

Contents?: true

Size: 824 Bytes

Versions: 11

Compression:

Stored size: 824 Bytes

Contents

require 'active_support/inflector'
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"]').remove
        self
      end
    end
  end
end

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
junoser-0.2.3 lib/junoser/xsd/parsable.rb
junoser-0.2.2 lib/junoser/xsd/parsable.rb
junoser-0.2.1 lib/junoser/xsd/parsable.rb
junoser-0.2.0 lib/junoser/xsd/parsable.rb
junoser-0.1.6 lib/junoser/xsd/parsable.rb
junoser-0.1.5 lib/junoser/xsd/parsable.rb
junoser-0.1.4 lib/junoser/xsd/parsable.rb
junoser-0.1.3 lib/junoser/xsd/parsable.rb
junoser-0.1.2 lib/junoser/xsd/parsable.rb
junoser-0.1.1 lib/junoser/xsd/parsable.rb
junoser-0.1.0 lib/junoser/xsd/parsable.rb