README.md in msgpack_rails-0.0.1 vs README.md in msgpack_rails-0.1.0

- old
+ new

@@ -1,8 +1,9 @@ -# MsgpackRails +# msgpack_rails -TODO: Write a gem description +The Rails way to serialize/deserialize with [Message Pack](http://msgpack.org). +It implements an [ActiveSupport](http://rubygems.org/gems/activesupport) adapter and an [ActiveModel](http://rubygems.org/gems/activemodel) adapter for Message Pack. ## Installation Add this line to your application's Gemfile: @@ -16,10 +17,51 @@ $ gem install msgpack_rails ## Usage -TODO: Write usage instructions here +`msgpack_rails` converts data type using `as_json` before feeding it into [msgpack](http://rubygems.org/gems/msgpack). +Here are a few examples: + + $ ActiveSupport::MessagePack.encode(:a => :b) + => "\x81\xA1a\xA1b" + + $ ActiveSupport::MessagePack.encode(Time.now) + => "\xB92013-09-11T10:40:39-07:00" + + $ Time.now.as_msgpack + => "2013-09-11T10:48:13-07:00" + + $ Time.now.to_msgpack + => "\xB92013-09-11T10:40:39-07:00" + + $ ActiveSupport::MessagePack.decode Time.now.to_msgpack + => "2013-09-11T11:23:07-07:00" + + # After setting ActiveSupport.parse_msgpack_times to true + $ ActiveSupport::MessagePack.decode Time.now.to_msgpack + => Wed, 11 Sep 2013 11:25:18 -0700 + +You can also use it as part of `ActiveModel`: + +```ruby +class Contact + include ActiveModel::Serializers::MessagePack + + ... +end + +@contact = Contact.new +@contact.name = 'Konata Izumi' +@contact.age = 16 +@contact.created_at = Time.utc(2006, 8, 1) +@contact.awesome = true +@contact.preferences = { 'shows' => 'anime' } + +@contact.to_msgpack # => msgpack output +@contact.to_msgpack(:root => true) # => include root in msgpack output +``` + ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`)