class OpenApiConstraint

Constants

OPEN_API_PRODUCTS

Public Class Methods

errors_available() click to toggle source
# File lib/nexmo_developer/app/constraints/open_api_constraint.rb, line 14
def self.errors_available
  all = list.dup.concat(['application'])
  { definition: Regexp.new(all.join('|')) }
end
find_all_versions(name) click to toggle source
# File lib/nexmo_developer/app/constraints/open_api_constraint.rb, line 23
def self.find_all_versions(name)
  # Remove the .v2 etc if needed
  name = name.gsub(/(\.v\d+)/, '')

  matches = list.select do |s|
    s.starts_with?(name) && s.exclude?("#{name}/")
  end

  matches = matches.map do |s|
    m = /\.v(\d+)/.match(s)
    next { 'version' => '1', 'name' => s } unless m

    { 'version' => m[1], 'name' => s }
  end

  matches.sort_by { |v| v['version'] }
end
list() click to toggle source
# File lib/nexmo_developer/app/constraints/open_api_constraint.rb, line 6
def self.list
  @list ||= OPEN_API_PRODUCTS.sort.reject { |d| d.include? 'common/' }
end
match?(definition, code_language = nil) click to toggle source
# File lib/nexmo_developer/app/constraints/open_api_constraint.rb, line 41
def self.match?(definition, code_language = nil)
  if code_language.nil?
    products_with_code_language[:definition].match?(definition)
  else
    products_with_code_language[:definition].match?(definition) &&
      products_with_code_language[:code_language].match?(code_language)
  end
end
products() click to toggle source
# File lib/nexmo_developer/app/constraints/open_api_constraint.rb, line 10
def self.products
  { definition: Regexp.new("^(#{list.join('|')})$") }
end
products_with_code_language() click to toggle source
# File lib/nexmo_developer/app/constraints/open_api_constraint.rb, line 19
def self.products_with_code_language
  products.merge(Nexmo::Markdown::CodeLanguage.route_constraint)
end