gibbon 0.1.7 → 0.2.0
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.lock +5 -3
- data/README.markdown +15 -3
- data/VERSION +1 -1
- data/gibbon.gemspec +6 -6
- data/lib/gibbon.rb +24 -19
- metadata +110 -116
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (3.0
|
4
|
+
activesupport (3.1.0)
|
5
|
+
multi_json (~> 1.0)
|
5
6
|
crack (0.1.8)
|
6
7
|
git (1.2.5)
|
7
8
|
httparty (0.7.8)
|
@@ -10,10 +11,11 @@ GEM
|
|
10
11
|
bundler (~> 1.0.0)
|
11
12
|
git (>= 1.2.5)
|
12
13
|
rake
|
13
|
-
json (1.5.
|
14
|
+
json (1.5.4)
|
14
15
|
mocha (0.9.12)
|
16
|
+
multi_json (1.0.3)
|
15
17
|
rake (0.9.2)
|
16
|
-
rcov (0.9.
|
18
|
+
rcov (0.9.10)
|
17
19
|
shoulda (2.11.3)
|
18
20
|
|
19
21
|
PLATFORMS
|
data/README.markdown
CHANGED
@@ -12,12 +12,23 @@ A MailChimp account and API key. You can see your API keys [here](http://admin.m
|
|
12
12
|
|
13
13
|
##Usage
|
14
14
|
|
15
|
-
|
15
|
+
There are a few ways to use Gibbon:
|
16
16
|
|
17
|
-
|
17
|
+
You can create an instance of the API wrapper:
|
18
|
+
|
19
|
+
gb = Gibbon.new("your_api_key")
|
20
|
+
|
21
|
+
You can set your api_key globally and call class methods:
|
22
|
+
|
23
|
+
Gibbon.api_key = "your_api_key"
|
24
|
+
Gibbon.lists
|
25
|
+
|
26
|
+
You can also set the environment variable 'MC_API_KEY' and Gibbon will use it when you create an instance:
|
27
|
+
|
28
|
+
u = Gibbon.new
|
18
29
|
|
19
30
|
Fetching data is as simple as calling API methods directly on the wrapper object.
|
20
|
-
Check the API [documentation](http://
|
31
|
+
Check the API [documentation](http://apidocs.mailchimp.com/api/1.3/) for details.
|
21
32
|
|
22
33
|
### Fetching Campaigns
|
23
34
|
|
@@ -67,6 +78,7 @@ as opposed to the string the MailChimp API returns. I understand the extra depen
|
|
67
78
|
* [elshimone](https://github.com/elshimone)
|
68
79
|
* [jlxw](https://github.com/jlxw)
|
69
80
|
* [Jon McCartie](https://github.com/jmccartie)
|
81
|
+
* [Calvin Yu](https://github.com/cyu)
|
70
82
|
* Rails for camelize gsub
|
71
83
|
|
72
84
|
##Copyrights
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
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.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date = %q{2011-
|
11
|
+
s.authors = [%q{Amro Mousa}]
|
12
|
+
s.date = %q{2011-09-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 = [
|
@@ -30,9 +30,9 @@ Gem::Specification.new do |s|
|
|
30
30
|
"test/test_gibbon.rb"
|
31
31
|
]
|
32
32
|
s.homepage = %q{http://github.com/amro/gibbon}
|
33
|
-
s.licenses = [
|
34
|
-
s.require_paths = [
|
35
|
-
s.rubygems_version = %q{1.
|
33
|
+
s.licenses = [%q{MIT}]
|
34
|
+
s.require_paths = [%q{lib}]
|
35
|
+
s.rubygems_version = %q{1.8.9}
|
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",
|
data/lib/gibbon.rb
CHANGED
@@ -3,33 +3,32 @@ require 'httparty'
|
|
3
3
|
require 'json'
|
4
4
|
require 'cgi'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
default_timeout 30
|
6
|
+
class Gibbon
|
7
|
+
include HTTParty
|
8
|
+
format :plain
|
9
|
+
default_timeout 30
|
11
10
|
|
12
|
-
|
11
|
+
attr_accessor :api_key, :timeout
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
def initialize(api_key = nil, extra_params = {})
|
14
|
+
@api_key = api_key || ENV['MC_API_KEY'] || self.class.api_key
|
15
|
+
@default_params = {:apikey => @api_key}.merge(extra_params)
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
def api_key=(value)
|
19
|
+
@api_key = value
|
20
|
+
@default_params = @default_params.merge({:apikey => @api_key})
|
21
|
+
end
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
def base_api_url
|
24
|
+
dc = @api_key.blank? ? '' : "#{@api_key.split("-").last}."
|
25
|
+
"https://#{dc}api.mailchimp.com/1.3/?method="
|
26
|
+
end
|
28
27
|
|
29
28
|
def call(method, params = {})
|
30
29
|
url = base_api_url + method
|
31
30
|
params = @default_params.merge(params)
|
32
|
-
response =
|
31
|
+
response = self.class.post(url, :body => CGI::escape(params.to_json), :timeout => @timeout)
|
33
32
|
|
34
33
|
begin
|
35
34
|
response = ActiveSupport::JSON.decode(response.body)
|
@@ -47,5 +46,11 @@ module Gibbon
|
|
47
46
|
call(method, args)
|
48
47
|
end
|
49
48
|
|
49
|
+
class << self
|
50
|
+
attr_accessor :api_key
|
51
|
+
|
52
|
+
def method_missing(sym, *args, &block)
|
53
|
+
new(self.api_key).send(sym, *args, &block)
|
54
|
+
end
|
50
55
|
end
|
51
56
|
end
|
metadata
CHANGED
@@ -1,182 +1,179 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: gibbon
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
4
5
|
prerelease:
|
5
|
-
version: 0.1.7
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Amro Mousa
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-09-02 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
17
15
|
name: shoulda
|
18
|
-
requirement: &
|
16
|
+
requirement: &70152611695940 !ruby/object:Gem::Requirement
|
19
17
|
none: false
|
20
|
-
requirements:
|
21
|
-
- -
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version:
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
24
22
|
type: :development
|
25
23
|
prerelease: false
|
26
|
-
version_requirements: *
|
27
|
-
- !ruby/object:Gem::Dependency
|
24
|
+
version_requirements: *70152611695940
|
25
|
+
- !ruby/object:Gem::Dependency
|
28
26
|
name: bundler
|
29
|
-
requirement: &
|
27
|
+
requirement: &70152611695460 !ruby/object:Gem::Requirement
|
30
28
|
none: false
|
31
|
-
requirements:
|
29
|
+
requirements:
|
32
30
|
- - ~>
|
33
|
-
- !ruby/object:Gem::Version
|
31
|
+
- !ruby/object:Gem::Version
|
34
32
|
version: 1.0.0
|
35
33
|
type: :development
|
36
34
|
prerelease: false
|
37
|
-
version_requirements: *
|
38
|
-
- !ruby/object:Gem::Dependency
|
35
|
+
version_requirements: *70152611695460
|
36
|
+
- !ruby/object:Gem::Dependency
|
39
37
|
name: jeweler
|
40
|
-
requirement: &
|
38
|
+
requirement: &70152611694980 !ruby/object:Gem::Requirement
|
41
39
|
none: false
|
42
|
-
requirements:
|
40
|
+
requirements:
|
43
41
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
42
|
+
- !ruby/object:Gem::Version
|
45
43
|
version: 1.5.1
|
46
44
|
type: :development
|
47
45
|
prerelease: false
|
48
|
-
version_requirements: *
|
49
|
-
- !ruby/object:Gem::Dependency
|
46
|
+
version_requirements: *70152611694980
|
47
|
+
- !ruby/object:Gem::Dependency
|
50
48
|
name: rcov
|
51
|
-
requirement: &
|
49
|
+
requirement: &70152611694420 !ruby/object:Gem::Requirement
|
52
50
|
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version:
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
57
55
|
type: :development
|
58
56
|
prerelease: false
|
59
|
-
version_requirements: *
|
60
|
-
- !ruby/object:Gem::Dependency
|
57
|
+
version_requirements: *70152611694420
|
58
|
+
- !ruby/object:Gem::Dependency
|
61
59
|
name: json
|
62
|
-
requirement: &
|
60
|
+
requirement: &70152611693940 !ruby/object:Gem::Requirement
|
63
61
|
none: false
|
64
|
-
requirements:
|
65
|
-
- -
|
66
|
-
- !ruby/object:Gem::Version
|
62
|
+
requirements:
|
63
|
+
- - ! '>'
|
64
|
+
- !ruby/object:Gem::Version
|
67
65
|
version: 1.4.0
|
68
66
|
type: :development
|
69
67
|
prerelease: false
|
70
|
-
version_requirements: *
|
71
|
-
- !ruby/object:Gem::Dependency
|
68
|
+
version_requirements: *70152611693940
|
69
|
+
- !ruby/object:Gem::Dependency
|
72
70
|
name: httparty
|
73
|
-
requirement: &
|
71
|
+
requirement: &70152611693460 !ruby/object:Gem::Requirement
|
74
72
|
none: false
|
75
|
-
requirements:
|
76
|
-
- -
|
77
|
-
- !ruby/object:Gem::Version
|
73
|
+
requirements:
|
74
|
+
- - ! '>'
|
75
|
+
- !ruby/object:Gem::Version
|
78
76
|
version: 0.6.0
|
79
77
|
type: :development
|
80
78
|
prerelease: false
|
81
|
-
version_requirements: *
|
82
|
-
- !ruby/object:Gem::Dependency
|
79
|
+
version_requirements: *70152611693460
|
80
|
+
- !ruby/object:Gem::Dependency
|
83
81
|
name: mocha
|
84
|
-
requirement: &
|
82
|
+
requirement: &70152611692960 !ruby/object:Gem::Requirement
|
85
83
|
none: false
|
86
|
-
requirements:
|
87
|
-
- -
|
88
|
-
- !ruby/object:Gem::Version
|
84
|
+
requirements:
|
85
|
+
- - ! '>'
|
86
|
+
- !ruby/object:Gem::Version
|
89
87
|
version: 0.9.11
|
90
88
|
type: :development
|
91
89
|
prerelease: false
|
92
|
-
version_requirements: *
|
93
|
-
- !ruby/object:Gem::Dependency
|
90
|
+
version_requirements: *70152611692960
|
91
|
+
- !ruby/object:Gem::Dependency
|
94
92
|
name: activesupport
|
95
|
-
requirement: &
|
93
|
+
requirement: &70152603455920 !ruby/object:Gem::Requirement
|
96
94
|
none: false
|
97
|
-
requirements:
|
98
|
-
- -
|
99
|
-
- !ruby/object:Gem::Version
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
100
98
|
version: 3.0.0
|
101
99
|
type: :development
|
102
100
|
prerelease: false
|
103
|
-
version_requirements: *
|
104
|
-
- !ruby/object:Gem::Dependency
|
101
|
+
version_requirements: *70152603455920
|
102
|
+
- !ruby/object:Gem::Dependency
|
105
103
|
name: httparty
|
106
|
-
requirement: &
|
104
|
+
requirement: &70152603455380 !ruby/object:Gem::Requirement
|
107
105
|
none: false
|
108
|
-
requirements:
|
109
|
-
- -
|
110
|
-
- !ruby/object:Gem::Version
|
106
|
+
requirements:
|
107
|
+
- - ! '>'
|
108
|
+
- !ruby/object:Gem::Version
|
111
109
|
version: 0.6.0
|
112
110
|
type: :runtime
|
113
111
|
prerelease: false
|
114
|
-
version_requirements: *
|
115
|
-
- !ruby/object:Gem::Dependency
|
112
|
+
version_requirements: *70152603455380
|
113
|
+
- !ruby/object:Gem::Dependency
|
116
114
|
name: activesupport
|
117
|
-
requirement: &
|
115
|
+
requirement: &70152603454860 !ruby/object:Gem::Requirement
|
118
116
|
none: false
|
119
|
-
requirements:
|
120
|
-
- -
|
121
|
-
- !ruby/object:Gem::Version
|
117
|
+
requirements:
|
118
|
+
- - ! '>'
|
119
|
+
- !ruby/object:Gem::Version
|
122
120
|
version: 3.0.0
|
123
121
|
type: :runtime
|
124
122
|
prerelease: false
|
125
|
-
version_requirements: *
|
126
|
-
- !ruby/object:Gem::Dependency
|
123
|
+
version_requirements: *70152603454860
|
124
|
+
- !ruby/object:Gem::Dependency
|
127
125
|
name: json
|
128
|
-
requirement: &
|
126
|
+
requirement: &70152603454380 !ruby/object:Gem::Requirement
|
129
127
|
none: false
|
130
|
-
requirements:
|
131
|
-
- -
|
132
|
-
- !ruby/object:Gem::Version
|
128
|
+
requirements:
|
129
|
+
- - ! '>'
|
130
|
+
- !ruby/object:Gem::Version
|
133
131
|
version: 1.4.0
|
134
132
|
type: :runtime
|
135
133
|
prerelease: false
|
136
|
-
version_requirements: *
|
137
|
-
- !ruby/object:Gem::Dependency
|
134
|
+
version_requirements: *70152603454380
|
135
|
+
- !ruby/object:Gem::Dependency
|
138
136
|
name: httparty
|
139
|
-
requirement: &
|
137
|
+
requirement: &70152603453900 !ruby/object:Gem::Requirement
|
140
138
|
none: false
|
141
|
-
requirements:
|
142
|
-
- -
|
143
|
-
- !ruby/object:Gem::Version
|
139
|
+
requirements:
|
140
|
+
- - ! '>'
|
141
|
+
- !ruby/object:Gem::Version
|
144
142
|
version: 0.6.0
|
145
143
|
type: :development
|
146
144
|
prerelease: false
|
147
|
-
version_requirements: *
|
148
|
-
- !ruby/object:Gem::Dependency
|
145
|
+
version_requirements: *70152603453900
|
146
|
+
- !ruby/object:Gem::Dependency
|
149
147
|
name: json
|
150
|
-
requirement: &
|
148
|
+
requirement: &70152603453400 !ruby/object:Gem::Requirement
|
151
149
|
none: false
|
152
|
-
requirements:
|
153
|
-
- -
|
154
|
-
- !ruby/object:Gem::Version
|
150
|
+
requirements:
|
151
|
+
- - ! '>'
|
152
|
+
- !ruby/object:Gem::Version
|
155
153
|
version: 1.4.0
|
156
154
|
type: :development
|
157
155
|
prerelease: false
|
158
|
-
version_requirements: *
|
159
|
-
- !ruby/object:Gem::Dependency
|
156
|
+
version_requirements: *70152603453400
|
157
|
+
- !ruby/object:Gem::Dependency
|
160
158
|
name: mocha
|
161
|
-
requirement: &
|
159
|
+
requirement: &70152603452920 !ruby/object:Gem::Requirement
|
162
160
|
none: false
|
163
|
-
requirements:
|
164
|
-
- -
|
165
|
-
- !ruby/object:Gem::Version
|
161
|
+
requirements:
|
162
|
+
- - ! '>'
|
163
|
+
- !ruby/object:Gem::Version
|
166
164
|
version: 0.9.11
|
167
165
|
type: :development
|
168
166
|
prerelease: false
|
169
|
-
version_requirements: *
|
170
|
-
description: Gibbon is a simple API wrapper for interacting with MailChimp API version
|
167
|
+
version_requirements: *70152603452920
|
168
|
+
description: Gibbon is a simple API wrapper for interacting with MailChimp API version
|
169
|
+
1.3.
|
171
170
|
email: amromousa@gmail.com
|
172
171
|
executables: []
|
173
|
-
|
174
172
|
extensions: []
|
175
|
-
|
176
|
-
extra_rdoc_files:
|
173
|
+
extra_rdoc_files:
|
177
174
|
- LICENSE.txt
|
178
175
|
- README.markdown
|
179
|
-
files:
|
176
|
+
files:
|
180
177
|
- .document
|
181
178
|
- Gemfile
|
182
179
|
- Gemfile.lock
|
@@ -188,37 +185,34 @@ files:
|
|
188
185
|
- lib/gibbon.rb
|
189
186
|
- test/helper.rb
|
190
187
|
- test/test_gibbon.rb
|
191
|
-
has_rdoc: true
|
192
188
|
homepage: http://github.com/amro/gibbon
|
193
|
-
licenses:
|
189
|
+
licenses:
|
194
190
|
- MIT
|
195
191
|
post_install_message:
|
196
192
|
rdoc_options: []
|
197
|
-
|
198
|
-
require_paths:
|
193
|
+
require_paths:
|
199
194
|
- lib
|
200
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
195
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
201
196
|
none: false
|
202
|
-
requirements:
|
203
|
-
- -
|
204
|
-
- !ruby/object:Gem::Version
|
205
|
-
|
206
|
-
segments:
|
197
|
+
requirements:
|
198
|
+
- - ! '>='
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '0'
|
201
|
+
segments:
|
207
202
|
- 0
|
208
|
-
|
209
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
|
+
hash: 1475260258334143890
|
204
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
205
|
none: false
|
211
|
-
requirements:
|
212
|
-
- -
|
213
|
-
- !ruby/object:Gem::Version
|
214
|
-
version:
|
206
|
+
requirements:
|
207
|
+
- - ! '>='
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '0'
|
215
210
|
requirements: []
|
216
|
-
|
217
211
|
rubyforge_project:
|
218
|
-
rubygems_version: 1.
|
212
|
+
rubygems_version: 1.8.9
|
219
213
|
signing_key:
|
220
214
|
specification_version: 3
|
221
215
|
summary: Gibbon is a simple API wrapper for interacting with MailChimp API 1.3
|
222
|
-
test_files:
|
216
|
+
test_files:
|
223
217
|
- test/helper.rb
|
224
218
|
- test/test_gibbon.rb
|