OSX only gem

Hi,

I’ve written a LaunchAgent which is like a unix daemon but runs as a
user process, not a root/system process for OS X.

I’ve written some ruby code for working with the launch agent. A
collection of library routines, a few scripts and a collection of test
scripts for testing the launch agent. I’ve currently got no tests for
the ruby code itself. I’ve been using yard to generate documentation.

I’m still new to ruby, and am still at the stage that whenever I look at
code I wrote a couple of months ago I’m embarrassed.

My question relates to creating a ruby gem. I would like to create a gem
that can only be installed on OS X, and that can only be installed on
Mavericks and above. I want to keep the barrier to using my software as
low as sensibly possible so I’m not interested in installations of RVM
and the different versions of ruby that it provides access to. I want to
make sure everything works with the ruby 2.0.0 that comes installed with
Mavericks and not add complications.

I’ve been reading the documentation on gemspecs and it is not clear to
me how I can use the gemfile to limit to OS X Mavericks (or higher) the
gem can be installed on?

I know I’m not using ruby here in the way most people here are using it,
but when I looked at scripting languages to work with the LaunchAgent,
ruby looked really interesting as a new language to learn coming from an
Objective-C C++ background.

Some guidance would be appreciated.

Kevin

Hi Kevin,

I don’t think there is an official method for enabling your gem to be
installed only on some systems. However, you can put some check in the
gem
such that only OSX users would be allowed to use the functionality. The
RUBY_PLATFORM constant should be enought for that, as you can see from
this
stackoverflow post:

Hope that helps.


Carlos A.
Software Engineer
+55 11 97320-3878 | @carlos_agarie

2014-07-11 10:10 GMT-03:00 Kevin M. [email protected]:

Hi Carlos,

Thanks for responding. I have to say I’m surprised, being completely new
to ruby gems I assumed that the podspec would define on what platforms
it works and didn’t work and that would be used to restrict whether the
gem could be installed or not.

I suppose there is a good reason that this isn’t the case that I don’t
understand or that for some reason it is more difficult to implement
than I would have thought.

I am going to be writing my first gem while fairly new to ruby and that
gem is going to be made more complicated for this reason.

Kevin

Quoting S. [email protected]:

Keven I’m curious. You understand that rvm is not a dependency. What’s your
logic on restricting yourself to a specific system?

The launch agent I have written, is a native os x tool. It is written
in objective-c taking advantage of OS X frameworks. I’m using ruby to
drive this tool. The gem I am making will therefore have no point and
won’t work on platform other than OS X. Was that not clear from the
first paragraph of my original e-mail?

Kevin

The reason your seeing

Keven I’m curious. You understand that rvm is not a dependency. What’s
your
logic on restricting yourself to a specific system? The reason your
seeing
it as more complicated is because your making extra work for yourself by
avoiding the unix philosophy.

On Jul 11, 2014, at 6:10, Kevin M. [email protected] wrote:

I’ve been reading the documentation on gemspecs and it is not clear to me how I
can use the gemfile to limit to OS X Mavericks (or higher) the gem can be
installed on?

Specification Reference - RubyGems Guides

You can use platform= to limit it to OSX. I don’t think there is
distinction between varying versions of the OS. To do that, I’d call out
to sw_vers:

% sw_vers -productVersion
10.9.4

You might find an install hook that can manage that, or you can just put
it at the front of your cmdline tool.

I guess I don’t see it. GCC and Clang both have the objective-c natively
and in macros as well as end user support from both next, open and
gnustep.
Non the less for vender lockout consider implementing an inference
predicate assignment or save yourself some time and simply yield a note
to
the end user that this is an apple only cron job tool to aid users
unfamiliar with user level services and common sense protocols such at
or
atrun as but not exclusive to crontab -e if and only if one doesn’t want
to
call launch.d explicitly or write a dsl to act portabley and/or
implicitly
regardless of simplicity regardless how uname it.

I have no idea if next or any other platform has implemented frameworks
like Apple’s core image or NSXPCConnection.

I’m not aiming for web development here, just a tool so users can
process image files and movie frames on their mac.

I was thinking of writing an AppleScript interface but I thought I’d
check out other scripting languages on OSX first and decided that ruby
looked like an interesting choice. Nice to write code for but I’m
beginning to think the advantage AppleScript has is the exceptionally
low threshold needed for someone new to start getting stuff done. This
is what I’ve been trying to ensure with how I make my stuff available
for users.

Kevin

Sent from my iPhone