Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run gem from local source code

Tags:

ruby

I am currently working on developing a gem and I would like to be able to run that gem from command line and point it to my local source. Previously I've done this in rails by specifying the path in the gem file but now I would like to run the gem on a non rails app. So I would like to know how to call the gem from command line and specify that I want to use the source code in a certain directory.

For example can I cd into the directory that I want to run it on and do something like: ruby my_gem --path=~/code/mygem

Also do I have to build them gem or can I run it from source without building it?

like image 364
NateSHolland Avatar asked Mar 16 '15 14:03

NateSHolland


1 Answers

From the root directory of your gem, try this to execute lib/MyGem.rb:

ruby -Ilib lib/MyGem.rb

or test your gem interactive:

irb -Ilib
> require 'mygem'
true
like image 80
zwippie Avatar answered Oct 21 '22 00:10

zwippie