shaf_client 0.5.0 → 0.5.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/lib/shaf_client/empty_resource.rb +28 -0
- data/lib/shaf_client/error.rb +21 -0
- data/lib/shaf_client/form.rb +2 -2
- data/lib/shaf_client/resource.rb +6 -2
- data/lib/shaf_client.rb +7 -1
- data.tar.gz.sig +2 -2
- metadata +5 -3
- 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: 1a4938e6a4e81f0aa7b22ac3d93977f399f1405b3a1d1b61d6dd013b9cfc0a88
|
4
|
+
data.tar.gz: f5255401a3483953aceef590d1bf7aaaedf7ea03eea86b2302a7691f10c4bb1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ffdbf2f68b5da3d68dbfc881fb0a9ead6209d6bc6f5406fb4e1a4e774603e91c99c6bdd5adaa9e7e6ea8ee3cc86ca1f464366f5259f34bde7b03c71383c796e
|
7
|
+
data.tar.gz: 2ce0baf08bd971a286ece19a53e4847f48559bba2c35a5c97de7a4721ad92d995dab1768ec26297a6b143a563ea33dac40054362cea3561d9d6554cca27afee0
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'shaf_client/resource'
|
2
|
+
|
3
|
+
class ShafClient
|
4
|
+
class EmptyResource < Resource
|
5
|
+
attr_reader :http_status, :headers
|
6
|
+
|
7
|
+
profile '__shaf_client_emtpy__'
|
8
|
+
|
9
|
+
def initialize(_client, _payload, status = nil, headers = {})
|
10
|
+
@http_status = status
|
11
|
+
@headers = headers
|
12
|
+
@attributes = {}.freeze
|
13
|
+
@links = {}.freeze
|
14
|
+
@curies = {}.freeze
|
15
|
+
@embedded_resources = {}.freeze
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_h
|
19
|
+
{}
|
20
|
+
end
|
21
|
+
|
22
|
+
%i[get put post delete patch, get_doc, reload!].each do |method|
|
23
|
+
define_method(method) do |*_args|
|
24
|
+
raise "EmptyResource: #{method} not available"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'shaf_client/link'
|
3
|
+
|
4
|
+
class ShafClient
|
5
|
+
class ApiError < Resource
|
6
|
+
|
7
|
+
profile 'shaf-error'
|
8
|
+
|
9
|
+
def title
|
10
|
+
attribute(:title)
|
11
|
+
end
|
12
|
+
|
13
|
+
def code
|
14
|
+
attribute(:code)
|
15
|
+
end
|
16
|
+
|
17
|
+
def fields
|
18
|
+
attribute(:fields)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/shaf_client/form.rb
CHANGED
data/lib/shaf_client/resource.rb
CHANGED
@@ -12,11 +12,11 @@ class ShafClient
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def for(name)
|
15
|
-
all[name]
|
15
|
+
all[name&.to_sym]
|
16
16
|
end
|
17
17
|
|
18
18
|
def set(name, clazz)
|
19
|
-
all[name] = clazz
|
19
|
+
all[name.to_sym] = clazz
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -62,6 +62,10 @@ class ShafClient
|
|
62
62
|
self << get(:self, headers: {'Cache-Control': 'no-cache'})
|
63
63
|
end
|
64
64
|
|
65
|
+
def destroy!
|
66
|
+
delete(:delete)
|
67
|
+
end
|
68
|
+
|
65
69
|
protected
|
66
70
|
|
67
71
|
def <<(other)
|
data/lib/shaf_client.rb
CHANGED
@@ -6,6 +6,8 @@ require 'json'
|
|
6
6
|
require 'shaf_client/middleware/redirect'
|
7
7
|
require 'shaf_client/resource'
|
8
8
|
require 'shaf_client/form'
|
9
|
+
require 'shaf_client/error'
|
10
|
+
require 'shaf_client/empty_resource'
|
9
11
|
|
10
12
|
class ShafClient
|
11
13
|
class Error < StandardError; end
|
@@ -40,7 +42,11 @@ class ShafClient
|
|
40
42
|
payload: payload,
|
41
43
|
opts: options
|
42
44
|
)
|
43
|
-
|
45
|
+
|
46
|
+
body = String(response.body)
|
47
|
+
response.headers['content-type'] = 'profile=__shaf_client_emtpy__' if body.empty?
|
48
|
+
|
49
|
+
Resource.build(self, body, response.status, response.headers)
|
44
50
|
end
|
45
51
|
end
|
46
52
|
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
�
|
1
|
+
���K��i�4�&vk!y���jK�L>�A��y��;�A���F$�u#��C�HK
|
2
|
+
ID߲8NqY�Ht|�DE苸r�t�N��?Lh��*�I,��\�.*�-��Ս5B�"����l�̜D����#���f(b*;��= ���6n�=Y#��&q�����!2kK�bՇ��P=�.��י���J��*:�-�H��8[*dH���M|� ��Ui��2��@�}-�e��B�? ��֩������L�J�6��,
|
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.5.
|
4
|
+
version: 0.5.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: 2019-
|
33
|
+
date: 2019-09-06 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: faraday
|
@@ -103,6 +103,8 @@ files:
|
|
103
103
|
- lib/shaf_client.rb
|
104
104
|
- lib/shaf_client/base_resource.rb
|
105
105
|
- lib/shaf_client/curie.rb
|
106
|
+
- lib/shaf_client/empty_resource.rb
|
107
|
+
- lib/shaf_client/error.rb
|
106
108
|
- lib/shaf_client/form.rb
|
107
109
|
- lib/shaf_client/link.rb
|
108
110
|
- lib/shaf_client/middleware/redirect.rb
|
@@ -126,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
128
|
- !ruby/object:Gem::Version
|
127
129
|
version: '0'
|
128
130
|
requirements: []
|
129
|
-
rubygems_version: 3.0.
|
131
|
+
rubygems_version: 3.0.6
|
130
132
|
signing_key:
|
131
133
|
specification_version: 4
|
132
134
|
summary: HAL client for Shaf
|
metadata.gz.sig
CHANGED
Binary file
|