<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Justin Leitgeb &#187; Ruby</title>
	<atom:link href="http://justinleitgeb.com/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://justinleitgeb.com</link>
	<description>Perspectives on Ruby and OOP from a developer in NY</description>
	<lastBuildDate>Sun, 05 Sep 2010 04:43:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>iPhone app development with Ruby web services</title>
		<link>http://justinleitgeb.com/2009/09/iphone-app-development-with-ruby-web-services/</link>
		<comments>http://justinleitgeb.com/2009/09/iphone-app-development-with-ruby-web-services/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 13:00:48 +0000</pubDate>
		<dc:creator>Justin Leitgeb</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[sinatra]]></category>

		<guid isPermaLink="false">http://justinleitgeb.com/?p=65</guid>
		<description><![CDATA[The availability of elegant Web service frameworks like Sinatra, key-value storage systems such as Tokyo Cabinet, and tools such as Core Data in the iPhone development kit can be composed to create flexible and scalable web services that extend to mobile devices, as I found in my recent development of SubwayDelay.]]></description>
			<content:encoded><![CDATA[<p>I recently submitted SubwayDelay, an application I wrote to help NYC subway riders figure out the best train to take, to the App review process.  The application should be available in the App Store in about two weeks.  In this blog post, I&#8217;ll discuss some things that I learned while creating the application, which interacts with a web service built in Ruby.  In particular, I&#8217;ll touch on creating web services with Sinatra and key-value storage systems, and on using some of the new features of iPhone OS 3.0, including Core Data.  Finally, I&#8217;ll give some pointers on navigating the technical material from Apple related to more obscure parts of the App submission process.</p>
<h2>Sinatra + Tokyo Cabinet</h2>
<p>SubwayDelay requires a server to communicate with the iPhone application.  Instead of going with the popular Ruby on Rails stack, I decided to use a lighter-weight alternative called Sinatra.  Sinatra is great when you don&#8217;t need the overhead of Rails&#8230; it&#8217;s easy to figure out what&#8217;s going on in the framework since the codebase is small, and I&#8217;ve successfully used it in several cases where a web service component is needed.  For the user-visible web pages, I used Haml and Sass instead of the usual ERB since I find those DSL implementations a bit more succinct.</p>
<p>More importantly, in this application I was faced with data that would steadily increase in size.  I wanted to make sure that application performance remained constant, without becoming steadily worse as the size of data increased.  With AT&amp;T&#8217;s current network woes, the last thing I wanted was to cause users to wait extra time for their app to load because of slow delivery speed of my web stack!</p>
<p>For readers interested in things like computational complexity, this meant that I was looking to make sure that the algorithms would be able to complete in <a href="http://en.wikipedia.org/wiki/Constant_time" target="_blank">constant time</a>.  In order to achieve this, I realized that a Hash-type data store would come in handy.  I used Tokyo Cabinet with Tokyo Tyrant, which serializes and deserializes small Ruby Hash objects as my application needs them.</p>
<p>The result was an application that was extremely quick to develop, and which should have great scaling properties.</p>
<h2>Core Data on iPhone</h2>
<p>When I was approximately halfway through developing my iPhone application, which stores user preferences, Apple released iPhone OS 3.0.  Among many improvements to the toolkit was Core Data, a feature which had only been available previously on Mac OS X for desktop computers.  Essentially, Core Data is an Object-Relational Mapping system.  It enables the user to set up a backend data store using sqlite, and helps with flushing changes, selecting objects, and instantiating the correct models for your application.</p>
<p>I realized immediately that it was exactly what I was looking for to handle storing the basic data that I needed to maintain.  I took a step back, realizing that it would probably delay the release by a few days, and dug into the Core Data learning materials on the Apple Developers web site and the sample applications.  In the end, the slight detour was well worth the effort.  I have an application that adheres to the data store that Apple suggests, and the fact that Core Data integrates well into the strict MVC framework on the iPhone was icing on the cake.  I&#8217;d recommend a similar approach to anyone currently working on an iPhone application.</p>
<h2>Apple Developer Docs and App Submission</h2>
<p>As a Ruby developer, I&#8217;m used to being able to Google just about any problem that I come across and find a solution on the web.  With the iPhone, this isn&#8217;t necessarily the case.  The NDA that Apple had in place during early App development stifled some important discussion.  Now that this has been lifted, the Internet is starting to fill up with more useful information for the iPhone developer.  In particular I&#8217;ve been impressed with <a href="http://stackoverflow.com" target="_blank">StackOverflow.com</a> for relevant and helpful exchanges among developers.</p>
<p>There are still substantial deficits in information on the web, though, especially in things like the provisioning process.  It also complicates matters a bit because I believe that Apple has made some very slight changes to their tools, rendering some public web pages obsolete.  What I found in the end is that if you follow the yellow brick road laid out by Apple, things tend to fall into place.  Having trouble getting your keys in place to release the application?  Read the HowTo guide in iTunes Connect a couple of times and nine out of ten times the suggested approach will just work.  Afterwards, maybe there will be some useful information to be gleaned by general Googling, but try to restrain yourself and you may end up fixing things faster by just reading the Apple docs closely.  They really are very well written and comprehensive.</p>
<h2>Conclusion</h2>
<p>The availability of elegant Web service frameworks like Sinatra, key-value storage systems such as Tokyo Cabinet, and tools such as Core Data in the iPhone development kit can be composed to create flexible and scalable web services that extend to mobile devices, as I found in my recent development of <a href="http://subwaydelay.com" target="_blank">SubwayDelay</a>.  Any other tools that have come in handy for you in building apps using a similar stack?  Let me know in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://justinleitgeb.com/2009/09/iphone-app-development-with-ruby-web-services/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>NYC.rb Lightning Talk on Feedtosis</title>
		<link>http://justinleitgeb.com/2009/07/nyc-rb-lightning-talk-on-feedtosis/</link>
		<comments>http://justinleitgeb.com/2009/07/nyc-rb-lightning-talk-on-feedtosis/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 03:15:31 +0000</pubDate>
		<dc:creator>Justin Leitgeb</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://justinleitgeb.com/?p=5</guid>
		<description><![CDATA[This evening I gave a short talk at NYC.rb on Feedtosis, my ruby library for efficiently finding new information on RSS and Atom feeds.  I wrote this library for some side projects where I needed to quickly figure out which feed entries are new among lots of different feeds.  It helps by hiding the details [...]]]></description>
			<content:encoded><![CDATA[<p>This evening I gave a short talk at <a href="http://nycruby.org/wiki/" target="_blank">NYC.rb</a> on <a href="http://github.com/jsl/feedtosis/tree/master" target="_blank">Feedtosis</a>, my ruby library for efficiently finding new information on RSS and Atom feeds.  I wrote this library for some side projects where I needed to quickly figure out which feed entries are new among lots of different feeds.  It helps by hiding the details of using HTTP conditional retrieval (using Etag and last_modified tags) for RSS and Atom feeds, and also by taking care of figuring out which feed entries are new.</p>
<p>Although there are other libraries out there that do some of the same things, I decided to write this library after some careful thought because nothing else really had the right balance of features that I needed in terms of abstraction of the details of new feed detection and conditional GET.  Feedtosis is also lightweight in that it delegates the heavy lifting of actually making HTTP requests and normalizing feeds to the very capable ruby libraries taf2-curb and FeedNormalizer respectively.  In Feedtosis I tried to follow a Unix-like philosophy of building utilities that only solve one particular problem, while allowing composition with other minimal utilities in order to create robust systems.  I hope that you find it useful!  Feel free to forward me any comments, and please post any issues that you have with the library on its <a href="http://github.com/jsl/" target="_blank">GitHub page</a>.</p>
<p>In case you&#8217;d like to see the material from the presentation, check out the attached <a href="http://justinleitgeb.com/wp-content/uploads/2009/07/Feedtosis.pdf">Presentation PDF</a> or <a href="http://justinleitgeb.com/wp-content/uploads/2009/07/Feedtosis.pptx">Powerpoint</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://justinleitgeb.com/2009/07/nyc-rb-lightning-talk-on-feedtosis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
