luigi-httparty 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/.gitignore +6 -0
  2. data/History +141 -0
  3. data/MIT-LICENSE +20 -0
  4. data/Manifest +47 -0
  5. data/README.rdoc +54 -0
  6. data/Rakefile +71 -0
  7. data/VERSION +1 -0
  8. data/bin/httparty +98 -0
  9. data/cucumber.yml +1 -0
  10. data/examples/aaws.rb +32 -0
  11. data/examples/basic.rb +11 -0
  12. data/examples/delicious.rb +37 -0
  13. data/examples/google.rb +16 -0
  14. data/examples/rubyurl.rb +14 -0
  15. data/examples/twitter.rb +31 -0
  16. data/examples/whoismyrep.rb +10 -0
  17. data/features/basic_authentication.feature +20 -0
  18. data/features/command_line.feature +7 -0
  19. data/features/deals_with_http_error_codes.feature +26 -0
  20. data/features/handles_multiple_formats.feature +34 -0
  21. data/features/steps/env.rb +16 -0
  22. data/features/steps/httparty_response_steps.rb +26 -0
  23. data/features/steps/httparty_steps.rb +19 -0
  24. data/features/steps/mongrel_helper.rb +56 -0
  25. data/features/steps/remote_service_steps.rb +52 -0
  26. data/features/supports_redirection.feature +22 -0
  27. data/features/supports_timeout_option.feature +12 -0
  28. data/httparty.gemspec +110 -0
  29. data/lib/httparty.rb +216 -0
  30. data/lib/httparty/cookie_hash.rb +22 -0
  31. data/lib/httparty/core_extensions.rb +25 -0
  32. data/lib/httparty/exceptions.rb +7 -0
  33. data/lib/httparty/module_inheritable_attributes.rb +25 -0
  34. data/lib/httparty/parsers.rb +31 -0
  35. data/lib/httparty/request.rb +175 -0
  36. data/lib/httparty/response.rb +23 -0
  37. data/lib/httparty/version.rb +3 -0
  38. data/spec/fixtures/delicious.xml +23 -0
  39. data/spec/fixtures/empty.xml +0 -0
  40. data/spec/fixtures/google.html +3 -0
  41. data/spec/fixtures/twitter.json +1 -0
  42. data/spec/fixtures/twitter.xml +403 -0
  43. data/spec/fixtures/undefined_method_add_node_for_nil.xml +2 -0
  44. data/spec/httparty/cookie_hash_spec.rb +71 -0
  45. data/spec/httparty/request_spec.rb +244 -0
  46. data/spec/httparty/response_spec.rb +68 -0
  47. data/spec/httparty_spec.rb +328 -0
  48. data/spec/spec.opts +2 -0
  49. data/spec/spec_helper.rb +24 -0
  50. data/website/css/common.css +47 -0
  51. data/website/index.html +73 -0
  52. metadata +136 -0
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format specdoc
@@ -0,0 +1,24 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'httparty')
2
+ gem 'rspec', '1.2.8'
3
+ gem 'fakeweb'
4
+ require 'spec/autorun'
5
+ require 'fakeweb'
6
+
7
+ FakeWeb.allow_net_connect = false
8
+
9
+ def file_fixture(filename)
10
+ open(File.join(File.dirname(__FILE__), 'fixtures', "#{filename.to_s}")).read
11
+ end
12
+
13
+ def stub_http_response_with(filename)
14
+ format = filename.split('.').last.intern
15
+ data = file_fixture(filename)
16
+
17
+ response = Net::HTTPOK.new("1.1", 200, "Content for you")
18
+ response.stub!(:body).and_return(data)
19
+
20
+ http_request = HTTParty::Request.new(Net::HTTP::Get, 'http://localhost', :format => format)
21
+ http_request.stub!(:perform_actual_request).and_return(response)
22
+
23
+ HTTParty::Request.should_receive(:new).and_return(http_request)
24
+ 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,73 @@
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://rubyforge.org/projects/httparty/">Rubyforge</a></li>
19
+ </ul>
20
+ </div>
21
+
22
+ <div id="content">
23
+ <h2>Install</h2>
24
+ <pre><code>$ sudo gem install httparty</code></pre>
25
+
26
+ <h2>Some Quick Examples</h2>
27
+
28
+ <p>The following is a simple example of wrapping Twitter's API for posting updates.</p>
29
+
30
+ <pre><code>class Twitter
31
+ include HTTParty
32
+ base_uri 'twitter.com'
33
+ basic_auth 'username', 'password'
34
+ end
35
+
36
+ Twitter.post('/statuses/update.json', :query => {:status => "It's an HTTParty and everyone is invited!"})</code></pre>
37
+
38
+ <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>
39
+
40
+ <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>
41
+
42
+ <pre><code>class Twitter
43
+ include HTTParty
44
+ base_uri 'twitter.com'
45
+
46
+ def initialize(u, p)
47
+ @auth = {:username => u, :password => p}
48
+ end
49
+
50
+ def post(text)
51
+ options = { :query => {:status => text}, :basic_auth => @auth }
52
+ self.class.post('/statuses/update.json', options)
53
+ end
54
+ end
55
+
56
+ Twitter.new('username', 'password').post("It's an HTTParty and everyone is invited!")</code></pre>
57
+
58
+ <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>
59
+
60
+ <h2>Support</h2>
61
+ <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://github.com/jnunemaker/httparty">Github</a>.</p>
62
+
63
+
64
+ </div>
65
+
66
+ <div id="footer">
67
+ <p>Created by <a href="http://addictedtonew.com/about/">John Nunemaker</a> |
68
+ <a href="http://orderedlist.com/">Hire Me at Ordered List</a></p>
69
+ </div>
70
+ </div>
71
+
72
+ </body>
73
+ </html>
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: luigi-httparty
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.6
5
+ platform: ruby
6
+ authors:
7
+ - John Nunemaker
8
+ - Sandro Turriate
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-10-29 00:00:00 -04:00
14
+ default_executable: httparty
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: crack
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 0.1.1
25
+ version:
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ type: :development
29
+ version_requirement:
30
+ version_requirements: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "="
33
+ - !ruby/object:Gem::Version
34
+ version: 1.2.8
35
+ version:
36
+ description: Makes http fun! Also, makes consuming restful web services dead easy.
37
+ email: nunemaker@gmail.com
38
+ executables:
39
+ - httparty
40
+ extensions: []
41
+
42
+ extra_rdoc_files:
43
+ - README.rdoc
44
+ files:
45
+ - .gitignore
46
+ - History
47
+ - MIT-LICENSE
48
+ - Manifest
49
+ - README.rdoc
50
+ - Rakefile
51
+ - VERSION
52
+ - bin/httparty
53
+ - cucumber.yml
54
+ - examples/aaws.rb
55
+ - examples/basic.rb
56
+ - examples/delicious.rb
57
+ - examples/google.rb
58
+ - examples/rubyurl.rb
59
+ - examples/twitter.rb
60
+ - examples/whoismyrep.rb
61
+ - features/basic_authentication.feature
62
+ - features/command_line.feature
63
+ - features/deals_with_http_error_codes.feature
64
+ - features/handles_multiple_formats.feature
65
+ - features/steps/env.rb
66
+ - features/steps/httparty_response_steps.rb
67
+ - features/steps/httparty_steps.rb
68
+ - features/steps/mongrel_helper.rb
69
+ - features/steps/remote_service_steps.rb
70
+ - features/supports_redirection.feature
71
+ - features/supports_timeout_option.feature
72
+ - httparty.gemspec
73
+ - lib/httparty.rb
74
+ - lib/httparty/cookie_hash.rb
75
+ - lib/httparty/core_extensions.rb
76
+ - lib/httparty/exceptions.rb
77
+ - lib/httparty/module_inheritable_attributes.rb
78
+ - lib/httparty/parsers.rb
79
+ - lib/httparty/request.rb
80
+ - lib/httparty/response.rb
81
+ - lib/httparty/version.rb
82
+ - spec/fixtures/delicious.xml
83
+ - spec/fixtures/empty.xml
84
+ - spec/fixtures/google.html
85
+ - spec/fixtures/twitter.json
86
+ - spec/fixtures/twitter.xml
87
+ - spec/fixtures/undefined_method_add_node_for_nil.xml
88
+ - spec/httparty/cookie_hash_spec.rb
89
+ - spec/httparty/request_spec.rb
90
+ - spec/httparty/response_spec.rb
91
+ - spec/httparty_spec.rb
92
+ - spec/spec.opts
93
+ - spec/spec_helper.rb
94
+ - website/css/common.css
95
+ - website/index.html
96
+ has_rdoc: true
97
+ homepage: http://httparty.rubyforge.org
98
+ licenses: []
99
+
100
+ post_install_message: When you HTTParty, you must party hard!
101
+ rdoc_options:
102
+ - --charset=UTF-8
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: "0"
110
+ version:
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: "0"
116
+ version:
117
+ requirements: []
118
+
119
+ rubyforge_project: httparty
120
+ rubygems_version: 1.3.5
121
+ signing_key:
122
+ specification_version: 3
123
+ summary: Makes http fun! Also, makes consuming restful web services dead easy.
124
+ test_files:
125
+ - spec/httparty/cookie_hash_spec.rb
126
+ - spec/httparty/request_spec.rb
127
+ - spec/httparty/response_spec.rb
128
+ - spec/httparty_spec.rb
129
+ - spec/spec_helper.rb
130
+ - examples/aaws.rb
131
+ - examples/basic.rb
132
+ - examples/delicious.rb
133
+ - examples/google.rb
134
+ - examples/rubyurl.rb
135
+ - examples/twitter.rb
136
+ - examples/whoismyrep.rb