Module: Beaker::Options::PEVersionScraper

Included in:
DSL::PE
Defined in:
lib/beaker-pe/options/pe_version_scraper.rb

Overview

A set of functions to determine the PE version to use during testing

Class Method Summary collapse

Class Method Details

.load_pe_version(dist_dir, version_file) ⇒ String?

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

Parameters:

  • dist_dir (String)

    The directory containing the version_file

  • version_file (String)

    The file to scrape

Returns:

  • (String, nil)

    The PE version in the version_file or nil if not found

Raises:

  • (ArgumentError)

    Raises if version_file does not exist or cannot be opened



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# 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