After some good reading of rubygems excellent documentation I got it work on the system Ruby. These are the steps assuming that the gem is downloaded in the Download folder
First download the gem from https://rubygems.org/downloads/ruby_clipper-5.0.3.gem
Unpack the gem
gem unpack ruby_clipper-5.0.3
cd ruby_clipper-5.03
Modify lib/clipper/version.rb adding the top level namespace
module Clipper
......
to
module RG::Clipper #RG is my top level namespace
Now modify the rbclipper.cpp from
VALUE mod = rb_define_module("Clipper");
VALUE k = rb_define_class_under(mod, "Clipper", rb_cObject);
rb_define_singleton_method(k, "new",
(ruby_method) rbclipper_new, 0);
to
VALUE top = rb_define_module("RG"); #Top level namespace
VALUE mod = rb_define_module_under(top, "Clipper"); #Clipper module under RG namespace
VALUE k = rb_define_class_under(mod, "Clipper", rb_cObject);
rb_define_singleton_method(k, "new",
(ruby_method) rbclipper_new, 0);
Now clipper is under the top level namespace RG.
We need to create the gemspec file. Move back to Download and extract the gemspec file from the original gem (this has not changed). This command extracts the gemspec file in ruby format (–ruby)
gem spec ruby_clipper-5.0.3.gem --ruby > ruby_clipper-5.0.3/ruby_clipper-5.0.3.gemspec
Now we need to rebuild the gem. Move back to the gem folder
cd ruby_clipper-5.0.3
and build the gem using the gemspec file just created
gem build ruby_clipper-5.0.3.gemspec
At this point we can install the modified gem from the local file (we are still in the gem folder)
sudo gem install --force --local ruby_clipper-5.0.3.gem
--force #Ignore dependencies
--local #Restrict operations to the LOCAL domain
The (modified) gem is now installed in system Ruby.
In irb we can write
require 'clipper'
c = RG::Clipper::Clipper.new
and get
=> #<RG::Clipper::Clipper:0x007f8ea232ca48 @multiplier=1048576>
Now I move
/Library/Ruby/Gems/2.0.0/gems/ruby_clipper-5.0.3/ext/clipper/clipper.bundle
to my SU RG folder
Users/ruggiero/Library/Application Support/SketchUp 2015/SketchUp/Plugins/RG/ext
but when i require clipper
require 'RG/ext/clipper'
I get a ugly bug splat!!!
Am i doing something wrong?
Thanks