README.md in rapidash-0.0.1 vs README.md in rapidash-0.0.2

- old
+ new

@@ -1,6 +1,6 @@ -# Rapidash +# Rapidash [![Build Status](https://travis-ci.org/Gazler/rapidash.png?branch=master)](https://travis-ci.org/Gazler/rapidash) Rapidash is an opinionated core for you to build a client for your API on. The goal is to define a standard way that developers can quickly write a client for the consumption of their RESTful API. ## Installation @@ -21,13 +21,27 @@ ### Resources Resources can be defined as follows: class Users < Rapidash::Base - url "users" end +The URL of the resource will be inferred from the class name. In this case Users. If you want to override that, you can with the url method. + + class Users < Rapidash::Base + url :members # or url "members" is also supported + end + +Resources can exist inside other resources. For example, on Github, a user has repositories. The following could be how you build the resources: + + class Repos < Rapidash::Base + end + + class Users < Rapidash::Base + resource :repos + end + ### Client The main thing a client must do is define a method, `oauth` and `http` are currently supported. You can also define resources which links a resource as defined above to the client. class Client < Rapidash::Client @@ -53,60 +67,46 @@ ### Facebook require 'rapidash' class Me < Rapidash::Base - url "me" end class Facebook < Rapidash::Client method :oauth resource :me end - client = Facebook`.new({ + client = Facebook.new({ :site => "https://graph.facebook.com", :uid => "YOUR_ID", :secret => "YOUR_SECRET", :access_token => "YOUR_TOKEN" }) p client.me!.first_name #Gary ### Github - require 'rapidash' + require 'rapidash' - class Users < Rapidash::Base - url :users + class Repos < Rapidash::Base - def user(name) - self.url += "/#{name}" - self + class Users < Rapidash::Base + resource :repos end - def repos! - self.url += "/repos" - call! - end + class Github < Rapidash::Client + method :http + resource :users - def user!(name) - user(name) - call! + def initialize + @site = "https://api.github.com/" + end end - end - class Github < Rapidash::Client - method :http - resource :users - - def initialize - @site = "https://api.github.com/" - end - end - - client = Github.new - p client.users.user!("Gazler").name #Gary Rennie - p client.users.user("Gazler").repos![0].name #Githug + client = Github.new + p client.users!("Gazler").name #Gary Rennie + p client.users("Gazler").repos![0].name #Githug ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`)