Skip to content

Commit 24fcb96

Browse files
committed
require_more
1 parent a29e2b4 commit 24fcb96

3 files changed

Lines changed: 26 additions & 2 deletions

File tree

lib/coaster/core_ext/require_more.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def require_more
1414
more_load_paths.each do |load_path|
1515
path = File.join(load_path, load_name)
1616
if File.exist?(path)
17-
return require_dependency path
17+
return require path
1818
end
1919
end
2020

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
def require_more
2+
required_file_path = caller[0].split(':', 2).first
3+
load_name = nil
4+
load_path_index = $LOAD_PATH.each_with_index do |load_path, ix|
5+
scanned = required_file_path.scan(/(#{load_path})#{File::SEPARATOR}(.*)/).first
6+
next false unless scanned
7+
load_name = scanned[1]
8+
break ix
9+
end
10+
11+
return false unless load_path_index
12+
13+
more_load_paths = $LOAD_PATH.drop(load_path_index + 1)
14+
more_load_paths.each do |load_path|
15+
path = File.join(load_path, load_name)
16+
if File.exist?(path)
17+
loaded = require(path)
18+
loaded = load(path) unless loaded
19+
return loaded
20+
end
21+
end
22+
23+
raise LoadError, "cannot require more -- #{load_name}"
24+
end

lib/coaster/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Coaster
2-
VERSION = '1.4.26'
2+
VERSION = '1.4.27'
33
end

0 commit comments

Comments
 (0)