Class: Wheneverd::Job::Command
- Inherits:
-
Object
- Object
- Wheneverd::Job::Command
- Defined in:
- lib/wheneverd/job/command.rb
Overview
A oneshot command job rendered as ExecStart= in a systemd service unit.
This job accepts either:
- A String (inserted into
ExecStart=as-is, after stripping surrounding whitespace), or - An argv Array (formatted/escaped into a systemd-compatible
ExecStart=string).
If you need shell features like pipes, redirects, or environment variable expansion, wrap the command explicitly:
Constant Summary collapse
- SAFE_UNQUOTED =
%r{\A[A-Za-z0-9_@%+=:,./-]+\z}.freeze
Instance Attribute Summary collapse
-
#argv ⇒ Array<String>?
readonly
Original argv form (when constructed with an Array).
-
#command ⇒ String
readonly
Rendered
ExecStart=value. -
#signature ⇒ String
readonly
Stable signature used for unit naming.
Instance Method Summary collapse
-
#initialize(command:) ⇒ Command
constructor
A new instance of Command.
Constructor Details
#initialize(command:) ⇒ Command
Returns a new instance of Command.
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/wheneverd/job/command.rb', line 39 def initialize(command:) @argv = nil @signature = nil @command = nil case command when String then init_string(command) when Array then init_argv(command) else raise InvalidCommandError, "Command must be a String or an Array (got #{command.class})" end end |
Instance Attribute Details
#argv ⇒ Array<String>? (readonly)
Original argv form (when constructed with an Array).
31 32 33 |
# File 'lib/wheneverd/job/command.rb', line 31 def argv @argv end |
#command ⇒ String (readonly)
Rendered ExecStart= value.
26 27 28 |
# File 'lib/wheneverd/job/command.rb', line 26 def command @command end |
#signature ⇒ String (readonly)
Stable signature used for unit naming.
36 37 38 |
# File 'lib/wheneverd/job/command.rb', line 36 def signature @signature end |