[MacRuby-devel] Gems again; signing records

Joshua Ballanco jballanc at gmail.com
Fri Jan 28 10:25:16 PST 2011


On Fri, Jan 28, 2011 at 12:41 PM, Martin Hawkins
<martin.hawkins at gmail.com>wrote:

> In rb_main.rb
>
> $:.unshift  File.join(File.dirname(__FILE__), 'Vendor/uuid-2.3.1/lib')
> $:.unshift  File.join(File.dirname(__FILE__), 'Vendor/macaddr-1.0.0/
> lib')
>
> require 'macaddr'
> require 'uuid'
>
> However, when I try to require 'macaddr' or 'uuid' from another class
> definition file, I get 'no such file to load'.
>

Two things:

-- You should only have to require these files once, unless you expect the
other class definitions to be used independently of your main project.
Putting these in rb_main.rb is typically a good idea.
-- This might be obvious, but just in case: the "File.join(File.dirname..."
patern will only work in rb_main.rb or any other file in the same directory.
If you've put your class definition files in lib/ then you'll need to change
the relative path.


> 1. What is the *proper* way of incorporating gems into a MacRuby
> project using XCode to build and run; and
>

Typically, when you unpack a gem it will have a structure like:

/foo_gem-1.0/lib
/foo_gem-1.0/lib/foo_gem.rb
/foo_gem-1.0/lib/foo_gem/library_files.rb

In other words, usually the "lib" directory is already partitioned by gem
name inside the gem. So, what I do is to just collect all the contents of
the "lib" directories for all the gems and put them together (either
directly in my own lib/ or in vendor/lib/). There's no reason for the extra
directories...just adds complexity.


> 2. All I want to do is sign records for later comparison. Can anybody
> suggest an alternative method, other than using UUID?
>

In MacRuby you can use the CFUUID utilities:
http://developer.apple.com/library/mac/#documentation/CoreFoundation/Reference/CFUUIDRef/Reference/reference.html

> macirb
irb(main):001:0> framework 'Foundation'
=> true
irb(main):002:0> cfuuid = CFUUIDCreate(nil)
=> #<__NSCFType:0x200f6dd60>
irb(main):003:0> id = CFUUIDCreateString(nil, cfuuid)
=> "689369A5-5CCD-41D0-BF83-1759BFD4F3EA"
irb(main):004:0> CFRelease(cfuuid)
=> nil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20110128/c271b653/attachment.html>


More information about the MacRuby-devel mailing list