module TwineLinkChecker::Checker
Constants
- EXTENSIONS
- FILE_MATCHER
Public Class Methods
check_file(filename)
click to toggle source
# File lib/twine-link-checker/checker.rb, line 19 def self.check_file(filename) Dir.chdir(File.dirname(File.expand_path(filename))) do extract_paths(File.basename(filename)).reject(&File.method(:file?)) end end
extract_paths(filename)
click to toggle source
as one can see, not all valid characters will be matched the file must be a relative path
# File lib/twine-link-checker/checker.rb, line 11 def self.extract_paths(filename) File.open(filename) do |file| file.readlines.map(&HTMLEntities.new.method(:decode)).map do |line| line[FILE_MATCHER]&.gsub(/\\\\|\\/, '/') end.compact.uniq end end