Module: Scmd
- Defined in:
- lib/scmd/command.rb,
lib/scmd.rb,
lib/scmd/version.rb,
lib/scmd/command_spy.rb,
lib/scmd/stored_commands.rb
Overview
Scmd::Command is a base wrapper for handling system commands. Initialize it with with a string specifying the command to execute. You can then run the command and inspect its results. It can be used as is, or inherited from to create a more custom command wrapper.
Defined Under Namespace
Classes: Call, Command, CommandSpy, RunError, StoredCommands
Constant Summary
collapse
- TimeoutError =
Class.new(::RuntimeError)
- VERSION =
"3.0.2"
Class Method Summary
collapse
Class Method Details
.add_command(cmd_str, &block) ⇒ Object
38
39
40
|
# File 'lib/scmd.rb', line 38
def self.add_command(cmd_str, &block)
self.commands.add(cmd_str, &block)
end
|
.calls ⇒ Object
27
28
29
30
|
# File 'lib/scmd.rb', line 27
def self.calls
raise NoMethodError if !ENV['SCMD_TEST_MODE']
@calls ||= []
end
|
.commands ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/scmd.rb', line 19
def self.commands
raise NoMethodError if !ENV['SCMD_TEST_MODE']
@commands ||= begin
require 'scmd/stored_commands'
StoredCommands.new
end
end
|
.new(*args) ⇒ Object
Scmd can be run in “test mode”. This means that command spies will be used in place of “live” commands, each time a command is run or started will be logged in a collection and option-specific spies can be added and used to “stub” spies with specific attributes in specific contexts.
11
12
13
14
15
16
17
|
# File 'lib/scmd.rb', line 11
def self.new(*args)
if !ENV['SCMD_TEST_MODE']
Command.new(*args)
else
self.commands.get(*args)
end
end
|
.reset ⇒ Object
32
33
34
35
36
|
# File 'lib/scmd.rb', line 32
def self.reset
raise NoMethodError if !ENV['SCMD_TEST_MODE']
self.calls.clear
self.commands.remove_all
end
|