module Wisp

Constants

ACTIONS
CANARY_NOUNS_PATH
CANARY_SCHEMA_PATH
CANARY_VERSION
NOUNS_PATH
SCHEMA_PATH
SEMANTIC_STABLE_VERSION
STABLE_VERSION
VERSION

Public Class Methods

action_schemer(raw_version, action) click to toggle source
# File lib/wisp-schema.rb, line 61
def action_schemer(raw_version, action)
  raise NotSupportedAction unless ACTIONS.include?(action)

  if is_canary?(raw_version)
    JSONSchemer.schema(Pathname.new(File.expand_path("../canary/actions/#{action}.json", __dir__)))
  else
    JSONSchemer.schema(Pathname.new(File.expand_path("../stable/actions/#{action}.json", __dir__)))
  end
end
is_canary?(raw_version) click to toggle source
# File lib/wisp-schema.rb, line 38
def is_canary?(raw_version)
  Semantic::Version.new(raw_version) > SEMANTIC_STABLE_VERSION
end
nouns_schemer(raw_version) click to toggle source
# File lib/wisp-schema.rb, line 52
def nouns_schemer(raw_version)
  if is_canary?(raw_version)
    JSONSchemer.schema(Pathname.new(Wisp::CANARY_NOUNS_PATH))
  else
    JSONSchemer.schema(Pathname.new(Wisp::NOUNS_PATH))
  end
end
wisp_schemer(raw_version) click to toggle source
# File lib/wisp-schema.rb, line 43
def wisp_schemer(raw_version)
  if is_canary?(raw_version)
    JSONSchemer.schema(Pathname.new(Wisp::CANARY_SCHEMA_PATH))
  else
    JSONSchemer.schema(Pathname.new(Wisp::SCHEMA_PATH))
  end
end

Private Instance Methods

action_schemer(raw_version, action) click to toggle source
# File lib/wisp-schema.rb, line 61
def action_schemer(raw_version, action)
  raise NotSupportedAction unless ACTIONS.include?(action)

  if is_canary?(raw_version)
    JSONSchemer.schema(Pathname.new(File.expand_path("../canary/actions/#{action}.json", __dir__)))
  else
    JSONSchemer.schema(Pathname.new(File.expand_path("../stable/actions/#{action}.json", __dir__)))
  end
end
is_canary?(raw_version) click to toggle source
# File lib/wisp-schema.rb, line 38
def is_canary?(raw_version)
  Semantic::Version.new(raw_version) > SEMANTIC_STABLE_VERSION
end
nouns_schemer(raw_version) click to toggle source
# File lib/wisp-schema.rb, line 52
def nouns_schemer(raw_version)
  if is_canary?(raw_version)
    JSONSchemer.schema(Pathname.new(Wisp::CANARY_NOUNS_PATH))
  else
    JSONSchemer.schema(Pathname.new(Wisp::NOUNS_PATH))
  end
end
wisp_schemer(raw_version) click to toggle source
# File lib/wisp-schema.rb, line 43
def wisp_schemer(raw_version)
  if is_canary?(raw_version)
    JSONSchemer.schema(Pathname.new(Wisp::CANARY_SCHEMA_PATH))
  else
    JSONSchemer.schema(Pathname.new(Wisp::SCHEMA_PATH))
  end
end