Class: Rubble::FileSet
- Inherits:
-
Object
- Object
- Rubble::FileSet
- Defined in:
- lib/rubble/file_set.rb
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(dir, *files) ⇒ FileSet
constructor
A new instance of FileSet.
- #paths ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(dir, *files) ⇒ FileSet
Returns a new instance of FileSet.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rubble/file_set.rb', line 8 def initialize(dir, *files) @dir = Pathname.pwd + Pathname(dir) if files.nil? then @files = [] else flattened_files = (files || []).collect {|f| Array(f)}.flatten @files = flattened_files.map do |f| p = (@dir + Pathname(f)).relative_path_from(@dir) if p.to_s.start_with?('../') or p.to_s == '.' then raise ArgumentError, "File name '#{f}' must be relative to base directory #{@dir} of the file set." end p end @files.sort! end @files.freeze end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
5 6 7 |
# File 'lib/rubble/file_set.rb', line 5 def dir @dir end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
6 7 8 |
# File 'lib/rubble/file_set.rb', line 6 def files @files end |
Instance Method Details
#empty? ⇒ Boolean
33 34 35 |
# File 'lib/rubble/file_set.rb', line 33 def empty? @files.empty? end |
#paths ⇒ Object
29 30 31 |
# File 'lib/rubble/file_set.rb', line 29 def paths @files.map {|f| @dir + f} end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/rubble/file_set.rb', line 37 def to_s to_yaml end |