Class: Folder::Magic
- Inherits:
-
Object
- Object
- Folder::Magic
- Defined in:
- lib/require-dsl.rb
Instance Attribute Summary collapse
-
#current_path ⇒ Object
Returns the value of attribute current_path.
-
#dir_stack ⇒ Object
Returns the value of attribute dir_stack.
Instance Method Summary collapse
- #all(*globs) ⇒ Object
- #enter(dir) ⇒ Object
-
#initialize ⇒ Magic
constructor
A new instance of Magic.
Constructor Details
#initialize ⇒ Magic
Returns a new instance of Magic.
86 87 88 89 |
# File 'lib/require-dsl.rb', line 86 def initialize @dir_stack = [] @current_path = FileUtils.pwd end |
Instance Attribute Details
#current_path ⇒ Object
Returns the value of attribute current_path.
83 84 85 |
# File 'lib/require-dsl.rb', line 83 def current_path @current_path end |
#dir_stack ⇒ Object
Returns the value of attribute dir_stack.
84 85 86 |
# File 'lib/require-dsl.rb', line 84 def dir_stack @dir_stack end |
Instance Method Details
#all(*globs) ⇒ Object
104 105 106 107 108 109 110 111 |
# File 'lib/require-dsl.rb', line 104 def all(*globs) globs = '**/*.rb' if globs.empty? list = FileList.new(globs) list.extend(MagicList) list.base_path = dir_stack.first list.rel_path = current_path list.freeze end |
#enter(dir) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/require-dsl.rb', line 91 def enter(dir) FileUtils.cd dir dir_stack.push path = FileUtils.pwd @current_path = path if block_given? yield path current_path = dir_stack.last old_dir = dir_stack.last if dir_stack.pop FileUtils.cd old_dir if old_dir end path end |