A couple of years ago in the dark ages of Ruby, one created one Gem at a time, hopefully unit tested it and perhaps integrated it into a project.
Every minute change in a Gem could mean painstaking work often doing various builds, includes and/or install steps over and over. No more!
I created this simple Gem (a Gem itself!) that at run-time builds and installs all Gems in paths matching patterns defined by you.
I invite brave souls to try it out this EXPERIMENTAL release now pending a more thoroughly tested/mature release. Install RuntimeGemIncluder, define some simple configuration in your environment.rb or a similar place and use require as you normally would:
Here’s an example I used to include everything in my NetBeans workspace with JRuby.
Download the Gem from http://rubyforge.org/frs/?group_id=9252
To install, go to the directory where you have downloaded the Gem and type:
gem install runtime-gem-includer-0.0.1.gem
(Soon you may be able to install directly from RubyForge by simply typing ‘gem install runtime-gem-includer
‘.)
Some place before you load the rest of your project (like environment.rb if you’re using Rails) insert the following code:
trace_flag = "--trace"
$runtime_gem_includer_config =
{
:gem_build_cmd = "\"#{ENV['JRUBY_HOME']}/bin/jruby\" -S rake #{trace_flag} gem",
:gem_install_cmd = "\"#{ENV['JRUBY_HOME']}/bin/jruby\" -S gem install",
:gem_uninstall_cmd = "\"#{ENV['JRUBY_HOME']}/bin/jruby\" -S gem uninstall",
:gem_clean_cmd = "\"#{ENV['JRUBY_HOME']}/bin/jruby\" -S rake clean",
:force_rebuild = false,
:gem_source_path_patterns = [ "/home/erictucker/NetBeansProjects/*" ],
:gem_source_path_exclusion_patterns = []
}
require 'runtime_gem_includer'
If you are using JRuby and would like to just use the defaults, the following code should be sufficient:
$runtime_gem_includer_config =
{
:gem_source_path_patterns = [ "/home/erictucker/NetBeansProjects/*" ],
:gem_source_path_exclusion_patterns = []
}
require 'runtime_gem_includer'
Now simply in any source file as you normally would:
require 'my_gem_name'
And you’re off to the races!
Gems are dynamically built and installed at runtime (accomplished by overriding Kernel::require). Edit everywhere, click run, watch the magic! There may be some applications for this Gem in continuous integration. Rebuilds and reloads of specified Gems should occur during application startup/initialization once per instance/run of your application.
Interested in source, documentation, etc.? http://rtgemincl.rubyforge.org/