[MacRuby-devel] allowedFileTypes and NSOpenPanel

2010-11-13 Thread Gregoire LEJEUNE
Hi,

I try to use setAllowedFileTypes with an NSOpenPanel using this code :

panel = NSOpenPanel.openPanel()
panel.canChooseFiles = true
panel.allowedFileTypes = ["graphml", "gml", "xml"]
result = panel.runModal()

But it doesn't work. I can chose any type of file.

If I use the (10.6) deprecated runModalWithTypes, it works... So is it
me or setAllowedFileTypes which's buggy ?

Thanks for your help.

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


[MacRuby-devel] Exception backtraces in instance_eval

2010-11-13 Thread Martijn Walraven
Hi,

I'm trying to use RSpec (latest version, 2.1.0) with MacRuby, but there seems 
to be information missing from the exception backtraces which makes it 
difficult to see where exactly specs fail.

Running a straightforward helloworld_spec.rb with a failing example for 
instance, shows a reference to the failing line (hello_world.greeting.should == 
"Hello World!") in MRI Ruby 1.9.2:

Failures:
  1) A new HelloWorld object should return the appropriate greeting
 Failure/Error: hello_world.greeting.should == "Hello World!"
 expected: "Hello World!",
  got: "Hello Earth!" (using ==)
 # ./Spec/helloworld_spec.rb:6:in `block (2 levels) in '

In MacRuby (0.7.1) however, RSpec displays a 'Failure/Error: Unable to find 
matching line from backtrace' instead, which makes sense with no traces present 
referring to the actual spec:

Failures:
  1) A new HelloWorld object should return the appropriate greeting
 Failure/Error: Unable to find matching line from backtrace
 expected: "Hello World!",
  got: "Hello Earth!" (using ==)
 # 
/usr/local/rvm/gems/macruby-0@test/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:41:in
 `block'
 # 
/usr/local/rvm/gems/macruby-0@test/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:39:in
 `block'
 # 
/usr/local/rvm/gems/macruby-0@test/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:75:in
 `block'
 # 
/usr/local/rvm/gems/macruby-0@test/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:74:in
 `with_pending_capture'
 # 
/usr/local/rvm/gems/macruby-0@test/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:32:in
 `run:'
 # 
/usr/local/rvm/gems/macruby-0@test/gems/rspec-core-2.1.0/lib/rspec/core/example_group.rb:260:in
 `block'
 # 
/usr/local/rvm/gems/macruby-0@test/gems/rspec-core-2.1.0/lib/rspec/core/example_group.rb:257:in
 `run_examples:'
 # 
/usr/local/rvm/gems/macruby-0@test/gems/rspec-core-2.1.0/lib/rspec/core/example_group.rb:222:in
 `run:'
 # 
/usr/local/rvm/gems/macruby-0@test/gems/rspec-core-2.1.0/lib/rspec/core/command_line.rb:26:in
 `block'
 # 
/usr/local/rvm/gems/macruby-0@test/gems/rspec-core-2.1.0/lib/rspec/core/command_line.rb:15:in
 `run:'
 # 
/usr/local/rvm/gems/macruby-0@test/gems/rspec-core-2.1.0/lib/rspec/core/runner.rb:10:in
 `block'
'
Looking at the complete backtrace in MRI Ruby 1.9.2 shows there seems to be a 
lot of information missing from the MacRuby backtrace. Apart from missing 
information about the context of a block and other differences in descriptions, 
MacRuby doesn't seem to list any traces beyond the instance_eval. The RSpec 
source (example.rb) shows it indeed uses instance_eval to evaluate the example 
block. I checked the backtraces in the rescue clauses there, but they don't 
contain traces from any execution beyond the instance_eval call. Is loss of 
exception backtraces in instance_eval a known limitations of MacRuby? Are there 
any plans to improve backtraces?

Failures:
  1) A new HelloWorld object should return the appropriate greeting
 Failure/Error: hello_world.greeting.should == "Hello World!"
 expected: "Hello World!",
  got: "Hello Earth!" (using ==)
 # 
/usr/local/rvm/gems/ruby-1.9.2...@test/gems/rspec-expectations-2.1.0/lib/rspec/expectations/fail_with.rb:29:in
 `fail_with'
 # 
/usr/local/rvm/gems/ruby-1.9.2...@test/gems/rspec-expectations-2.1.0/lib/rspec/matchers/operator_matcher.rb:48:in
 `fail_with_message'
 # 
/usr/local/rvm/gems/ruby-1.9.2...@test/gems/rspec-expectations-2.1.0/lib/rspec/matchers/operator_matcher.rb:70:in
 `__delegate_operator'
 # 
/usr/local/rvm/gems/ruby-1.9.2...@test/gems/rspec-expectations-2.1.0/lib/rspec/matchers/operator_matcher.rb:60:in
 `eval_match'
 # 
/usr/local/rvm/gems/ruby-1.9.2...@test/gems/rspec-expectations-2.1.0/lib/rspec/matchers/operator_matcher.rb:29:in
 `block in use_custom_matcher_or_delegate'
 # ./Spec/helloworld_spec.rb:6:in `block (2 levels) in '
 # 
/usr/local/rvm/gems/ruby-1.9.2...@test/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:42:in
 `instance_eval'
 # 
/usr/local/rvm/gems/ruby-1.9.2...@test/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:42:in
 `block (2 levels) in run'
 # 
/usr/local/rvm/gems/ruby-1.9.2...@test/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:81:in
 `call'
 # 
/usr/local/rvm/gems/ruby-1.9.2...@test/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:81:in
 `with_around_hooks'
 # 
/usr/local/rvm/gems/ruby-1.9.2...@test/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:39:in
 `block in run'
 # 
/usr/local/rvm/gems/ruby-1.9.2...@test/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:75:in
 `call'
 # 
/usr/local/rvm/gems/ruby-1.9.2...@test/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:75:in
 `block in with_pending_capture'
 # 
/usr/local/rvm/gems/ruby-1.9.2...@test/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:74:in
 `catch'
 # 
/usr/local/rvm/gems/ruby-1.9.2...@test/gems/rspec-co

[MacRuby-devel] Neat MacRuby app, HotCocoa, and more!

2010-11-13 Thread Leigh Caplan
Hey everybody,

I wanted to say hi to the list and introduce myself - I've been lurking for
awhile and come by when I need help, but RubyConf has me all fired up, so
I'd like to start engaging more with the community. My name is Leigh Caplan,
and I'm a developer in Seattle, WA. I like long walks on the beach, dinner
by candlelight, and not having to write my Mac OS X apps in Objective C.

First, I wanted to tell everyone about a potentially useful menu extra that
I created called CobraMenu. It's meant to be a simple "traffic light" for CI
Joe (the super simple/awesome CI server written by the Github guys). You can
find more info at http://texel.github.com/CobraMenu/ or just clone/fork it
from https://github.com/texel/CobraMenu

Next, developing this got me thinking about HotCocoa, and how it could
evolve into a really useful project in the future. I had a chat w/ Matt
Aimonetti today, and he mentioned that Rich Kilmer, while still interested
in the project, both didn't have time to maintain it and also wasn't
convinced that its current goal as a DSL for creating UI elements was
necessarily useful for anything but trivial projects. Apparently there's
also been some discussion to this effect on this list, but I'm a bit late to
the party, so I apologize.

Now, I *can* see a need for a ruby-like DSL for Cocoa, but in my opinion, it
would be much more exciting if we endeavored to wrap other Cocoa classes and
idioms in a loving Ruby-like embrace. Here's a rudimentary example (very
much like something I've done in CobraMenu):

HotCocoa::URLConnection.get('http://google.com') do |c|
  c.success { success_callback }
  c.failure { failure_callback }
  c.error   { |e| error_handler.call_something e }
end


I'd be interested to see if other people think this is a good idea. If so, I
can formulate a strategy, and get to work :)

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


Re: [MacRuby-devel] allowedFileTypes and NSOpenPanel

2010-11-13 Thread Matt Aimonetti
Here is an extract from one of my apps:

  def browse(sender)
# Create the File Open Dialog class.
dialog = NSOpenPanel.openPanel
# Disable the selection of files in the dialog.
dialog.canChooseFiles = false
# Enable the selection of directories in the dialog.
dialog.canChooseDirectories = true
# Disable the selection of multiple items in the dialog.
dialog.allowsMultipleSelection = false

# Display the dialog and process the selected folder
if dialog.runModalForDirectory(nil, file:nil) == NSOKButton
  selection = dialog.filenames.first
  location.stringValue = dialog.filenames.first.to_s
end
  end

Note that location is an attr_accessor that I have and the the #browser
method gets called when pushing a button.

I hope that helps.

- Matt

On Sat, Nov 13, 2010 at 7:38 AM, Gregoire LEJEUNE <
[email protected]> wrote:

> Hi,
>
> I try to use setAllowedFileTypes with an NSOpenPanel using this code :
>
> panel = NSOpenPanel.openPanel()
> panel.canChooseFiles = true
> panel.allowedFileTypes = ["graphml", "gml", "xml"]
> result = panel.runModal()
>
> But it doesn't work. I can chose any type of file.
>
> If I use the (10.6) deprecated runModalWithTypes, it works... So is it
> me or setAllowedFileTypes which's buggy ?
>
> Thanks for your help.
>
> Greg
> ___
> 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