Posts filed under 'ruby'

As2Api and RubyScript2Exe (darwinized)

I recently sat down and took a look at as2api, which seems to be the most recommended JavaDoc exporter for actionscript. Once I had everything figured out, it seems to work fine, and I’m sure there are some little nuggets that I haven’t quite figured out yet, which I’m looking forward to figuring out. (read more for the skinny and darwin downloads)

However, for those of you out there in Mac OSX land, I wouldn’t recommend downloading the current version listed on the site for OSX, entitled “as2api-allinone-osx-0.4.sit” in the downloads section. I think that it is missing files, or that it just doesn’t work correctly at all. I would recommend instead downloading the first link for “as2api-0.4.tar”. The downside of downloading this version is that there is no OSX command line executable in there, so you have to run the Ruby script “ruby as2api.rb packages –classpath classpath” which works just fine.

Honestly, I don’t know enough about ANT scripts yet to know if you can run Ruby scripts from an ANT script target, so I used rubyscript2exe, another handy little application to convert the Ruby scripts into a mac command line executable. (Incidentally, and to add a little geek comedy to this post, you have to install the Pascal compiler and compile a piece of the rubyscript2exe library in order to run it…so I had to compile one application in order to create another one…).

Anyway, I have included below 2 downloadables in this post. The first is the command line version of as2api that is compiled from the package that you can download as Ruby code from the as2api site. The down side is that you cannot tweek the css and html templates that are part of that code; the up side is that you can actually use it as a command line executable, which is entitled “as2api_darwin”. You can used it exactly as you would the as2api.rb Ruby script.

PlasticWare Downloadable ::
Darwin Executable of As2Api (JavaDoc for Actionscript) (Sep. 5, 2006)
Download (~4.5mB) :: as2api-0.4.zip

The second downloadable I have included here is the rubyscript2exe download, altered to include the eee_darwin file that I compiled from the pascal source on my mactel laptop in OSX 10.4.7, and repackaged using tar2rubyscript.rb, which was also necessary to get it running properly. I have also included the example hello world script “hello.rb” from the tutorial, which you can use to test the code and make a hello world exe.

PlasticWare Downloadable ::
RubyScript2Exe with eee_darwin for OSX environment (Sep. 5, 2006)
Download (~1.1mB) :: rubyscript2exe.zip.gz

Both of these pieces of software are released by their proper creators under the GNU License, and I have included the source and license for each as well, as posted on their sites. Please download judiciously, the executable for as2api package is 4.5 mb.

7 comments Tue, 2006 Sep 05, 5:55pm

Hacking TextMate to Edit a Blog Post by ID

OK, so the blogging functionality in TextMate is pretty nice. Its a little primitive, but it does have some cool features and all the text editing features that it offers to boot. I wanted to go back and clean up some old entries using TM, just to play around with it a bit; however, I was a little disappointed that I could not see more than the last 20 entries when choosing the command from the menu "Bundles/Blogging/Fetch Post." So, since TM is very customizable, I set about fixing this issue, by creating the ability to fetch a post if you know the id of the post in your blogging engine. In order to do this, you must edit the blogging Ruby file in the blogging bundle (which is located in the TextMate.app bundle), and then add a command using the bundle editor. All this is assuming that you have been able to get the blogging functionality working at the base level in TextMate. So, let's get started - read on...

** Note (added July 31, 2006): After posting this and shutting down, it occurred to me that it would be better to actually add the edited ruby code to an external directory so that it would not be overwritten in the process of updating Textmate; in addition, if you migrate your user to another computer (which I'm about to do soon), Migration Assistant should copy the changes over to the new machine. I've changed the content of the tutorial to reflect this change.

Edit "blogging.rb" Ruby file

  1. Go to the TextMate application.
  2. Right-click (command click) the TextMate application icon and choose "Show Package Contents" -- you will probably have to authenticate.
  3. In the new window open the sub directory of the path "Contents/SharedSupport/Bundles" -- you will see a list of bundles.
  4. Right-click, as before, the bundle called "Blogging.tmbundle" and choose "Show Package Contents" again.
  5. In the new window for the Blogging bundle, go into the directory path "Support/lib" -- you should see some Ruby files, and one called "blogging.rb".
  6. Make a copy of "blogging.rb" and place it into a directory in your user folder. I placed it here: "file:///Users/--username--/Library/Application Support/TextMate/BundleEdits/Blogging/blogging.rb". (the name BundleEdits for the new folder in the TextMate support folder is arbitrary, but its what I chose...)
  7. Open the new "blogging.rb" with your text editor (TextMate is fine). (I chose not to use TextMate, just being superstitious.)
  8. Search for the string "# Command: Fetch" which is the commented line above the Fetch command for the blogging funtionality. Cursor to the line after the "fetch" function definition, and paste the code below:
  9. CODE:
    1. # fetch_post_page
    2.  
    3. def fetch_post_page
    4. begin
    5. _password = password
    6. self.post = client.getPost(post_id, username, _password)
    7. TextMate.exit_create_new_document(post_to_document)
    8. @mw_success = true
    9. rescue XMLRPC::FaultException => e
    10. TextMate.exit_show_tool_tip("Error retrieving post. Check your configuration and try again.")
    11. end
    12. end
    13.  
    14. # Command: Fetch_By_Id
    15.  
    16. def fetch_by_id
    17. if post_id
    18. fetch_post_page
    19. else
    20. TextMate.exit_show_tool_tip("A Post ID is required to fetch the post by id.")
    21. end
    22. end

  10. Now save the code and close out the document.

Create a new command in the TextMate Bundle Editor

  1. Open TextMate and choose menu item "Bundles", then "Bundle Editor", and finally "Edit Commands..." (you can also just use the key command of Control-Option-Command-C).
  2. Open the Blogging section on the left hand side of the Bundle Editor and select "Fetch Post" (but don't do anything with it)
  3. Now click the duplicate button at the bottom left (looks like two +'s) to create a new command. Rename the command something like "Fetch Post By Id"
  4. Paste the following text into the field named "Command(s):". Make sure that you substitute your system user name and if you did not create a directory called "BundleEdits", use the name you used there.
  5. #!/usr/bin/env ruby -rjcode -Ku
    require "Users/--username--/Library/Application Support/TextMate/BundleEdits/Blogging/blogging.rb"
    Blogging.new.fetch_by_id
  6. Leave the rest of it the same and close the Bundle Editor.

Open a Post

I have my settings as the default in WordPress, so that it's fairly easy to find out what the post id is for a particular posting. As the default, the post id is the number at the end of the URL string when you click the permanent link for a posting. Once you've gotten the post id for the post you would like to view/edit, open a new text document in TextMate and type in the text "Post: XX", where XX is your posting id.

Now choose the menu "Bundles/Blogging/Fetch Post By Id," and after authenticating, Textmate will open your post in a new window for editing...

4 comments Fri, 2006 Jul 28, 7:04pm


Site Decryption

info = { PlaIns: "the section of the PlasticStare site, the digital external brain-repository of Ryan Todd, whose brain otherwise occupies space in San Francisco, CA", ryota: "mungified version of ryan's name", haikuBio: "robotic from birth. hears sounds - listens to music. makes pixels act." }

Calendar

July 2008
S M T W T F S
« Jun    
 12345
6789101112
13141516171819
20212223242526
2728293031  

Posts by Month

Posts by Category