Class: Deadlink::Scanner
- Inherits:
-
Object
- Object
- Deadlink::Scanner
- Defined in:
- lib/deadlink/scanner.rb
Instance Method Summary collapse
-
#initialize(target_path) ⇒ Scanner
constructor
A new instance of Scanner.
- #md_files ⇒ Object
- #paths(files) ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(target_path) ⇒ Scanner
Returns a new instance of Scanner.
3 4 5 6 7 8 9 10 11 |
# File 'lib/deadlink/scanner.rb', line 3 def initialize(target_path) if target_path.nil? @repo_root = repo_root(".") @target_path = @repo_root else @target_path = target_path @repo_root = repo_root(@target_path) end end |
Instance Method Details
#md_files ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/deadlink/scanner.rb', line 21 def md_files files = [] if File.directory?(@target_path) glob do |file_path| files.push(MdFile.new(file_path, @repo_root)) end else files.push(MdFile.new(@target_path, @repo_root)) end MdFiles.new(files) end |
#paths(files) ⇒ Object
33 34 35 |
# File 'lib/deadlink/scanner.rb', line 33 def paths(files) Paths.new(files) end |
#valid? ⇒ Boolean
13 14 15 16 17 18 19 |
# File 'lib/deadlink/scanner.rb', line 13 def valid? unless FileTest.exist?(@target_path) puts @target_path + ": No such file or directory" return false end true end |