Class: Markdown::Debug

Inherits:
Object
  • Object
show all
Defined in:
lib/tool-markdown/markdown/debug.rb

Class Method Summary collapse

Class Method Details



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/tool-markdown/markdown/debug.rb', line 24

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

.match_data(result) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/tool-markdown/markdown/debug.rb', line 6

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


17
18
19
20
21
22
# File 'lib/tool-markdown/markdown/debug.rb', line 17

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

.stopObject



42
43
44
# File 'lib/tool-markdown/markdown/debug.rb', line 42

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