Access to Ruby standard library from scripts?
-
I posted this a week ago to the google group but that seems to get almost zero traffic.
Apologies if this has been posted and answered already.
I'm trying to utilize the CSV class from the 1.8.7 standard library [http://ruby-doc.org/stdlib-1.8.7/libdoc/csv/rdoc/CSV.html]. However 'require csv.rb' leads to an unknown file error. I also tried to link directly to the 1.8 lib directory on my machine [for me it's /usr/lib/ruby/1.8 and ruby --version returns => ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
Am I doing something wrong or is this not supported?
Thanks in advance,
Chris. -
@crudolph said:
Am I doing something wrong or is this not supported?
Both, partially,
Firstly, I am by no means an expert on the subject, just an over zealous mac hacker...
Sketchup's 'require' doesn't include the 'standard ruby' in it's load path array, you need to tell SU where to look...
and a couple of other things.some things can be 'loaded' on there own using a full path, but others won't work without additional requires...
some can be copied into a relative folder, with the same proviso.It is possible to switch between SU's 1.8.5 ruby and the Systems 1.8.7 ruby and there is a ruby beta that adds a reload so you can do it on the fly.
BUT, it all depends on your end game.
if your distributing a plugin, I wouldn't use ruby switching, it has some hiccups (including potential loss of system ruby, which might annoy your users)
There are more details in other threads, so have a dig, fill in your user profile and post some details of what you need to achieve, then we can help more...
john -
Standard Library isn't compatible with SketchUp Ruby. For instance, the Set class that SketchUp bundle isn't compatible with the STL Set class.
Advertisement