Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ported from old atomy; probably warrants another look, but it at least works
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Patch up RubyGems/require (indirectly) to support loading | ||
# Atomy gems | ||
|
||
Gem.suffixes << ".ay" | ||
|
||
module Kernel | ||
alias atomy_original_gem_original_require gem_original_require | ||
alias atomy_original_require require | ||
|
||
def require(name) | ||
if file = Atomy::CodeLoader.find_source(name) | ||
Atomy::CodeLoader.require(file) | ||
else | ||
atomy_original_require(name) | ||
end | ||
end | ||
|
||
def gem_original_require(name) | ||
if file = Atomy::CodeLoader.find_source(name) | ||
Atomy::CodeLoader.require(file) | ||
else | ||
atomy_original_gem_original_require(name) | ||
end | ||
end | ||
|
||
module_function :require | ||
module_function :gem_original_require | ||
|
||
private :atomy_original_gem_original_require | ||
private :atomy_original_require | ||
end | ||
|
||
# this is here so it's more likely to be filtered out of caller checks | ||
# | ||
# (e.g. sinatra/base) | ||
class Atomy::Module | ||
def require(path) | ||
if path.start_with? "./" | ||
Kernel.require(File.expand_path("../" + path, @file.to_s)) | ||
else | ||
Kernel.require(path) | ||
end | ||
end | ||
end |