Class: Minitest::Filesystem::Matcher::MatchingTree

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/filesystem/matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ MatchingTree

Returns a new instance of MatchingTree.



97
98
99
100
# File 'lib/minitest/filesystem/matcher.rb', line 97

def initialize(root)
  @root = Pathname.new(root)
  @tree = expand_tree_under @root
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



95
96
97
# File 'lib/minitest/filesystem/matcher.rb', line 95

def root
  @root
end

Instance Method Details

#expand_path(file) ⇒ Object



114
115
116
# File 'lib/minitest/filesystem/matcher.rb', line 114

def expand_path(file)
  @root + Pathname.new(file)
end


118
119
120
# File 'lib/minitest/filesystem/matcher.rb', line 118

def follow_link(link)
  Pathname.new(File.readlink(expand_path(link)))
end

#has_target?(entry, target) ⇒ Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/minitest/filesystem/matcher.rb', line 110

def has_target?(entry, target)
  expand_path(target) == follow_link(entry)
end

#include?(entry) ⇒ Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/minitest/filesystem/matcher.rb', line 102

def include?(entry)
  @tree.include?(expand_path(entry))
end

#is_a?(entry, kind) ⇒ Boolean

Returns:

  • (Boolean)


106
107
108
# File 'lib/minitest/filesystem/matcher.rb', line 106

def is_a?(entry, kind)
  (expand_path entry).send("#{kind}?")
end