Following up on https://github.com/noniq/Markdown-MathJax.tmbundle/commit/6d003d9c9808acc954... I created a very simple test script:
#!/usr/bin/env ruby20 require "#{ENV['TM_SUPPORT_PATH']}/lib/ui" TextMate::UI.alert(:warning, 'Title', 'Message', 'OK')
Running this gives an “ArgumentError: An object in the argument tree could not be converted” in method to_plist in ui.rb at line 54.
If I change the script to use the `ruby18` shim, it works as intended. Is this expected behaviour or am I doing something wrong?
Stefan
The Ruby code in bundle support has never been verified to work on anything else than Ruby 1.8.
On 20 Aug 2016, at 12:19, Stefan Daschek wrote:
Running this gives an “ArgumentError: An object in the argument tree could not be converted” in method to_plist in ui.rb at line 54.
We have our binary plist extension for ruby 1.8 which does not work with 2.0.
I think we can switch to https://github.com/ckruse/CFPropertyList and then add a compatibility layer for the old plist API.
There might be other issues with the current ruby code we have in bundle support, but the specific error above, I am quite sure is about the plist extension.
It would be nice to get all of our support code updated to work with both 1.8 and 2.0, but it’s also a daunting task because we have lots of code from lots of people collected over a decade, some of it should probably just be removed…
I think we can switch to https://github.com/ckruse/CFPropertyList and then add a compatibility layer for the old plist API.
There might be other issues with the current ruby code we have in bundle support, but the specific error above, I am quite sure is about the plist extension.
It would be nice to get all of our support code updated to work with both 1.8 and 2.0, but it’s also a daunting task because we have lots of code from lots of people collected over a decade, some of it should probably just be removed…
I’d be happy to give this a try. Could you give me some hints on what code you think could / should be removed? (I think removing unneeded code first and then updating the remaining code to work with Ruby 2 is the most efficient strategy.)
To check if code isn’t used in other bundles before removing it: Would it be sufficient to search across all bundles that are listed in TextMate’s bundle index? (Btw, where can I find the source of this index?)
Stefan.
On 21 Aug 2016, at 13:29, Stefan Daschek wrote:
I’d be happy to give this a try. Could you give me some hints on what code you think could / should be removed?
Unused code, whatever that is :) And code that is only used by a single bundle can be moved to that bundle.
There might also be use of some code that could be replaced with stdlib functionality, for example a lot of bundles use `e_sh` from `escape.rb` when they should probably instead use the `Shellwords` library.
To check if code isn’t used in other bundles before removing it: Would it be sufficient to search across all bundles that are listed in TextMate’s bundle index?
Yes, I think if none of “our” bundles use the code, there should be no need to support it anymore.
(Btw, where can I find the source of this index?)
This code will echo the “git clone” instructions required to clone all bundles in the index (pipe it to `sh` when you ensure it works):
pp ~/Library/Application\ Support/TextMate/Managed/Cache/org.textmate.updates.default \ |grep -o 'https://api.textmate.org/.*%5C.tbz' \ |while read url; do curl -s $url \ |tar -jxO info.plist|pp \ |sed -n 's/.*url = "(.*git.*)";/\1/p' \ |( read repos; echo git clone $repos ); done
Here `pp` is the property list tool found in the _Property List_ bundle (under `Support/bin`).
It basically just reads a property list from stdin and outputs the old-style format to stdout so that we can easily grep it. A bit like `pl` but that tool lacks support for binary property lists.
And you will btw need to clone all the repositories because the deployed versions use binary property lists, so searching these would not find everything.
Am 21.08.16 um 13:59 schrieb Allan Odgaard:
This code will echo the “git clone” instructions required to clone all bundles in the index (pipe it to |sh| when you ensure it works): |pp ~/Library/Application\ Support/TextMate/Managed/Cache/org.textmate.updates.default \ |grep -o 'https://api.textmate.org/.*%5C.tbz' \ |while read url; do curl -s $url \ |tar -jxO info.plist|pp \ |sed -n 's/.*url = "(.*git.*)";/\1/p' \ |( read repos; echo git clone $repos ); done |
Here |pp| is the property list tool found in the /Property List/ bundle (under |Support/bin|).
Thanks, worked like a charm. Let’s get this cleanup party started! 👷🕵
First candidate for removal is |bluecloth.rb|: Seems to be only used from the Typo3 bundle, and the code referring to it there seems itself to be unused, see https://github.com/textmate/typo3.tmbundle/pull/1
Stefan