gibbon 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of gibbon might be problematic. Click here for more details.
- data/Gemfile +3 -0
- data/Gemfile.lock +9 -1
- data/Rakefile +6 -3
- data/VERSION +1 -1
- data/gibbon.gemspec +21 -3
- data/lib/gibbon.rb +16 -2
- data/test/helper.rb +1 -0
- data/test/test_gibbon.rb +69 -2
- metadata +74 -8
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
crack (0.1.8)
|
4
5
|
git (1.2.5)
|
5
|
-
|
6
|
+
httparty (0.7.4)
|
7
|
+
crack (= 0.1.8)
|
8
|
+
jeweler (1.5.2)
|
6
9
|
bundler (~> 1.0.0)
|
7
10
|
git (>= 1.2.5)
|
8
11
|
rake
|
12
|
+
json (1.5.1)
|
13
|
+
mocha (0.9.12)
|
9
14
|
rake (0.8.7)
|
10
15
|
rcov (0.9.9)
|
11
16
|
shoulda (2.11.3)
|
@@ -15,6 +20,9 @@ PLATFORMS
|
|
15
20
|
|
16
21
|
DEPENDENCIES
|
17
22
|
bundler (~> 1.0.0)
|
23
|
+
httparty (> 0.6.0)
|
18
24
|
jeweler (~> 1.5.1)
|
25
|
+
json (> 1.4.0)
|
26
|
+
mocha (> 0.9.11)
|
19
27
|
rcov
|
20
28
|
shoulda
|
data/Rakefile
CHANGED
@@ -21,9 +21,12 @@ Jeweler::Tasks.new do |gem|
|
|
21
21
|
gem.authors = ["Amro Mousa"]
|
22
22
|
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
23
|
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
gem.add_runtime_dependency 'httparty', '> 0.6.0'
|
25
|
+
gem.add_runtime_dependency 'json', '> 1.4.0'
|
26
|
+
gem.add_development_dependency 'httparty', '> 0.6.0'
|
27
|
+
gem.add_development_dependency 'json', '> 1.4.0'
|
28
|
+
gem.add_development_dependency 'mocha', '> 0.9.11'
|
29
|
+
#gem.add_development_dependency 'rspec', '> 1.2.3'
|
27
30
|
end
|
28
31
|
Jeweler::RubygemsDotOrgTasks.new
|
29
32
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
data/gibbon.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{gibbon}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Amro Mousa"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-04-05}
|
13
13
|
s.description = %q{Gibbon is a simple API wrapper for interacting with MailChimp API version 1.3.}
|
14
14
|
s.email = %q{amromousa@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
|
|
32
32
|
s.homepage = %q{http://github.com/amro/gibbon}
|
33
33
|
s.licenses = ["MIT"]
|
34
34
|
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = %q{1.
|
35
|
+
s.rubygems_version = %q{1.6.2}
|
36
36
|
s.summary = %q{Gibbon is a simple API wrapper for interacting with MailChimp API 1.3}
|
37
37
|
s.test_files = [
|
38
38
|
"test/helper.rb",
|
@@ -47,23 +47,41 @@ Gem::Specification.new do |s|
|
|
47
47
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
48
48
|
s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
|
49
49
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
50
|
+
s.add_development_dependency(%q<json>, ["> 1.4.0"])
|
51
|
+
s.add_development_dependency(%q<httparty>, ["> 0.6.0"])
|
52
|
+
s.add_development_dependency(%q<mocha>, ["> 0.9.11"])
|
50
53
|
s.add_runtime_dependency(%q<httparty>, ["> 0.6.0"])
|
51
54
|
s.add_runtime_dependency(%q<json>, ["> 1.4.0"])
|
55
|
+
s.add_development_dependency(%q<httparty>, ["> 0.6.0"])
|
56
|
+
s.add_development_dependency(%q<json>, ["> 1.4.0"])
|
57
|
+
s.add_development_dependency(%q<mocha>, ["> 0.9.11"])
|
52
58
|
else
|
53
59
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
54
60
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
55
61
|
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
56
62
|
s.add_dependency(%q<rcov>, [">= 0"])
|
63
|
+
s.add_dependency(%q<json>, ["> 1.4.0"])
|
64
|
+
s.add_dependency(%q<httparty>, ["> 0.6.0"])
|
65
|
+
s.add_dependency(%q<mocha>, ["> 0.9.11"])
|
66
|
+
s.add_dependency(%q<httparty>, ["> 0.6.0"])
|
67
|
+
s.add_dependency(%q<json>, ["> 1.4.0"])
|
57
68
|
s.add_dependency(%q<httparty>, ["> 0.6.0"])
|
58
69
|
s.add_dependency(%q<json>, ["> 1.4.0"])
|
70
|
+
s.add_dependency(%q<mocha>, ["> 0.9.11"])
|
59
71
|
end
|
60
72
|
else
|
61
73
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
62
74
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
63
75
|
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
64
76
|
s.add_dependency(%q<rcov>, [">= 0"])
|
77
|
+
s.add_dependency(%q<json>, ["> 1.4.0"])
|
78
|
+
s.add_dependency(%q<httparty>, ["> 0.6.0"])
|
79
|
+
s.add_dependency(%q<mocha>, ["> 0.9.11"])
|
80
|
+
s.add_dependency(%q<httparty>, ["> 0.6.0"])
|
81
|
+
s.add_dependency(%q<json>, ["> 1.4.0"])
|
65
82
|
s.add_dependency(%q<httparty>, ["> 0.6.0"])
|
66
83
|
s.add_dependency(%q<json>, ["> 1.4.0"])
|
84
|
+
s.add_dependency(%q<mocha>, ["> 0.9.11"])
|
67
85
|
end
|
68
86
|
end
|
69
87
|
|
data/lib/gibbon.rb
CHANGED
@@ -26,8 +26,7 @@ module Gibbon
|
|
26
26
|
|
27
27
|
def call(method, params = {})
|
28
28
|
url = base_api_url + method
|
29
|
-
params = @default_params.merge(params)
|
30
|
-
params.each_pair {|k,v| params[k] = CGI::escape(v) if v.class == String}
|
29
|
+
params = escape_params(@default_params.merge(params))
|
31
30
|
response = API.post(url, :body => params.to_json, :timeout => @timeout)
|
32
31
|
|
33
32
|
begin
|
@@ -45,5 +44,20 @@ module Gibbon
|
|
45
44
|
args = args[0] if (args.class.to_s == "Array")
|
46
45
|
call(method, args)
|
47
46
|
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def escape_params(param)
|
51
|
+
case param
|
52
|
+
when String
|
53
|
+
CGI::escape(param)
|
54
|
+
when Array
|
55
|
+
param.collect{|v| escape_params(v)}
|
56
|
+
when Hash
|
57
|
+
param.keys.inject({}) {|r,k| r[escape_params(k)] = escape_params(param[k]) ;r}
|
58
|
+
else
|
59
|
+
param
|
60
|
+
end
|
61
|
+
end
|
48
62
|
end
|
49
63
|
end
|
data/test/helper.rb
CHANGED
data/test/test_gibbon.rb
CHANGED
@@ -1,7 +1,74 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestGibbon < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
4
|
+
|
5
|
+
context "build api url" do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@gibbon = Gibbon::API.new
|
9
|
+
end
|
10
|
+
|
11
|
+
should "handle empty api key" do
|
12
|
+
expect_post("https://api.mailchimp.com/1.3/?method=sayHello", {"apikey" => nil})
|
13
|
+
|
14
|
+
@gibbon.say_hello
|
15
|
+
end
|
16
|
+
|
17
|
+
should "handle timeout" do
|
18
|
+
expect_post("https://api.mailchimp.com/1.3/?method=sayHello", {"apikey" => nil}, 120)
|
19
|
+
@gibbon.timeout=120
|
20
|
+
@gibbon.say_hello
|
21
|
+
end
|
22
|
+
|
23
|
+
should "handle api key with dc" do
|
24
|
+
@gibbon.apikey="TESTKEY-us1"
|
25
|
+
expect_post("https://us1.api.mailchimp.com/1.3/?method=sayHello", {"apikey" => "TESTKEY-us1"})
|
26
|
+
|
27
|
+
@gibbon.say_hello
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "build api body" do
|
32
|
+
setup do
|
33
|
+
@key = "TESTKEY-us1"
|
34
|
+
@gibbon = Gibbon::API.new(@key)
|
35
|
+
@url = "https://us1.api.mailchimp.com/1.3/?method=sayHello"
|
36
|
+
end
|
37
|
+
|
38
|
+
should "escape string parameters" do
|
39
|
+
expect_post(@url, {"apikey" => @key, "message" => "simon+says"})
|
40
|
+
@gibbon.say_hello(:message => "simon says")
|
41
|
+
end
|
42
|
+
|
43
|
+
should "escape string parameters in an array" do
|
44
|
+
expect_post(@url, {"apikey" => @key, "messages" => ["simon+says", "do+this"]})
|
45
|
+
@gibbon.say_hello(:messages => ["simon says", "do this"])
|
46
|
+
end
|
47
|
+
|
48
|
+
should "escape string parameters in a hash" do
|
49
|
+
expect_post(@url, {"apikey" => @key, "messages" => {"simon+says" => "do+this"}})
|
50
|
+
@gibbon.say_hello(:messages => {"simon says" => "do this"})
|
51
|
+
end
|
52
|
+
|
53
|
+
should "escape nested string parameters" do
|
54
|
+
expect_post(@url, {"apikey" => @key, "messages" => {"simon+says" => ["do+this", "and+this"]}})
|
55
|
+
@gibbon.say_hello(:messages => {"simon says" => ["do this", "and this"]})
|
56
|
+
end
|
57
|
+
|
58
|
+
should "pass through non string parameters" do
|
59
|
+
expect_post(@url, {"apikey" => @key, "fee" => 99})
|
60
|
+
@gibbon.say_hello(:fee => 99)
|
61
|
+
end
|
62
|
+
|
6
63
|
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def expect_post(expected_url, expected_body, expected_timeout=nil)
|
68
|
+
Gibbon::API.expects(:post).with do |url, opts|
|
69
|
+
url == expected_url &&
|
70
|
+
JSON.parse(opts[:body]) == expected_body &&
|
71
|
+
opts[:timeout] == expected_timeout
|
72
|
+
end.returns(Struct.new(:body).new("") )
|
73
|
+
end
|
7
74
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: gibbon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Amro Mousa
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-04-05 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -58,8 +58,41 @@ dependencies:
|
|
58
58
|
prerelease: false
|
59
59
|
version_requirements: *id004
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
|
-
name:
|
61
|
+
name: json
|
62
62
|
requirement: &id005 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 1.4.0
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: *id005
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: httparty
|
73
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 0.6.0
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: *id006
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: mocha
|
84
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ">"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.9.11
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: *id007
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: httparty
|
95
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
63
96
|
none: false
|
64
97
|
requirements:
|
65
98
|
- - ">"
|
@@ -67,10 +100,10 @@ dependencies:
|
|
67
100
|
version: 0.6.0
|
68
101
|
type: :runtime
|
69
102
|
prerelease: false
|
70
|
-
version_requirements: *
|
103
|
+
version_requirements: *id008
|
71
104
|
- !ruby/object:Gem::Dependency
|
72
105
|
name: json
|
73
|
-
requirement: &
|
106
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
74
107
|
none: false
|
75
108
|
requirements:
|
76
109
|
- - ">"
|
@@ -78,7 +111,40 @@ dependencies:
|
|
78
111
|
version: 1.4.0
|
79
112
|
type: :runtime
|
80
113
|
prerelease: false
|
81
|
-
version_requirements: *
|
114
|
+
version_requirements: *id009
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: httparty
|
117
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ">"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 0.6.0
|
123
|
+
type: :development
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: *id010
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: json
|
128
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ">"
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 1.4.0
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: *id011
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: mocha
|
139
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
141
|
+
requirements:
|
142
|
+
- - ">"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 0.9.11
|
145
|
+
type: :development
|
146
|
+
prerelease: false
|
147
|
+
version_requirements: *id012
|
82
148
|
description: Gibbon is a simple API wrapper for interacting with MailChimp API version 1.3.
|
83
149
|
email: amromousa@gmail.com
|
84
150
|
executables: []
|
@@ -114,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
180
|
requirements:
|
115
181
|
- - ">="
|
116
182
|
- !ruby/object:Gem::Version
|
117
|
-
hash:
|
183
|
+
hash: 2466538827739644299
|
118
184
|
segments:
|
119
185
|
- 0
|
120
186
|
version: "0"
|
@@ -127,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
193
|
requirements: []
|
128
194
|
|
129
195
|
rubyforge_project:
|
130
|
-
rubygems_version: 1.
|
196
|
+
rubygems_version: 1.6.2
|
131
197
|
signing_key:
|
132
198
|
specification_version: 3
|
133
199
|
summary: Gibbon is a simple API wrapper for interacting with MailChimp API 1.3
|