Sha256: 00004363798eb0845ea8745f3f45a8a0f2f5c366e6b2dbc1d3ed50d8b9058240
Contents?: true
Size: 824 Bytes
Versions: 3
Compression:
Stored size: 824 Bytes
Contents
require_relative 'compositor' require_relative 'parsing/hash_parser' require_relative 'parsing/json_parser' module Vedeu class ParseError < StandardError; end class Parser def self.parse(output = {}) new(output).parse end def initialize(output = {}) @output = output end def parse return nil if empty? Compositor.enqueue(parsed_output) end private attr_reader :output def parsed_output @parsed ||= parser.parse(output) end def parser return JSONParser if json? return HashParser if hash? fail ParseError, 'Cannot process output from command.' end def hash? output.is_a?(Hash) end def json? output.is_a?(String) end def empty? output.nil? || output.empty? end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.0.36 | lib/vedeu/support/parser.rb |
vedeu-0.0.35 | lib/vedeu/support/parser.rb |
vedeu-0.0.34 | lib/vedeu/support/parser.rb |