Ruby serialport gem.
Ruby-serialport doesn’t play well with RubyGems. Trying to require ’serialport’ when using RubyGems results in:
NameError: (eval):1:in `private_class_method': undefined method `create' for class `Class'
from (eval):1
from (eval):1
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from (irb):2The quick fix to get around this is by doing:
Kernel::require 'serialport'
It would be nicer if we could avoid the conflict with RubyGems. It would be even nicer if the serialport library was itself packaged as a gem. Turns out this has been done by aaronp but it doesn’t take advantage of GitHub’s automatic gem builder and doesn’t build correctly using GCC.
I’ve cloned and tidied the git repository. This gem version should build the needed native extension and work on both POSIX compatible and Windows operating systems.
Installing the serialport gem
If you haven’t configured GitHub as a gem source yet you will need to run the following command:
gem sources -a http://gems.github.com
Then, you can install the gem as normal:
sudo gem install toholio-serialport
Unlike the official ruby-serialport extension, this gem works with RubyGems (duh!). When you want to use it you should only need to do the following:
require 'rubygems' require 'serialport'
On a side note: git and GitHub rock. Forking, contributing to and merging projects should be this simple.