Class: Semverve::DocsPublisher::Shell
- Inherits:
-
Object
- Object
- Semverve::DocsPublisher::Shell
- Defined in:
- lib/semverve/docs_publisher.rb
Overview
Small command runner used by the publisher.
Instance Method Summary collapse
-
#capture(command, chdir: nil) ⇒ String
Captures a command's standard output and raises when it fails.
-
#run(command, chdir: nil) ⇒ String
Runs a command and raises when it fails.
-
#success?(command, chdir: nil) ⇒ Boolean
Whether a command exits successfully.
Instance Method Details
#capture(command, chdir: nil) ⇒ String
Captures a command's standard output and raises when it fails.
40 41 42 |
# File 'lib/semverve/docs_publisher.rb', line 40 def capture(command, chdir: nil) run(command, chdir: chdir) end |
#run(command, chdir: nil) ⇒ String
Runs a command and raises when it fails.
26 27 28 29 30 31 |
# File 'lib/semverve/docs_publisher.rb', line 26 def run(command, chdir: nil) stdout, stderr, status = capture_command(command, chdir: chdir) return stdout if status.success? raise Error, "Command failed: #{command.join(" ")}\n#{stderr}" end |
#success?(command, chdir: nil) ⇒ Boolean
Whether a command exits successfully.
51 52 53 54 |
# File 'lib/semverve/docs_publisher.rb', line 51 def success?(command, chdir: nil) _stdout, _stderr, status = capture_command(command, chdir: chdir) status.success? end |