Skip to content

Commit

Permalink
rdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Wiggins committed Mar 9, 2008
1 parent 06a1afc commit 15f58e6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rdoc
14 changes: 7 additions & 7 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ Sinatra...) style of specifying actions: get, put, post, delete.

== Usage

require 'rest_client'
require 'rest_client'

xml = RestClient.get 'http://some/resource'
jpg = RestClient.get 'http://some/resource', :accept => 'image/jpg'
xml = RestClient.get 'http://some/resource'
jpg = RestClient.get 'http://some/resource', :accept => 'image/jpg'

RestClient.put 'http://some/resource', File.read('my.pdf'), :content_type => 'application/pdf'
RestClient.put 'http://some/resource', File.read('my.pdf'), :content_type => 'application/pdf'

RestClient.post 'http://some/resource', xml, :content_type => 'application/xml'
RestClient.post 'http://some/resource', xml, :content_type => 'application/xml'

RestClient.delete 'http://some/resource'
RestClient.delete 'http://some/resource'

== Shell

Require rest_client from within irb to access RestClient interactively, like
using curl at the command line. Better yet, require gem from within your
~/.rush/env.rb and have instant access to it from within your rush sessions.
~/.rush/env.rb and have instant access to it from within your rush (http://rush.heroku.com) sessions.

== Meta

Expand Down
11 changes: 11 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ spec = Gem::Specification.new do |s|
s.description = "A simple REST client for Ruby, inspired by the microframework (Camping, Sinatra...) style of specifying actions: get, put, post, delete."
s.author = "Adam Wiggins"
s.email = "[email protected]"
s.rubyforge_project = "rest-client"

s.platform = Gem::Platform::RUBY
s.has_rdoc = true

s.files = %w(Rakefile) + Dir.glob("{lib,spec}/**/*")

Expand All @@ -66,5 +68,14 @@ Rake::TestTask.new do |t|
t.verbose = true
end

Rake::RDocTask.new do |t|
t.rdoc_dir = 'rdoc'
t.title = "rest-client, fetch RESTful resources effortlessly"
t.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
t.options << '--charset' << 'utf-8'
t.rdoc_files.include('README')
t.rdoc_files.include('lib/rest_client.rb')
end

CLEAN.include [ 'pkg', '*.gem', '.config' ]

4 changes: 0 additions & 4 deletions lib/rest_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,18 @@

# This module's static methods are the entry point for using the REST client.
module RestClient
# GET http://some/resource
def self.get(url, headers={})
Request.new(:get, url, nil, headers).execute
end

# POST http://some/resource, payload
def self.post(url, payload=nil, headers={})
Request.new(:post, url, payload, headers).execute
end

# PUT http://some/resource, payload
def self.put(url, payload=nil, headers={})
Request.new(:put, url, payload, headers).execute
end

# DELETE http://some/resource
def self.delete(url, headers={})
Request.new(:delete, url, nil, headers).execute
end
Expand Down

0 comments on commit 15f58e6

Please sign in to comment.