Re: [MacRuby-devel] [hotcocoa] MVC helper?

2009-04-20 Thread isaac kearse
I forked the repo and fixed applied the fix here:
http://github.com/isaac/phare/commit/b6d78dd4d60b61ea5d7532fc6e43f7e72fdfa894

On Tue, Apr 21, 2009 at 7:25 AM, Matt Aimonetti wrote:

> I made some modifications and I probably broke some stuff. Sorry about
> that. Rich and I worked on a new super cool HotCocoa app's structure.
>
> It's not fully done yet but we'll work on it in 2 weeks at RailsConf.
>
> - Matt
>
>
> On Mon, Apr 20, 2009 at 8:39 AM, Emil Tin  wrote:
>
>> cool!
>> i cloned the git repo, but when i do 'macrake' in the dir, it fails.
>>
>> ~/phare$ macrake
>> (in /Users/emiltin/phare)
>>
>> 2009-04-17 09:29:21.313 Phare[12075:613] registering AccountSetupView
>> 2009-04-17 09:29:21.440 Phare[12075:613] registering ProjectSelectionView
>> 2009-04-17 09:29:22.707 Phare[12075:613] registering WebView
>> 2009-04-17 09:29:23.492 Phare[12075:613] Loading Lighthouse Account
>> Settings
>> 2009-04-17 09:29:23.494 Phare[12075:613] available view classes:
>> [{:klass=>"AccountSetupView", :description=>"Lighthouse Account Settings"},
>> {:klass=>"ProjectSelectionView", :description=>"Project Selection"},
>> {:klass=>"WebView", :description=>"Lighthouse Help"}]
>> 2009-04-17 09:29:23.495 Phare[12075:613] looking for Lighthouse Account
>> Settings
>> 2009-04-17 09:29:23.496 Phare[12075:613] HotCocoa couldn't find a view
>> with a description defined as: ''
>> 2009-04-17 09:29:23.496 Phare[12075:613] stack trace:
>> ***
>> 2009-04-17 09:29:23.497 Phare[12075:613]
>> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/vendor/mvc.rb:75:in
>> `display'
>> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/application.rb:32:in
>> `block in start'
>> /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.1/hotcocoa/mappings/application.rb:9:in
>> `call'
>> /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.1/hotcocoa/mappings/application.rb:9:in
>> `handle_block'
>> /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.1/hotcocoa/mapper.rb:67:in
>> `block in map_method'
>> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/application.rb:21:in
>> `start'
>> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/vendor/mvc.rb:12:in
>> `initialize'
>> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/application.rb:47:in
>> `new'
>> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/application.rb:47:in
>> `'
>> /Users/emiltin/phare/Phare.app/Contents/Resources/rb_main.rb:2:in `load'
>> /Users/emiltin/phare/Phare.app/Contents/Resources/rb_main.rb:2:in `'
>> 2009-04-17 09:29:23.498 Phare[12075:613]
>> ***
>> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/vendor/mvc.rb:76:in
>> `display': undefined method `new' for nil:NilClass (NoMethodError)
>>  from
>> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/application.rb:32:in
>> `block in start'
>> from
>> /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.1/hotcocoa/mappings/application.rb:9:in
>> `call'
>>  from
>> /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.1/hotcocoa/mappings/application.rb:9:in
>> `handle_block'
>> from
>> /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.1/hotcocoa/mapper.rb:67:in
>> `block in map_method'
>>  from
>> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/application.rb:21:in
>> `start'
>> from
>> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/vendor/mvc.rb:12:in
>> `initialize'
>>  from
>> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/application.rb:47:in
>> `new'
>> from
>> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/application.rb:47:in
>> `'
>>  from /Users/emiltin/phare/Phare.app/Contents/Resources/rb_main.rb:2:in
>> `load'
>> from /Users/emiltin/phare/Phare.app/Contents/Resources/rb_main.rb:2:in
>> `'
>>
>>
>>
>>
>>
>> On 17/04/2009, at 02.07, Matt Aimonetti wrote:
>>
>> I recently worked on a proof of concept with HotCocoa. I wanted to see how
>> easy it would be to stay in pure Ruby and still use a MVC type approach.
>> I put together the beginning of a sample app to see how it would work in
>> real life: http://github.com/mattetti/phare/
>>
>> I first wanted to make sure to separate the controller code and the view
>> code. I also wanted to avoid use class variables to deal with my views.
>> There isn't much there but you can see how I organized the various parts
>> of my app:
>>
>>
>> http://github.com/mattetti/phare/tree/2d8d06ceefcfced5040bbe99fdea9b892a0db877/lib
>>
>> lib/controllers
>> lib/views
>> lib/vendor (string.rb extends String, logger.rb will eventually let you
>> log at different debugging levels, mvc.rb takes care of loading the various
>> files)
>>
>> Views just need to respond to render and have a description if you want to
>> use the segmented controller helper.
>>
>> Anyways, as I said there isn't much, it's lacking the entire testing part
>> of the app and the code could definitively be cleaned up/optimized.
>> I just want to know if that's somethin

Re: [MacRuby-devel] How to retrieve an observer's context?

2009-04-20 Thread Edward Hynes

Hi Laurent,

Thanks for the help.  Did you mean to set the context ivar on the  
observer or on the subject?  Wouldn't setting it on the observer  
result in the last registration 'winning' if the observer is watching  
more than one subject?


Ed

On Apr 20, 2009, at 4:28 PM, Laurent Sansonetti wrote:


Hi Edward,

Context arguments in Objective-C are generally void pointers, which  
makes them hard to use in Ruby. Also, since we run in Objective-C GC  
mode, objects could potentially be collected since contexts do not  
set up AFAIK write barriers.


I would recommend to set up an instance variable on your observer  
instead (and pass nil as the context).


 observer.instance_variable_set(:@context, your_context)

And later in your observer method, retrieve the ivar.

Laurent


___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] Using built-in ruby libraries in packaged applications.

2009-04-20 Thread Alex Vollmer

On Apr 20, 2009, at Apr 20, 5:51 PM, Laurent Sansonetti wrote:

That is actually a pretty good idea, the default rb_main.rb could  
require an extra file if it exists in the resource directory, and  
the target would generate it.


If anyone wants to contribute a patch I would commit it :-)


Cool! I'll clone the git repo and see if I can formulate a fix. Just  
send the patch to the mailing list?


Cheers,

Alex


Musings & Notes — http://alexvollmer.com
Track what you lend and borrow — http://moochbot.com





___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] Using built-in ruby libraries in packaged applications.

2009-04-20 Thread Laurent Sansonetti
That is actually a pretty good idea, the default rb_main.rb could  
require an extra file if it exists in the resource directory, and the  
target would generate it.


If anyone wants to contribute a patch I would commit it :-)

Laurent

Sent from my iPhone

On Apr 20, 2009, at 4:37 PM, Alex Vollmer   
wrote:



On Apr 20, 2009, at Apr 20, 1:32 PM, Laurent Sansonetti wrote:

This is the right way to do it. The "Embed MacRuby" target  
configures the linking settings of your app but you still need to  
hack the load path in rb_main.rb to point it to the MacRuby stdlib.


Here is another way:

$:.map! { |x| x.sub(/^\/Library\/Frameworks/,  
NSBundle.mainBundle.privateFrameworksPath) }

$:.unshift NSBundle.mainBundle.resourcePath.fileSystemRepresentation

I wasn't able to perform this change automatically during the  
target build. Maybe we could ship a new rb_main.rb in the template  
that does this change based on a heuristic... if you have any idea  
let me know.


Thanks for the response Laurent. I wonder if there wouldn't be some  
way to have the "Embed MacRuby" target generate an additional file  
that would modify the load path in that way. Then it could just be  
an additional ruby file that gets automatically required by the  
default rb_main.rb. There would obviously be a problem of ensuring  
the load-order so we could always do it with a conditional require.  
Hmmm...maybe that's kind of hacky too. :-P


Cheers,

Alex


Musings & Notes
http://blog.livollmers.net



___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] retrieving password from keychain

2009-04-20 Thread Karl Varga
Thanks for the reply Laurent.  Yes I did generate a BridgeSupport file
and included it in my build.  I did try to call the method and pass in
a pointer for the item reference (using Pointer.new_for_type('@')) but
the object that was assigned after the call was some weird NSCFType
object which, when I googled it, basically translates to "you're
screwed" :)   I do get some malloc warnings when I include the
bridgesupport file so I was a bit uneasy about the whole thing.

I'll try writing my own Objective-C class.  I'm looking forward to
getting past this issue.

Cheers,
Karl

On Tue, Apr 21, 2009 at 6:44 AM, Laurent Sansonetti
 wrote:
> Hi Karl,
>
> On Apr 19, 2009, at 8:17 PM, Karl Varga wrote:
>
>> Hi there,
>>
>> I am having a strange problem that other people don't seem to be
>> having because I can't find any references to in google searches.  I
>> am using MacRuby 0.4 installed from the binary available on the
>> macruby binary releases page (MacRuby version 0.4 (ruby 1.9.1)
>> [universal-darwin9.5, x86_64])
>>
>> I have an application which stores username/passwords in the keychain.
>> I can add items to the keychain (so I can call
>> SecKeychainAddGenericPassword() fine and therefore I think my setup
>> must be OK), but I cannot retrieve them.  When I call:
>>
>>   status, *data = SecKeychainFindGenericPassword(
>>       nil, service.length, service, username.length, username)
>>
>> I get an error:
>>
>> Configuration.app/Contents/Resources/Controller.rb:99:in
>> `SecKeychainFindGenericPassword': wrong number of arguments (5 for 8)
>> (ArgumentError)
>>
>> The method signature is this:
>>
>> OSStatus SecKeychainFindGenericPassword (
>>  CFTypeRef keychainOrArray,
>>  UInt32 serviceNameLength,
>>  const char *serviceName,
>>  UInt32 accountNameLength,
>>  const char *accountName,
>>  UInt32 *passwordLength,
>>  void **passwordData,
>>  SecKeychainItemRef *itemRef
>> );
>>
>>
>> All the examples I've read suggest that this method in macruby should
>> only take 5 args and return the status, password length, password
>> string and item reference (the last 3 extracted from *data) instead of
>> passing in pointers (which I don't know how to do BTW).
>>
>> What gives?  Anyone have any idea or had the same problem?
>
> I am surprised you were able to call SecKeychainFindGenericPassword() from
> MacRuby, did you generate a BridgeSupport file for the Security framework?
>
> As for your question, MacRuby currently doesn't support the RubyCocoa way of
> dealing with returned-by-reference arguments (which is what you're trying to
> do I think), so you must allocate Pointer objects instead. In the case of
> this call it may be painful, so I would recommend to wrap this in an
> Objective-C class in the interim and use that class from MacRuby.
>
> HTH,
> Laurent
>



-- 
Karl Varga
kjva...@gmail.com
Cell: +61 (0)4 2075 1356
___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] Using built-in ruby libraries in packaged applications.

2009-04-20 Thread Alex Vollmer

On Apr 20, 2009, at Apr 20, 1:32 PM, Laurent Sansonetti wrote:

This is the right way to do it. The "Embed MacRuby" target  
configures the linking settings of your app but you still need to  
hack the load path in rb_main.rb to point it to the MacRuby stdlib.


Here is another way:

$:.map! { |x| x.sub(/^\/Library\/Frameworks/,  
NSBundle.mainBundle.privateFrameworksPath) }

$:.unshift NSBundle.mainBundle.resourcePath.fileSystemRepresentation

I wasn't able to perform this change automatically during the target  
build. Maybe we could ship a new rb_main.rb in the template that  
does this change based on a heuristic... if you have any idea let me  
know.


Thanks for the response Laurent. I wonder if there wouldn't be some  
way to have the "Embed MacRuby" target generate an additional file  
that would modify the load path in that way. Then it could just be an  
additional ruby file that gets automatically required by the default  
rb_main.rb. There would obviously be a problem of ensuring the load- 
order so we could always do it with a conditional require.  
Hmmm...maybe that's kind of hacky too. :-P


Cheers,

Alex


Musings & Notes
http://blog.livollmers.net



___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] Macrake is building/launching the wrong application

2009-04-20 Thread Frisco Del Rosario

Me:
>> I relaunched Demo.app with a doubleclick, but instead of the
>> Demo.app launching, HotConsole launched.
>>
>> I quit, trashed the Demo.app, ran the rakefile again, but Demo.app
>> continues to launch as HotConsole.

Laurent:
> I wasn't able to reproduce this strange issue... if you can still do
> it could you archive the directory and send it to us?
My fault. I altered the directory path to Developer/Examples/Ruby/ 
MacRuby/HotCocoa/demo, which caused the muck. Restoring the directory  
path fixed it. (And changing the path in the same fashion caused the  
problem to recur, so I know not to do that again.)

Thank you.

___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] retrieving password from keychain

2009-04-20 Thread Laurent Sansonetti

Hi Karl,

On Apr 19, 2009, at 8:17 PM, Karl Varga wrote:


Hi there,

I am having a strange problem that other people don't seem to be
having because I can't find any references to in google searches.  I
am using MacRuby 0.4 installed from the binary available on the
macruby binary releases page (MacRuby version 0.4 (ruby 1.9.1)
[universal-darwin9.5, x86_64])

I have an application which stores username/passwords in the keychain.
I can add items to the keychain (so I can call
SecKeychainAddGenericPassword() fine and therefore I think my setup
must be OK), but I cannot retrieve them.  When I call:

   status, *data = SecKeychainFindGenericPassword(
   nil, service.length, service, username.length, username)

I get an error:

Configuration.app/Contents/Resources/Controller.rb:99:in
`SecKeychainFindGenericPassword': wrong number of arguments (5 for 8)
(ArgumentError)

The method signature is this:

OSStatus SecKeychainFindGenericPassword (
  CFTypeRef keychainOrArray,
  UInt32 serviceNameLength,
  const char *serviceName,
  UInt32 accountNameLength,
  const char *accountName,
  UInt32 *passwordLength,
  void **passwordData,
  SecKeychainItemRef *itemRef
);


All the examples I've read suggest that this method in macruby should
only take 5 args and return the status, password length, password
string and item reference (the last 3 extracted from *data) instead of
passing in pointers (which I don't know how to do BTW).

What gives?  Anyone have any idea or had the same problem?


I am surprised you were able to call SecKeychainFindGenericPassword()  
from MacRuby, did you generate a BridgeSupport file for the Security  
framework?


As for your question, MacRuby currently doesn't support the RubyCocoa  
way of dealing with returned-by-reference arguments (which is what  
you're trying to do I think), so you must allocate Pointer objects  
instead. In the case of this call it may be painful, so I would  
recommend to wrap this in an Objective-C class in the interim and use  
that class from MacRuby.


HTH,
Laurent
___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] Macrake is building/launching the wrong application

2009-04-20 Thread Laurent Sansonetti

Hi Frisco,

On Apr 20, 2009, at 2:24 AM, Frisco Del Rosario wrote:

I used macrake to build Demo.app in Developers/Examples/Ruby/MacRuby/ 
HotCocoa/demo. After a while, the beachball (it's not a "beachball"  
anymore; what do people call the spinning thing that says your app  
is hung?) spun, and I Force Quit the demo.


(I call it the pizza of the death.)

I relaunched Demo.app with a doubleclick, but instead of the  
Demo.app launching, HotConsole launched.


I quit, trashed the Demo.app, ran the rakefile again, but Demo.app  
continues to launch as HotConsole.



I wasn't able to reproduce this strange issue... if you can still do  
it could you archive the directory and send it to us? There is surely  
something wrong going there.


Thanks,
Laurent
___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] Using built-in ruby libraries in packaged applications.

2009-04-20 Thread Laurent Sansonetti

Hi Alex,

On Apr 19, 2009, at 9:53 PM, Alex Vollmer wrote:

I have a bit of code that uses the Ruby base64 library and I would  
like to package the MacRuby framework into my application. I've  
added the "Embed MacRuby" target to my build and the MacRuby  
framework shows up properly in my application's contents directory.  
The problem is that when the program launches the call for requiring  
the base64.rb file causes the runtime to bomb out saying it couldn't  
find 'base64.rb'. After a bit of hacking I ended up adding this  
stanza in the rb_main.rb file prior to the loop that requires all  
the local files:


$:.unshift(File.join(NSBundle.mainBundle.privateFrameworksPath,
"MacRuby.framework",
"Versions",
"Current",
"usr/lib/ruby/1.9.1"))

This seems a little hacky to me. Is there a better way of doing this?


This is the right way to do it. The "Embed MacRuby" target configures  
the linking settings of your app but you still need to hack the load  
path in rb_main.rb to point it to the MacRuby stdlib.


Here is another way:

$:.map! { |x| x.sub(/^\/Library\/Frameworks/,  
NSBundle.mainBundle.privateFrameworksPath) }

$:.unshift NSBundle.mainBundle.resourcePath.fileSystemRepresentation

I wasn't able to perform this change automatically during the target  
build. Maybe we could ship a new rb_main.rb in the template that does  
this change based on a heuristic... if you have any idea let me know.


Laurent
___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] How to retrieve an observer's context?

2009-04-20 Thread Laurent Sansonetti

Hi Edward,

Context arguments in Objective-C are generally void pointers, which  
makes them hard to use in Ruby. Also, since we run in Objective-C GC  
mode, objects could potentially be collected since contexts do not set  
up AFAIK write barriers.


I would recommend to set up an instance variable on your observer  
instead (and pass nil as the context).


  observer.instance_variable_set(:@context, your_context)

And later in your observer method, retrieve the ivar.

Laurent

On Apr 20, 2009, at 8:57 AM, Edward Hynes wrote:

I'd like to use contexts when registering some observers, but have  
been unable to retrieve them, getting a "can't convert C/Objective-C  
value `0x2822731' of type `v' to Ruby object" instead.  The  
following code, for example, will trigger the error


class Subject
 attr_accessor :abc
end

class Observer
 def observeValueForKeyPath keyPath, ofObject:object, change:change,  
context:context

   context[0]
 end
end

subject = Subject.new
observer = Observer.new

subject.addObserver observer, forKeyPath:'abc', options:0,  
context:'a context'

subject.setAbc 'some value'

Is there a way to retrieve an observation context?  Or is there an  
alternative way for observers to distinguish among multiple  
registrations for a given object/keyPath?


Thanks,
Ed

___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] [hotcocoa] MVC helper?

2009-04-20 Thread Matt Aimonetti
I made some modifications and I probably broke some stuff. Sorry about that.
Rich and I worked on a new super cool HotCocoa app's structure.

It's not fully done yet but we'll work on it in 2 weeks at RailsConf.

- Matt

On Mon, Apr 20, 2009 at 8:39 AM, Emil Tin  wrote:

> cool!
> i cloned the git repo, but when i do 'macrake' in the dir, it fails.
>
> ~/phare$ macrake
> (in /Users/emiltin/phare)
>
> 2009-04-17 09:29:21.313 Phare[12075:613] registering AccountSetupView
> 2009-04-17 09:29:21.440 Phare[12075:613] registering ProjectSelectionView
> 2009-04-17 09:29:22.707 Phare[12075:613] registering WebView
> 2009-04-17 09:29:23.492 Phare[12075:613] Loading Lighthouse Account
> Settings
> 2009-04-17 09:29:23.494 Phare[12075:613] available view classes:
> [{:klass=>"AccountSetupView", :description=>"Lighthouse Account Settings"},
> {:klass=>"ProjectSelectionView", :description=>"Project Selection"},
> {:klass=>"WebView", :description=>"Lighthouse Help"}]
> 2009-04-17 09:29:23.495 Phare[12075:613] looking for Lighthouse Account
> Settings
> 2009-04-17 09:29:23.496 Phare[12075:613] HotCocoa couldn't find a view with
> a description defined as: ''
> 2009-04-17 09:29:23.496 Phare[12075:613] stack trace:
> ***
> 2009-04-17 09:29:23.497 Phare[12075:613]
> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/vendor/mvc.rb:75:in
> `display'
> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/application.rb:32:in
> `block in start'
> /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.1/hotcocoa/mappings/application.rb:9:in
> `call'
> /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.1/hotcocoa/mappings/application.rb:9:in
> `handle_block'
> /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.1/hotcocoa/mapper.rb:67:in
> `block in map_method'
> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/application.rb:21:in
> `start'
> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/vendor/mvc.rb:12:in
> `initialize'
> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/application.rb:47:in
> `new'
> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/application.rb:47:in
> `'
> /Users/emiltin/phare/Phare.app/Contents/Resources/rb_main.rb:2:in `load'
> /Users/emiltin/phare/Phare.app/Contents/Resources/rb_main.rb:2:in `'
> 2009-04-17 09:29:23.498 Phare[12075:613]
> ***
> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/vendor/mvc.rb:76:in
> `display': undefined method `new' for nil:NilClass (NoMethodError)
> from
> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/application.rb:32:in
> `block in start'
> from
> /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.1/hotcocoa/mappings/application.rb:9:in
> `call'
> from
> /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.1/hotcocoa/mappings/application.rb:9:in
> `handle_block'
> from
> /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.1/hotcocoa/mapper.rb:67:in
> `block in map_method'
> from
> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/application.rb:21:in
> `start'
> from
> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/vendor/mvc.rb:12:in
> `initialize'
> from
> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/application.rb:47:in
> `new'
> from
> /Users/emiltin/phare/Phare.app/Contents/Resources/lib/application.rb:47:in
> `'
> from /Users/emiltin/phare/Phare.app/Contents/Resources/rb_main.rb:2:in
> `load'
> from /Users/emiltin/phare/Phare.app/Contents/Resources/rb_main.rb:2:in
> `'
>
>
>
>
>
> On 17/04/2009, at 02.07, Matt Aimonetti wrote:
>
> I recently worked on a proof of concept with HotCocoa. I wanted to see how
> easy it would be to stay in pure Ruby and still use a MVC type approach.
> I put together the beginning of a sample app to see how it would work in
> real life: http://github.com/mattetti/phare/
>
> I first wanted to make sure to separate the controller code and the view
> code. I also wanted to avoid use class variables to deal with my views.
> There isn't much there but you can see how I organized the various parts of
> my app:
>
>
> http://github.com/mattetti/phare/tree/2d8d06ceefcfced5040bbe99fdea9b892a0db877/lib
>
> lib/controllers
> lib/views
> lib/vendor (string.rb extends String, logger.rb will eventually let you log
> at different debugging levels, mvc.rb takes care of loading the various
> files)
>
> Views just need to respond to render and have a description if you want to
> use the segmented controller helper.
>
> Anyways, as I said there isn't much, it's lacking the entire testing part
> of the app and the code could definitively be cleaned up/optimized.
> I just want to know if that's something others are interested in, or if you
> prefer to
> 1. come up with your own solution every time
> 2. don't bother with mvc
> 3. use xcode/ib
>
> - Matt
> ___
> MacRuby-devel mailing list
> MacRuby-devel@lists.macosforge.org
> http://lists.macosforge.org/mailman/listi

Re: [MacRuby-devel] [hotcocoa] MVC helper?

2009-04-20 Thread Emil Tin

cool!

i cloned the git repo, but when i do 'macrake' in the dir, it fails.

~/phare$ macrake
(in /Users/emiltin/phare)

2009-04-17 09:29:21.313 Phare[12075:613] registering AccountSetupView
2009-04-17 09:29:21.440 Phare[12075:613] registering  
ProjectSelectionView

2009-04-17 09:29:22.707 Phare[12075:613] registering WebView
2009-04-17 09:29:23.492 Phare[12075:613] Loading Lighthouse Account  
Settings
2009-04-17 09:29:23.494 Phare[12075:613] available view classes:  
[{:klass=>"AccountSetupView", :description=>"Lighthouse Account  
Settings"}, {:klass=>"ProjectSelectionView", :description=>"Project  
Selection"}, {:klass=>"WebView", :description=>"Lighthouse Help"}]
2009-04-17 09:29:23.495 Phare[12075:613] looking for Lighthouse  
Account Settings
2009-04-17 09:29:23.496 Phare[12075:613] HotCocoa couldn't find a view  
with a description defined as: ''

2009-04-17 09:29:23.496 Phare[12075:613] stack trace:
***
2009-04-17 09:29:23.497 Phare[12075:613] /Users/emiltin/phare/ 
Phare.app/Contents/Resources/lib/vendor/mvc.rb:75:in `display'
/Users/emiltin/phare/Phare.app/Contents/Resources/lib/application.rb: 
32:in `block in start'
/Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.1/ 
hotcocoa/mappings/application.rb:9:in `call'
/Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.1/ 
hotcocoa/mappings/application.rb:9:in `handle_block'
/Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.1/ 
hotcocoa/mapper.rb:67:in `block in map_method'
/Users/emiltin/phare/Phare.app/Contents/Resources/lib/application.rb: 
21:in `start'
/Users/emiltin/phare/Phare.app/Contents/Resources/lib/vendor/mvc.rb: 
12:in `initialize'
/Users/emiltin/phare/Phare.app/Contents/Resources/lib/application.rb: 
47:in `new'
/Users/emiltin/phare/Phare.app/Contents/Resources/lib/application.rb: 
47:in `'

/Users/emiltin/phare/Phare.app/Contents/Resources/rb_main.rb:2:in `load'
/Users/emiltin/phare/Phare.app/Contents/Resources/rb_main.rb:2:in  
`'

2009-04-17 09:29:23.498 Phare[12075:613]
***
/Users/emiltin/phare/Phare.app/Contents/Resources/lib/vendor/mvc.rb: 
76:in `display': undefined method `new' for nil:NilClass (NoMethodError)
	from /Users/emiltin/phare/Phare.app/Contents/Resources/lib/ 
application.rb:32:in `block in start'
	from /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/ 
1.9.1/hotcocoa/mappings/application.rb:9:in `call'
	from /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/ 
1.9.1/hotcocoa/mappings/application.rb:9:in `handle_block'
	from /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/ 
1.9.1/hotcocoa/mapper.rb:67:in `block in map_method'
	from /Users/emiltin/phare/Phare.app/Contents/Resources/lib/ 
application.rb:21:in `start'
	from /Users/emiltin/phare/Phare.app/Contents/Resources/lib/vendor/ 
mvc.rb:12:in `initialize'
	from /Users/emiltin/phare/Phare.app/Contents/Resources/lib/ 
application.rb:47:in `new'
	from /Users/emiltin/phare/Phare.app/Contents/Resources/lib/ 
application.rb:47:in `'
	from /Users/emiltin/phare/Phare.app/Contents/Resources/rb_main.rb: 
2:in `load'
	from /Users/emiltin/phare/Phare.app/Contents/Resources/rb_main.rb: 
2:in `'






On 17/04/2009, at 02.07, Matt Aimonetti wrote:

I recently worked on a proof of concept with HotCocoa. I wanted to  
see how easy it would be to stay in pure Ruby and still use a MVC  
type approach.
I put together the beginning of a sample app to see how it would  
work in real life: http://github.com/mattetti/phare/


I first wanted to make sure to separate the controller code and the  
view code. I also wanted to avoid use class variables to deal with  
my views.
There isn't much there but you can see how I organized the various  
parts of my app:


http://github.com/mattetti/phare/tree/2d8d06ceefcfced5040bbe99fdea9b892a0db877/lib

lib/controllers
lib/views
lib/vendor (string.rb extends String, logger.rb will eventually let  
you log at different debugging levels, mvc.rb takes care of loading  
the various files)


Views just need to respond to render and have a description if you  
want to use the segmented controller helper.


Anyways, as I said there isn't much, it's lacking the entire testing  
part of the app and the code could definitively be cleaned up/ 
optimized.
I just want to know if that's something others are interested in, or  
if you prefer to

1. come up with your own solution every time
2. don't bother with mvc
3. use xcode/ib

- Matt
___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


[MacRuby-devel] How to retrieve an observer's context?

2009-04-20 Thread Edward Hynes
I'd like to use contexts when registering some observers, but have  
been unable to retrieve them, getting a "can't convert C/Objective-C  
value `0x2822731' of type `v' to Ruby object" instead.  The following  
code, for example, will trigger the error


class Subject
  attr_accessor :abc
end

class Observer
  def observeValueForKeyPath keyPath, ofObject:object, change:change,  
context:context

context[0]
  end
end

subject = Subject.new
observer = Observer.new

subject.addObserver observer, forKeyPath:'abc', options:0, context:'a  
context'

subject.setAbc 'some value'

Is there a way to retrieve an observation context?  Or is there an  
alternative way for observers to distinguish among multiple  
registrations for a given object/keyPath?



Thanks,
Ed

___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] Mixing Objective-C and Ruby classes

2009-04-20 Thread victor jalencas
Many thanks John and Laurent.

 After reading your messages I came back to XCode and discovered I had
made a typo in the ObjC part of the code (which, curiously, compiled)
and that's why my ruby code didn't find my selector.

 As for calling ruby code from the obj-c side, I agree it's a bit
convoluted (not to mention deprecated). I hope there's a better way to
do that in store for upcoming versions. If I understood well your
example, you first created the Obj-C subclass and later, dynamically,
set its parent to be the ruby class. Anyway, seeing that the norm in
Cocoa is delegation rather than extension, and if all ruby classes are
readily available in Obj-C, I think I'll manage with just calling ruby
code instead of extending it. Apparently I lacked only calling the
sharedRuntime method, will need to experiment a bit more when I get
back to my Mac.



cheers,
Victor

-- 
--
Victor Jalencas 
___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


[MacRuby-devel] Macrake is building/launching the wrong application

2009-04-20 Thread Frisco Del Rosario
I used macrake to build Demo.app in Developers/Examples/Ruby/MacRuby/ 
HotCocoa/demo. After a while, the beachball (it's not a "beachball"  
anymore; what do people call the spinning thing that says your app is  
hung?) spun, and I Force Quit the demo.


I relaunched Demo.app with a doubleclick, but instead of the Demo.app  
launching, HotConsole launched.


I quit, trashed the Demo.app, ran the rakefile again, but Demo.app  
continues to launch as HotConsole.


___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel