ljxia / plistifier

A rails plugin to use the .plist format to return binary plists

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Plistifier
==========

Adds the ActiveRecord#to_plist and Array#to_plist methods similar to ActiveRecord#to_xml.
The :only, :except, :methods, and :include options are supported.

It too ads the :plist option to the ActiveRecord::Base#render method. With help of that
you get binary plist files which you can easy use in your iPhone.


Install
=======

script/plugin install git://github.com/jeena/plistifier.git


Example
=======

In your PostController use for example:

	def index
	  @posts = Post.all

	  respond_to do |format|
	    format.html # index.html.erb
	    format.xml  { render :xml => @posts }
	    format.plist { render :plist => @posts.to_plist(:only => [:id, :title]) }
	  end
	end

	def show
	  @post = Post.find(params[:id])

	  respond_to do |format|
	    format.html # show.html.erb
	    format.xml  { render :xml => @post }
			format.plist { render :plist => @post }
	  end
	end
	
Basic example
	NSURL *url = [NSURL URLWithString:@"http://example.com/posts.plist"];
	NSArray *posts = [[NSArray alloc] initWithContentsOfURL:url];
	NSLog(@"Title: %@", [[posts objectAtIndex:0] objectForKey:@"title"]);

On the iPhone I have categories that simplify the parsing of the plist data checkout http://github.com/pcrawfor/plistSerialization for usage.

Thanks
======

This plugin uses Christian Kruses CFPropertyList http://github.com/ckruse/CFPropertyList
to generate Plists.

This plugin started as a copy of http://github.com/chuyeow/jsonifier/ I just changed it to
support and added the CFPropertyList stuff.

This plugin is a fork and extension of http://github.com/jeena/plistifier I've extended it to support parsing plist
data in both directions I've also fixed several bugs with the property list data format serialization and the way request data was 
built and sent.

Copyright (c) 2010 Paul Crawford, released under the MIT license

About

A rails plugin to use the .plist format to return binary plists

License:MIT License


Languages

Language:Ruby 100.0%