[MacRuby] #275: [HotCocoa] convert underscore names to camelcase names in mapper
#275: [HotCocoa] convert underscore names to camelcase names in mapper ---------------------------------+------------------------------------------ Reporter: dj2@… | Owner: lsansonetti@… Type: enhancement | Status: new Priority: minor | Milestone: Component: MacRuby | Keywords: ---------------------------------+------------------------------------------ Attached is a patch to try converting underscore names to camel case. I'm not using key.capitalize because that will change things like drawsBackground to Drawsbackground which isn't what we want. -- Ticket URL: <http://www.macruby.org/trac/ticket/275> MacRuby <http://macruby.org/>
#275: [HotCocoa] convert underscore names to camelcase names in mapper ---------------------------------+------------------------------------------ Reporter: dj2@… | Owner: lsansonetti@… Type: enhancement | Status: new Priority: minor | Milestone: Component: MacRuby | Keywords: ---------------------------------+------------------------------------------ Comment(by eloy.de.enige@…): I like that you got to it immediately :) I have a few remarks/questions: * Since this is a real functional change, I'd like to see some test coverage with the patch. * If I recall correctly, Rich already added a String#camel_case method to HotCocoa, so you should use that to convert to the selector. * Why actually, and this was before your change there as well, do we use Kernel#eval to set the value? The setter methods will always be public, so I don't see why we can't just change "eval 'control.#{key} = value"' to 'control.send("#{key}=", value)'. Thanks for your time! -- Ticket URL: <http://www.macruby.org/trac/ticket/275#comment:1> MacRuby <http://macruby.org/>
#275: [HotCocoa] convert underscore names to camelcase names in mapper ---------------------------------+------------------------------------------ Reporter: dj2@… | Owner: lsansonetti@… Type: enhancement | Status: new Priority: minor | Milestone: Component: MacRuby | Keywords: ---------------------------------+------------------------------------------ Comment(by dj2@…): Add a test_mapping_methods test to the mapper_test suite. Covers the current cases in the mapper. The camel_case method was part of the sample-macruby mvc code. I've copied that, and underscore into attribute_string.rb as additions to the string class. I also created an attributed_string_test case and moved the underscore test over there along with a simple camel case test. I tried using control.send("#{key}=", value) and got the following error (I'm assuming because the title= method is automatically remapped to setTitle?) /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.1/hotcocoa/mapper.rb:57:in `send': super: no superclass method `title=:' for #<NSWindow:0x80032c8e0> (NoMethodError) -- Ticket URL: <http://www.macruby.org/trac/ticket/275#comment:2> MacRuby <http://macruby.org/>
#275: [HotCocoa] convert underscore names to camelcase names in mapper ---------------------------------+------------------------------------------ Reporter: dj2@… | Owner: rich@… Type: enhancement | Status: new Priority: minor | Milestone: Component: MacRuby | Keywords: ---------------------------------+------------------------------------------ Changes (by eloy.de.enige@…): * owner: lsansonetti@… => rich@… Comment: Looks great! Thanks for your time. I think we should keep a tab on the need for eval problem, because that's definitely not the way it should work. But it could very well already be fixed when moving to 0.5. -- Ticket URL: <http://www.macruby.org/trac/ticket/275#comment:3> MacRuby <http://macruby.org/>
#275: [HotCocoa] convert underscore names to camelcase names in mapper ---------------------------------+------------------------------------------ Reporter: dj2@… | Owner: rich@… Type: enhancement | Status: closed Priority: minor | Milestone: Component: MacRuby | Resolution: fixed Keywords: | ---------------------------------+------------------------------------------ Changes (by rich@…): * status: new => closed * resolution: => fixed Comment: This has been applied with some minor changes, I did not just apply the diff. I do not want to open String and put in underscore and camel_case, they are just in the mapper right now as class methods. -- Ticket URL: <http://www.macruby.org/trac/ticket/275#comment:4> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby