Top Level Namespace
Constant Summary collapse
- VERSION =
'1.1.0'
Instance Method Summary collapse
Instance Method Details
#autoloads(base, symbols = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/requires.rb', line 20 def autoloads(base, symbols = nil) unless symbols symbols = base base = '.' end base_path = caller_locations(1..1).first.path base_dir = File.dirname base_path path = File. base, base_dir symbols.each do |symbol| file = symbol.to_s .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') # Break consecutive uppercase letters before the last capital .gsub(/([a-z\d])([A-Z])/, '\1_\2') # Break lowercase or digits before an uppercase letter .downcase autoload symbol, "#{path}/#{file}" end end |
#requires(item) ⇒ Object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/requires.rb', line 1 def requires(item) base_path = caller_locations(1..1).first.path base_dir = File.dirname base_path path = File. item, base_dir if File.directory? path Dir["#{path}/**/*.rb"].each do |file| require file end elsif File.file?("#{path}.rb") || File.file?(path.to_s) require path else require item end end |