Sha256: f94465d06663536cc13ac22c80fbe0e7a3ba278cefd41f65ba83658fbc1d0118

Contents?: true

Size: 1.4 KB

Versions: 11

Compression:

Stored size: 1.4 KB

Contents

require "pathname"
require "json_schemer"

module Eddy
  module Summary

    # Check a Segment definition file against Eddy's JSON schema.
    #
    # @param path [String] Path to the file.
    # @return [Boolean]
    def self.valid_segment_data?(path)
      schema = Pathname.new(File.join(Eddy::Util.data_dir, "schema", "segment_summary.json"))
      schemer = JSONSchemer.schema(schema, ref_resolver: "net/http")
      data = Eddy::Util.read_json_or_yaml(path, symbolize: false)
      schemer.valid?(data)
    end

    # Check a Loop definition file against Eddy's JSON schema.
    #
    # @param path [String] Path to the file.
    # @return [Boolean]
    def self.valid_loop_data?(path)
      schema = Pathname.new(File.join(Eddy::Util.data_dir, "schema", "loop_summary.json"))
      schemer = JSONSchemer.schema(schema, ref_resolver: "net/http")
      data = Eddy::Util.read_json_or_yaml(path, symbolize: false)
      schemer.valid?(data)
    end

    # Check a Transaction Set definition file against Eddy's JSON schema.
    #
    # @param path [String] Path to the file.
    # @return [Boolean]
    def self.valid_transaction_set_data?(path)
      schema = Pathname.new(File.join(Eddy::Util.data_dir, "schema", "transaction_set_summary.json"))
      schemer = JSONSchemer.schema(schema, ref_resolver: "net/http")
      data = Eddy::Util.read_json_or_yaml(path, symbolize: false)
      schemer.valid?(data)
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
eddy-0.10.0 lib/eddy/summary/validate.rb
eddy-0.9.2 lib/eddy/summary/validate.rb
eddy-0.9.1 lib/eddy/summary/validate.rb
eddy-0.9.0 lib/eddy/summary/validate.rb
eddy-0.8.4 lib/eddy/summary/validate.rb
eddy-0.8.3 lib/eddy/summary/validate.rb
eddy-0.8.2 lib/eddy/summary/validate.rb
eddy-0.8.1 lib/eddy/summary/validate.rb
eddy-0.8.0 lib/eddy/summary/validate.rb
eddy-0.7.0 lib/eddy/summary/validate.rb
eddy-0.6.0 lib/eddy/summary/validate.rb