Class: RazorRisk::Razor::Connectivity::Razor3::RazorRequester::Executable

Inherits:
Object
  • Object
show all
Includes:
Core::System::SystemTraits, Xqsr3::Quality::ParameterChecking
Defined in:
lib/razor_risk/razor/connectivity/razor_3/razor_requester.rb

Overview

Represents the executable

Defined Under Namespace

Modules: Constants

Instance Method Summary collapse

Constructor Details

#initialize(executable) ⇒ Executable

Initialises the instance

Parameters:

  • executable (::String, Array<::String>) —

    As string with 1 or more elements separated by '|' (or by the platform's separator - ';' on Windows; ':' otherwise)

Raises:

  • (::ArgumentError)


199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/razor_risk/razor/connectivity/razor_3/razor_requester.rb', line 199

def initialize executable

    check_parameter executable, 'executable', types: [ ::String, [ ::String ] ]

    exec_parts  =   executable.split(windows? ? /[|;]/ : /[|:]/) if ::String === executable
    exec_parts  =   exec_parts.flatten
    exec_parts  =   exec_parts.reject { |xp| xp.strip.empty? }

    raise ::ArgumentError, "the given executable '#{executable}' resolves to nothing" if exec_parts.empty?

    arg0        =   exec_parts.shift

    @arg0       =   Recls.stat(arg0) or raise ArgumentError, "given executable '#{arg0}' does not exist"
    @argv       =   exec_parts
end

Instance Method Details

#form_command(config_path, request_path, **options) ⇒ ::String

Forms the full command to be executed, based on the given parameters, options, and also on the nature of the executable specified in the initialiser

Parameters:

  • config_path (::String) —

    The ClarITe configuration

  • request_path (::String) —

    The path of the request document.

  • options (::Hash) —

    Options hash

Options Hash (**options):

  • :username (::String) —

    The user to use fro the credentials.

  • :password (::String) —

    The password to use for credentials.

  • :domain (::String) —

    The domain to use for credentials.

  • :impersonatee (::String) —

    The user to impersonate.

  • :razor_environment (::String) —

    The Razor environment.

  • :session (Boolean) —

    Uses a Razor session for the request.

  • :debug (Boolean) —

    Turns on debug.

  • :log_to_stderr (Boolean) —

    Turns on logging.

Returns:

  • (::String) —

    The command to execute.



237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/razor_risk/razor/connectivity/razor_3/razor_requester.rb', line 237

def form_command config_path, request_path, **options

    cmd = []
    cmd << program_path.to_s.quote_if

    unless program_arguments.empty?

        program_arguments.each do |arg|

            cmd << arg.quote_if
        end
    else

        cmd << '/config' << config_path.quote_if
        cmd << '/request' << request_path.quote_if unless request_path.nil?

        Constants::RRParameters.each do |key,value|
            cmd << value << options[key].quote_if if options[key]
        end

        Constants::RROptions.each do |key,value|
            cmd << value if options[key]
        end
    end

    cmd * ' '
end

#program_arguments ⇒ Object



266
# File 'lib/razor_risk/razor/connectivity/razor_3/razor_requester.rb', line 266

def program_arguments; @argv; end

#program_path ⇒ Object



265
# File 'lib/razor_risk/razor/connectivity/razor_3/razor_requester.rb', line 265

def program_path; @arg0; end