NateSHolland
NateSHolland

Reputation: 1170

Run gem from local source code

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?

Upvotes: 7

Views: 2320

Answers (1)

zwippie
zwippie

Reputation: 15515

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

Upvotes: 10

Related Questions