mirror of
https://github.com/rest-client/rest-client.git
synced 2022-11-09 13:49:40 -05:00
rdocs
This commit is contained in:
parent
06a1afc1e7
commit
15f58e67dd
4 changed files with 19 additions and 11 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
rdoc
|
14
README
14
README
|
@ -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
|
||||
|
||||
|
|
11
Rakefile
11
Rakefile
|
@ -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 = "adam@heroku.com"
|
||||
s.rubyforge_project = "rest-client"
|
||||
|
||||
s.platform = Gem::Platform::RUBY
|
||||
s.has_rdoc = true
|
||||
|
||||
s.files = %w(Rakefile) + Dir.glob("{lib,spec}/**/*")
|
||||
|
||||
|
@ -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' ]
|
||||
|
||||
|
|
|
@ -3,22 +3,18 @@ require 'net/http'
|
|||
|
||||
# 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
|
||||
|
|
Loading…
Reference in a new issue