-
Notifications
You must be signed in to change notification settings - Fork 207
Use motion-support for the string inflector #220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Use motion-support for the string inflector #220
Conversation
|
How much work would option 1 take? |
|
How about using motion-require for BubbleWrap? |
|
@ryansobol it wouldnt take much work; I already hacked a solution together, like 20 LOC. my beef is that Bubblewrap already does a lot of unexpected things to the build system that I'd like to see removed, and I'm hesitant to add more stuff to it for this one case =\ @tkadauke I'd be all for that and plan on doing it, but I don't think it would solve this case since motion-require is a separate gem and not in the BW project? since motion-require == |
Makes sense. What would you like to see removed? How much work would it take? |
|
mmm, I think
|
So how different is
I agree with everything here.
Excellent. (Sorry if you get two emails. That'll teach me to reply by email.) |
Mmm pretty big and basically incompatible. it's a different but more sensible and natural way of declaring RubyMotion dependencies https://github.com/clayallsopp/motion-require
I'll check; lrz mentioned it on twitter when motion-require came out. |
|
Well, I found a smaller work-around to include motion-support: 4ad615d Tests pass now; it still supports the old Will merge soon if no one has any objects cc @ryansobol |
|
I'm +1 on implementing it manually, not a fan of including external deps in BW :) |
|
@mneorr what's the downside of an external dependency? i.e. if we wanted to use |
|
@clayallsopp the only downside is dependenciesception |
Well done! |
I'm pumped to start using Each external dependency should be safe to depend on.BubbleWrap is a post 1.0 library. As a contributor and an end-user, this implies a sense of stability and maturity. I believe the responsible thing to do is to apply the same measuring stick to external dependencies. How mature and stable are BubbleWrap should use the majority of APIs loaded from each external dependency.I see that this patch requires Are there any other APIs loaded into memory that we can't see? BubbleWrap should be compatible with libraries it doesn't depend on.BubbleWrap is probably the most popular RubyMotion library to date. Partly because it's a one-stop-shop for essential, productivity-boosting APIs. Inevitably, other libraries will rise and implement certain APIs better than BubbleWrap. I look at passing the torch to these libraries, like BubbleWrap pollutes a handful of core classes (e.g. String). It's in the best interest of the community if we start phasing this out, whether or not
In my experience, using Bundler makes this a non-issue. Maybe I'm missing something? |
|
All good points. motion-support is pretty stable and API-safe, since it's just ActiveSupport. I guess @tkadauke can comment on that better than I.
Though perhaps we should hold on integrating this until HipByte/RubyMotion#81 is resolved; basically RubyMotion's build system needs more fine-grained options for turning off |
|
As a side note, I'd like to point out all the internal uses of
https://github.com/rubymotion/BubbleWrap/blob/master/motion/core/string.rb#L50
https://github.com/rubymotion/BubbleWrap/blob/master/motion/core/device/camera.rb#L144 |
|
motion-support is indeed pretty stable. The version number (0.2) is because not everything is ported over, not because of concerns over stability (there are so many tests, it's ridiculous). Also, there are many open questions about the usefulness of certain parts that can only be answered as people start using the library. Since the last point means that useless parts of the library might be removed at any time, a major version of 0 seems appropriate to me. Of course I won't remove stuff that people actually use, so that's nothing to worry about. The fact that camelize is only used at a few places in BubbleWrap doesn't mean that a better implementation won't help. People use camelize outside of BubbleWrap and could make use of the more powerful inflector behind it. Just as an example, motion-support's camelize can correctly camelize xml_http_api as XMLHTTPAPI and the underscore method does the same in reverse (provided you define the acronyms XML, HTTP and API). That acronym support also allows to camelize Cocoa-style class names like ui_view or ns_string. |
|
Requiring
Plus some methods in From the
I can live with these additions. I wish |
|
@ryansobol oops, that must've slipped through. Of course String#parameterize should be removed. Constantize is slow because Object#const_get is slow. My theory is that this is because there are just so many constants defined in RubyMotion (all the Cocoa classes plus all the enum values). So constantize should be cached whenever possible. |
Thanks for clarifying. I assumed that |
|
Well, |
We should probably use motion-support where appropriate, starting with string inflection.
The problem is BW's original
camelizemethod actually acceptedtrueandfalseas arguments, which the Motion/ActiveSupport variant does not (these only accept:upperand:lower, which BW also supports).And because of how BubbleWrap monkey patches the build order, if we wanted to write a version of
camelizewhich issued a deprecation warning and converted the boolean parameter to the appropriate symbol, it require several changes to the build system. (as I'm understanding it, BubbleWrap will add its own files to the build order first and then insert any other files added to the app afterwards, so by default motion-support is getting included after our string.rb)so, I think we can:
camelizetrue/falseversion ofcamelize(again, BW already supports:lowerand:upperas arguments)cc @tkadauke