gibbon 0.1.5 → 0.1.6
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/README.markdown +10 -0
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/gibbon.gemspec +5 -2
- data/lib/gibbon.rb +20 -33
- metadata +22 -11
data/README.markdown
CHANGED
@@ -55,8 +55,18 @@ Gibbon defaults to a 30 second timeout. You can optionally set your own timeout
|
|
55
55
|
|
56
56
|
gb.timeout = 5
|
57
57
|
|
58
|
+
### Notes
|
59
|
+
|
60
|
+
As of 0.1.6, gibbon uses ActiveSupport::JSON.decode(). This means code that checked for weird API responses (like "true"
|
61
|
+
on a successful call to "listSubscribe" or similar) will need to be tweaked to handle the boolean JSON.decode() returns
|
62
|
+
as opposed to the string the MailChimp API returns. I understand the extra dependency might be a pain for some.
|
63
|
+
|
58
64
|
##Thanks
|
59
65
|
|
66
|
+
* [Justin Ip](https://github.com/ippy04)
|
67
|
+
* [elshimone](https://github.com/elshimone)
|
68
|
+
* [jlxw](https://github.com/jlxw)
|
69
|
+
|
60
70
|
* Rails for camelize gsub
|
61
71
|
|
62
72
|
##Copyrights
|
data/Rakefile
CHANGED
@@ -22,6 +22,7 @@ Jeweler::Tasks.new do |gem|
|
|
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
24
|
gem.add_runtime_dependency 'httparty', '> 0.6.0'
|
25
|
+
gem.add_runtime_dependency 'activesupport', '> 3.0.0'
|
25
26
|
gem.add_runtime_dependency 'json', '> 1.4.0'
|
26
27
|
gem.add_development_dependency 'httparty', '> 0.6.0'
|
27
28
|
gem.add_development_dependency 'json', '> 1.4.0'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.6
|
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.6"
|
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-06-02}
|
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 = [
|
@@ -51,6 +51,7 @@ Gem::Specification.new do |s|
|
|
51
51
|
s.add_development_dependency(%q<httparty>, ["> 0.6.0"])
|
52
52
|
s.add_development_dependency(%q<mocha>, ["> 0.9.11"])
|
53
53
|
s.add_runtime_dependency(%q<httparty>, ["> 0.6.0"])
|
54
|
+
s.add_runtime_dependency(%q<activesupport>, ["> 3.0.0"])
|
54
55
|
s.add_runtime_dependency(%q<json>, ["> 1.4.0"])
|
55
56
|
s.add_development_dependency(%q<httparty>, ["> 0.6.0"])
|
56
57
|
s.add_development_dependency(%q<json>, ["> 1.4.0"])
|
@@ -64,6 +65,7 @@ Gem::Specification.new do |s|
|
|
64
65
|
s.add_dependency(%q<httparty>, ["> 0.6.0"])
|
65
66
|
s.add_dependency(%q<mocha>, ["> 0.9.11"])
|
66
67
|
s.add_dependency(%q<httparty>, ["> 0.6.0"])
|
68
|
+
s.add_dependency(%q<activesupport>, ["> 3.0.0"])
|
67
69
|
s.add_dependency(%q<json>, ["> 1.4.0"])
|
68
70
|
s.add_dependency(%q<httparty>, ["> 0.6.0"])
|
69
71
|
s.add_dependency(%q<json>, ["> 1.4.0"])
|
@@ -78,6 +80,7 @@ Gem::Specification.new do |s|
|
|
78
80
|
s.add_dependency(%q<httparty>, ["> 0.6.0"])
|
79
81
|
s.add_dependency(%q<mocha>, ["> 0.9.11"])
|
80
82
|
s.add_dependency(%q<httparty>, ["> 0.6.0"])
|
83
|
+
s.add_dependency(%q<activesupport>, ["> 3.0.0"])
|
81
84
|
s.add_dependency(%q<json>, ["> 1.4.0"])
|
82
85
|
s.add_dependency(%q<httparty>, ["> 0.6.0"])
|
83
86
|
s.add_dependency(%q<json>, ["> 1.4.0"])
|
data/lib/gibbon.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'active_support'
|
1
2
|
require 'httparty'
|
2
3
|
require 'json'
|
3
4
|
require 'cgi'
|
@@ -24,40 +25,26 @@ module Gibbon
|
|
24
25
|
"https://#{dc}api.mailchimp.com/1.3/?method="
|
25
26
|
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
begin
|
33
|
-
response = JSON.parse(response.body)
|
34
|
-
rescue
|
35
|
-
response = response.body
|
36
|
-
end
|
37
|
-
response
|
38
|
-
end
|
28
|
+
def call(method, params = {})
|
29
|
+
url = base_api_url + method
|
30
|
+
params = @default_params.merge(params)
|
31
|
+
response = Gibbon::API.post(url, :body => CGI::escape(params.to_json), :timeout => @timeout)
|
39
32
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
args = args[0] if (args.class.to_s == "Array")
|
45
|
-
call(method, args)
|
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
|
33
|
+
begin
|
34
|
+
response = ActiveSupport::JSON.decode(response.body)
|
35
|
+
rescue
|
36
|
+
response = response.body
|
61
37
|
end
|
38
|
+
response
|
39
|
+
end
|
40
|
+
|
41
|
+
def method_missing(method, *args)
|
42
|
+
method = method.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } #Thanks for the gsub, Rails
|
43
|
+
method = method[0].chr.downcase + method[1..-1].gsub(/aim$/i, 'AIM')
|
44
|
+
args = {} unless args.length > 0
|
45
|
+
args = args[0] if (args.class.to_s == "Array")
|
46
|
+
call(method, args)
|
47
|
+
end
|
48
|
+
|
62
49
|
end
|
63
50
|
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.6
|
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-06-02 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -102,19 +102,30 @@ dependencies:
|
|
102
102
|
prerelease: false
|
103
103
|
version_requirements: *id008
|
104
104
|
- !ruby/object:Gem::Dependency
|
105
|
-
name:
|
105
|
+
name: activesupport
|
106
106
|
requirement: &id009 !ruby/object:Gem::Requirement
|
107
107
|
none: false
|
108
108
|
requirements:
|
109
109
|
- - ">"
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version:
|
111
|
+
version: 3.0.0
|
112
112
|
type: :runtime
|
113
113
|
prerelease: false
|
114
114
|
version_requirements: *id009
|
115
115
|
- !ruby/object:Gem::Dependency
|
116
|
-
name:
|
116
|
+
name: json
|
117
117
|
requirement: &id010 !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ">"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 1.4.0
|
123
|
+
type: :runtime
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: *id010
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: httparty
|
128
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
118
129
|
none: false
|
119
130
|
requirements:
|
120
131
|
- - ">"
|
@@ -122,10 +133,10 @@ dependencies:
|
|
122
133
|
version: 0.6.0
|
123
134
|
type: :development
|
124
135
|
prerelease: false
|
125
|
-
version_requirements: *
|
136
|
+
version_requirements: *id011
|
126
137
|
- !ruby/object:Gem::Dependency
|
127
138
|
name: json
|
128
|
-
requirement: &
|
139
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
129
140
|
none: false
|
130
141
|
requirements:
|
131
142
|
- - ">"
|
@@ -133,10 +144,10 @@ dependencies:
|
|
133
144
|
version: 1.4.0
|
134
145
|
type: :development
|
135
146
|
prerelease: false
|
136
|
-
version_requirements: *
|
147
|
+
version_requirements: *id012
|
137
148
|
- !ruby/object:Gem::Dependency
|
138
149
|
name: mocha
|
139
|
-
requirement: &
|
150
|
+
requirement: &id013 !ruby/object:Gem::Requirement
|
140
151
|
none: false
|
141
152
|
requirements:
|
142
153
|
- - ">"
|
@@ -144,7 +155,7 @@ dependencies:
|
|
144
155
|
version: 0.9.11
|
145
156
|
type: :development
|
146
157
|
prerelease: false
|
147
|
-
version_requirements: *
|
158
|
+
version_requirements: *id013
|
148
159
|
description: Gibbon is a simple API wrapper for interacting with MailChimp API version 1.3.
|
149
160
|
email: amromousa@gmail.com
|
150
161
|
executables: []
|
@@ -180,7 +191,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
180
191
|
requirements:
|
181
192
|
- - ">="
|
182
193
|
- !ruby/object:Gem::Version
|
183
|
-
hash:
|
194
|
+
hash: -4187933229700536350
|
184
195
|
segments:
|
185
196
|
- 0
|
186
197
|
version: "0"
|