stub_requests 0.1.9 → 0.1.10
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/.reek.yml +5 -9
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +23 -0
- data/README.md +9 -9
- data/Rakefile +7 -5
- data/lib/stub_requests.rb +30 -16
- data/lib/stub_requests/api.rb +45 -26
- data/lib/stub_requests/callback.rb +3 -1
- data/lib/stub_requests/callback_registry.rb +9 -55
- data/lib/stub_requests/concerns/argument_validation.rb +47 -0
- data/lib/stub_requests/concerns/property.rb +114 -0
- data/lib/stub_requests/concerns/property/validator.rb +137 -0
- data/lib/stub_requests/concerns/register_verb.rb +110 -0
- data/lib/stub_requests/configuration.rb +19 -2
- data/lib/stub_requests/dsl.rb +5 -6
- data/lib/stub_requests/dsl/method_definition.rb +2 -8
- data/lib/stub_requests/endpoint.rb +22 -23
- data/lib/stub_requests/endpoint_registry.rb +157 -0
- data/lib/stub_requests/exceptions.rb +28 -10
- data/lib/stub_requests/request_stub.rb +29 -14
- data/lib/stub_requests/service.rb +55 -7
- data/lib/stub_requests/service_registry.rb +30 -79
- data/lib/stub_requests/stub_registry.rb +22 -80
- data/lib/stub_requests/stub_requests.rb +8 -5
- data/lib/stub_requests/uri.rb +0 -17
- data/lib/stub_requests/utils/fuzzy.rb +70 -0
- data/lib/stub_requests/version.rb +1 -1
- data/lib/stub_requests/webmock/builder.rb +9 -51
- data/lib/stub_requests/webmock/stub_registry_extension.rb +1 -1
- data/lib/tasks/changelog.rake +1 -7
- data/stub_requests.gemspec +1 -0
- data/update_docs.sh +2 -2
- metadata +27 -8
- data/lib/stub_requests/argument_validation.rb +0 -48
- data/lib/stub_requests/endpoint_stub.rb +0 -89
- data/lib/stub_requests/endpoints.rb +0 -246
- data/lib/stub_requests/hash_util.rb +0 -32
- data/lib/stub_requests/observable.rb +0 -18
- data/lib/stub_requests/property.rb +0 -112
- data/lib/stub_requests/property/validator.rb +0 -135
@@ -36,7 +36,7 @@ module StubRequests
|
|
36
36
|
request_stub = request_stub_for_orig(request_signature)
|
37
37
|
return request_stub unless request_stub
|
38
38
|
|
39
|
-
StubRequests::StubRegistry.mark_as_responded(request_stub)
|
39
|
+
StubRequests::StubRegistry.instance.mark_as_responded(request_stub)
|
40
40
|
request_stub
|
41
41
|
end
|
42
42
|
end
|
data/lib/tasks/changelog.rake
CHANGED
@@ -12,18 +12,12 @@ task :changelog do
|
|
12
12
|
--no-verbose
|
13
13
|
--token
|
14
14
|
]
|
15
|
-
CHECKOUT_CHANGELOG_CMD ||= "git checkout -B update-changelog"
|
16
15
|
ADD_CHANGELOG_CMD ||= "git add --all"
|
17
16
|
COMMIT_CHANGELOG_CMD ||= "git commit -a -m 'Update changelog'"
|
18
|
-
GIT_PUSH_CMD ||= "git push -u origin update-changelog"
|
19
|
-
OPEN_PR_CMD ||= "hub pull-request -b master -m 'Update Changelog' -a mhenrixon -l changelog"
|
20
17
|
# rubocop:enable Style/MutableConstant
|
21
18
|
|
19
|
+
sh("git checkout master")
|
22
20
|
sh(*CHANGELOG_CMD.push(ENV["CHANGELOG_GITHUB_TOKEN"]))
|
23
|
-
sh(CHECKOUT_CHANGELOG_CMD)
|
24
21
|
sh(ADD_CHANGELOG_CMD)
|
25
22
|
sh(COMMIT_CHANGELOG_CMD)
|
26
|
-
sh(GIT_PUSH_CMD)
|
27
|
-
sh(OPEN_PR_CMD)
|
28
|
-
sh("git checkout master")
|
29
23
|
end
|
data/stub_requests.gemspec
CHANGED
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_dependency "webmock", ">= 2.3", "< 4.0"
|
35
35
|
spec.add_dependency "concurrent-ruby", "~> 1.0", "< 2"
|
36
36
|
spec.add_dependency "public_suffix", "~> 3.0", "< 4"
|
37
|
+
spec.add_dependency "jaro_winkler", "~> 1.0", "< 2"
|
37
38
|
|
38
39
|
# ===== Basics =====
|
39
40
|
spec.add_development_dependency "bundler", ">= 2.0"
|
data/update_docs.sh
CHANGED
@@ -9,7 +9,7 @@ if [[ "$(git diff --stat)" != "" ]]; then
|
|
9
9
|
git stash push -u -a -m "Before updating docs"
|
10
10
|
fi;
|
11
11
|
|
12
|
-
git
|
12
|
+
git pull --rebase
|
13
13
|
|
14
14
|
rake yard
|
15
15
|
|
@@ -24,7 +24,7 @@ mv doc/* ./
|
|
24
24
|
echo "Sending new documentation to github"
|
25
25
|
git add --all
|
26
26
|
git commit -a -m 'Update documentation'
|
27
|
-
git push
|
27
|
+
git push --force
|
28
28
|
|
29
29
|
if [[ $stash_created == 1 ]]; then
|
30
30
|
git stash pop
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stub_requests
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikael Henriksson
|
@@ -90,6 +90,26 @@ dependencies:
|
|
90
90
|
- - "<"
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: '4'
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: jaro_winkler
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - "~>"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '1.0'
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '2'
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '1.0'
|
110
|
+
- - "<"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '2'
|
93
113
|
- !ruby/object:Gem::Dependency
|
94
114
|
name: bundler
|
95
115
|
requirement: !ruby/object:Gem::Requirement
|
@@ -392,9 +412,12 @@ files:
|
|
392
412
|
- lib/rspec/subject_as_lambda.rb
|
393
413
|
- lib/stub_requests.rb
|
394
414
|
- lib/stub_requests/api.rb
|
395
|
-
- lib/stub_requests/argument_validation.rb
|
396
415
|
- lib/stub_requests/callback.rb
|
397
416
|
- lib/stub_requests/callback_registry.rb
|
417
|
+
- lib/stub_requests/concerns/argument_validation.rb
|
418
|
+
- lib/stub_requests/concerns/property.rb
|
419
|
+
- lib/stub_requests/concerns/property/validator.rb
|
420
|
+
- lib/stub_requests/concerns/register_verb.rb
|
398
421
|
- lib/stub_requests/configuration.rb
|
399
422
|
- lib/stub_requests/core_ext.rb
|
400
423
|
- lib/stub_requests/core_ext/all.rb
|
@@ -408,13 +431,8 @@ files:
|
|
408
431
|
- lib/stub_requests/dsl/define_method.rb
|
409
432
|
- lib/stub_requests/dsl/method_definition.rb
|
410
433
|
- lib/stub_requests/endpoint.rb
|
411
|
-
- lib/stub_requests/
|
412
|
-
- lib/stub_requests/endpoints.rb
|
434
|
+
- lib/stub_requests/endpoint_registry.rb
|
413
435
|
- lib/stub_requests/exceptions.rb
|
414
|
-
- lib/stub_requests/hash_util.rb
|
415
|
-
- lib/stub_requests/observable.rb
|
416
|
-
- lib/stub_requests/property.rb
|
417
|
-
- lib/stub_requests/property/validator.rb
|
418
436
|
- lib/stub_requests/request_stub.rb
|
419
437
|
- lib/stub_requests/service.rb
|
420
438
|
- lib/stub_requests/service_registry.rb
|
@@ -425,6 +443,7 @@ files:
|
|
425
443
|
- lib/stub_requests/uri/scheme.rb
|
426
444
|
- lib/stub_requests/uri/suffix.rb
|
427
445
|
- lib/stub_requests/uri/validator.rb
|
446
|
+
- lib/stub_requests/utils/fuzzy.rb
|
428
447
|
- lib/stub_requests/version.rb
|
429
448
|
- lib/stub_requests/webmock/builder.rb
|
430
449
|
- lib/stub_requests/webmock/stub_registry_extension.rb
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "addressable/uri"
|
4
|
-
require "public_suffix"
|
5
|
-
|
6
|
-
#
|
7
|
-
# Abstraction over WebMock to reduce duplication
|
8
|
-
#
|
9
|
-
# @author Mikael Henriksson <mikael@zoolutions.se>
|
10
|
-
# @since 0.1.0
|
11
|
-
#
|
12
|
-
module StubRequests
|
13
|
-
#
|
14
|
-
# Module ArgumentValidation provides validation of method arguments
|
15
|
-
#
|
16
|
-
# @author Mikael Henriksson <mikael@zoolutions.se>
|
17
|
-
#
|
18
|
-
module ArgumentValidation
|
19
|
-
extend self
|
20
|
-
|
21
|
-
#
|
22
|
-
# Require the value to be any of the types past in
|
23
|
-
#
|
24
|
-
#
|
25
|
-
# @param [Symbol] name the name of the argument
|
26
|
-
# @param [Object] value the actual value of the argument
|
27
|
-
# @param [Array, Class, Module] type nil the expected argument value class
|
28
|
-
#
|
29
|
-
# @raise [InvalidArgumentType] when the value is disallowed
|
30
|
-
#
|
31
|
-
# @return [void]
|
32
|
-
#
|
33
|
-
def validate!(name:, value:, type:)
|
34
|
-
validate_type!(:name, name, [Symbol, String]) unless name
|
35
|
-
validate_type!(name, value, type) if type
|
36
|
-
end
|
37
|
-
|
38
|
-
def validate_type!(name, value, type)
|
39
|
-
expected_types = Array(type).flatten
|
40
|
-
return if expected_types.any? { |is_a| value.is_a?(is_a) }
|
41
|
-
|
42
|
-
raise StubRequests::InvalidArgumentType,
|
43
|
-
name: name,
|
44
|
-
actual: value.class,
|
45
|
-
expected: expected_types
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Abstraction over WebMock to reduce duplication
|
5
|
-
#
|
6
|
-
# @author Mikael Henriksson <mikael@zoolutions.se>
|
7
|
-
# @since 0.1.0
|
8
|
-
#
|
9
|
-
module StubRequests
|
10
|
-
#
|
11
|
-
# Class Endpoint provides metrics for stubbed endpoints
|
12
|
-
#
|
13
|
-
# @author Mikael Henriksson <mikael@zoolutions.se>
|
14
|
-
# @since 0.1.2
|
15
|
-
#
|
16
|
-
class EndpointStub
|
17
|
-
# includes "Enumerable"
|
18
|
-
# @!parse include Enumerable
|
19
|
-
include Enumerable
|
20
|
-
# @api private
|
21
|
-
include Property
|
22
|
-
# @api private
|
23
|
-
|
24
|
-
#
|
25
|
-
# @!attribute [r] service_id
|
26
|
-
# @return [Symbol] the id of a {StubRequests::Service}
|
27
|
-
property :service_id, type: Symbol
|
28
|
-
#
|
29
|
-
# @!attribute [r] endpoint_id
|
30
|
-
# @return [Symbol] the id of an endpoint
|
31
|
-
property :endpoint_id, type: Symbol
|
32
|
-
#
|
33
|
-
# @!attribute [r] verb
|
34
|
-
# @return [String] the HTTP verb/method for this endpoint
|
35
|
-
property :verb, type: Symbol
|
36
|
-
#
|
37
|
-
# @!attribute [r] path
|
38
|
-
# @return [String] the full URI template for the endpoint
|
39
|
-
property :path, type: String
|
40
|
-
#
|
41
|
-
# @!attribute [r] stubs
|
42
|
-
# @return [Array] an array with recorded stubs
|
43
|
-
attr_reader :stubs
|
44
|
-
|
45
|
-
#
|
46
|
-
# Initializes a new Endpoint
|
47
|
-
#
|
48
|
-
# @param [Service] service a service
|
49
|
-
# @param [Endpoint] endpoint an endpoint
|
50
|
-
#
|
51
|
-
def initialize(service, endpoint)
|
52
|
-
self.service_id = service.id
|
53
|
-
self.endpoint_id = endpoint.id
|
54
|
-
self.verb = endpoint.verb
|
55
|
-
self.path = [service.uri, endpoint.path].join("/")
|
56
|
-
|
57
|
-
@stubs = Concurrent::Array.new
|
58
|
-
end
|
59
|
-
|
60
|
-
def find_by(attribute:, value:)
|
61
|
-
find { |request| request.send(attribute) == value }
|
62
|
-
end
|
63
|
-
|
64
|
-
#
|
65
|
-
# Required by Enumerable
|
66
|
-
#
|
67
|
-
#
|
68
|
-
# @return [Concurrent::Map<Symbol, Service>] an map with services
|
69
|
-
#
|
70
|
-
# @yield used by Enumerable
|
71
|
-
#
|
72
|
-
def each(&block)
|
73
|
-
stubs.each(&block)
|
74
|
-
end
|
75
|
-
|
76
|
-
#
|
77
|
-
# Records a WebMock::RequestStub as stubbed
|
78
|
-
#
|
79
|
-
# @param [WebMock::RequestStub] webmock_stub <description>
|
80
|
-
#
|
81
|
-
# @return [RequestStub]
|
82
|
-
#
|
83
|
-
def record(webmock_stub)
|
84
|
-
request_stub = RequestStub.new(self, webmock_stub)
|
85
|
-
stubs.push(request_stub)
|
86
|
-
request_stub
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
@@ -1,246 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Abstraction over WebMock to reduce duplication
|
5
|
-
#
|
6
|
-
# @author Mikael Henriksson <mikael@zoolutions.se>
|
7
|
-
# @since 0.1.0
|
8
|
-
#
|
9
|
-
module StubRequests
|
10
|
-
#
|
11
|
-
# Class Endpoints manages a collection of endpoints
|
12
|
-
#
|
13
|
-
# @author Mikael Henriksson <mikael@zoolutions.se>
|
14
|
-
#
|
15
|
-
class Endpoints
|
16
|
-
include Enumerable
|
17
|
-
|
18
|
-
#
|
19
|
-
# @!attribute [rw] service
|
20
|
-
# @return [Service] the service the collection belongs to
|
21
|
-
attr_reader :service
|
22
|
-
#
|
23
|
-
# @!attribute [rw] endpoints
|
24
|
-
# @return [Concurrent::Map<Symbol, Endpoint>] a map with endpoints
|
25
|
-
attr_reader :endpoints
|
26
|
-
|
27
|
-
def initialize(service)
|
28
|
-
@service = service
|
29
|
-
@endpoints = Concurrent::Map.new
|
30
|
-
end
|
31
|
-
|
32
|
-
#
|
33
|
-
# Required by Enumerable
|
34
|
-
#
|
35
|
-
# @return [Concurrent::Map<Symbol, Service>] a map with endpoints
|
36
|
-
#
|
37
|
-
# @yield used by Enumerable
|
38
|
-
#
|
39
|
-
def each(&block)
|
40
|
-
endpoints.each(&block)
|
41
|
-
end
|
42
|
-
|
43
|
-
#
|
44
|
-
# Registers an endpoint in the collection
|
45
|
-
#
|
46
|
-
# @param [Symbol] endpoint_id the id of this Endpoint
|
47
|
-
# @param [Symbol] verb a HTTP verb
|
48
|
-
# @param [String] path the URI to reach the endpoint
|
49
|
-
#
|
50
|
-
# @return [Endpoint]
|
51
|
-
#
|
52
|
-
def register(endpoint_id, verb, path)
|
53
|
-
endpoint =
|
54
|
-
if (endpoint = find(endpoint_id))
|
55
|
-
StubRequests.logger.warn("Endpoint already registered: #{endpoint}")
|
56
|
-
endpoint.update(verb, path)
|
57
|
-
else
|
58
|
-
Endpoint.new(service, endpoint_id, verb, path)
|
59
|
-
end
|
60
|
-
|
61
|
-
endpoints[endpoint.id] = endpoint
|
62
|
-
endpoint
|
63
|
-
end
|
64
|
-
|
65
|
-
#
|
66
|
-
# Convenience wrapper for register
|
67
|
-
#
|
68
|
-
#
|
69
|
-
# @example **Register a get endpoint**
|
70
|
-
# . get("documents/:id", as: :documents_show)
|
71
|
-
#
|
72
|
-
# @param [String] path the path to the endpoint
|
73
|
-
# @param [Symbol] as the id of the endpoint
|
74
|
-
#
|
75
|
-
# @return [Endpoint] the registered endpoint
|
76
|
-
#
|
77
|
-
def any(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
|
78
|
-
register(as, __method__, path)
|
79
|
-
end
|
80
|
-
|
81
|
-
#
|
82
|
-
# Convenience wrapper for register
|
83
|
-
#
|
84
|
-
#
|
85
|
-
# @example **Register a get endpoint**
|
86
|
-
# . get("documents/:id", as: :documents_show)
|
87
|
-
#
|
88
|
-
# @param [String] path the path to the endpoint
|
89
|
-
# @param [Symbol] as the id of the endpoint
|
90
|
-
#
|
91
|
-
# @return [Endpoint] the registered endpoint
|
92
|
-
#
|
93
|
-
def get(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
|
94
|
-
register(as, __method__, path)
|
95
|
-
end
|
96
|
-
|
97
|
-
#
|
98
|
-
# Register a :post endpoint
|
99
|
-
#
|
100
|
-
#
|
101
|
-
# @example **Register a post endpoint**
|
102
|
-
# . post("documents", as: :documents_create)
|
103
|
-
#
|
104
|
-
# @param [String] path the path to the endpoint
|
105
|
-
# @param [Symbol] as the id of the endpoint
|
106
|
-
#
|
107
|
-
# @return [Endpoint] the registered endpoint
|
108
|
-
#
|
109
|
-
def post(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
|
110
|
-
register(as, __method__, path)
|
111
|
-
end
|
112
|
-
|
113
|
-
#
|
114
|
-
# Register a :patch endpoint
|
115
|
-
#
|
116
|
-
#
|
117
|
-
# @example **Register a patch endpoint**
|
118
|
-
# . patch("documents/:id", as: :documents_update)
|
119
|
-
#
|
120
|
-
# @param [String] path the path to the endpoint
|
121
|
-
# @param [Symbol] as the id of the endpoint
|
122
|
-
#
|
123
|
-
# @return [Endpoint] the registered endpoint
|
124
|
-
#
|
125
|
-
def patch(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
|
126
|
-
register(as, __method__, path)
|
127
|
-
end
|
128
|
-
|
129
|
-
#
|
130
|
-
# Register a :put endpoint
|
131
|
-
#
|
132
|
-
#
|
133
|
-
# @example **Register a put endpoint**
|
134
|
-
# . put("documents/:id", as: :documents_update)
|
135
|
-
#
|
136
|
-
# @param [String] path the path to the endpoint
|
137
|
-
# @param [Symbol] as the id of the endpoint
|
138
|
-
#
|
139
|
-
# @return [Endpoint] the registered endpoint
|
140
|
-
#
|
141
|
-
def put(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
|
142
|
-
register(as, __method__, path)
|
143
|
-
end
|
144
|
-
|
145
|
-
#
|
146
|
-
# Register a :delete endpoint
|
147
|
-
#
|
148
|
-
#
|
149
|
-
# @example **Register a delete endpoint**
|
150
|
-
# . delete("documents/:id", as: :documents_destroy)
|
151
|
-
#
|
152
|
-
# @param [String] path the path to the endpoint
|
153
|
-
# @param [Symbol] as the id of the endpoint
|
154
|
-
#
|
155
|
-
# @return [Endpoint] the registered endpoint
|
156
|
-
#
|
157
|
-
def delete(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
|
158
|
-
register(as, __method__, path)
|
159
|
-
end
|
160
|
-
|
161
|
-
#
|
162
|
-
# Updates an endpoint
|
163
|
-
#
|
164
|
-
#
|
165
|
-
# @param [Symbol] endpoint_id the id of the endpoint
|
166
|
-
# @param [Symbol] verb a HTTP verb
|
167
|
-
# @param [String] path the path to the endpoint
|
168
|
-
#
|
169
|
-
# @raise [EndpointNotFound] when the endpoint couldn't be found
|
170
|
-
#
|
171
|
-
# @return [Endpoint] returns the updated endpoint
|
172
|
-
#
|
173
|
-
def update(endpoint_id, verb, path)
|
174
|
-
endpoint = find!(endpoint_id)
|
175
|
-
endpoint.update(verb, path)
|
176
|
-
end
|
177
|
-
|
178
|
-
#
|
179
|
-
# Removes an endpoint from the collection
|
180
|
-
#
|
181
|
-
#
|
182
|
-
# @param [Symbol] endpoint_id the id of the endpoint, `:file_service`
|
183
|
-
#
|
184
|
-
# @return [Endpoint] the endpoint that was removed
|
185
|
-
#
|
186
|
-
def remove(endpoint_id)
|
187
|
-
endpoints.delete(endpoint_id)
|
188
|
-
end
|
189
|
-
|
190
|
-
#
|
191
|
-
# Fetches an endpoint from the collection
|
192
|
-
#
|
193
|
-
#
|
194
|
-
# @param [<type>] endpoint_id <description>
|
195
|
-
#
|
196
|
-
# @return [Endpoint]
|
197
|
-
#
|
198
|
-
def find(endpoint_id)
|
199
|
-
endpoints[endpoint_id]
|
200
|
-
end
|
201
|
-
|
202
|
-
#
|
203
|
-
# Fetches an endpoint from the collection or raises an error
|
204
|
-
#
|
205
|
-
#
|
206
|
-
# @param [Symbol] endpoint_id the id of the endpoint
|
207
|
-
#
|
208
|
-
# @raise [EndpointNotFound] when an endpoint couldn't be found
|
209
|
-
#
|
210
|
-
# @return [Endpoint, nil]
|
211
|
-
#
|
212
|
-
def find!(endpoint_id)
|
213
|
-
find(endpoint_id) || raise(EndpointNotFound, "Couldn't find an endpoint with id=:#{endpoint_id}")
|
214
|
-
end
|
215
|
-
|
216
|
-
#
|
217
|
-
# Returns a descriptive string with all endpoints in the collection
|
218
|
-
#
|
219
|
-
#
|
220
|
-
# @return [String]
|
221
|
-
#
|
222
|
-
def to_s
|
223
|
-
[
|
224
|
-
+"#<#{self.class} endpoints=",
|
225
|
-
+endpoints_string,
|
226
|
-
+">",
|
227
|
-
].join("")
|
228
|
-
end
|
229
|
-
|
230
|
-
#
|
231
|
-
# Returns a nicely formatted string with an array of endpoints
|
232
|
-
#
|
233
|
-
#
|
234
|
-
# @return [<type>] <description>
|
235
|
-
#
|
236
|
-
def endpoints_string
|
237
|
-
"[#{endpoints_as_string}]"
|
238
|
-
end
|
239
|
-
|
240
|
-
private
|
241
|
-
|
242
|
-
def endpoints_as_string
|
243
|
-
endpoints.values.map(&:to_s).join(",") if endpoints.size.positive?
|
244
|
-
end
|
245
|
-
end
|
246
|
-
end
|