Sha256: a01a4abe019c3c76a93a8fc92592b232459cacad1a622b3acb691ab2befd7547

Contents?: true

Size: 896 Bytes

Versions: 2

Compression:

Stored size: 896 Bytes

Contents

# frozen_string_literal: true

module DataTaster
  # helpers used globally in DataTaster
  module Helper
    def sanitize_command(command, params = nil)
      sanitized_command = command.gsub(Shellwords.escape(ENV.fetch("DEV_DUMP_USER", nil)), "<username>")
                                 .gsub(Shellwords.escape(ENV.fetch("DEV_DUMP_PASSWORD", nil)), "<pwd>")
                                 .gsub(ENV.fetch("DEV_DUMP_PASSWORD", nil), "<pwd>")

      sanitized_command = sanitized_command.gsub(Shellwords.escape(params["password"]), "<pwd>") if params

      sanitized_command
    end

    def db_yml
      @db_yml ||= YAML.safe_load(ERB.new(Rails.root.join("config", "database.yml").read).result, aliases: true)
    end

    def db_config
      @db_config ||= db_yml[Rails.env]
    end

    def logg(message)
      DataTaster.logger.debug { "[#{Time.current}] #{message}" }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
data_taster-0.3.0 lib/data_taster/helper.rb
data_taster-0.2.2 lib/data_taster/helper.rb