Class: RazorRisk::Razor::Connectivity::Razor3::RazorRequester::Executable
- Inherits:
-
Object
- Object
- RazorRisk::Razor::Connectivity::Razor3::RazorRequester::Executable
- 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
-
#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.
-
#initialize(executable) ⇒ Executable
constructor
Initialises the instance.
- #program_arguments ⇒ Object
- #program_path ⇒ Object
Constructor Details
#initialize(executable) ⇒ Executable
Initialises the instance
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
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, ** 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 << [key].quote_if if [key] end Constants::RROptions.each do |key,value| cmd << value if [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 |