mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
Tweaking information and readme.
This commit is contained in:
parent
aafde86709
commit
36f24a417d
4 changed files with 48 additions and 43 deletions
|
@ -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
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
|
|
20
Manifest.txt
20
Manifest.txt
|
@ -6,20 +6,22 @@ README.txt
|
||||||
Rakefile
|
Rakefile
|
||||||
config/hoe.rb
|
config/hoe.rb
|
||||||
config/requirements.rb
|
config/requirements.rb
|
||||||
lib/web.rb
|
examples/aaws.rb
|
||||||
lib/web/version.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/console
|
||||||
script/destroy
|
script/destroy
|
||||||
script/generate
|
script/generate
|
||||||
script/txt2html
|
script/txt2html
|
||||||
setup.rb
|
setup.rb
|
||||||
|
spec/hash_spec.rb
|
||||||
|
spec/httparty_spec.rb
|
||||||
|
spec/spec.opts
|
||||||
|
spec/spec_helper.rb
|
||||||
tasks/deployment.rake
|
tasks/deployment.rake
|
||||||
tasks/environment.rake
|
tasks/environment.rake
|
||||||
tasks/website.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
|
|
||||||
|
|
67
README.txt
67
README.txt
|
@ -1,48 +1,51 @@
|
||||||
= httparty
|
= httparty
|
||||||
|
|
||||||
* FIX (url)
|
|
||||||
|
|
||||||
== DESCRIPTION:
|
== DESCRIPTION:
|
||||||
|
|
||||||
FIX (describe your package)
|
Makes http fun again!
|
||||||
|
|
||||||
== FEATURES/PROBLEMS:
|
== 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:
|
== 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:
|
== REQUIREMENTS:
|
||||||
|
|
||||||
* FIX (list of requirements)
|
* Active Support >= 2.1
|
||||||
|
|
||||||
== INSTALL:
|
== INSTALL:
|
||||||
|
|
||||||
* FIX (sudo gem install, anything else)
|
* sudo gem install httparty
|
||||||
|
|
||||||
== 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.
|
|
|
@ -8,7 +8,7 @@ RUBYFORGE_PROJECT = 'httparty' # The unix name for your project
|
||||||
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
||||||
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
||||||
EXTRA_DEPENDENCIES = [
|
EXTRA_DEPENDENCIES = [
|
||||||
# ['activesupport', '>= 1.3.1']
|
['activesupport', '>= 2.1']
|
||||||
] # An array of rubygem dependencies [name, version]
|
] # An array of rubygem dependencies [name, version]
|
||||||
|
|
||||||
@config_file = "~/.rubyforge/user-config.yml"
|
@config_file = "~/.rubyforge/user-config.yml"
|
||||||
|
|
Loading…
Add table
Reference in a new issue