1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00
This commit is contained in:
Adam Wiggins 2008-03-09 13:31:52 -07:00
parent 06a1afc1e7
commit 15f58e67dd
4 changed files with 19 additions and 11 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
rdoc

14
README
View file

@ -5,22 +5,22 @@ Sinatra...) style of specifying actions: get, put, post, delete.
== Usage == Usage
require 'rest_client' require 'rest_client'
xml = RestClient.get 'http://some/resource' xml = RestClient.get 'http://some/resource'
jpg = RestClient.get 'http://some/resource', :accept => 'image/jpg' 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 == Shell
Require rest_client from within irb to access RestClient interactively, like Require rest_client from within irb to access RestClient interactively, like
using curl at the command line. Better yet, require gem from within your 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 == Meta

View file

@ -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.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.author = "Adam Wiggins"
s.email = "adam@heroku.com" s.email = "adam@heroku.com"
s.rubyforge_project = "rest-client"
s.platform = Gem::Platform::RUBY s.platform = Gem::Platform::RUBY
s.has_rdoc = true
s.files = %w(Rakefile) + Dir.glob("{lib,spec}/**/*") s.files = %w(Rakefile) + Dir.glob("{lib,spec}/**/*")
@ -66,5 +68,14 @@ Rake::TestTask.new do |t|
t.verbose = true t.verbose = true
end 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' ] CLEAN.include [ 'pkg', '*.gem', '.config' ]

View file

@ -3,22 +3,18 @@ require 'net/http'
# This module's static methods are the entry point for using the REST client. # This module's static methods are the entry point for using the REST client.
module RestClient module RestClient
# GET http://some/resource
def self.get(url, headers={}) def self.get(url, headers={})
Request.new(:get, url, nil, headers).execute Request.new(:get, url, nil, headers).execute
end end
# POST http://some/resource, payload
def self.post(url, payload=nil, headers={}) def self.post(url, payload=nil, headers={})
Request.new(:post, url, payload, headers).execute Request.new(:post, url, payload, headers).execute
end end
# PUT http://some/resource, payload
def self.put(url, payload=nil, headers={}) def self.put(url, payload=nil, headers={})
Request.new(:put, url, payload, headers).execute Request.new(:put, url, payload, headers).execute
end end
# DELETE http://some/resource
def self.delete(url, headers={}) def self.delete(url, headers={})
Request.new(:delete, url, nil, headers).execute Request.new(:delete, url, nil, headers).execute
end end