From 15f58e67ddf0510232bb1a710b1b7bc6a87cc780 Mon Sep 17 00:00:00 2001 From: Adam Wiggins Date: Sun, 9 Mar 2008 13:31:52 -0700 Subject: [PATCH] rdocs --- .gitignore | 1 + README | 14 +++++++------- Rakefile | 11 +++++++++++ lib/rest_client.rb | 4 ---- 4 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4dfaa2a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +rdoc diff --git a/README b/README index 449d839..509f44a 100644 --- a/README +++ b/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 diff --git a/Rakefile b/Rakefile index ee2bff9..4050a14 100644 --- a/Rakefile +++ b/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' ] diff --git a/lib/rest_client.rb b/lib/rest_client.rb index b2fcbc6..80aa0d0 100644 --- a/lib/rest_client.rb +++ b/lib/rest_client.rb @@ -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