Sha256: 7129eb7f556cdfd3200ddce2219d441198aefc48b8394e928d254d9bd1bf10ea

Contents?: true

Size: 722 Bytes

Versions: 8

Compression:

Stored size: 722 Bytes

Contents

module Climatic
  module Utils

    module SafeExec

      def safely_exec_code(*args, message: nil, &block)
        if self.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

8 entries across 8 versions & 1 rubygems

Version Path
climatic-0.2.34 lib/climatic/utils/safe_exec.rb
climatic-0.2.32 lib/climatic/utils/safe_exec.rb
climatic-0.2.31 lib/climatic/utils/safe_exec.rb
climatic-0.2.30 lib/climatic/utils/safe_exec.rb
climatic-0.2.29 lib/climatic/utils/safe_exec.rb
climatic-0.2.28 lib/climatic/utils/safe_exec.rb
climatic-0.2.27 lib/climatic/utils/safe_exec.rb
climatic-0.2.26 lib/climatic/utils/safe_exec.rb