Sha256: abc9cf4638420f4c1f78e6d4c47a854f69ef3353ca78e8a46c611435068d0cbe

Contents?: true

Size: 1.13 KB

Versions: 22

Compression:

Stored size: 1.13 KB

Contents

require 'open-uri'
module Beaker
  module Options
    #A set of functions to determine the PE version to use during testing
    module PEVersionScraper
      # 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
      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

    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
beaker-1.11.0 lib/beaker/options/pe_version_scraper.rb
beaker-1.10.0 lib/beaker/options/pe_version_scraper.rb
beaker-1.9.1 lib/beaker/options/pe_version_scraper.rb
beaker-1.9.0 lib/beaker/options/pe_version_scraper.rb
beaker-1.8.2 lib/beaker/options/pe_version_scraper.rb
beaker-1.8.1 lib/beaker/options/pe_version_scraper.rb
beaker-1.8.0 lib/beaker/options/pe_version_scraper.rb
beaker-1.7.0 lib/beaker/options/pe_version_scraper.rb
beaker-1.6.2 lib/beaker/options/pe_version_scraper.rb
beaker-1.6.1 lib/beaker/options/pe_version_scraper.rb
beaker-1.6.0 lib/beaker/options/pe_version_scraper.rb
beaker-1.5.0 lib/beaker/options/pe_version_scraper.rb
beaker-1.4.1 lib/beaker/options/pe_version_scraper.rb
beaker-1.4.0 lib/beaker/options/pe_version_scraper.rb
beaker-1.3.2 lib/beaker/options/pe_version_scraper.rb
beaker-1.3.1 lib/beaker/options/pe_version_scraper.rb
beaker-1.3.0 lib/beaker/options/pe_version_scraper.rb
beaker-1.2.0 lib/beaker/options/pe_version_scraper.rb
beaker-1.1.0 lib/beaker/options/pe_version_scraper.rb
beaker-1.0.1 lib/beaker/options/pe_version_scraper.rb