class Middleman::HashiCorp::Releases
Constants
- RELEASES_URL
Public Class Methods
fetch(product, version)
click to toggle source
# File lib/middleman-hashicorp/releases.rb, line 8 def self.fetch(product, version) url = "#{RELEASES_URL}/#{product}/#{version}/index.json" r = JSON.parse(open(url).read, create_additions: false, symbolize_names: true, ) # Convert the builds into the following format: # # { # "os" => { # "arch" => "https://download.url" # } # } # {}.tap do |h| r[:builds].each do |b| build = Build.new(*b.values_at(*Build.members)) h[build.os] ||= {} h[build.os][build.arch] = build.url end end end
fetch_latest_version(product)
click to toggle source
Gets only the most recently released version data for a given product
# File lib/middleman-hashicorp/releases.rb, line 36 def self.fetch_latest_version(product) url = "#{RELEASES_URL}/#{product}/index.json" res = JSON.parse(open(url).read, create_additions: false, symbolize_names: true, ) versions = res[:versions] # Releases are formatted as an object rather than an array in the JSON # structure, so we need to convert to an array then sort by version to # get the latest. We then return all info for that version. versions[versions.keys.sort_by(&Gem::Version.method(:new)).last] end