Class: CIHelper::Commands::BaseCommand
- Inherits:
-
Object
- Object
- CIHelper::Commands::BaseCommand
- Defined in:
- lib/ci_helper/commands.rb
Direct Known Subclasses
BundlerAudit, CheckCoverage, CheckDBDevelopment, CheckDBRollback, CheckSidekiqSchedulerConfig, CheckSpecSuffixes, RubocopLint, RunSpecs
Class Method Summary collapse
- .call! ⇒ Object
-
.process_stdout ⇒ Object
:nocov:.
Instance Method Summary collapse
- #execute(*commands) ⇒ Object
- #execute_with_env(*commands) ⇒ Object
-
#initialize(**options) ⇒ BaseCommand
constructor
A new instance of BaseCommand.
Constructor Details
#initialize(**options) ⇒ BaseCommand
Returns a new instance of BaseCommand.
20 21 22 |
# File 'lib/ci_helper/commands.rb', line 20 def initialize(**) self. = end |
Class Method Details
.call! ⇒ Object
9 10 11 |
# File 'lib/ci_helper/commands.rb', line 9 def call!(**) new(**).call end |
.process_stdout ⇒ Object
:nocov:
14 15 16 |
# File 'lib/ci_helper/commands.rb', line 14 def process_stdout @process_stdout ||= $stdout end |
Instance Method Details
#execute(*commands) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ci_helper/commands.rb', line 29 def execute(*commands) command = commands.join(" && ") process_stdout.puts(Tools::Colorize.command(command)) Open3.popen2e(command) do |_stdin, stdout, thread| stdout.each_char { |char| process_stdout.print(char) } exit_code = thread.value.exitstatus fail!("Bad exit code #{exit_code} for command #{command.inspect}") unless exit_code.zero? 0 end end |
#execute_with_env(*commands) ⇒ Object
24 25 26 27 |
# File 'lib/ci_helper/commands.rb', line 24 def execute_with_env(*commands) commands = ["export RAILS_ENV=#{env}", *commands] if env execute(*commands) end |