grid_rest 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +4 -0
- data/Gemfile +6 -2
- data/config/locales/grid_rest.en.yml +101 -0
- data/grid_rest.gemspec +3 -2
- data/lib/grid_rest.rb +14 -10
- metadata +27 -26
data/CHANGELOG.rdoc
CHANGED
data/Gemfile
CHANGED
@@ -2,14 +2,18 @@ source "http://rubygems.org"
|
|
2
2
|
# Add dependencies required to use your gem here.
|
3
3
|
# Example:
|
4
4
|
# gem "activesupport", ">= 2.3.5"
|
5
|
-
gem "activesupport", ">= 3.0.
|
5
|
+
gem "activesupport", ">= 3.0.9"
|
6
6
|
gem "rest-client"
|
7
|
+
gem "i18n"
|
7
8
|
|
8
9
|
# Add dependencies to develop your gem here.
|
9
10
|
# Include everything needed to run rake, tests, features, etc.
|
10
11
|
group :development do
|
11
|
-
gem "shoulda", ">= 0"
|
12
12
|
gem "bundler", "~> 1.0.0"
|
13
13
|
gem "jeweler", "~> 1.6.0"
|
14
14
|
gem "rcov", ">= 0"
|
15
15
|
end
|
16
|
+
group :test do
|
17
|
+
gem 'rspec'
|
18
|
+
gem 'capybara'
|
19
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
en:
|
2
|
+
grid_rest:
|
3
|
+
error:
|
4
|
+
for response type: There was a problem with the request (%{type})
|
5
|
+
for response code: There was a problem with the request (%{code})
|
6
|
+
message:
|
7
|
+
ECONNREFUSED: The connection to the server could not be established
|
8
|
+
RequestTimeout: De server timed out
|
9
|
+
ServerBrokeConnection: The server has disconnected
|
10
|
+
|
11
|
+
Continue: Continue
|
12
|
+
SwitchProtocol: SwitchProtocol
|
13
|
+
Processing: Processing (WebDAV)
|
14
|
+
|
15
|
+
OK: OK
|
16
|
+
Created: Created
|
17
|
+
Accepted: Accepted
|
18
|
+
NonAuthoritativeInformation: NonAuthoritativeInformation
|
19
|
+
NoContent: NoContent
|
20
|
+
ResetContent: ResetContent
|
21
|
+
PartialContent: PartialContent
|
22
|
+
|
23
|
+
MultipleChoice: MultipleChoice
|
24
|
+
MovedPermanently: MovedPermanently
|
25
|
+
Found: Found
|
26
|
+
SeeOther: SeeOther
|
27
|
+
NotModified: NotModified
|
28
|
+
UseProxy: UseProxy
|
29
|
+
TemporaryRedirect: TemporaryRedirect
|
30
|
+
|
31
|
+
BadRequest: BadRequest
|
32
|
+
Unauthorized: Unauthorized
|
33
|
+
PaymentRequired: PaymentRequired
|
34
|
+
Forbidden: Forbidden
|
35
|
+
NotFound: NotFound
|
36
|
+
MethodNotAllowed: MethodNotAllowed
|
37
|
+
NotAcceptable: NotAcceptable
|
38
|
+
ProxyAuthenticationRequired: ProxyAuthenticationRequired
|
39
|
+
RequestTimeOut: RequestTimeOut
|
40
|
+
Conflict: Conflict
|
41
|
+
Gone: Gone
|
42
|
+
LengthRequired: LengthRequired
|
43
|
+
PreconditionFailed: PreconditionFailed
|
44
|
+
RequestEntityTooLarge: RequestEntityTooLarge
|
45
|
+
RequestURITooLong: RequestURITooLong
|
46
|
+
UnsupportedMediaType: UnsupportedMediaType
|
47
|
+
RequestedRangeNotSatisfiable: RequestedRangeNotSatisfiable
|
48
|
+
ExpectationFailed: ExpectationFailed
|
49
|
+
|
50
|
+
InternalServerError: InternalServerError
|
51
|
+
NotImplemented: NotImplemented
|
52
|
+
BadGateway: BadGateway
|
53
|
+
ServiceUnavailable: ServiceUnavailable
|
54
|
+
GatewayTimeOut: GatewayTimeOut
|
55
|
+
VersionNotSupported: VersionNotSupported
|
56
|
+
code:
|
57
|
+
100: Continue
|
58
|
+
101: SwitchProtocol
|
59
|
+
102: Processing
|
60
|
+
|
61
|
+
200: OK
|
62
|
+
201: Created
|
63
|
+
202: Accepted
|
64
|
+
203: NonAuthoritativeInformation
|
65
|
+
204: NoContent
|
66
|
+
205: ResetContent
|
67
|
+
206: PartialContent
|
68
|
+
|
69
|
+
300: MultipleChoice
|
70
|
+
301: MovedPermanently
|
71
|
+
302: Found
|
72
|
+
303: SeeOther
|
73
|
+
304: NotModified
|
74
|
+
305: UseProxy
|
75
|
+
307: TemporaryRedirect
|
76
|
+
|
77
|
+
400: BadRequest
|
78
|
+
401: Unauthorized
|
79
|
+
402: PaymentRequired
|
80
|
+
403: Forbidden
|
81
|
+
404: NotFound
|
82
|
+
405: MethodNotAllowed
|
83
|
+
406: NotAcceptable
|
84
|
+
407: ProxyAuthenticationRequired
|
85
|
+
408: RequestTimeOut
|
86
|
+
409: Conflict
|
87
|
+
410: Gone
|
88
|
+
411: LengthRequired
|
89
|
+
412: PreconditionFailed
|
90
|
+
413: RequestEntityTooLarge
|
91
|
+
414: RequestURITooLong
|
92
|
+
415: UnsupportedMediaType
|
93
|
+
416: RequestedRangeNotSatisfiable
|
94
|
+
417: ExpectationFailed
|
95
|
+
|
96
|
+
500: InternalServerError
|
97
|
+
501: NotImplemented
|
98
|
+
502: BadGateway
|
99
|
+
503: ServiceUnavailable
|
100
|
+
504: GatewayTimeOut
|
101
|
+
505: VersionNotSupported
|
data/grid_rest.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{grid_rest}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Benjamin ter Kuile"]
|
@@ -29,7 +29,8 @@ Gem::Specification.new do |s|
|
|
29
29
|
"lib/grid_rest.rb",
|
30
30
|
"lib/grid_rest/engine.rb",
|
31
31
|
"test/helper.rb",
|
32
|
-
"test/test_grid_rest.rb"
|
32
|
+
"test/test_grid_rest.rb",
|
33
|
+
"config/locales/grid_rest.en.yml"
|
33
34
|
]
|
34
35
|
s.homepage = %q{http://github.com/bterkuile/grid_rest}
|
35
36
|
s.licenses = ["MIT"]
|
data/lib/grid_rest.rb
CHANGED
@@ -224,13 +224,13 @@ module GridRest
|
|
224
224
|
true
|
225
225
|
end
|
226
226
|
rescue RestClient::ResourceNotFound => e
|
227
|
-
r = Error.new(
|
227
|
+
r = Error.new(e, :url => rest_url, :method => method)
|
228
228
|
grid_rest_log method, rest_url, rparams, "resource not found response"
|
229
|
-
rescue Errno::ECONNREFUSED
|
230
|
-
r = Error.new(
|
229
|
+
rescue Errno::ECONNREFUSED => e
|
230
|
+
r = Error.new(e, :url => rest_url, :method => method)
|
231
231
|
grid_rest_log method, rest_url, rparams, "connection refused response"
|
232
232
|
rescue => e
|
233
|
-
r = Error.new
|
233
|
+
r = Error.new e, :url => rest_url, :method => method
|
234
234
|
grid_rest_log method, rest_url, rparams, "error in request"
|
235
235
|
end
|
236
236
|
r
|
@@ -283,13 +283,16 @@ module GridRest
|
|
283
283
|
# with a normal request, but most importantly returns false on the
|
284
284
|
# valid? question.
|
285
285
|
class Error
|
286
|
-
attr_reader :message, :code, :url, :request_method
|
287
|
-
def initialize(
|
288
|
-
@
|
289
|
-
@code = rparams.delete(:code)
|
286
|
+
attr_reader :message, :code, :url, :request_method, :response, :type
|
287
|
+
def initialize(e, rparams)
|
288
|
+
@request_method = rparams.delete(:request_method) || rparams.delete(:method)
|
289
|
+
@code = e.respond_to?(:http_code) ? e.http_code : (rparams.delete(:code) || 500)
|
290
|
+
@response = e.response if e.respond_to?(:response)
|
291
|
+
@type = e.class.name.split('::').last
|
292
|
+
@message = I18n.t(@type, :scope => [:grid_rest, :message], :default => nil)
|
290
293
|
@url = rparams.delete(:url)
|
291
|
-
@request_method = rparams.delete(:request_method)
|
292
294
|
end
|
295
|
+
|
293
296
|
def code
|
294
297
|
@code || 500
|
295
298
|
end
|
@@ -316,12 +319,13 @@ module GridRest
|
|
316
319
|
end
|
317
320
|
|
318
321
|
class ErrorArray < Array
|
319
|
-
attr_reader :message, :code, :url, :request_method
|
322
|
+
attr_reader :message, :code, :url, :request_method, :response
|
320
323
|
def initialize(e)
|
321
324
|
@message = e.message
|
322
325
|
@code = e.code
|
323
326
|
@url = e.url
|
324
327
|
@request_method = e.request_method
|
328
|
+
@response = e.response
|
325
329
|
end
|
326
330
|
def to_s
|
327
331
|
''
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Benjamin ter Kuile
|
@@ -18,7 +18,9 @@ date: 2011-06-15 00:00:00 +02:00
|
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
21
|
+
name: activesupport
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
22
24
|
requirements:
|
23
25
|
- - ">="
|
24
26
|
- !ruby/object:Gem::Version
|
@@ -27,36 +29,36 @@ dependencies:
|
|
27
29
|
- 0
|
28
30
|
- 7
|
29
31
|
version: 3.0.7
|
30
|
-
requirement: *id001
|
31
|
-
prerelease: false
|
32
32
|
type: :runtime
|
33
|
-
|
33
|
+
version_requirements: *id001
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
|
-
|
35
|
+
name: rest-client
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
38
|
requirements:
|
37
39
|
- - ">="
|
38
40
|
- !ruby/object:Gem::Version
|
39
41
|
segments:
|
40
42
|
- 0
|
41
43
|
version: "0"
|
42
|
-
requirement: *id002
|
43
|
-
prerelease: false
|
44
44
|
type: :runtime
|
45
|
-
|
45
|
+
version_requirements: *id002
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
-
|
47
|
+
name: shoulda
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
48
50
|
requirements:
|
49
51
|
- - ">="
|
50
52
|
- !ruby/object:Gem::Version
|
51
53
|
segments:
|
52
54
|
- 0
|
53
55
|
version: "0"
|
54
|
-
requirement: *id003
|
55
|
-
prerelease: false
|
56
56
|
type: :development
|
57
|
-
|
57
|
+
version_requirements: *id003
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
|
-
|
59
|
+
name: bundler
|
60
|
+
prerelease: false
|
61
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
60
62
|
requirements:
|
61
63
|
- - ~>
|
62
64
|
- !ruby/object:Gem::Version
|
@@ -65,12 +67,12 @@ dependencies:
|
|
65
67
|
- 0
|
66
68
|
- 0
|
67
69
|
version: 1.0.0
|
68
|
-
requirement: *id004
|
69
|
-
prerelease: false
|
70
70
|
type: :development
|
71
|
-
|
71
|
+
version_requirements: *id004
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
|
-
|
73
|
+
name: jeweler
|
74
|
+
prerelease: false
|
75
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
74
76
|
requirements:
|
75
77
|
- - ~>
|
76
78
|
- !ruby/object:Gem::Version
|
@@ -79,22 +81,20 @@ dependencies:
|
|
79
81
|
- 6
|
80
82
|
- 0
|
81
83
|
version: 1.6.0
|
82
|
-
requirement: *id005
|
83
|
-
prerelease: false
|
84
84
|
type: :development
|
85
|
-
|
85
|
+
version_requirements: *id005
|
86
86
|
- !ruby/object:Gem::Dependency
|
87
|
-
|
87
|
+
name: rcov
|
88
|
+
prerelease: false
|
89
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
88
90
|
requirements:
|
89
91
|
- - ">="
|
90
92
|
- !ruby/object:Gem::Version
|
91
93
|
segments:
|
92
94
|
- 0
|
93
95
|
version: "0"
|
94
|
-
requirement: *id006
|
95
|
-
prerelease: false
|
96
96
|
type: :development
|
97
|
-
|
97
|
+
version_requirements: *id006
|
98
98
|
description: |-
|
99
99
|
grid_rest is a gem that makes your rails application interact with other backends through a REST interface. It is build in a situation where one rails application was talking to 2 java backends.
|
100
100
|
The main development focus is JSON communication, but XML should be just as easy
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- lib/grid_rest/engine.rb
|
120
120
|
- test/helper.rb
|
121
121
|
- test/test_grid_rest.rb
|
122
|
+
- config/locales/grid_rest.en.yml
|
122
123
|
has_rdoc: true
|
123
124
|
homepage: http://github.com/bterkuile/grid_rest
|
124
125
|
licenses:
|