spreedly 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/Manifest.txt +66 -0
- data/README.txt +68 -0
- data/Rakefile +72 -0
- data/lib/spreedly.rb +154 -0
- data/lib/spreedly/common.rb +24 -0
- data/lib/spreedly/mock.rb +113 -0
- data/lib/spreedly/version.rb +3 -0
- data/test/spreedly_gem_test.rb +152 -0
- data/test/test_site.yml +2 -0
- data/vendor/httparty/History +108 -0
- data/vendor/httparty/MIT-LICENSE +20 -0
- data/vendor/httparty/Manifest +55 -0
- data/vendor/httparty/README +35 -0
- data/vendor/httparty/Rakefile +47 -0
- data/vendor/httparty/bin/httparty +98 -0
- data/vendor/httparty/cucumber.yml +1 -0
- data/vendor/httparty/examples/aaws.rb +32 -0
- data/vendor/httparty/examples/basic.rb +11 -0
- data/vendor/httparty/examples/delicious.rb +37 -0
- data/vendor/httparty/examples/google.rb +16 -0
- data/vendor/httparty/examples/rubyurl.rb +14 -0
- data/vendor/httparty/examples/twitter.rb +31 -0
- data/vendor/httparty/examples/whoismyrep.rb +10 -0
- data/vendor/httparty/features/basic_authentication.feature +20 -0
- data/vendor/httparty/features/command_line.feature +7 -0
- data/vendor/httparty/features/deals_with_http_error_codes.feature +26 -0
- data/vendor/httparty/features/handles_multiple_formats.feature +34 -0
- data/vendor/httparty/features/steps/env.rb +15 -0
- data/vendor/httparty/features/steps/httparty_response_steps.rb +26 -0
- data/vendor/httparty/features/steps/httparty_steps.rb +15 -0
- data/vendor/httparty/features/steps/mongrel_helper.rb +55 -0
- data/vendor/httparty/features/steps/remote_service_steps.rb +47 -0
- data/vendor/httparty/features/supports_redirection.feature +22 -0
- data/vendor/httparty/httparty.gemspec +37 -0
- data/vendor/httparty/lib/core_extensions.rb +189 -0
- data/vendor/httparty/lib/httparty.rb +201 -0
- data/vendor/httparty/lib/httparty/cookie_hash.rb +9 -0
- data/vendor/httparty/lib/httparty/exceptions.rb +7 -0
- data/vendor/httparty/lib/httparty/logging.rb +35 -0
- data/vendor/httparty/lib/httparty/module_inheritable_attributes.rb +25 -0
- data/vendor/httparty/lib/httparty/parsers.rb +4 -0
- data/vendor/httparty/lib/httparty/parsers/json.rb +74 -0
- data/vendor/httparty/lib/httparty/parsers/xml.rb +209 -0
- data/vendor/httparty/lib/httparty/request.rb +169 -0
- data/vendor/httparty/lib/httparty/response.rb +17 -0
- data/vendor/httparty/lib/httparty/version.rb +3 -0
- data/vendor/httparty/setup.rb +1585 -0
- data/vendor/httparty/spec/fixtures/delicious.xml +23 -0
- data/vendor/httparty/spec/fixtures/empty.xml +0 -0
- data/vendor/httparty/spec/fixtures/google.html +3 -0
- data/vendor/httparty/spec/fixtures/twitter.json +1 -0
- data/vendor/httparty/spec/fixtures/twitter.xml +403 -0
- data/vendor/httparty/spec/fixtures/undefined_method_add_node_for_nil.xml +2 -0
- data/vendor/httparty/spec/hash_spec.rb +49 -0
- data/vendor/httparty/spec/httparty/cookie_hash_spec.rb +38 -0
- data/vendor/httparty/spec/httparty/parsers/json_spec.rb +44 -0
- data/vendor/httparty/spec/httparty/parsers/xml_spec.rb +454 -0
- data/vendor/httparty/spec/httparty/request_spec.rb +203 -0
- data/vendor/httparty/spec/httparty/response_spec.rb +53 -0
- data/vendor/httparty/spec/httparty_spec.rb +259 -0
- data/vendor/httparty/spec/spec.opts +3 -0
- data/vendor/httparty/spec/spec_helper.rb +21 -0
- data/vendor/httparty/spec/string_spec.rb +29 -0
- data/vendor/httparty/website/css/common.css +47 -0
- data/vendor/httparty/website/index.html +74 -0
- metadata +141 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'rspec'
|
3
|
+
require 'spec'
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/httparty')
|
5
|
+
|
6
|
+
def file_fixture(filename)
|
7
|
+
open(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,29 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe String, "#snake_case" do
|
4
|
+
it "lowercases one word CamelCase" do
|
5
|
+
"Merb".snake_case.should == "merb"
|
6
|
+
end
|
7
|
+
|
8
|
+
it "makes one underscore snake_case two word CamelCase" do
|
9
|
+
"MerbCore".snake_case.should == "merb_core"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "handles CamelCase with more than 2 words" do
|
13
|
+
"SoYouWantContributeToMerbCore".snake_case.should == "so_you_want_contribute_to_merb_core"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "handles CamelCase with more than 2 capital letter in a row" do
|
17
|
+
"CNN".snake_case.should == "cnn"
|
18
|
+
"CNNNews".snake_case.should == "cnn_news"
|
19
|
+
"HeadlineCNNNews".snake_case.should == "headline_cnn_news"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "does NOT change one word lowercase" do
|
23
|
+
"merb".snake_case.should == "merb"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "leaves snake_case as is" do
|
27
|
+
"merb_core".snake_case.should == "merb_core"
|
28
|
+
end
|
29
|
+
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>
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spreedly
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nathaniel Talbott
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-03-18 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: thoughtbot-shoulda
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: hoe
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.11.0
|
34
|
+
version:
|
35
|
+
description: The Spreedly gem provides a convenient Ruby wrapper for the goodness that is the http://spreedly.com API. Created by Terralien[http://terralien.com].
|
36
|
+
email:
|
37
|
+
- nathaniel@terralien.com
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files:
|
43
|
+
- History.txt
|
44
|
+
- Manifest.txt
|
45
|
+
- README.txt
|
46
|
+
files:
|
47
|
+
- History.txt
|
48
|
+
- Manifest.txt
|
49
|
+
- README.txt
|
50
|
+
- Rakefile
|
51
|
+
- lib/spreedly.rb
|
52
|
+
- lib/spreedly/common.rb
|
53
|
+
- lib/spreedly/mock.rb
|
54
|
+
- lib/spreedly/version.rb
|
55
|
+
- test/spreedly_gem_test.rb
|
56
|
+
- test/test_site.yml
|
57
|
+
- vendor/httparty/History
|
58
|
+
- vendor/httparty/MIT-LICENSE
|
59
|
+
- vendor/httparty/Manifest
|
60
|
+
- vendor/httparty/README
|
61
|
+
- vendor/httparty/Rakefile
|
62
|
+
- vendor/httparty/bin/httparty
|
63
|
+
- vendor/httparty/cucumber.yml
|
64
|
+
- vendor/httparty/examples/aaws.rb
|
65
|
+
- vendor/httparty/examples/basic.rb
|
66
|
+
- vendor/httparty/examples/delicious.rb
|
67
|
+
- vendor/httparty/examples/google.rb
|
68
|
+
- vendor/httparty/examples/rubyurl.rb
|
69
|
+
- vendor/httparty/examples/twitter.rb
|
70
|
+
- vendor/httparty/examples/whoismyrep.rb
|
71
|
+
- vendor/httparty/features/basic_authentication.feature
|
72
|
+
- vendor/httparty/features/command_line.feature
|
73
|
+
- vendor/httparty/features/deals_with_http_error_codes.feature
|
74
|
+
- vendor/httparty/features/handles_multiple_formats.feature
|
75
|
+
- vendor/httparty/features/steps/env.rb
|
76
|
+
- vendor/httparty/features/steps/httparty_response_steps.rb
|
77
|
+
- vendor/httparty/features/steps/httparty_steps.rb
|
78
|
+
- vendor/httparty/features/steps/mongrel_helper.rb
|
79
|
+
- vendor/httparty/features/steps/remote_service_steps.rb
|
80
|
+
- vendor/httparty/features/supports_redirection.feature
|
81
|
+
- vendor/httparty/httparty.gemspec
|
82
|
+
- vendor/httparty/lib/core_extensions.rb
|
83
|
+
- vendor/httparty/lib/httparty.rb
|
84
|
+
- vendor/httparty/lib/httparty/cookie_hash.rb
|
85
|
+
- vendor/httparty/lib/httparty/exceptions.rb
|
86
|
+
- vendor/httparty/lib/httparty/logging.rb
|
87
|
+
- vendor/httparty/lib/httparty/module_inheritable_attributes.rb
|
88
|
+
- vendor/httparty/lib/httparty/parsers.rb
|
89
|
+
- vendor/httparty/lib/httparty/parsers/json.rb
|
90
|
+
- vendor/httparty/lib/httparty/parsers/xml.rb
|
91
|
+
- vendor/httparty/lib/httparty/request.rb
|
92
|
+
- vendor/httparty/lib/httparty/response.rb
|
93
|
+
- vendor/httparty/lib/httparty/version.rb
|
94
|
+
- vendor/httparty/setup.rb
|
95
|
+
- vendor/httparty/spec/fixtures/delicious.xml
|
96
|
+
- vendor/httparty/spec/fixtures/empty.xml
|
97
|
+
- vendor/httparty/spec/fixtures/google.html
|
98
|
+
- vendor/httparty/spec/fixtures/twitter.json
|
99
|
+
- vendor/httparty/spec/fixtures/twitter.xml
|
100
|
+
- vendor/httparty/spec/fixtures/undefined_method_add_node_for_nil.xml
|
101
|
+
- vendor/httparty/spec/hash_spec.rb
|
102
|
+
- vendor/httparty/spec/httparty/cookie_hash_spec.rb
|
103
|
+
- vendor/httparty/spec/httparty/parsers/json_spec.rb
|
104
|
+
- vendor/httparty/spec/httparty/parsers/xml_spec.rb
|
105
|
+
- vendor/httparty/spec/httparty/request_spec.rb
|
106
|
+
- vendor/httparty/spec/httparty/response_spec.rb
|
107
|
+
- vendor/httparty/spec/httparty_spec.rb
|
108
|
+
- vendor/httparty/spec/spec.opts
|
109
|
+
- vendor/httparty/spec/spec_helper.rb
|
110
|
+
- vendor/httparty/spec/string_spec.rb
|
111
|
+
- vendor/httparty/website/css/common.css
|
112
|
+
- vendor/httparty/website/index.html
|
113
|
+
has_rdoc: true
|
114
|
+
homepage: http://terralien.com/static/projects/spreedly-gem/
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options:
|
117
|
+
- --main
|
118
|
+
- README.txt
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: "0"
|
126
|
+
version:
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: "0"
|
132
|
+
version:
|
133
|
+
requirements: []
|
134
|
+
|
135
|
+
rubyforge_project: terralien
|
136
|
+
rubygems_version: 1.3.1
|
137
|
+
signing_key:
|
138
|
+
specification_version: 2
|
139
|
+
summary: The Spreedly gem provides a convenient Ruby wrapper for the goodness that is the http://spreedly.com API
|
140
|
+
test_files:
|
141
|
+
- test/spreedly_gem_test.rb
|