Sha256: beeaca87149b2ca62509b871385136038ac10532304f429a8b68b32b9ea8300d

Contents?: true

Size: 726 Bytes

Versions: 6

Compression:

Stored size: 726 Bytes

Contents

module Climatic
  module Utils

    module SafeExec

      def safely_exec_code(*args, message: nil, &block)
        if Climatic.config[:simulate]
          Climatic.logger.puts_and_logs "[SIMULATION MODE]: #{message}" unless message.nil?
        else
          Climatic.logger.puts_and_logs message
          block.call *args
        end
      end

      def safely_exec_command(command, message: nil, show_output: false, log_output: true)
        safely_exec_code command, message: message do |cmd|
          process = Climatic::Processes::Base.new cmd
          process.show_output = show_output
          process.log_output = log_output
          process.execute
          process
        end
      end

    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
climatic-0.2.40 lib/climatic/utils/safe_exec.rb
climatic-0.2.39 lib/climatic/utils/safe_exec.rb
climatic-0.2.38 lib/climatic/utils/safe_exec.rb
climatic-0.2.37 lib/climatic/utils/safe_exec.rb
climatic-0.2.36 lib/climatic/utils/safe_exec.rb
climatic-0.2.35 lib/climatic/utils/safe_exec.rb