Sha256: fdd1c7385ea8c2fda67512e0ffac3b8bf9cf796d44bf722ce66300912ae50683

Contents?: true

Size: 1.04 KB

Versions: 14

Compression:

Stored size: 1.04 KB

Contents

class RakeCommander
  module Patcher
    # Helpers to patch
    module Debug
      # Helper for debugging
      def rake_comm_debug(msg, prefix = '', num: nil, pid: false)
        return unless RakeCommander::Patcher.debug?
        rake_comm_debug_random_object_id
        num = num ? "#{num}. " : nil
        if pid
          meta = "(PID: #{Process.pid} ++ Thread: #{Thread.current.object_id} ++ Ruby 'main': #{rake_comm_debug_main_object_id})"
          msg  = "#{prefix}( #{num}#{Rake.application.object_id})   #{msg}   #{meta}"
        elsif num
          msg  = "#{prefix}( #{num})   #{msg}   "
        end
        puts msg
      end

      def rake_comm_debug_main_object_id
        eval('self.object_id', TOPLEVEL_BINDING, __FILE__, __LINE__)
      end

      def rake_comm_debug_random_object_id
        return false if @rake_comm_debug_random_object_id
        @rake_comm_debug_random_object_id = Array(1..20).sample.times.map do |i|
          i.to_s.tap(&:object_id)
        end
        true
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rake-commander-0.4.0 lib/rake-commander/patcher/debug.rb
rake-commander-0.3.6 lib/rake-commander/patcher/debug.rb
rake-commander-0.3.5 lib/rake-commander/patcher/debug.rb
rake-commander-0.3.3 lib/rake-commander/patcher/debug.rb
rake-commander-0.2.12 lib/rake-commander/patcher/debug.rb
rake-commander-0.2.11 lib/rake-commander/patcher/debug.rb
rake-commander-0.2.10 lib/rake-commander/patcher/debug.rb
rake-commander-0.2.7 lib/rake-commander/patcher/debug.rb
rake-commander-0.2.6 lib/rake-commander/patcher/debug.rb
rake-commander-0.2.5 lib/rake-commander/patcher/debug.rb
rake-commander-0.2.4 lib/rake-commander/patcher/debug.rb
rake-commander-0.2.3 lib/rake-commander/patcher/debug.rb
rake-commander-0.2.2 lib/rake-commander/patcher/debug.rb
rake-commander-0.2.0 lib/rake-commander/patcher/debug.rb