2
シェフとルビーには比較的新しいので、古い同僚の古いコードをクリーンアップしようとしています。私は3件のレシピがありますシェフ - 同一のコードを複数のレシピから削除する
- 料理/プロバイダ/ domain.rb
- 料理/プロバイダ/ domaincontroller.rb
- 料理/プロバイダ/ rename.rb
を、同一のRubyコードブロックがあります
def computer_exists?
comp = Mixlib::ShellOut.new('powershell.exe -command \"get-wmiobject -class win32_computersystem -computername . | select domain\"').run_command
comp.stdout.include?(new_resource.name) || comp.stdout.include?(new_resource.name.upcase)
end
このコードブロックを属性にラップする方法はありますか私たちは常に各レシピに同じ4行を書き直すわけではありませんか?