module Beaker::Options::PEVersionScraper
A set of functions to determine the PE version to use during testing
Public Class Methods
load_pe_version(dist_dir, version_file)
click to toggle source
Scrape the PE version (such as 3.0) from the file at dist_dir/version_file
Version file is of the format
3.0.1-3-g57b669e
@param [String] dist_dir The directory containing the version_file @param [String] version_file The file to scrape
@return [String, nil] The PE version in the version_file or nil if not found @raise [ArgumentError] Raises if version_file does not exist or cannot be opened
# File lib/beaker-pe/options/pe_version_scraper.rb, line 17 def self.load_pe_version dist_dir, version_file version = nil begin open("#{dist_dir}/#{version_file}") do |file| while line = file.gets if /(\w.*)/ =~ line then version = $1.strip end end end rescue Errno::ENOENT, OpenURI::HTTPError => e raise ArgumentError, "Failure to examine #{dist_dir}/#{version_file}\n\t\t#{e.to_s}" end return version end