Sha256: 23510b3c7f181b80dd395bd9e047445393d9a9272a4ea67f37e9d554dccab4f8
Contents?: true
Size: 1.71 KB
Versions: 2
Compression:
Stored size: 1.71 KB
Contents
module Nexmo module OAS module Renderer module Presenters class Versions def initialize(definition_name) @definition_name = definition_name end def base_name @base_name ||= @definition_name.gsub(/\.v\d+/, '') end def current_version @current_version ||= begin m = /\.v(\d+)/.match(@definition_name) m.nil? ? '1' : m[1] end end def available_versions @available_versions ||= begin matches = definitions.select do |definition| definition.starts_with?(base_name) && !definition.include?("#{base_name}/") end matches.map do |definition| name = definition.chomp('.yml') m = /\.v(\d+)/.match(name) next { 'version' => '1', 'name' => name } unless m { 'version' => m[1], 'name' => name } end.sort_by { |v| v['version'] } end end def definitions @definitions ||= begin Dir.glob("#{API.oas_path}/definitions/**/*.yml").map do |file| definition = file.sub("#{API.oas_path}/definitions/", '').chomp('.yml') end end end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nexmo-oas-renderer-0.6.4 | lib/nexmo/oas/renderer/presenters/versions.rb |
nexmo-oas-renderer-0.6.3 | lib/nexmo/oas/renderer/presenters/versions.rb |