From 36f24a417d13aaedebc982c32e8c25446955c124 Mon Sep 17 00:00:00 2001 From: John Nunemaker Date: Mon, 28 Jul 2008 13:20:03 -0400 Subject: [PATCH] Tweaking information and readme. --- License.txt | 2 +- Manifest.txt | 20 ++++++++------- README.txt | 67 +++++++++++++++++++++++++++------------------------ config/hoe.rb | 2 +- 4 files changed, 48 insertions(+), 43 deletions(-) diff --git a/License.txt b/License.txt index 10aab649..ea4d3405 100644 --- a/License.txt +++ b/License.txt @@ -1,4 +1,4 @@ -Copyright (c) 2008 FIXME full name +Copyright (c) 2008 John Nunemaker Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/Manifest.txt b/Manifest.txt index 9ceb1246..d5b63585 100644 --- a/Manifest.txt +++ b/Manifest.txt @@ -6,20 +6,22 @@ README.txt Rakefile config/hoe.rb config/requirements.rb -lib/web.rb -lib/web/version.rb +examples/aaws.rb +examples/delicious.rb +examples/twitter.rb +lib/httparty.rb +lib/httparty/core_ext.rb +lib/httparty/core_ext/hash.rb +lib/httparty/version.rb script/console script/destroy script/generate script/txt2html setup.rb +spec/hash_spec.rb +spec/httparty_spec.rb +spec/spec.opts +spec/spec_helper.rb tasks/deployment.rake tasks/environment.rake tasks/website.rake -test/test_helper.rb -test/test_web.rb -website/index.html -website/index.txt -website/javascripts/rounded_corners_lite.inc.js -website/stylesheets/screen.css -website/template.html.erb diff --git a/README.txt b/README.txt index d1b48603..9542dbc3 100644 --- a/README.txt +++ b/README.txt @@ -1,48 +1,51 @@ = httparty -* FIX (url) - == DESCRIPTION: -FIX (describe your package) +Makes http fun again! == FEATURES/PROBLEMS: -* FIX (list of features or problems) +* Easy get, post, put, delete requests +* Basic http authentication +* Default request query string parameters (ie: for api keys that are needed on each request) +* Automatic parsing of JSON and XML into ruby hashes == SYNOPSIS: - FIX (code sample of usage) +The following is a simple example of wrapping Twitter's API for posting updates. + + class Twitter + include HTTParty + base_uri 'twitter.com' + basic_auth 'username', 'password' + end + + Twitter.post('/statuses/udpate.json', :query => {:status => "It's an HTTParty and everyone is invited!"}) + +That is really it! The object returned is a ruby hash that is decoded from Twitter's json response. JSON parsing is used because of the .json extension in the path of the request. You can also explicitly set a format (see the examples). + +That works and all but what if you don't want to embed your username and password in the class? Below is an example to fix that: + + class Twitter + include HTTParty + base_uri 'twitter.com' + + def initialize(user, pass) + self.class.basic_auth user, pass + end + + def post(text) + self.class.post('/statuses/update.json', :query => {:status => text}) + end + end + + Twitter.new('username', 'password').post("It's an HTTParty and everyone is invited!") == REQUIREMENTS: -* FIX (list of requirements) +* Active Support >= 2.1 == INSTALL: -* FIX (sudo gem install, anything else) - -== LICENSE: - -(The MIT License) - -Copyright (c) 2008 FIXME full name - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file +* sudo gem install httparty \ No newline at end of file diff --git a/config/hoe.rb b/config/hoe.rb index aa5ea0ba..69dc74bf 100644 --- a/config/hoe.rb +++ b/config/hoe.rb @@ -8,7 +8,7 @@ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org" DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}" EXTRA_DEPENDENCIES = [ -# ['activesupport', '>= 1.3.1'] + ['activesupport', '>= 2.1'] ] # An array of rubygem dependencies [name, version] @config_file = "~/.rubyforge/user-config.yml"