Module: Folder::MagicList
- Defined in:
- lib/folder/magic_list.rb
Instance Attribute Summary collapse
-
#base_path ⇒ Object
Returns the value of attribute base_path.
-
#rel_path ⇒ Object
Returns the value of attribute rel_path.
Instance Method Summary collapse
- #do_require(*options) ⇒ Object
- #except(*reg_exps) ⇒ Object
- #matching(*reg_exps) ⇒ Object
- #show_require(*options) ⇒ Object
Instance Attribute Details
#base_path ⇒ Object
Returns the value of attribute base_path.
3 4 5 |
# File 'lib/folder/magic_list.rb', line 3 def base_path @base_path end |
#rel_path ⇒ Object
Returns the value of attribute rel_path.
4 5 6 |
# File 'lib/folder/magic_list.rb', line 4 def rel_path @rel_path end |
Instance Method Details
#do_require(*options) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/folder/magic_list.rb', line 6 def do_require(*) rel_path = .shift if && !.empty? each do |file| req_file = self.rel_path ? File.join(self.rel_path, file) : file require req_file end self end |
#except(*reg_exps) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/folder/magic_list.rb', line 26 def except(*reg_exps) duplicate = self.dup.extend(MagicList) duplicate.each do |file| reg_exps.each {|re| duplicate.delete(file) if file.match(re) } end duplicate end |
#matching(*reg_exps) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/folder/magic_list.rb', line 34 def matching(*reg_exps) duplicate = self.dup.extend(MagicList) keep_list = [] duplicate.each do |file| reg_exps.each do |re| re = fix(re) if re.kind_of? String keep_list << file if file.match(re) end end reject_list = (duplicate - keep_list).flatten duplicate.delete_these(reject_list) end |
#show_require(*options) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/folder/magic_list.rb', line 15 def show_require(*) each do |f| if .include? :relative file_path = File.join(rel_path, f) path = Require::Directory.relative_path(base_path, file_path) end path = File.join(base_path, f) if !.include? :relative path end end |