Add `:path` option for git repository.
authorTakeshi Watanabe <[email protected]>
Thu, 22 Mar 2018 03:42:41 +0000 (22 12:42 +0900)
committerTakeshi Watanabe <[email protected]>
Thu, 22 Mar 2018 03:42:41 +0000 (22 12:42 +0900)
doc/guides/mrbgems.md
lib/mruby/build/load_gems.rb

index 258f405..8dac0dc 100644 (file)
@@ -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'
index b48df65..723be6f 100644 (file)
@@ -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