class Specinfra::CommandRunner::Base
Public Class Methods
new()
click to toggle source
# File lib/specinfra/command_runner/base.rb, line 8 def initialize raise NotImplementedError end
Public Instance Methods
check_command(*args)
click to toggle source
backend上でコマンドの実行結果のステータスコードが0かどうかを返す 以下のURLのコードとほぼ同じ github.com/itamae-kitchen/itamae/blob/v1.9.11/lib/itamae/resource/base.rb#L306
# File lib/specinfra/command_runner/base.rb, line 39 def check_command(*args) args << {} unless args.last.is_a?(Hash) args.last[:error] = false run_command(*args).exit_status == 0 end
run_command(*args)
click to toggle source
backend上でコマンドを実行するためのメソッド, 配列で指定する 以下のURLのコードとほぼ同じ github.com/itamae-kitchen/itamae/blob/v1.9.11/lib/itamae/resource/base.rb#L295
# File lib/specinfra/command_runner/base.rb, line 48 def run_command(*args) args << {} unless args.last.is_a?(Hash) @backend.run_command(*args) end
run_specinfra(type, *args)
click to toggle source
typeを指定してspecinfraを呼び出すためのメソッド 以下のURLのコードとほぼ同じ github.com/itamae-kitchen/itamae/blob/v1.9.11/lib/itamae/resource/base.rb#L316 typeにはsymbolを指定, 命名規則は以下のURLのmethを参照 github.com/mizzy/specinfra/blob/v2.72.1/lib/specinfra/command_factory.rb#L61
# File lib/specinfra/command_runner/base.rb, line 17 def run_specinfra(type, *args) # 例えば以下のURLのcheck_is_ec2_instanceメソッドのコマンドを実行したい場合 # https://github.com/mizzy/specinfra/blob/v2.72.1/lib/specinfra/command/base/localhost.rb#L3 # typeには:check_localhost_is_ec2_instanceを指定する cmd = specinfra_command(type, *args) # typeにcheck_の文字が入っている場合check_commandを実行 if type.to_s.start_with?('check_') check_command(cmd) else run_command(cmd) end end
specinfra_command(type, *args)
click to toggle source
Specinfraのコマンドを文字列で返す
# File lib/specinfra/command_runner/base.rb, line 32 def specinfra_command(type, *args) raise NotImplementedError end