Sha256: 4b4a5c8e4e1bb116035419291f010ce74155659e4ed2d31b4d1d534e58cd4736

Contents?: true

Size: 555 Bytes

Versions: 15

Compression:

Stored size: 555 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'webgen/error'
require 'systemu'

module Webgen
  module Utils

    # This module provides methods for easily working with external commands.
    module ExternalCommand

      # Raise an error if the given command is not available.
      #
      # This just checks if the exit status is zero.
      def self.ensure_available!(cmd, *args)
        status = systemu([cmd, *args], 'stdout' => '', 'stdin' => '')
        raise Webgen::CommandNotFoundError.new(cmd) if status.exitstatus != 0
      end

    end

  end
end




Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
webgen-1.7.3 lib/webgen/utils/external_command.rb
webgen-1.7.2 lib/webgen/utils/external_command.rb
webgen-1.7.1 lib/webgen/utils/external_command.rb
webgen-1.7.0 lib/webgen/utils/external_command.rb
webgen-1.6.0 lib/webgen/utils/external_command.rb
webgen-1.5.2 lib/webgen/utils/external_command.rb
webgen-1.5.1 lib/webgen/utils/external_command.rb
webgen-1.5.0 lib/webgen/utils/external_command.rb
webgen-1.4.1 lib/webgen/utils/external_command.rb
webgen-1.4.0 lib/webgen/utils/external_command.rb
webgen-1.3.0 lib/webgen/utils/external_command.rb
webgen-1.2.1 lib/webgen/utils/external_command.rb
webgen-1.2.0 lib/webgen/utils/external_command.rb
webgen-1.1.0 lib/webgen/utils/external_command.rb
webgen-1.0.0 lib/webgen/utils/external_command.rb