eac_rest 0.12.0 → 0.14.0
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.
- checksums.yaml +4 -4
- data/lib/eac_rest/api.rb +0 -4
- data/lib/eac_rest/entity/children.rb +24 -0
- data/lib/eac_rest/entity/data.rb +0 -2
- data/lib/eac_rest/entity/fetching.rb +16 -12
- data/lib/eac_rest/entity.rb +2 -11
- data/lib/eac_rest/helper.rb +0 -2
- data/lib/eac_rest/request.rb +1 -5
- data/lib/eac_rest/response.rb +0 -4
- data/lib/eac_rest/version.rb +1 -1
- data/lib/eac_rest.rb +5 -2
- metadata +24 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: df7aa217e469793d8c1f35aa2e953fd51f3ed6c0231cc6cfbe588028e768a194
|
|
4
|
+
data.tar.gz: 25802e61e7df6dbb0a3a3079dedf6e19cc47255b11ae7788b885d8a67bd178b7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3f86bd37a5060a7119fb6be948f99fd48ab55e5539763c3f93a5923ab4acea5f63ab9f77fa2ee7746380f6badc194355751f8d9e6971846b48d4ab4b385e070d
|
|
7
|
+
data.tar.gz: fd8ba8ac361edc097c3c0a9f5e785405d4717d052f7c0b3a629e5aec4346bc3207473d818831fcb89b835b4d572e7dad0d8bdff30f46b5dde682d48212b1d0f8
|
data/lib/eac_rest/api.rb
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module EacRest
|
|
4
|
+
class Entity
|
|
5
|
+
module Children
|
|
6
|
+
# @param entity_class [Class]
|
|
7
|
+
# @param data_or_id [Hash|Object]
|
|
8
|
+
# @param options [Hash]
|
|
9
|
+
# @return [EacRest::Entity]
|
|
10
|
+
def child_entity(entity_class, data_or_id, options = {})
|
|
11
|
+
api.entity(entity_class, data_or_id, options.merge(OPTION_PARENT => self))
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# @param entity_class [Class<T>]
|
|
15
|
+
# @param path_suffix [String]
|
|
16
|
+
# @return [Enumerable<T>]
|
|
17
|
+
def child_list(entity_class, path_suffix)
|
|
18
|
+
items = request(path_suffix).response.body_data
|
|
19
|
+
items = yield(items) if block_given?
|
|
20
|
+
items.map { |e| child_entity(entity_class, e) }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
data/lib/eac_rest/entity/data.rb
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'eac_rest/helper'
|
|
4
|
-
require 'eac_ruby_utils/core_ext'
|
|
5
|
-
|
|
6
3
|
module EacRest
|
|
7
4
|
class Entity
|
|
8
5
|
module Fetching
|
|
9
|
-
# @return [Addressable::URI]
|
|
10
|
-
def entity_root_url_suffix
|
|
11
|
-
parent_entity.if_present('', &:entity_root_url_suffix).to_uri
|
|
12
|
-
end
|
|
13
|
-
|
|
14
6
|
# @param url_suffix [Addressable::URI]
|
|
15
7
|
# @return [EacRest::Request]
|
|
16
8
|
def request(url_suffix)
|
|
17
|
-
|
|
9
|
+
request_json(url_suffix)
|
|
18
10
|
end
|
|
19
11
|
|
|
20
12
|
# @param url_suffix [Addressable::URI]
|
|
21
|
-
# @return [
|
|
22
|
-
def
|
|
23
|
-
|
|
13
|
+
# @return [EacRest::Request]
|
|
14
|
+
def request_json(url_suffix = '')
|
|
15
|
+
api.request_json(to_api_address_suffix(url_suffix))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# @return [String]
|
|
19
|
+
def to_api_address_suffix(url_suffix = '')
|
|
20
|
+
r = [to_api_address_suffix_self, url_suffix].join
|
|
21
|
+
r = parent_entity.to_api_address_suffix(r) if parent_entity
|
|
22
|
+
r
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# @return [String]
|
|
26
|
+
def to_api_address_suffix_self
|
|
27
|
+
raise_abstract_method __method__
|
|
24
28
|
end
|
|
25
29
|
end
|
|
26
30
|
end
|
data/lib/eac_rest/entity.rb
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
|
4
|
-
|
|
5
3
|
module EacRest
|
|
6
4
|
class Entity
|
|
7
5
|
enable_abstract_methods
|
|
@@ -13,18 +11,11 @@ module EacRest
|
|
|
13
11
|
end
|
|
14
12
|
|
|
15
13
|
class << self
|
|
16
|
-
def from_array_data(api, array_data, *
|
|
17
|
-
array_data.map { |item_data| new(api, item_data, *
|
|
14
|
+
def from_array_data(api, array_data, *)
|
|
15
|
+
array_data.map { |item_data| new(api, item_data, *) }
|
|
18
16
|
end
|
|
19
17
|
end
|
|
20
18
|
|
|
21
|
-
# @param entity_class [Class]
|
|
22
|
-
# @param url_suffix [String]
|
|
23
|
-
# @return [EacRest::Entity]
|
|
24
|
-
def child_entity(entity_class, data_or_id, options = {})
|
|
25
|
-
api.entity(entity_class, data_or_id, options.merge(OPTION_PARENT => self))
|
|
26
|
-
end
|
|
27
|
-
|
|
28
19
|
# @return [EacRest::Entity, nil]
|
|
29
20
|
def parent_entity
|
|
30
21
|
options[OPTION_PARENT]
|
data/lib/eac_rest/helper.rb
CHANGED
data/lib/eac_rest/request.rb
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'eac_envs/http/request'
|
|
4
|
-
require 'eac_rest/response'
|
|
5
|
-
require 'eac_ruby_utils/core_ext'
|
|
6
|
-
|
|
7
3
|
module EacRest
|
|
8
4
|
class Request
|
|
9
5
|
BODY_DATA_JSON_HEADERS = { 'Content-Type' => 'application/json' }.freeze
|
|
@@ -25,7 +21,7 @@ module EacRest
|
|
|
25
21
|
delegate :sanitized_verb, :url, to: :internal_request
|
|
26
22
|
|
|
27
23
|
{
|
|
28
|
-
auth: 0, body_data: 0, header: 1, headers: 0, ssl_verify: 0, verb: 0
|
|
24
|
+
auth: 0, body_data: 0, header: 1, headers: 0, ssl_verify: 0, timeout: 0, verb: 0
|
|
29
25
|
}.each do |method_name, read_args_count|
|
|
30
26
|
define_method method_name do |*args|
|
|
31
27
|
if args.count <= read_args_count
|
data/lib/eac_rest/response.rb
CHANGED
data/lib/eac_rest/version.rb
CHANGED
data/lib/eac_rest.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: eac_rest
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.14.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Eduardo H. Bogoni
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: eac_envs-http
|
|
@@ -16,58 +15,68 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - "~>"
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0.
|
|
18
|
+
version: '0.7'
|
|
19
|
+
- - ">="
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: 0.7.2
|
|
20
22
|
type: :runtime
|
|
21
23
|
prerelease: false
|
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
25
|
requirements:
|
|
24
26
|
- - "~>"
|
|
25
27
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0.
|
|
28
|
+
version: '0.7'
|
|
29
|
+
- - ">="
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: 0.7.2
|
|
27
32
|
- !ruby/object:Gem::Dependency
|
|
28
33
|
name: eac_fs
|
|
29
34
|
requirement: !ruby/object:Gem::Requirement
|
|
30
35
|
requirements:
|
|
31
36
|
- - "~>"
|
|
32
37
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0.
|
|
38
|
+
version: '0.20'
|
|
39
|
+
- - ">="
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: 0.20.3
|
|
34
42
|
type: :runtime
|
|
35
43
|
prerelease: false
|
|
36
44
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
45
|
requirements:
|
|
38
46
|
- - "~>"
|
|
39
47
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '0.
|
|
48
|
+
version: '0.20'
|
|
49
|
+
- - ">="
|
|
50
|
+
- !ruby/object:Gem::Version
|
|
51
|
+
version: 0.20.3
|
|
41
52
|
- !ruby/object:Gem::Dependency
|
|
42
53
|
name: eac_ruby_utils
|
|
43
54
|
requirement: !ruby/object:Gem::Requirement
|
|
44
55
|
requirements:
|
|
45
56
|
- - "~>"
|
|
46
57
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '0.
|
|
58
|
+
version: '0.136'
|
|
48
59
|
type: :runtime
|
|
49
60
|
prerelease: false
|
|
50
61
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
62
|
requirements:
|
|
52
63
|
- - "~>"
|
|
53
64
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0.
|
|
65
|
+
version: '0.136'
|
|
55
66
|
- !ruby/object:Gem::Dependency
|
|
56
67
|
name: eac_ruby_gem_support
|
|
57
68
|
requirement: !ruby/object:Gem::Requirement
|
|
58
69
|
requirements:
|
|
59
70
|
- - "~>"
|
|
60
71
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '0.
|
|
72
|
+
version: '0.15'
|
|
62
73
|
type: :development
|
|
63
74
|
prerelease: false
|
|
64
75
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
76
|
requirements:
|
|
66
77
|
- - "~>"
|
|
67
78
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '0.
|
|
69
|
-
description:
|
|
70
|
-
email:
|
|
79
|
+
version: '0.15'
|
|
71
80
|
executables: []
|
|
72
81
|
extensions: []
|
|
73
82
|
extra_rdoc_files: []
|
|
@@ -75,6 +84,7 @@ files:
|
|
|
75
84
|
- lib/eac_rest.rb
|
|
76
85
|
- lib/eac_rest/api.rb
|
|
77
86
|
- lib/eac_rest/entity.rb
|
|
87
|
+
- lib/eac_rest/entity/children.rb
|
|
78
88
|
- lib/eac_rest/entity/data.rb
|
|
79
89
|
- lib/eac_rest/entity/fetching.rb
|
|
80
90
|
- lib/eac_rest/error.rb
|
|
@@ -82,10 +92,8 @@ files:
|
|
|
82
92
|
- lib/eac_rest/request.rb
|
|
83
93
|
- lib/eac_rest/response.rb
|
|
84
94
|
- lib/eac_rest/version.rb
|
|
85
|
-
homepage:
|
|
86
95
|
licenses: []
|
|
87
96
|
metadata: {}
|
|
88
|
-
post_install_message:
|
|
89
97
|
rdoc_options: []
|
|
90
98
|
require_paths:
|
|
91
99
|
- lib
|
|
@@ -100,8 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
100
108
|
- !ruby/object:Gem::Version
|
|
101
109
|
version: '0'
|
|
102
110
|
requirements: []
|
|
103
|
-
rubygems_version: 3.
|
|
104
|
-
signing_key:
|
|
111
|
+
rubygems_version: 3.6.9
|
|
105
112
|
specification_version: 4
|
|
106
113
|
summary: A REST helper for Ruby.
|
|
107
114
|
test_files: []
|