Sha256: 61255e534a5ae86ee898429d944d6e4193b58af4bc70cc6d58d1bd8ff22d7fe5
Contents?: true
Size: 830 Bytes
Versions: 24
Compression:
Stored size: 830 Bytes
Contents
module LitmusPaper module Dependency class FileContents def initialize(path, regex, options = {}) @path = path @regex = regex @timeout = options.fetch(:timeout, 5) end def available? Timeout.timeout(@timeout) do if File.read(@path).match(@regex) true else LitmusPaper.logger.info("Available check of #{@path} failed, content did not match #{@regex.inspect}") false end end rescue Timeout::Error LitmusPaper.logger.info("Timeout reading #{@path}") false rescue => e LitmusPaper.logger.info("Error reading #{@path}: '#{e.message}'") false end def to_s "Dependency::FileContents(#{@path}, #{@regex.inspect})" end end end end
Version data entries
24 entries across 24 versions & 1 rubygems