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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c7758e0a388759de54cd305d5b1541c01c071d0155939fca0dd8a2f9fb57438
4
- data.tar.gz: c297702586a42855ec25e3f8e0d9fef33936393b3ade5b3258a2a89b03b85896
3
+ metadata.gz: 1a4938e6a4e81f0aa7b22ac3d93977f399f1405b3a1d1b61d6dd013b9cfc0a88
4
+ data.tar.gz: f5255401a3483953aceef590d1bf7aaaedf7ea03eea86b2302a7691f10c4bb1b
5
5
  SHA512:
6
- metadata.gz: 2a82f835d9fdd3ec4a9fd131c93263fcfc99f51ac737cafb3e0fdec5d75b51b4f3280d0b0110d75f1d80d097462437bbd2a72aa754eb46a02db8459861d6a12a
7
- data.tar.gz: bb44a183ec62744bfdc163e526d072ba00b543eea33098a3d2828ad58fc16aa9b0fc444a129d3b5e420707530951c44be51f88c63acacf8d4ecab114cdd645ed
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
@@ -15,11 +15,11 @@ class ShafClient
15
15
  end
16
16
 
17
17
  def [](key)
18
- values[key]
18
+ values[key.to_sym]
19
19
  end
20
20
 
21
21
  def []=(key, value)
22
- values[key] = value
22
+ values[key.to_sym] = value
23
23
  end
24
24
 
25
25
  def target
@@ -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
- Resource.build(self, response.body, response.status, response.headers)
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�ӳ�&;M����ťPY�����"��$y��J��<uVZ�Y���H>����>��%�\w�����]�� �'huQ��Ok��8JlӦ�f��&����'��[�)d�!�b�������f$��H�&rz^�;m,��
2
- w ��Y��+3)G?�����jO0:��19}�,ꍤj��N<ⷈ�-ڒb�f���0�[U�?y��:,�������JG)�/>���5J着L�2㤛SR�6�ƥ�1�
1
+ ���K��i�4�&vk!y���jK�L>�A��y��;�A���F$�u#��C�HK
2
+ ID߲8NqYHt|�DE苸r�t�N��?L h��*�I,��\�.*�-��Ս5B�"����l�̜D����#���f(b*;��= ���6n�=Y#��&q�����!2kKbՇ��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.0
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-08-23 00:00:00.000000000 Z
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.1
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