Class: Rote::FilePatterns
- Inherits:
-
Object
- Object
- Rote::FilePatterns
- Defined in:
- lib/rote/rotetasks.rb
Overview
Just a temporary holder for a set of patterns that are used to construct a relative FileList
for pages and resources.
Instance Attribute Summary collapse
-
#dir ⇒ Object
Access the base dir for these patterns.
-
#excludes ⇒ Object
readonly
Returns the value of attribute excludes.
-
#includes ⇒ Object
readonly
Access the pattern arrays.
Instance Method Summary collapse
-
#exclude(*patterns) ⇒ Object
Specify glob patterns or regexps to exclude.
-
#include(*patterns) ⇒ Object
Specify glob patterns to include.
-
#initialize(basedir = '.') ⇒ FilePatterns
constructor
A new instance of FilePatterns.
-
#to_filelist ⇒ Object
Create a
FileList
with these patterns.
Constructor Details
#initialize(basedir = '.') ⇒ FilePatterns
Returns a new instance of FilePatterns.
18 19 20 21 |
# File 'lib/rote/rotetasks.rb', line 18 def initialize(basedir = '.') @dir = basedir @includes, @excludes = [], [] end |
Instance Attribute Details
#dir ⇒ Object
Access the base dir for these patterns
28 29 30 |
# File 'lib/rote/rotetasks.rb', line 28 def dir @dir end |
#excludes ⇒ Object (readonly)
Returns the value of attribute excludes.
25 26 27 |
# File 'lib/rote/rotetasks.rb', line 25 def excludes @excludes end |
#includes ⇒ Object (readonly)
Access the pattern arrays
24 25 26 |
# File 'lib/rote/rotetasks.rb', line 24 def includes @includes end |
Instance Method Details
#exclude(*patterns) ⇒ Object
Specify glob patterns or regexps to exclude
38 39 40 41 42 |
# File 'lib/rote/rotetasks.rb', line 38 def exclude(*patterns) patterns.each { |it| @excludes << it } end |
#include(*patterns) ⇒ Object
Specify glob patterns to include
31 32 33 34 35 |
# File 'lib/rote/rotetasks.rb', line 31 def include(*patterns) patterns.each { |it| @includes << it } end |
#to_filelist ⇒ Object
Create a FileList
with these patterns
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rote/rotetasks.rb', line 45 def to_filelist fl = FileList.new fl.include(*includes.map { |it| "#{dir}/#{it}"} ) unless includes.empty? # excludes may be regexp too fl.exclude(*excludes.map { |it| it.is_a?(String) ? "#{dir}/#{it}" : it } ) unless excludes.empty? # don't allow dir to be changed anymore. freeze fl end |