datacatalog 0.4.11 → 0.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/datacatalog.gemspec +2 -2
- data/lib/base.rb +20 -16
- data/lib/main.rb +6 -1
- metadata +3 -3
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ begin
|
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "datacatalog"
|
8
|
-
gem.version = '0.4.
|
8
|
+
gem.version = '0.4.12'
|
9
9
|
gem.rubyforge_project = "datacatalog"
|
10
10
|
gem.summary = %Q{Client for the National Data Catalog API}
|
11
11
|
gem.description = %Q{A Ruby client library for the National Data Catalog API}
|
data/datacatalog.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{datacatalog}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.12"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Luigi Montanez", "David James"]
|
12
|
-
s.date = %q{2010-03-
|
12
|
+
s.date = %q{2010-03-17}
|
13
13
|
s.description = %q{A Ruby client library for the National Data Catalog API}
|
14
14
|
s.email = %q{luigi@sunlightfoundation.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/base.rb
CHANGED
@@ -21,12 +21,12 @@ module DataCatalog
|
|
21
21
|
|
22
22
|
def self.check_status(response)
|
23
23
|
case response.code
|
24
|
-
when 400
|
25
|
-
when 401
|
26
|
-
when 403
|
27
|
-
when 404
|
28
|
-
when 409
|
29
|
-
when 500
|
24
|
+
when 400 then error(BadRequest, response)
|
25
|
+
when 401 then error(Unauthorized, response)
|
26
|
+
when 403 then error(Forbidden, response)
|
27
|
+
when 404 then error(NotFound, response)
|
28
|
+
when 409 then error(Conflict, response)
|
29
|
+
when 500 then error(InternalServerError, response)
|
30
30
|
end
|
31
31
|
response
|
32
32
|
end
|
@@ -40,17 +40,21 @@ module DataCatalog
|
|
40
40
|
})
|
41
41
|
end
|
42
42
|
|
43
|
-
def self.error(response)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
43
|
+
def self.error(exception_class, response)
|
44
|
+
e = exception_class.new
|
45
|
+
e.response_body = response.body
|
46
|
+
parsed_response_body = begin
|
47
|
+
JSON.parse(response.body)
|
48
|
+
rescue JSON::ParserError
|
49
|
+
nil
|
50
|
+
end
|
51
|
+
if !parsed_response_body.empty?
|
52
|
+
e.parsed_response_body = parsed_response_body
|
53
|
+
if parsed_response_body["errors"]
|
54
|
+
e.errors = parsed_response_body["errors"]
|
55
|
+
end
|
51
56
|
end
|
52
|
-
|
53
|
-
"Unable to parse: #{response.body.inspect}"
|
57
|
+
raise e
|
54
58
|
end
|
55
59
|
|
56
60
|
def self._first(response)
|
data/lib/main.rb
CHANGED
@@ -2,7 +2,12 @@ module DataCatalog
|
|
2
2
|
|
3
3
|
# == Exceptions
|
4
4
|
|
5
|
-
class Error
|
5
|
+
class Error < RuntimeError
|
6
|
+
attr_accessor :response_body # String
|
7
|
+
attr_accessor :parsed_response_body # Hash
|
8
|
+
attr_accessor :errors # Hash
|
9
|
+
end
|
10
|
+
|
6
11
|
class BadRequest < Error; end # 400
|
7
12
|
class Unauthorized < Error; end # 401
|
8
13
|
class Forbidden < Error; end # 403
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 12
|
9
|
+
version: 0.4.12
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Luigi Montanez
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-03-
|
18
|
+
date: 2010-03-17 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|