Class: Build::Files::Glob
- Inherits:
-
List
- Object
- List
- Build::Files::Glob
show all
- Defined in:
- lib/build/files/glob.rb
Constant Summary
Constants inherited
from List
List::NONE
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from List
#+, #-, #==, coerce, #copy, #create, #delete, #empty?, #exist?, #intersects?, #map, #to_paths, #to_s, #touch, #with
Constructor Details
#initialize(root, pattern) ⇒ Glob
Returns a new instance of Glob.
17
18
19
20
|
# File 'lib/build/files/glob.rb', line 17
def initialize(root, pattern)
@root = root
@pattern = pattern
end
|
Instance Attribute Details
#pattern ⇒ Object
Returns the value of attribute pattern.
23
24
25
|
# File 'lib/build/files/glob.rb', line 23
def pattern
@pattern
end
|
#root ⇒ Object
Returns the value of attribute root.
22
23
24
|
# File 'lib/build/files/glob.rb', line 22
def root
@root
end
|
Instance Method Details
#each(&block) ⇒ Object
Enumerate all paths matching the pattern.
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/build/files/glob.rb', line 34
def each(&block)
return to_enum unless block_given?
::Dir.glob(full_pattern, ::File::FNM_DOTMATCH) do |path|
next if path =~ /\/..?$/
yield Path.new(path, @root)
end
end
|
#eql?(other) ⇒ Boolean
45
46
47
|
# File 'lib/build/files/glob.rb', line 45
def eql?(other)
self.class.eql?(other.class) and @root.eql?(other.root) and @pattern.eql?(other.pattern)
end
|
#full_pattern ⇒ Object
29
30
31
|
# File 'lib/build/files/glob.rb', line 29
def full_pattern
Path.join(@root, @pattern)
end
|
#hash ⇒ Object
49
50
51
|
# File 'lib/build/files/glob.rb', line 49
def hash
[@root, @pattern].hash
end
|
#include?(path) ⇒ Boolean
53
54
55
|
# File 'lib/build/files/glob.rb', line 53
def include?(path)
File.fnmatch(full_pattern, path)
end
|
#inspect ⇒ Object
61
62
63
|
# File 'lib/build/files/glob.rb', line 61
def inspect
"<Glob #{full_pattern.inspect}>"
end
|
#rebase(root) ⇒ Object
57
58
59
|
# File 'lib/build/files/glob.rb', line 57
def rebase(root)
self.class.new(root, @pattern)
end
|
#roots ⇒ Object
25
26
27
|
# File 'lib/build/files/glob.rb', line 25
def roots
[@root]
end
|