From 4940ddb9fcc1484730781a9a0b2e30957a8f6735 Mon Sep 17 00:00:00 2001 From: Takeshi Watanabe Date: Thu, 22 Mar 2018 12:42:41 +0900 Subject: Add `:path` option for git repository. --- doc/guides/mrbgems.md | 5 +++++ lib/mruby/build/load_gems.rb | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/guides/mrbgems.md b/doc/guides/mrbgems.md index 258f405b5..8dac0dc86 100644 --- a/doc/guides/mrbgems.md +++ b/doc/guides/mrbgems.md @@ -26,6 +26,11 @@ conf.gem :github => 'masuidrive/mrbgems-example', :branch => 'master' conf.gem :bitbucket => 'mruby/mrbgems-example', :branch => 'master' ``` +You can specify the sub directory of the repository with `:path` option: +```ruby +conf.gem github: 'mruby/mruby', path: 'mrbgems/mruby-socket' +``` + To use mrbgem from [mgem-list](https://github.com/mruby/mgem-list) use `:mgem` option: ```ruby conf.gem :mgem => 'mruby-yaml' diff --git a/lib/mruby/build/load_gems.rb b/lib/mruby/build/load_gems.rb index b48df6510..723be6ffc 100644 --- a/lib/mruby/build/load_gems.rb +++ b/lib/mruby/build/load_gems.rb @@ -76,9 +76,6 @@ module MRuby if params[:core] gemdir = "#{root}/mrbgems/#{params[:core]}" - elsif params[:path] - require 'pathname' - gemdir = Pathname.new(params[:path]).absolute? ? params[:path] : "#{root}/#{params[:path]}" elsif params[:git] url = params[:git] gemdir = "#{gem_clone_dir}/#{url.match(/([-\w]+)(\.[-\w]+|)$/).to_a[1]}" @@ -108,6 +105,11 @@ module MRuby # Jump to the top of the branch git.run_checkout gemdir, branch if $pull_gems end + + gemdir << "/#{params[:path]}" if params[:path] + elsif params[:path] + require 'pathname' + gemdir = Pathname.new(params[:path]).absolute? ? params[:path] : "#{root}/#{params[:path]}" else fail "unknown gem option #{params}" end -- cgit v1.2.3