Monthly Archive for November, 2011

eBay PHP Framework, Tumblr for Kohana, and More

I’ve been throwing a decent amount of code on GitHub + Gist recently; I wanted to highlight a couple of the projects that the community might find useful.

eBay PHP Framework Wrapper

There isn’t a ton of documentation or examples around the eBay PHP Accelerator toolkit. Actually, I think it has been a couple years since the framework itself has been updated. I’ve put together a small eBay PHP library with some generic posting and searching wrapper functions. The code was pulled out of an active project and still has some references to the context in which it was situated, but it should provide a good starting point to anyone looking to work with the eBay PHP framework. In additional to providing some wrapper functions, it also has some fixes to the underlying eBat NS framework.

NetSuite PHP Framework Wrapper

Similar to the eBay wrapper library, I’ve made a wrapper around the PHP NetSuite framework. Although the library is structured as a Kohana 2 library, it would be fairly easily to rearrange the library for use in another PHP framework or as a standalone library. The wrapper provides some useful information about working with custom record types (reading + writing) and some wrappers around some trickier NetSuite functionality. The library also provides fixes to the underlying netsuite PHP framework . If you have been having trouble with the NetSuite framework throwing errors when returning a valid SOAP response, take a look through the commit log and pull out the patches.

Tumblr + Kohana

If you are looking to integrate a Tumblr blog with a custom design take a look the phumblr library which provides an easy way to integrate Tumblr via a PHP interface.

MacRuby Deployment + Load Order

After reading the official MacRuby docs on deployment, I read over this guide. Although the deployment build seemed to be working fine on my local machine when I dropped it on my laptop with a standard Lion install it crashed, claiming that there was an defined constant – but that constant was a class. How could it be undefined if it ran fine locally?

Looking into it a bit more the class that was undefined was being used as a superclass for another ruby class. Taking a look at rb_main.rb revealed that there is no specific load order. Since the load order was undefined, the class requiring the other ruby class as a superclass was being loaded before the superclass was loaded. I ended up tweaking the rb_main.rb file to allow for a manual load order, followed by the standard automatic load.

# Loading the Cocoa framework. If you need to load more frameworks, you can
# do that here too.
framework 'Cocoa'

# Loading all the Ruby project files.

# manual load allows up to specify the load order for some of the classes
manualLoad = ["VTiTunesHeader"]
for file in manualLoad
require file
end

manualLoad < < File.basename(__FILE__, File.extname(__FILE__))

# Auto load the direct of the files in the dir
dir_path = NSBundle.mainBundle.resourcePath
Dir.glob(File.join(dir_path, '*.{rb,rbo}')).map { |x| File.basename(x, File.extname(x)) }.uniq.each do |path|
if not manualLoad.include? path
require(path)
end
end

# Starting the Cocoa main loop.
NSApplicationMain(0, nil)

You can grab the gist here.

Cocoa Resources

Some Cocoa libraries / snippet repos that I found during my latest dev session.

Random Tidbits

  • Although old news to most, you can grab the the last n bytes of a file using tail -c. Very useful for cutting down on the size of large text log files.
  • I pulled the build versioning code out from a project I was working on. Take a look at this build numbering gist, provides source to pull version number from git or svn and write it in your Info.plist
  • The Ruby logging class is more robust than the Log4r class and the built in logger class.
  • attr_accessor :variable makes a instance variable Key Value Coding compliant. Just set @variable in your initializer.
  • Awesome side-by-side reference sheet for PHP, Ruby, Perl, and Python. Handy reference to python to ruby conversion.
  • Obj-c blocks in MacRuby
  • Although you can `macgem install json`, macruby comes with a json library built in that seems to have tweaks for deployment. Don’t install the json gem
  • The Open3 Ruby library does not return subprocess status correctly when using MacRuby
  • Online version of “MacRuby: The Definitive Guide”
  • PyObjc on Lion is dead. Although you might get an application to run, there are so many bugs it really isn’t usable for production
  • Although macrubyd exists, it doesn’t seem to work with full-fledged Cocoa + MacRuby apps. There isn’t any Xcode integration. Ruby-Debug also doesn’t seem to be compatible with MacRuby. Bottom line: no strong debugging tools for MacRuby… yet.
  • The “throw your dotfiles on github” trend has been an interested learning experience for me