Sha256: c223fbc48bb3fb8a27691a8cbbc56ca13f0c632672551c6289a74b1211fdb2db

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

require 'colorize'

class Markdown
  class Debug
    def self.match_data(result)
      if result.to_a.size.zero?
        puts "\n[ignore] #{line}"
      else
        puts "\n[ DEBUG] #{result}: "
        result.to_a.each_with_index do |value,index|
          puts " #{(index+1)} : #{value}".white
        end
      end
    end

    def self.show_lines_with_links(lines)
      lines.each do |line|
        lineindex = "%04d" % line[:lineindex]
        puts "    LINE: #{lineindex} | URL: #{line[:linkurl]}"
      end
    end

    def self.check_links(lines: , dirpath: )
      checked = []
      lines.each do |line|
        filepath = File.join(dirpath, line[:linkurl])
        status = 'FAIL'
        status = ' ok ' if File.exist? filepath

        lineindex = "%04d" % line[:lineindex]
        msg = "    LINE: #{lineindex} | #{status} | URL: #{line[:linkurl]}"

        if status == 'FAIL'
          puts msg.light_red
        else
          puts msg.white
        end
      end
    end

    def self.stop
      require 'pry-byebug'; binding.pry
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tool-markdown-0.0.5 lib/tool-markdown/markdown/debug.rb
tool-markdown-0.0.4 lib/tool-markdown/markdown/debug.rb
tool-markdown-0.0.3 lib/markdown/markdown/debug.rb
tool-markdown-0.0.2 lib/markdown/markdown/debug.rb
tool-markdown-0.0.1 lib/markdown/markdown/debug.rb