shaf_client 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/shaf_client.rb +1 -0
- data/lib/shaf_client/base_resource.rb +36 -16
- data/lib/shaf_client/mime_types.rb +0 -1
- data/lib/shaf_client/problem_json.rb +38 -0
- data/lib/shaf_client/resource.rb +4 -0
- data/lib/shaf_client/status_codes.rb +70 -0
- data/lib/shaf_client/version.rb +1 -1
- metadata +11 -9
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4eda6aea2ca9040216f1dee7732b7123e98edfbbec2d3b53dd567f50940d145
|
4
|
+
data.tar.gz: a1d43989ce6bff97ac6801ef4fcb67f77e01933cbdf796694e6339d57606d9d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0ca1c6347bf9fb9d15eab004cf7cc83c5f9d571f32cb0fa65c8aaec179c03f9a6f6cd1762951d9904c2eecd537ea0d2b0d04ff347c171099541c7ef1628f9f3
|
7
|
+
data.tar.gz: 976c5ce8cd4e7868c957c7b4c74696298cb7b262ddb314a359efd28e52b6aa4c1925fe698718eed75472acf646737b12cddedaefb7bb9311026e9599fc934ef3
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/shaf_client.rb
CHANGED
@@ -15,6 +15,7 @@ require 'shaf_client/resource'
|
|
15
15
|
require 'shaf_client/shaf_form'
|
16
16
|
require 'shaf_client/hal_form'
|
17
17
|
require 'shaf_client/api_error'
|
18
|
+
require 'shaf_client/problem_json'
|
18
19
|
require 'shaf_client/empty_resource'
|
19
20
|
require 'shaf_client/unknown_resource'
|
20
21
|
require 'shaf_client/hypertext_cache_strategy'
|
@@ -39,20 +39,24 @@ class ShafClient
|
|
39
39
|
to_s
|
40
40
|
end
|
41
41
|
|
42
|
-
def attribute(key)
|
43
|
-
|
42
|
+
def attribute(key, &block)
|
43
|
+
block ||= proc { raise Error, "No attribute for key: #{key}" }
|
44
|
+
_attribute(key, &block)
|
44
45
|
end
|
45
46
|
|
46
|
-
def link(rel)
|
47
|
-
|
47
|
+
def link(rel, &block)
|
48
|
+
block ||= proc { raise Error, "No link with rel: #{rel}" }
|
49
|
+
_link(rel, &block)
|
48
50
|
end
|
49
51
|
|
50
|
-
def curie(rel)
|
51
|
-
|
52
|
+
def curie(rel, &block)
|
53
|
+
block ||= proc { raise Error, "No curie with rel: #{rel}" }
|
54
|
+
_curie(rel, &block)
|
52
55
|
end
|
53
56
|
|
54
|
-
def embedded(rel)
|
55
|
-
|
57
|
+
def embedded(rel, &block)
|
58
|
+
block ||= proc { raise Error, "No embedded resources with rel: #{rel}" }
|
59
|
+
_embedded(rel, &block)
|
56
60
|
end
|
57
61
|
|
58
62
|
def rel?(rel)
|
@@ -75,22 +79,38 @@ class ShafClient
|
|
75
79
|
@payload ||= {}
|
76
80
|
end
|
77
81
|
|
78
|
-
def _attribute(key)
|
79
|
-
|
82
|
+
def _attribute(key, &block)
|
83
|
+
if block
|
84
|
+
attributes.fetch(key.to_sym, &block)
|
85
|
+
else
|
86
|
+
attributes[key.to_sym]
|
87
|
+
end
|
80
88
|
end
|
81
89
|
|
82
|
-
def _link(rel)
|
90
|
+
def _link(rel, &block)
|
83
91
|
rewritten_rel = best_match(links.keys, rel)
|
84
|
-
|
92
|
+
if block
|
93
|
+
links.fetch(rewritten_rel, &block)
|
94
|
+
else
|
95
|
+
links[rewritten_rel]
|
96
|
+
end
|
85
97
|
end
|
86
98
|
|
87
|
-
def _curie(rel)
|
88
|
-
|
99
|
+
def _curie(rel, &block)
|
100
|
+
if block
|
101
|
+
curies.fetch(rel.to_sym, &block)
|
102
|
+
else
|
103
|
+
curies[rel.to_sym]
|
104
|
+
end
|
89
105
|
end
|
90
106
|
|
91
|
-
def _embedded(rel)
|
107
|
+
def _embedded(rel, &block)
|
92
108
|
rewritten_rel = best_match(embedded_resources.keys, rel)
|
93
|
-
|
109
|
+
if block
|
110
|
+
embedded_resources.fetch(rewritten_rel, &block)
|
111
|
+
else
|
112
|
+
embedded_resources[rewritten_rel]
|
113
|
+
end
|
94
114
|
end
|
95
115
|
|
96
116
|
def <<(other)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'shaf_client/form'
|
2
|
+
require 'shaf_client/status_codes'
|
3
|
+
|
4
|
+
class ShafClient
|
5
|
+
class ProblemJson < Resource
|
6
|
+
include StatusCodes
|
7
|
+
|
8
|
+
content_type 'application/problem+json'
|
9
|
+
|
10
|
+
def type
|
11
|
+
attribute(:type) { 'about:blank' }
|
12
|
+
end
|
13
|
+
|
14
|
+
def title
|
15
|
+
attribute(:title) do
|
16
|
+
next unless type == 'about:blank'
|
17
|
+
|
18
|
+
StatusCode[status] if (400..599).include? status.to_i
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def status
|
23
|
+
attribute(:status) { http_status }
|
24
|
+
end
|
25
|
+
|
26
|
+
def detail
|
27
|
+
attribute(:detail)
|
28
|
+
end
|
29
|
+
|
30
|
+
def instance
|
31
|
+
attribute(:instance)
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_h
|
35
|
+
attributes
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/shaf_client/resource.rb
CHANGED
@@ -0,0 +1,70 @@
|
|
1
|
+
class ShafClient
|
2
|
+
module StatusCodes
|
3
|
+
StatusCode = {
|
4
|
+
100 => 'Continue',
|
5
|
+
101 => 'Switching Protocols',
|
6
|
+
102 => 'Processing',
|
7
|
+
103 => 'Early Hints',
|
8
|
+
200 => 'OK',
|
9
|
+
201 => 'Created',
|
10
|
+
202 => 'Accepted',
|
11
|
+
203 => 'Non-Authoritative Information',
|
12
|
+
204 => 'No Content',
|
13
|
+
205 => 'Reset Content',
|
14
|
+
206 => 'Partial Content',
|
15
|
+
207 => 'Multi-Status',
|
16
|
+
208 => 'Already Reported',
|
17
|
+
226 => 'IM Used',
|
18
|
+
300 => 'Multiple Choices',
|
19
|
+
301 => 'Moved Permanently',
|
20
|
+
302 => 'Found',
|
21
|
+
303 => 'See Other',
|
22
|
+
304 => 'Not Modified',
|
23
|
+
305 => 'Use Proxy',
|
24
|
+
306 => '(Unused)',
|
25
|
+
307 => 'Temporary Redirect',
|
26
|
+
308 => 'Permanent Redirect',
|
27
|
+
400 => 'Bad Request',
|
28
|
+
401 => 'Unauthorized',
|
29
|
+
402 => 'Payment Required',
|
30
|
+
403 => 'Forbidden',
|
31
|
+
404 => 'Not Found',
|
32
|
+
405 => 'Method Not Allowed',
|
33
|
+
406 => 'Not Acceptable',
|
34
|
+
407 => 'Proxy Authentication Required',
|
35
|
+
408 => 'Request Timeout',
|
36
|
+
409 => 'Conflict',
|
37
|
+
410 => 'Gone',
|
38
|
+
411 => 'Length Required',
|
39
|
+
412 => 'Precondition Failed',
|
40
|
+
413 => 'Payload Too Large',
|
41
|
+
414 => 'URI Too Long',
|
42
|
+
415 => 'Unsupported Media Type',
|
43
|
+
416 => 'Range Not Satisfiable',
|
44
|
+
417 => 'Expectation Failed',
|
45
|
+
421 => 'Misdirected Request',
|
46
|
+
422 => 'Unprocessable Entity',
|
47
|
+
423 => 'Locked',
|
48
|
+
424 => 'Failed Dependency',
|
49
|
+
425 => 'Too Early',
|
50
|
+
426 => 'Upgrade Required',
|
51
|
+
428 => 'Precondition Required',
|
52
|
+
429 => 'Too Many Requests',
|
53
|
+
431 => 'Request Header Fields Too Large',
|
54
|
+
451 => 'Unavailable For Legal Reasons',
|
55
|
+
500 => 'Internal Server Error',
|
56
|
+
501 => 'Not Implemented',
|
57
|
+
502 => 'Bad Gateway',
|
58
|
+
503 => 'Service Unavailable',
|
59
|
+
504 => 'Gateway Timeout',
|
60
|
+
505 => 'HTTP Version Not Supported',
|
61
|
+
506 => 'Variant Also Negotiates',
|
62
|
+
507 => 'Insufficient Storage',
|
63
|
+
508 => 'Loop Detected',
|
64
|
+
510 => 'Not Extended',
|
65
|
+
511 => 'Network Authentication Required',
|
66
|
+
}
|
67
|
+
StatusCode.default = 'Unassigned'
|
68
|
+
StatusCode.freeze
|
69
|
+
end
|
70
|
+
end
|
data/lib/shaf_client/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shaf_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sammy Henningsson
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
ZMhjYR7sRczGJx+GxGU2EaR0bjRsPVlC4ywtFxoOfRG3WaJcpWGEoAoMJX6Z0bRv
|
31
31
|
M40=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date:
|
33
|
+
date: 2020-05-16 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: faraday
|
@@ -38,14 +38,14 @@ dependencies:
|
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '0
|
41
|
+
version: '1.0'
|
42
42
|
type: :runtime
|
43
43
|
prerelease: false
|
44
44
|
version_requirements: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '0
|
48
|
+
version: '1.0'
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: faraday-http-cache
|
51
51
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,14 +66,14 @@ dependencies:
|
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
69
|
+
version: '13.0'
|
70
70
|
type: :development
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '
|
76
|
+
version: '13.0'
|
77
77
|
- !ruby/object:Gem::Dependency
|
78
78
|
name: minitest
|
79
79
|
requirement: !ruby/object:Gem::Requirement
|
@@ -83,7 +83,7 @@ dependencies:
|
|
83
83
|
version: '5'
|
84
84
|
- - ">="
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version: '5.
|
86
|
+
version: '5.14'
|
87
87
|
type: :development
|
88
88
|
prerelease: false
|
89
89
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -93,7 +93,7 @@ dependencies:
|
|
93
93
|
version: '5'
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '5.
|
96
|
+
version: '5.14'
|
97
97
|
description: A HAL client customized for Shaf APIs
|
98
98
|
email: sammy.henningsson@gmail.com
|
99
99
|
executables: []
|
@@ -114,9 +114,11 @@ files:
|
|
114
114
|
- lib/shaf_client/link.rb
|
115
115
|
- lib/shaf_client/middleware/redirect.rb
|
116
116
|
- lib/shaf_client/mime_types.rb
|
117
|
+
- lib/shaf_client/problem_json.rb
|
117
118
|
- lib/shaf_client/resource.rb
|
118
119
|
- lib/shaf_client/resource_mapper.rb
|
119
120
|
- lib/shaf_client/shaf_form.rb
|
121
|
+
- lib/shaf_client/status_codes.rb
|
120
122
|
- lib/shaf_client/unknown_resource.rb
|
121
123
|
- lib/shaf_client/version.rb
|
122
124
|
homepage: https://github.com/sammyhenningsson/shaf_client
|
@@ -138,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
140
|
- !ruby/object:Gem::Version
|
139
141
|
version: '0'
|
140
142
|
requirements: []
|
141
|
-
rubygems_version: 3.0.
|
143
|
+
rubygems_version: 3.0.3
|
142
144
|
signing_key:
|
143
145
|
specification_version: 4
|
144
146
|
summary: HAL client for Shaf
|
metadata.gz.sig
CHANGED
Binary file
|