Sha256: ec152bdf544c8e93412345ce0c08326fab03d6dab98c4ba1052150e2e16d2661

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require 'scaffold_parser/scaffolders/xsd/parser/stack'
require 'scaffold_parser/scaffolders/xsd/parser/handlers/requires'

module ScaffoldParser
  module Scaffolders
    class XSD
      class Parser
        attr_reader :xsds

        def self.call(xsds, options)
          self.new(xsds, options).call
        end

        def initialize(xsds, options)
          @xsds = xsds
          @options = options
        end

        STACK = Stack.instance

        def call
          STACK.clear

          xsds.each do |xsd|
            xsd.reverse_traverse do |element, children_result|
              handler =
                if children_result.empty?
                  Handlers::Blank.new
                elsif children_result.one?
                  children_result.first
                else
                  Handlers::Elements.new(children_result)
                end

              handler.send(element.element_name, element)
            rescue
              p "Something happened during processing schema #{xsd.source} and node #{element.css_path}"
              raise
            end
          end

          STACK.to_a
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scaffold_parser-0.10.0 lib/scaffold_parser/scaffolders/xsd/parser.rb