yyyc514-httparty 0.4.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/History +131 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Manifest +47 -0
  4. data/README.rdoc +54 -0
  5. data/Rakefile +48 -0
  6. data/bin/httparty +98 -0
  7. data/cucumber.yml +1 -0
  8. data/examples/aaws.rb +32 -0
  9. data/examples/basic.rb +11 -0
  10. data/examples/delicious.rb +37 -0
  11. data/examples/google.rb +16 -0
  12. data/examples/rubyurl.rb +14 -0
  13. data/examples/twitter.rb +31 -0
  14. data/examples/whoismyrep.rb +10 -0
  15. data/features/basic_authentication.feature +20 -0
  16. data/features/command_line.feature +7 -0
  17. data/features/deals_with_http_error_codes.feature +26 -0
  18. data/features/handles_multiple_formats.feature +34 -0
  19. data/features/steps/env.rb +15 -0
  20. data/features/steps/httparty_response_steps.rb +26 -0
  21. data/features/steps/httparty_steps.rb +15 -0
  22. data/features/steps/mongrel_helper.rb +55 -0
  23. data/features/steps/remote_service_steps.rb +47 -0
  24. data/features/supports_redirection.feature +22 -0
  25. data/lib/httparty.rb +206 -0
  26. data/lib/httparty/class_inheritable_attributes.rb +25 -0
  27. data/lib/httparty/cookie_hash.rb +9 -0
  28. data/lib/httparty/core_extensions.rb +29 -0
  29. data/lib/httparty/exceptions.rb +7 -0
  30. data/lib/httparty/request.rb +141 -0
  31. data/lib/httparty/response.rb +18 -0
  32. data/lib/httparty/version.rb +3 -0
  33. data/spec/fixtures/delicious.xml +23 -0
  34. data/spec/fixtures/empty.xml +0 -0
  35. data/spec/fixtures/google.html +3 -0
  36. data/spec/fixtures/twitter.json +1 -0
  37. data/spec/fixtures/twitter.xml +403 -0
  38. data/spec/fixtures/undefined_method_add_node_for_nil.xml +2 -0
  39. data/spec/httparty/cookie_hash_spec.rb +38 -0
  40. data/spec/httparty/request_spec.rb +199 -0
  41. data/spec/httparty/response_spec.rb +62 -0
  42. data/spec/httparty_spec.rb +307 -0
  43. data/spec/spec.opts +3 -0
  44. data/spec/spec_helper.rb +21 -0
  45. data/website/css/common.css +47 -0
  46. data/website/index.html +74 -0
  47. data/yyyc514-httparty.gemspec +40 -0
  48. metadata +134 -0
@@ -0,0 +1,3 @@
1
+ --format
2
+ progress
3
+ --colour
@@ -0,0 +1,21 @@
1
+ require 'rubygems'
2
+ gem 'rspec', '>= 1.2.8'
3
+ require 'spec'
4
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'httparty')
5
+
6
+ def file_fixture(filename)
7
+ open(File.join(File.dirname(__FILE__), 'fixtures', "#{filename.to_s}")).read
8
+ end
9
+
10
+ def stub_http_response_with(filename)
11
+ format = filename.split('.').last.intern
12
+ data = file_fixture(filename)
13
+
14
+ response = Net::HTTPOK.new("1.1", 200, "Content for you")
15
+ response.stub!(:body).and_return(data)
16
+
17
+ http_request = HTTParty::Request.new(Net::HTTP::Get, 'http://localhost', :format => format)
18
+ http_request.stub!(:perform_actual_request).and_return(response)
19
+
20
+ HTTParty::Request.should_receive(:new).and_return(http_request)
21
+ end
@@ -0,0 +1,47 @@
1
+ @media screen, projection {
2
+ /*
3
+ Copyright (c) 2007, Yahoo! Inc. All rights reserved.
4
+ Code licensed under the BSD License:
5
+ http://developer.yahoo.net/yui/license.txt
6
+ version: 2.2.0
7
+ */
8
+ body {font:13px arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}table {font-size:inherit;font:100%;}select, input, textarea {font:99% arial,helvetica,clean,sans-serif;}pre, code {font:115% monospace;*font-size:100%;}body * {line-height:1.22em;}
9
+ body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}/*ol,ul {list-style:none;}*/caption,th {text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym {border:0;}
10
+ /* end of yahoo reset and fonts */
11
+
12
+ body {color:#333; background:#4b1a1a; line-height:1.3;}
13
+ p {margin:0 0 20px;}
14
+ a {color:#4b1a1a;}
15
+ a:hover {text-decoration:none;}
16
+ strong {font-weight:bold;}
17
+ em {font-style:italics;}
18
+ h1,h2,h3,h4,h5,h6 {font-weight:bold;}
19
+ h1 {font-size:197%; margin:30px 0; color:#4b1a1a;}
20
+ h2 {font-size:174%; margin:20px 0; color:#b8111a;}
21
+ h3 {font-size:152%; margin:10px 0;}
22
+ h4 {font-size:129%; margin:10px 0;}
23
+ pre {background:#eee; margin:0 0 20px; padding:20px; border:1px solid #ccc; font-size:100%; overflow:auto;}
24
+ code {font-size:100%; margin:0; padding:0;}
25
+ ul, ol {margin:10px 0 10px 25px;}
26
+ ol li {margin:0 0 10px;}
27
+
28
+
29
+
30
+
31
+
32
+ div#wrapper {background:#fff; width:560px; margin:0 auto; padding:20px; border:10px solid #bc8c46; border-width:0 10px;}
33
+ div#header {position:relative; border-bottom:1px dotted; margin:0 0 10px; padding:0 0 10px;}
34
+ div#header p {margin:0; padding:0;}
35
+ div#header h1 {margin:0; padding:0;}
36
+ ul#nav {position:absolute; top:0; right:0; list-style:none; margin:0; padding:0;}
37
+ ul#nav li {display:inline; padding:0 0 0 5px;}
38
+ ul#nav li a {}
39
+ div#content {}
40
+ div#footer {margin:40px 0 0; border-top:1px dotted; padding:10px 0 0;}
41
+
42
+
43
+
44
+
45
+
46
+
47
+ }
@@ -0,0 +1,74 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5
+ <title>HTTParty by John Nunemaker</title>
6
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
7
+ </head>
8
+ <body>
9
+
10
+ <div id="wrapper">
11
+ <div id="header">
12
+ <h1>HTTParty</h1>
13
+ <p>Tonight we're gonna HTTParty like it's 1999!</p>
14
+
15
+ <ul id="nav">
16
+ <li><a href="rdoc/">Docs</a></li>
17
+ <li><a href="http://github.com/jnunemaker/httparty">Github</a></li>
18
+ <li><a href="http://jnunemaker.lighthouseapp.com/projects/14842-httparty/tickets">Lighthouse</a></li>
19
+ <li><a href="http://rubyforge.org/projects/httparty/">Rubyforge</a></li>
20
+ </ul>
21
+ </div>
22
+
23
+ <div id="content">
24
+ <h2>Install</h2>
25
+ <pre><code>$ sudo gem install httparty</code></pre>
26
+
27
+ <h2>Some Quick Examples</h2>
28
+
29
+ <p>The following is a simple example of wrapping Twitter's API for posting updates.</p>
30
+
31
+ <pre><code>class Twitter
32
+ include HTTParty
33
+ base_uri 'twitter.com'
34
+ basic_auth 'username', 'password'
35
+ end
36
+
37
+ Twitter.post('/statuses/update.json', :query => {:status => "It's an HTTParty and everyone is invited!"})</code></pre>
38
+
39
+ <p>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). </p>
40
+
41
+ <p>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:</p>
42
+
43
+ <pre><code>class Twitter
44
+ include HTTParty
45
+ base_uri 'twitter.com'
46
+
47
+ def initialize(u, p)
48
+ @auth = {:username => u, :password => p}
49
+ end
50
+
51
+ def post(text)
52
+ options = { :query => {:status => text}, :basic_auth => @auth }
53
+ self.class.post('/statuses/update.json', options)
54
+ end
55
+ end
56
+
57
+ Twitter.new('username', 'password').post("It's an HTTParty and everyone is invited!")</code></pre>
58
+
59
+ <p><strong>More Examples:</strong> There are <a href="http://github.com/jnunemaker/httparty/tree/master/examples/">several examples in the gem itself</a>.</p>
60
+
61
+ <h2>Support</h2>
62
+ <p>Conversations welcome in the <a href="http://groups.google.com/group/httparty-gem">google group</a> and bugs/features over at <a href="http://jnunemaker.lighthouseapp.com/projects/14842-httparty/overview">Lightouse</a>.</p>
63
+
64
+
65
+ </div>
66
+
67
+ <div id="footer">
68
+ <p>Created by <a href="http://addictedtonew.com/about/">John Nunemaker</a> |
69
+ <a href="http://orderedlist.com/">Hire Me at Ordered List</a></p>
70
+ </div>
71
+ </div>
72
+
73
+ </body>
74
+ </html>
@@ -0,0 +1,40 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{yyyc514-httparty}
5
+ s.version = "0.4.4.2"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["John Nunemaker"]
9
+ s.date = %q{2009-07-19}
10
+ s.default_executable = %q{httparty}
11
+ s.description = %q{Makes http fun! Also, makes consuming restful web services dead easy.}
12
+ s.email = %q{nunemaker@gmail.com}
13
+ s.executables = ["httparty"]
14
+ s.extra_rdoc_files = ["bin/httparty", "lib/httparty/cookie_hash.rb", "lib/httparty/core_extensions.rb", "lib/httparty/exceptions.rb", "lib/httparty/class_inheritable_attributes.rb", "lib/httparty/request.rb", "lib/httparty/response.rb", "lib/httparty/version.rb", "lib/httparty.rb", "README.rdoc"]
15
+ s.files = ["bin/httparty", "cucumber.yml", "examples/aaws.rb", "examples/basic.rb", "examples/delicious.rb", "examples/google.rb", "examples/rubyurl.rb", "examples/twitter.rb", "examples/whoismyrep.rb", "features/basic_authentication.feature", "features/command_line.feature", "features/deals_with_http_error_codes.feature", "features/handles_multiple_formats.feature", "features/steps/env.rb", "features/steps/httparty_response_steps.rb", "features/steps/httparty_steps.rb", "features/steps/mongrel_helper.rb", "features/steps/remote_service_steps.rb", "features/supports_redirection.feature", "History", "yyyc514-httparty.gemspec", "lib/httparty/cookie_hash.rb", "lib/httparty/core_extensions.rb", "lib/httparty/exceptions.rb", "lib/httparty/class_inheritable_attributes.rb", "lib/httparty/request.rb", "lib/httparty/response.rb", "lib/httparty/version.rb", "lib/httparty.rb", "Manifest", "MIT-LICENSE", "Rakefile", "README.rdoc", "spec/fixtures/delicious.xml", "spec/fixtures/empty.xml", "spec/fixtures/google.html", "spec/fixtures/twitter.json", "spec/fixtures/twitter.xml", "spec/fixtures/undefined_method_add_node_for_nil.xml", "spec/httparty/cookie_hash_spec.rb", "spec/httparty/request_spec.rb", "spec/httparty/response_spec.rb", "spec/httparty_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "website/css/common.css", "website/index.html"]
16
+ s.has_rdoc = true
17
+ s.homepage = %q{http://httparty.rubyforge.org}
18
+ s.post_install_message = %q{When you HTTParty, you must party hard!}
19
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Httparty", "--main", "README.rdoc"]
20
+ s.require_paths = ["lib"]
21
+ s.rubyforge_project = %q{httparty}
22
+ s.rubygems_version = %q{1.3.1}
23
+ s.summary = %q{Makes http fun! Also, makes consuming restful web services dead easy.}
24
+
25
+ if s.respond_to? :specification_version then
26
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
27
+ s.specification_version = 2
28
+
29
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
30
+ s.add_runtime_dependency(%q<crack>, [">= 0.1.1"])
31
+ s.add_development_dependency(%q<echoe>, [">= 0"])
32
+ else
33
+ s.add_dependency(%q<crack>, [">= 0.1.1"])
34
+ s.add_dependency(%q<echoe>, [">= 0"])
35
+ end
36
+ else
37
+ s.add_dependency(%q<crack>, [">= 0.1.1"])
38
+ s.add_dependency(%q<echoe>, [">= 0"])
39
+ end
40
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yyyc514-httparty
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.4.2
5
+ platform: ruby
6
+ authors:
7
+ - John Nunemaker
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-19 00:00:00 -04:00
13
+ default_executable: httparty
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: crack
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.1.1
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: echoe
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ description: Makes http fun! Also, makes consuming restful web services dead easy.
36
+ email: nunemaker@gmail.com
37
+ executables:
38
+ - httparty
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - bin/httparty
43
+ - lib/httparty/cookie_hash.rb
44
+ - lib/httparty/core_extensions.rb
45
+ - lib/httparty/exceptions.rb
46
+ - lib/httparty/class_inheritable_attributes.rb
47
+ - lib/httparty/request.rb
48
+ - lib/httparty/response.rb
49
+ - lib/httparty/version.rb
50
+ - lib/httparty.rb
51
+ - README.rdoc
52
+ files:
53
+ - bin/httparty
54
+ - cucumber.yml
55
+ - examples/aaws.rb
56
+ - examples/basic.rb
57
+ - examples/delicious.rb
58
+ - examples/google.rb
59
+ - examples/rubyurl.rb
60
+ - examples/twitter.rb
61
+ - examples/whoismyrep.rb
62
+ - features/basic_authentication.feature
63
+ - features/command_line.feature
64
+ - features/deals_with_http_error_codes.feature
65
+ - features/handles_multiple_formats.feature
66
+ - features/steps/env.rb
67
+ - features/steps/httparty_response_steps.rb
68
+ - features/steps/httparty_steps.rb
69
+ - features/steps/mongrel_helper.rb
70
+ - features/steps/remote_service_steps.rb
71
+ - features/supports_redirection.feature
72
+ - History
73
+ - yyyc514-httparty.gemspec
74
+ - lib/httparty/cookie_hash.rb
75
+ - lib/httparty/core_extensions.rb
76
+ - lib/httparty/exceptions.rb
77
+ - lib/httparty/class_inheritable_attributes.rb
78
+ - lib/httparty/request.rb
79
+ - lib/httparty/response.rb
80
+ - lib/httparty/version.rb
81
+ - lib/httparty.rb
82
+ - Manifest
83
+ - MIT-LICENSE
84
+ - Rakefile
85
+ - README.rdoc
86
+ - spec/fixtures/delicious.xml
87
+ - spec/fixtures/empty.xml
88
+ - spec/fixtures/google.html
89
+ - spec/fixtures/twitter.json
90
+ - spec/fixtures/twitter.xml
91
+ - spec/fixtures/undefined_method_add_node_for_nil.xml
92
+ - spec/httparty/cookie_hash_spec.rb
93
+ - spec/httparty/request_spec.rb
94
+ - spec/httparty/response_spec.rb
95
+ - spec/httparty_spec.rb
96
+ - spec/spec.opts
97
+ - spec/spec_helper.rb
98
+ - website/css/common.css
99
+ - website/index.html
100
+ has_rdoc: true
101
+ homepage: http://httparty.rubyforge.org
102
+ licenses: []
103
+
104
+ post_install_message: When you HTTParty, you must party hard!
105
+ rdoc_options:
106
+ - --line-numbers
107
+ - --inline-source
108
+ - --title
109
+ - Httparty
110
+ - --main
111
+ - README.rdoc
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: "0"
119
+ version:
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: "1.2"
125
+ version:
126
+ requirements: []
127
+
128
+ rubyforge_project: httparty
129
+ rubygems_version: 1.3.5
130
+ signing_key:
131
+ specification_version: 2
132
+ summary: Makes http fun! Also, makes consuming restful web services dead easy.
133
+ test_files: []
134
+