Module: Callsite::LoadPathMethods

Defined in:
lib/callsite.rb

Instance Method Summary collapse

Instance Method Details

#add_currentObject



108
109
110
# File 'lib/callsite.rb', line 108

def add_current
  self << __DIR_REL__(caller.first)
end

#add_current!Object



112
113
114
# File 'lib/callsite.rb', line 112

def add_current!
  self.unshift(__DIR_REL__(caller.first))
end

#find_all_files(file, ext = nil) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
# File 'lib/callsite.rb', line 96

def find_all_files(file, ext = nil)
  file += ext if ext and File.extname(file) != ext
  inject([]){|ary, path| 
    target = File.expand_path(file, path)
    if File.readable?(target)
      ary << target
      yield target if block_given?
    end
    ary
  }
end

#find_file(file) ⇒ Object



91
92
93
94
# File 'lib/callsite.rb', line 91

def find_file(file)
  find_all_files(file){|f| return f}
  nil
end