Sha256: c5e7e6ae5212adbd0c6bbc59375e0daa0e3d4ad464549373e8f6b5620c6ccf51

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'vedeu/models/composition'
require 'vedeu/parsing/erb_parser'
require 'vedeu/parsing/raw_parser'
require 'vedeu/parsing/json_parser'
require 'vedeu/parsing/menu_parser'
require 'vedeu/parsing/raw_parser'

module Vedeu
  class View
    def self.render(type, output)
      new(type, output).render
    end

    def initialize(type, output)
      @type, @output = type, output
    end

    def render
      Composition.enqueue(parsed_output)
    end

    private

    attr_reader :type, :output

    def parsed_output
      @parsed ||= parser.parse(output)
    end

    def parser
      {
        erb:     ERBParser,
        json:    JSONParser,
        hash:    RawParser,
        menu:    MenuParser,
        raw:     RawRarser,
      }.fetch(type)
    end
  end
end

# ERBParser:  { :interface, :path, :object }
# RawParser: { 'interface_name' => String|Array }
#             { :interface_name  => String|Array }
# JSONParser: output (string which is converted into a hash)
# MenuParser: ['interface_name', Vedeu::Menu instance]

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.1.1 lib/vedeu/parsing/view.rb