# frozen_string_literal: true

source ENV['GEM_SOURCE'] || "https://rubygems.org"

def location_for(place, fake_version = nil)
  git_match = place.match(/^(git:[^#]*)#(.*)/)
  file_match = place.match(%r{^file://(.*)})
  if git_match
    git, branch = git_match.captures
    [fake_version, { git: git, branch: branch, require: false }].compact
  elsif file_match
    file_path = file_match[1]
    ['>= 0', { path: File.expand_path(file_path), require: false }]
  else
    [place, { require: false }]
  end
end

gem "beaker", *location_for(ENV['BEAKER_VERSION'] || "~> 4.0")
gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'] || "~> 1.0")

if File.exist? "Gemfile.local"
  eval_gemfile "Gemfile.local"
end
