Sha256: cd9ea6dcbae0612846b71fe837713586cb604b6fc3a9b8a2445b036986c13f25

Contents?: true

Size: 772 Bytes

Versions: 5

Compression:

Stored size: 772 Bytes

Contents

module LitmusPaper
  module Dependency
    class Script
      def initialize(command, options = {})
        @command = command
        @timeout = options.fetch(:timeout, 5)
      end

      def available?
        Timeout.timeout(@timeout) do
          output = %x[#{@command}]
          unless $CHILD_STATUS.success?
            LitmusPaper.logger.info("Available check to #{@command} failed with status #{$CHILD_STATUS.exitstatus}")
            LitmusPaper.logger.info("Failed output #{output}")
          end
          $CHILD_STATUS.success?
        end
      rescue Timeout::Error
        LitmusPaper.logger.info("Available check to '#{@command}' timed out")
        false
      end

      def to_s
        "Dependency::Script(#{@command})"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
litmus_paper-0.7.5 lib/litmus_paper/dependency/script.rb
litmus_paper-0.7.4 lib/litmus_paper/dependency/script.rb
litmus_paper-0.7.3 lib/litmus_paper/dependency/script.rb
litmus_paper-0.7.2 lib/litmus_paper/dependency/script.rb
litmus_paper-0.7.1 lib/litmus_paper/dependency/script.rb