Re: [MacRuby-devel] MacRuby-devel Digest, Vol 45, Issue 26

2011-11-17 Thread Jean-Denis MUYS
Thanks for your answer. I followed your advice, and indeed, it works quite 
nicely. However, in the meantime, I filed a ticket reporting the bug to the 
MacRuby project. And the bug is already fixed (thanks Watson1978). A commit has 
been added today with the fix. The latest nightly doesn't yet include the fix, 
but tomorrow's should. So I built MacRuby from source, and I can confirm that 
the short sample session that I quoted yesterday now works fine. I can't 
preclude other bugs to show up downstream, but I have no reason to suspect so.

So I now have two working options, between MCPKit and Sequel. MacRuby at its 
best.

For reference, the short version of the recipe for MCPKit is:

- Download the source code for Sequel Pro and open the included Xcode project. 
Sequel Pro uses Interface Builder plugins which are not support in Xcode 4. 
However, we won't build Sequel Pro, and it's OK here to use Xcode 4. I used 
Xcode 4.2

- Out of the 8 or so targets included in the Sequel Pro Xcode project, choose 
the framework target named MCPKit

- As of today, this target specifies an old SDK. In the target settings, switch 
the SDK to the latest SDK (10.7 under Lion for me).

- As of today, this target is set up as incompatible with GC. This doesn't work 
with MacRuby. Switch that target setting to "Supported". This setting is 
"Objective-C Garbage Collection" in the "Apple LLVM Compiler 3.0 - Language" 
section.

- The "Installation Directory" setting (in the "deployment" section) is set for 
installing the framework as a private framework in the application bundle. This 
works for me. If you want to install the framework system-wide, you'll have to 
change this.

- Build the target and copy the output package (MCPKit.framework) to your 
MacRuby source code directory.

- You can close the Sequel Pro Xcode project. Switch to your MacRuby Xcode 
project.

- Go to your app target "Build Phases" tab, and open the "Link Binary With 
Libraries" section. Click the + button to add the framework. In the library 
selection sheet, click "Add Other…" and select the MCPKit.framework package.

- Click the big + button at the bottom right of the Build Phases pane to add a 
new Copy Files phase. Select "Frameworks" in the new Copy Phase destination pop 
up menu. Drag the MCPKit.framework from your project source list to the Copy 
Phase file list (or alternatively use the + button).

- That's it.

This recipe actually works for any external private framework.

Jean-Denis



On 16 nov. 2011, at 19:28, 
mailto:[email protected]>>
 wrote:

Message: 3
Date: Wed, 16 Nov 2011 17:29:18 +
From: Steve Clarke mailto:[email protected]>>
To: "MacRuby development discussions."
mailto:[email protected]>>
Subject: Re: [MacRuby-devel] symbol not found: _rb_str_freeze
Message-ID: 
<[email protected]>
Content-Type: text/plain; charset=windows-1252

Hi Jean-Denis,

I can't answer your question directly but I may be able to help a bit. I also 
want to use mysql with `MacRuby.  I tried mysql gem version 2.8.1 and hit 
problems I couldn't work around.  I also tried ruby-mysql 2.9.4.  I did get 
that to work after some mods, but it was very slow to load and didn't seem 
totally reliable.

I then decided to use an Objective-C framework that accesses SQL.  Sequel Pro 
contains such a framework called MCPKit and it's open source.  This means no 
gems so it loads v quickly.  However, the version of MCPKit that I downloaded 
had manual memory management so wouldn't link with a MacRuby app.  I don't know 
much about Objective-C but I thought I would just try recompiling MCPKit with 
ARC and garbage collection.  To my surprise and delight it worked.  I'm afraid 
I don't know how robust this approach is likely to be.  Maybe I've just been 
lucky.  It would be interesting to hear from someone who understands memory 
management better than me.

Steve


On 16 Nov 2011, at 15:33, Jean-Denis MUYS wrote:

Hi,

I have a big showstopper with my app: sequel with the mysql gem fails with the 
following error message:

dyld: Symbol not found: _rb_str_freeze
Referenced from: /Library/Frameworks/MacRuby.frameword/[?]/mysql_api.bundle

This is mentioned on the net on the sequel project back in february. The 
diagnostic of the sequel developer was that this is a bug in MacRuby.

I am using MacRuby nightly latest as of November 17, 2011, which reports its 
version as 0.12
I have mysql gem version 2.8.1
I have sequel gem version 3.29.0

Steps to reproduce in macirb:

require 'ruby gems'
require 'sequel'
DB = Sequel.connect(:adapter => 'mysql', :user => 'root', :host => 'localhost', 
:database => 'test', :password => 'your password')
DB.tables

Is there any workaround/ easy fix?

I would appreciate any suggestion, including of alternate gems to use.

Jean-Denis

___
MacRuby-devel mailing list

Re: [MacRuby-devel] rubyfying Cocoa iterators

2011-11-17 Thread techzen
The Cbjective-C way to handle this would be to put a category that provided an 
`each` method on NSOrderedSet. Then when you called `each` it would just work. 
Ruby has a similar functionality but I can't remember right now what it's 
called. 

Using a category would be optimal in the case of Core Data because in some 
instances you can actually evoke a method as part of a key path when sending 
Key-Value messages.

Shannon

On Nov 16, 2011, at 4:11 AM, Jean-Denis MUYS wrote:

> I have this ordered Core Data to-many relation named "operations" that I want 
> to iterate over. I wrote:
> 
>self.operations.each { | operation | operation.doSomething }
> 
> However this fails because self.operations returns an NSOrderedSet and 
> NSOrderedSet doesn't have an 'each' method.
> 
> I was able to use the 'enumerateObjectsUsingBlock' method of NSOrderedSet 
> which is working fine.
> 
> My question is: what would be the MacRuby way to add an 'each' method to 
> NSOrderedSet?
> 
> Thanks,
> 
> Jean-Denis
> 
> 
> 
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


[MacRuby-devel] Is this possible in MacRuby?

2011-11-17 Thread [email protected]
Hi All,

Is it possible to make a Lion app(/option) with MacRuby which allows you to 
change the opacity (alpha value) of other apps/windows via the View menu?

So say I have a PDF open in Preview, I'd go to: view menu > transparency, and 
then set it to 50%

Is this possible? Would it be a pain to do? I don't think I've seen any MacRuby 
apps that add functionality to other apps like this so am guessing it's not 
trivial.

Cheers,

Aston
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] rubyfying Cocoa iterators

2011-11-17 Thread Kam Dahlin
If you didn't want to use a category, you could do:

orderedSet = NSOrderedSet.orderedSetWithArray(["1", "2", "3"])
orderedSet.class.send(:define_method, :each) do
   self.array.each do |item|
   yield item
   end
end

orderedSet.each do |item|
puts item
end

This method also has the advantage of capturing local scope, if needed.

hth
kam

On Nov 17, 2011, at 8:22 AM, techzen wrote:

> The Cbjective-C way to handle this would be to put a category that provided 
> an `each` method on NSOrderedSet. Then when you called `each` it would just 
> work. Ruby has a similar functionality but I can't remember right now what 
> it's called. 
> 
> Using a category would be optimal in the case of Core Data because in some 
> instances you can actually evoke a method as part of a key path when sending 
> Key-Value messages.
> 
> Shannon
> 
> On Nov 16, 2011, at 4:11 AM, Jean-Denis MUYS wrote:
> 
>> I have this ordered Core Data to-many relation named "operations" that I 
>> want to iterate over. I wrote:
>> 
>>   self.operations.each { | operation | operation.doSomething }
>> 
>> However this fails because self.operations returns an NSOrderedSet and 
>> NSOrderedSet doesn't have an 'each' method.
>> 
>> I was able to use the 'enumerateObjectsUsingBlock' method of NSOrderedSet 
>> which is working fine.
>> 
>> My question is: what would be the MacRuby way to add an 'each' method to 
>> NSOrderedSet?
>> 
>> Thanks,
>> 
>> Jean-Denis
>> 
>> 
>> 
>> ___
>> MacRuby-devel mailing list
>> [email protected]
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
> 
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] rubyfying Cocoa iterators

2011-11-17 Thread Matt Aimonetti
you could also create a module and mix it in with the objects you want have
the custom methods defined in.

- Matt

On Thu, Nov 17, 2011 at 3:21 PM, Kam Dahlin  wrote:

> If you didn't want to use a category, you could do:
>
> orderedSet = NSOrderedSet.orderedSetWithArray(["1", "2", "3"])
> orderedSet.class.send(:define_method, :each) do
>   self.array.each do |item|
>   yield item
>   end
> end
>
> orderedSet.each do |item|
>puts item
> end
>
> This method also has the advantage of capturing local scope, if needed.
>
> hth
> kam
>
> On Nov 17, 2011, at 8:22 AM, techzen wrote:
>
> > The Cbjective-C way to handle this would be to put a category that
> provided an `each` method on NSOrderedSet. Then when you called `each` it
> would just work. Ruby has a similar functionality but I can't remember
> right now what it's called.
> >
> > Using a category would be optimal in the case of Core Data because in
> some instances you can actually evoke a method as part of a key path when
> sending Key-Value messages.
> >
> > Shannon
> >
> > On Nov 16, 2011, at 4:11 AM, Jean-Denis MUYS wrote:
> >
> >> I have this ordered Core Data to-many relation named "operations" that
> I want to iterate over. I wrote:
> >>
> >>   self.operations.each { | operation | operation.doSomething }
> >>
> >> However this fails because self.operations returns an NSOrderedSet and
> NSOrderedSet doesn't have an 'each' method.
> >>
> >> I was able to use the 'enumerateObjectsUsingBlock' method of
> NSOrderedSet which is working fine.
> >>
> >> My question is: what would be the MacRuby way to add an 'each' method
> to NSOrderedSet?
> >>
> >> Thanks,
> >>
> >> Jean-Denis
> >>
> >>
> >>
> >> ___
> >> MacRuby-devel mailing list
> >> [email protected]
> >> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
> >
> > ___
> > MacRuby-devel mailing list
> > [email protected]
> > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


[MacRuby-devel] Key-Value Compliance & valueForKey:

2011-11-17 Thread Patrick Rogers
Hi everyone,

I'm trying to automatically generate the KVC-compliant methods for indexed 
to-many relationships.  

Here's my current attempt, https://gist.github.com/1374142, which borrows from 
hotcocoa's kvo_array (I couldn't get `kvo_array` to work and I wanted something 
that could just automatically be backed by an Array).

Anyways, countOf and objectInAtIndex: are both generated and work.

However, when I try and use valueForKey() on my generated keys, MacRuby 
crashes with:

> unknown: [BUG] unknown Objective-C immediate: 0x1 (nil)
> 
> MacRuby 0.11 (ruby 1.9.2) [universal-darwin10.0, x86_64]
> 
> [1]26123 abort  macruby kvo_array.rb


It is my understanding this should return an array based on my countOf and 
objectInAtIndex: methods.

On the other hand, when I use the manually defined methods, valueForKey(...) 
works as expected.

Is there an issue with my code/approach or is this a MacRuby bug?

Thanks,
Patrick
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


[MacRuby-devel] Mail Preference

2011-11-17 Thread Arron Mabrey
Hey guys,

A bit off topic I'm trying to change my list preference to do a daily batch
instead of real time. I can't seem to figure it out. Don't know where to
sign-in at.

Thanks

Arron Mabrey
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] Mail Preference

2011-11-17 Thread Perry E. Metzger
On Thu, 17 Nov 2011 16:08:50 -0500 Arron Mabrey 
wrote:
> Hey guys,
> 
> A bit off topic I'm trying to change my list preference to do a
> daily batch instead of real time. I can't seem to figure it out.
> Don't know where to sign-in at.
> 
> Thanks
> 
> Arron Mabrey

At the bottom of the mail you sent (or of this mail) you will see:

  MacRuby-devel mailing list
  [email protected]
  http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

Go to that URL and the rest will be obvious.

-- 
Perry E. [email protected]
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] symbol not found: _rb_str_freeze

2011-11-17 Thread Rob Ista
Well Jean-Denis .. thank you so much for a few solutions for questions that i 
posted but remained unanswered until now ;-) … one thing still left though : do 
you (or somebody else) have a solution for automatic code-signing of the 
private frameworks and "loose" dylibs too? (and with that may be for the .rbo 
files a swell? 
cheers, Rob
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel