gibbon 0.4.5 → 0.4.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.

Files changed (4) hide show
  1. data/README.markdown +4 -14
  2. data/gibbon.gemspec +1 -1
  3. data/lib/gibbon.rb +10 -4
  4. metadata +4 -4
data/README.markdown CHANGED
@@ -133,6 +133,9 @@ then Gibbon will not raise exceptions. This allows you to handle errors manually
133
133
  APIs will return a Hash with two keys "errors", a string containing some textual
134
134
  information about the error, and "code", the numeric code of the error.
135
135
 
136
+ If you rescue Gibbon::MailChimpError, you are provided with the error message itself as well as
137
+ a `code` attribute that you can map onto the API's [error code list](http://apidocs.mailchimp.com/api/rtfm/exceptions.field.php).
138
+
136
139
  > Note: In an effort to make Gibbon easier to use, errors are raised automatically as of version 0.4.0.
137
140
 
138
141
  ### Export API usage
@@ -153,20 +156,7 @@ of JSON objects rather than a single JSON array.
153
156
 
154
157
  ##Thanks
155
158
 
156
- The following people have contributed to Gibbon's development in some way:
157
-
158
- * [Justin Ip](https://github.com/ippy04)
159
- * [elshimone](https://github.com/elshimone)
160
- * [jlxw](https://github.com/jlxw)
161
- * [Jon McCartie](https://github.com/jmccartie)
162
- * [Calvin Yu](https://github.com/cyu)
163
- * [Dave Worth](https://github.com/daveworth)
164
- * [Mike Skalnik](https://github.com/skalnik)
165
- * [Kristopher Murata](https://github.com/krsmurata)
166
- * [Michael Klishin](https://github.com/michaelklishin)
167
- * [Adam Loving](https://github.com/adamloving)
168
- * [Kelly Dunn](https://github.com/kellydunn)
169
- * Rails for camelize gsub
159
+ Thanks to everyone who's [contributed](https://github.com/amro/gibbon/contributors) to Gibbon's development.
170
160
 
171
161
  ##Copyright
172
162
 
data/gibbon.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "gibbon"
6
- s.version = "0.4.5"
6
+ s.version = "0.4.6"
7
7
  s.authors = ["Amro Mousa"]
8
8
  s.email = ["amromousa@gmail.com"]
9
9
  s.homepage = "http://github.com/amro/gibbon"
data/lib/gibbon.rb CHANGED
@@ -9,8 +9,6 @@ class Gibbon
9
9
 
10
10
  attr_accessor :api_key, :api_endpoint, :timeout, :throws_exceptions
11
11
 
12
- MailChimpError = Class.new(StandardError)
13
-
14
12
  def initialize(api_key = nil, default_parameters = {})
15
13
  @api_key = api_key || self.class.api_key || ENV['MAILCHIMP_API_KEY']
16
14
  @api_key = @api_key.strip if @api_key
@@ -46,7 +44,9 @@ class Gibbon
46
44
  parsed_response = MultiJson.load("[#{response.body}]").first
47
45
 
48
46
  if should_raise_for_response?(parsed_response)
49
- raise MailChimpError.new("MailChimp API Error: #{parsed_response["error"]} (code #{parsed_response["code"]})")
47
+ error = MailChimpError.new("MailChimp API Error: #{parsed_response["error"]} (code #{parsed_response["code"]})")
48
+ error.code = parsed_response["code"]
49
+ raise error
50
50
  end
51
51
 
52
52
  parsed_response
@@ -105,6 +105,10 @@ class Gibbon
105
105
 
106
106
  data_center
107
107
  end
108
+
109
+ class MailChimpError < StandardError
110
+ attr_accessor :code
111
+ end
108
112
  end
109
113
 
110
114
  class GibbonExport < Gibbon
@@ -128,7 +132,9 @@ class GibbonExport < Gibbon
128
132
  first_line = MultiJson.load(lines.first) if lines.first
129
133
 
130
134
  if should_raise_for_response?(first_line)
131
- raise MailChimpError.new("MailChimp Export API Error: #{first_line["error"]} (code #{first_line["code"]})")
135
+ error = MailChimpError.new("MailChimp Export API Error: #{first_line["error"]} (code #{first_line["code"]})")
136
+ error.code = first_line["code"]
137
+ raise error
132
138
  end
133
139
  end
134
140
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gibbon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-07 00:00:00.000000000 Z
12
+ date: 2013-03-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -143,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
143
  version: '0'
144
144
  segments:
145
145
  - 0
146
- hash: 3427159394109996013
146
+ hash: -2273673627394400762
147
147
  required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  none: false
149
149
  requirements:
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  version: '0'
153
153
  segments:
154
154
  - 0
155
- hash: 3427159394109996013
155
+ hash: -2273673627394400762
156
156
  requirements: []
157
157
  rubyforge_project: gibbon
158
158
  rubygems_version: 1.8.24