Sha256: c96fc5401966cca79965982c1ce7d06ba0565e2bc07d3f2be5d84b0ca34e87bd

Contents?: true

Size: 1019 Bytes

Versions: 4

Compression:

Stored size: 1019 Bytes

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)
            end
          end

          STACK.to_a
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
scaffold_parser-0.9.1 lib/scaffold_parser/scaffolders/xsd/parser.rb
scaffold_parser-0.9.0 lib/scaffold_parser/scaffolders/xsd/parser.rb
scaffold_parser-0.8.0 lib/scaffold_parser/scaffolders/xsd/parser.rb
scaffold_parser-0.7.0 lib/scaffold_parser/scaffolders/xsd/parser.rb