Sha256: d605356b2ec4fcb60b64b30c97c96f6d66dd9f302c116ab7ceeae5d2f8c3f9f0

Contents?: true

Size: 985 Bytes

Versions: 3

Compression:

Stored size: 985 Bytes

Contents

require 'eeml/libxml_eeml_parser_v005'
require 'eeml/json_environment_parser_v005'
require 'eeml/json_environment_parser_v006'

module Eeml
  class EnvironmentBuilder # :nodoc:

    def self.build_from_xml(xml_str)
      parser = LibXMLEemlParserV005.new
      return parser.make_environment_from_xml(xml_str)
    end

    def self.build_list_from_xml(xml_str)
      parser = LibXMLEemlParserV005.new
      return parser.make_environments_from_xml(xml_str)
    end

    def self.build_from_json(json_str)
      json = JSON.parse(json_str)
      if json["version"].to_i == Constants::EEML5_VERSION.to_i
        parser = JsonEnvironmentParserV005.new
      elsif json["version"].to_f == Constants::EEML6_VERSION.to_f
        parser = JsonEnvironmentParserV006.new
      else
        raise "Invalid version specification. Permitted versions are #{Constants::EEML5_VERSION} and #{Constants::EEML6_VERSION}"
      end
      return parser.make_environment_from_hash(json)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
eeml-0.0.14 lib/eeml/environment_builder.rb
eeml-0.0.13 lib/eeml/environment_builder.rb
eeml-0.0.12 lib/eeml/environment_builder.rb