Class: ConvenientService::Examples::Standard::Gemfile::Services::RunShellCommand
- Inherits:
-
Object
- Object
- ConvenientService::Examples::Standard::Gemfile::Services::RunShellCommand
- Includes:
- Service::Configs::Standard
- Defined in:
- lib/convenient_service/examples/standard/gemfile/services/run_shell_command.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#debug ⇒ Object
readonly
Returns the value of attribute debug.
Instance Method Summary collapse
-
#initialize(command:, debug: false) ⇒ RunShellCommand
constructor
A new instance of RunShellCommand.
- #result ⇒ Object
Constructor Details
#initialize(command:, debug: false) ⇒ RunShellCommand
Returns a new instance of RunShellCommand.
23 24 25 26 |
# File 'lib/convenient_service/examples/standard/gemfile/services/run_shell_command.rb', line 23 def initialize(command:, debug: false) @command = command @debug = debug end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
11 12 13 |
# File 'lib/convenient_service/examples/standard/gemfile/services/run_shell_command.rb', line 11 def command @command end |
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
11 12 13 |
# File 'lib/convenient_service/examples/standard/gemfile/services/run_shell_command.rb', line 11 def debug @debug end |
Instance Method Details
#result ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/convenient_service/examples/standard/gemfile/services/run_shell_command.rb', line 28 def result ## # NOTE: When the command exit code is 0, `system` return `true`, and `false` otherwise. # - https://ruby-doc.org/core-3.1.2/Kernel.html#method-i-system # - https://stackoverflow.com/a/37329716/12201472 # if system(command) success else error("#{command} returned non-zero exit code") end end |