class LitmusPaper::Dependency::FileContents
Public Class Methods
new(path, regex, options = {})
click to toggle source
# File lib/litmus_paper/dependency/file_contents.rb, line 4 def initialize(path, regex, options = {}) @path = path @regex = regex @timeout = options.fetch(:timeout, 5) end
Public Instance Methods
available?()
click to toggle source
# File lib/litmus_paper/dependency/file_contents.rb, line 10 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
to_s()
click to toggle source
# File lib/litmus_paper/dependency/file_contents.rb, line 27 def to_s "Dependency::FileContents(#{@path}, #{@regex.inspect})" end