README.md in rapidash-0.1.2 vs README.md in rapidash-0.2.0
- old
+ new
@@ -23,10 +23,14 @@
A screencast on Rapidash is available to watch in mp4 and ogv formats.
* [Rapidash Screencast mp4](http://screencasts.gazler.com/rapidash.mp4)
* [Rapidash Screencast ogv](http://screencasts.gazler.com/rapidash.ogv)
+### Sample Rails app
+
+A sample rails app is available at [https://github.com/Gazler/rapidash-tester](https://github.com/Gazler/rapidash-tester) it provides a rails server and a Rapidash client. Please note that the client is also used as a form of integration test for rapidash.
+
### Resources
Resources can be defined as follows:
```ruby
@@ -35,47 +39,62 @@
```
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.
```ruby
-class Users < Rapidash::Base
+class User < 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:
```ruby
-class Repos < Rapidash::Base
+class Repo < Rapidash::Base
end
-class Users < Rapidash::Base
+class User < Rapidash::Base
resource :repos
end
```
#### Root elements
A root element can be set for create and post actions
```ruby
-class Posts < Rapidash::Base
+class Post < Rapidash::Base
end
client.posts.create!({:post => {:name => "a post"}})
```
With a root element, the code would look like this:
```ruby
-class Posts < Rapidash::Base
+class Post < Rapidash::Base
root :post
end
client.posts.create!(:name => "a post")
```
+### Class Names and Classes In Different Modules
+
+If you wish to use a class in a different module or a class with a different name as the class for your resource then you can use the `:class_name` option.
+
+```ruby
+module MyModule
+ class MyResource < Rapidash::Base
+ end
+end
+
+class AnotherResource < Rapidash::Base
+ resource :my_cool_resource, :class_name => "MyModule::MyResource"
+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.
```ruby
@@ -113,10 +132,11 @@
```ruby
require 'rapidash'
class Me < Rapidash::Base
+ url "me"
end
class Facebook < Rapidash::Client
method :oauth
resource :me
@@ -134,13 +154,13 @@
### Github
```ruby
require 'rapidash'
-class Repos < Rapidash::Base
+class Repo < Rapidash::Base
-class Users < Rapidash::Base
+class User < Rapidash::Base
resource :repos
end
class Github < Rapidash::Client
method :http
@@ -151,16 +171,33 @@
client = Github.new
p client.users!("Gazler").name #Gary Rennie
p client.users("Gazler").repos![0].name #Githug
```
+### HTTP Authentication
+
+```ruby
+require 'rapidash'
+
+class Client < Rapidash::Client
+ method :http
+ site "your site"
+end
+
+client = Client.new({
+ :login => "your login",
+ :password => "your password",
+})
+```
+
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
-4. Push to the branch (`git push origin my-new-feature`)
-5. Create new Pull Request
+4. Write your tests, start and check coverage: open file coverage/index.html in your browser. Must be 100.0% covered
+5. Push to the branch (`git push origin my-new-feature`)
+6. Create new Pull Request (into the development branch)
## Credits
Thanks to [@Sid3show](https://github.com/Sid3show) for the sweet logo!