Sha256: c67eaf6bd5b56f05ebc8ef13be7f69d7019d6a60a6b9d94409e25db6cb710f75

Contents?: true

Size: 623 Bytes

Versions: 1

Compression:

Stored size: 623 Bytes

Contents

# frozen_string_literal: true

# encoding=utf-8

require 'json'
require 'yaml'

require_relative 'env'
include Env # rubocop:disable Style/MixinUsage

# add function for in-line tap
#
module Tap
  $pdebug = env_bool 'MDE_DEBUG'

  def tap_config(enable)
    $pdebug = enable
  end

  def tap_inspect(format: nil, name: 'return')
    return self unless $pdebug

    cvt = {
      json: :to_json,
      string: :to_s,
      yaml: :to_yaml,
      else: :inspect
    }
    fn = cvt.fetch(format, cvt[:else])

    puts "-> #{caller[0].scan(/in `?(\S+)'$/)[0][0]}()" \
         " #{name}: #{method(fn).call}"

    self
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
markdown_exec-1.2.0 lib/tap.rb