Gems - current and future use

For several reasons, I’m wondering:

  1. Do you use any gems in SketchUp?

  2. Have you written a ‘public’ plugin that uses them?

  3. If known, were they extension gems (gems that include c code)?

  4. If 3, and windows related, did you use a pre-compiled ‘fat binary’ gem, or build it yourself?

  5. Are there gems you’d like to use, but haven’t? If so, why not?

  6. Are there gems you think should be pre-installed with SketchUp?

Note - some licenses may not allow including a gem in software that is not OSS.

Thanks, Greg

You probably know all my answers to this already, but I’ll just add it here for public record:

  1. I have used it for internal development tools.

  2. No.

  3. Yes - rubyprof for instance. Which I had to compile in a compatible standalone Ruby installation and copy over the compiled gem.

  4. Had to build it myself.

  5. For released “public” extensions I don’t want to use gems. At least not as they appear out of the box. Due to risk of clashing with other extensions. I would only use a gem if I modified it and bundled it with my own extension. (Forcing the user to have to wait to install and possible compile a gem isn’t ideal user experience.)

  6. Good question. I’ll be keeping an eye on the response for this.

-Thom

chunky_png-1.3.8
dom-1.0.1
htmlentities-4.3.4
mustache-1.0.5
pdf-core-0.7.0
plist-3.3.0
prawn-2.2.2
rake-12.2.1
rubyzip-1.2.1
ttfunk-1.5.1
xml-simple-1.1.5

not widely distributed

if they are I usually just use the bin script directly from ruby

n/a

yes there are others, but the Gem ENV on mac version is broken, some things point to system ruby rather than the packaged ruby…

ruby-zip would make cross platform easier, although API calls to SU’s internal zip/unzip would be better…

one example is the FreeImage can read direct from an image in a zip file, but it’s not exposed to the API so you have roll your own…

john

I tried using it for one extension some time back. I had SketchUp install the gem if it was missing and only load the extension when the Gem was available but that was messy and slow. I quickly changed my plugin to simply icnclude the Gem but wrapped into my own namespace.

To all,

Thank you for the replies. I have to think about this some more, but maybe a RubyGems utility might be helpful, since, as you know, RubyGems is really designed to be a CLI (command line) tool.

I’ve got gem code here and there that runs in scripts, and I think @DanRathbun has posted a few snippets. Regardless, if I do anything with it, I’m sure I’ll ask some really stupid MacOS questions, as I’m windows only.

The gem @tt_su mentioned, (ruby-prof) looks like it can be very helpful for development. From time to time, I’ve thought nokogiri would be helpful, as it makes creating/querying/updating xml and html very easy.

Note:

To clarify for people that may be unfamiliar with gems, they can be divided into two types –

The first are pure ruby gems, and should install into any version of ruby that they support.

The second, which are often called extension gems, have c code that must be compiled to use them. Re SU and plugins, the issue is that the compiled code is ruby major/minor version specific, as it links to the ruby dll or so file. IOW, code compiled for Ruby 2.2.x will not run on Ruby 2.3.x.

I think a SU specific branch from https://github.com/sawa/dom could be useful for you other endeavour…

I have only recently started playing with it for web dialogs…

john

I’ve used this in standalone Ruby - as part of development tool. Parsing and extracting strings from HTML pages. But not needed from SU itself. I think XML would have been more relevant a few years ago - but these days it appear that most APIs consume JSON (which is a good thing for SU extensions since JSON is part of StdLib.)

I’ve been working on a wrapper on top of this gem - very useful to pin down bottlenecks; GitHub - SketchUp/speedup: Profiling tool for SketchUp Ruby extensions.

Since this is a development tool it’s one of the times when I actually use gems within SU.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.