mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #1523 from wrl/relative-gembox-nokeyword
Implement gembox-relative gemdir paths
This commit is contained in:
@@ -297,6 +297,8 @@ module MRuby
|
||||
|
||||
GemBox = Object.new
|
||||
class << GemBox
|
||||
attr_accessor :path
|
||||
|
||||
def new(&block); block.call(self); end
|
||||
def config=(obj); @config = obj; end
|
||||
def gem(gemdir, &block); @config.gem(gemdir, &block); end
|
||||
|
||||
@@ -3,17 +3,26 @@ module MRuby
|
||||
def gembox(gemboxfile)
|
||||
gembox = File.expand_path("#{gemboxfile}.gembox", "#{MRUBY_ROOT}/mrbgems")
|
||||
fail "Can't find gembox '#{gembox}'" unless File.exists?(gembox)
|
||||
|
||||
GemBox.config = self
|
||||
GemBox.path = gembox
|
||||
|
||||
instance_eval File.read(gembox)
|
||||
|
||||
GemBox.path = nil
|
||||
end
|
||||
|
||||
def gem(gemdir, &block)
|
||||
caller_dir = File.expand_path(File.dirname(/^(.*?):\d/.match(caller.first).to_a[1]))
|
||||
|
||||
if gemdir.is_a?(Hash)
|
||||
gemdir = load_special_path_gem(gemdir)
|
||||
elsif GemBox.path && gemdir.is_a?(String)
|
||||
gemdir = File.expand_path(gemdir, File.dirname(GemBox.path))
|
||||
else
|
||||
gemdir = File.expand_path(gemdir, caller_dir)
|
||||
end
|
||||
|
||||
gemrake = File.join(gemdir, "mrbgem.rake")
|
||||
|
||||
fail "Can't find #{gemrake}" unless File.exists?(gemrake)
|
||||
|
||||
Reference in New Issue
Block a user