convenient_service 0.18.0 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/lib/convenient_service/commands/is_service.rb +28 -0
- data/lib/convenient_service/commands/is_service_class.rb +30 -0
- data/lib/convenient_service/commands.rb +4 -0
- data/lib/convenient_service/common/plugins.rb +2 -3
- data/lib/convenient_service/core/concern/class_methods.rb +3 -0
- data/lib/convenient_service/core/entities/config/entities/concerns/entities/stack.rb +22 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/container/concern/instance_methods.rb +1 -1
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/middleware_creators/observable/entities/event.rb +13 -15
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/middlewares/chain/commands/normalize_env.rb +55 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/middlewares/chain/commands.rb +1 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/middlewares/chain/concern/instance_methods.rb +3 -3
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/middlewares/classic.rb +14 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/stack.rb +22 -0
- data/lib/convenient_service/dependencies/built_in.rb +0 -7
- data/lib/convenient_service/dependencies/extractions/ds.rb +45 -0
- data/lib/convenient_service/dependencies/only_queries.rb +29 -0
- data/lib/convenient_service/dependencies/queries/gems/active_model.rb +38 -0
- data/lib/convenient_service/dependencies/queries/gems/logger.rb +39 -0
- data/lib/convenient_service/dependencies/queries/gems/paint.rb +39 -0
- data/lib/convenient_service/dependencies/queries/gems/rspec.rb +60 -0
- data/lib/convenient_service/dependencies/queries/ruby.rb +103 -0
- data/lib/convenient_service/dependencies/queries/version/null_version.rb +87 -0
- data/lib/convenient_service/dependencies/queries/version.rb +87 -0
- data/lib/convenient_service/dependencies/queries.rb +536 -0
- data/lib/convenient_service/dependencies.rb +2 -438
- data/lib/convenient_service/feature/configs/standard.rb +0 -2
- data/lib/convenient_service/service/configs/amazing_print_inspect/aliases.rb +7 -0
- data/lib/convenient_service/service/configs/amazing_print_inspect.rb +61 -0
- data/lib/convenient_service/service/configs/awesome_print_inspect.rb +1 -1
- data/lib/convenient_service/service/configs/{minimal.rb → essential.rb} +2 -107
- data/lib/convenient_service/service/configs/standard/v1.rb +5 -10
- data/lib/convenient_service/service/configs/standard.rb +19 -31
- data/lib/convenient_service/service/configs.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/and.rb +4 -1
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/empty.rb +4 -4
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb +7 -0
- data/lib/convenient_service/service/plugins/can_have_fallbacks/concern.rb +18 -0
- data/lib/convenient_service/service/plugins/can_have_fallbacks/exceptions.rb +22 -4
- data/lib/convenient_service/service/plugins/can_have_fallbacks/middleware.rb +3 -3
- data/lib/convenient_service/service/plugins/can_have_rollbacks/middleware.rb +66 -0
- data/lib/convenient_service/service/plugins/can_have_rollbacks.rb +3 -0
- data/lib/convenient_service/service/plugins/can_have_sequential_steps/entities/step_collection.rb +7 -0
- data/lib/convenient_service/service/plugins/can_have_steps/commands/is_step.rb +34 -0
- data/lib/convenient_service/service/plugins/can_have_steps/commands.rb +1 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/concern/instance_methods.rb +22 -14
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_method_step/can_be_executed/middleware.rb +1 -15
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_fallbacks/exceptions.rb +53 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_fallbacks/middleware.rb +60 -15
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_fallbacks.rb +1 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/has_amazing_print_inspect/concern.rb +46 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/has_amazing_print_inspect.rb +3 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/has_awesome_print_inspect/concern.rb +3 -2
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/has_result/middleware.rb +26 -1
- data/lib/convenient_service/service/plugins/can_have_steps.rb +41 -0
- data/lib/convenient_service/service/plugins/can_have_stubbed_results/commands/fetch_all_services_stubbed_results_cache.rb +2 -2
- data/lib/convenient_service/service/plugins/forbids_convenient_service_entities_as_constructor_arguments/exceptions.rb +53 -0
- data/lib/convenient_service/service/plugins/forbids_convenient_service_entities_as_constructor_arguments/middleware.rb +108 -0
- data/lib/convenient_service/service/plugins/forbids_convenient_service_entities_as_constructor_arguments.rb +4 -0
- data/lib/convenient_service/service/plugins/has_amazing_print_inspect/concern.rb +39 -0
- data/lib/convenient_service/service/plugins/has_amazing_print_inspect.rb +3 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_exception/concern.rb +32 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_exception.rb +3 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_step/concern.rb +7 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_amazing_print_inspect/concern.rb +41 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_amazing_print_inspect.rb +3 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_awesome_print_inspect/concern.rb +2 -2
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb +0 -140
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/code/plugins/has_amazing_print_inspect/concern.rb +46 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/code/plugins/has_amazing_print_inspect.rb +3 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/plugins/has_amazing_print_inspect/concern.rb +46 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/plugins/has_amazing_print_inspect.rb +3 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message/plugins/has_amazing_print_inspect/concern.rb +46 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message/plugins/has_amazing_print_inspect.rb +3 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/plugins/has_amazing_print_inspect/concern.rb +46 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/plugins/has_amazing_print_inspect.rb +3 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/helps_to_learn_similarities_with_common_objects/concern/instance_methods.rb +161 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/helps_to_learn_similarities_with_common_objects/concern.rb +27 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/helps_to_learn_similarities_with_common_objects/exceptions.rb +34 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/helps_to_learn_similarities_with_common_objects.rb +4 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins.rb +2 -0
- data/lib/convenient_service/service/plugins/has_mermaid_flowchart/concern.rb +6 -1
- data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/middleware.rb +1 -0
- data/lib/convenient_service/service/plugins.rb +3 -1
- data/lib/convenient_service/support/counter.rb +2 -0
- data/lib/convenient_service/support/middleware/stack_builder.rb +37 -0
- data/lib/convenient_service/support/thread_safe_counter.rb +1 -0
- data/lib/convenient_service/support.rb +0 -3
- data/lib/convenient_service/utils/object/get_own_method.rb +54 -0
- data/lib/convenient_service/utils/object/safe_send.rb +84 -0
- data/lib/convenient_service/utils/object.rb +24 -0
- data/lib/convenient_service/utils/string/enclose.rb +52 -0
- data/lib/convenient_service/utils/string.rb +5 -0
- data/lib/convenient_service/version.rb +1 -1
- data/lib/convenient_service.rb +62 -0
- metadata +149 -16
- data/lib/convenient_service/common/plugins/normalizes_env/middleware.rb +0 -31
- data/lib/convenient_service/common/plugins/normalizes_env.rb +0 -3
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_fallbacks/result.rb +0 -3
- data/lib/convenient_service/services.rb +0 -4
- data/lib/convenient_service/support/gems/active_model.rb +0 -36
- data/lib/convenient_service/support/gems/logger.rb +0 -37
- data/lib/convenient_service/support/gems/paint.rb +0 -37
- data/lib/convenient_service/support/gems/rspec.rb +0 -58
- data/lib/convenient_service/support/ruby.rb +0 -53
- data/lib/convenient_service/support/version/null_version.rb +0 -85
- data/lib/convenient_service/support/version.rb +0 -75
- /data/lib/convenient_service/{support → dependencies/queries}/gems.rb +0 -0
@@ -0,0 +1,536 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "queries/version"
|
4
|
+
require_relative "queries/ruby"
|
5
|
+
require_relative "queries/gems"
|
6
|
+
|
7
|
+
##
|
8
|
+
# `ConvenientService::Dependencies` can dynamically require plugins/extensions that have external dependencies.
|
9
|
+
#
|
10
|
+
# @internal
|
11
|
+
# https://github.com/marian13/convenient_service/wiki/Docs:-Dependencies
|
12
|
+
#
|
13
|
+
module ConvenientService
|
14
|
+
module Dependencies
|
15
|
+
##
|
16
|
+
# @internal
|
17
|
+
# IMPORTANT: Ensure this module NEVER uses any stdlibs that are not loaded by `rubygems` and external gems, since it is utilized in `gemspec`.
|
18
|
+
#
|
19
|
+
module Queries
|
20
|
+
##
|
21
|
+
# @internal
|
22
|
+
# NOTE: `module_function` does NOT define methods in a way to make them available by `extend` in other modules. That is why `extend self` is used.
|
23
|
+
#
|
24
|
+
extend self
|
25
|
+
|
26
|
+
##
|
27
|
+
# @api private
|
28
|
+
#
|
29
|
+
# @return [Boolean]
|
30
|
+
# @see ConvenientService.Dependencies.require_has_j_send_result_params_validations_using_active_model_validations
|
31
|
+
#
|
32
|
+
def support_has_j_send_result_params_validations_using_active_model_validations?
|
33
|
+
return false unless active_model.loaded?
|
34
|
+
return false if ruby.version >= 3.0 && active_model.version < 6.0
|
35
|
+
|
36
|
+
true
|
37
|
+
end
|
38
|
+
|
39
|
+
##
|
40
|
+
# @api private
|
41
|
+
#
|
42
|
+
# @return [Boolean]
|
43
|
+
#
|
44
|
+
# @see https://github.com/ruby/logger/commit/74690b87b15244e19dd91cd06ae295251e1e5781
|
45
|
+
#
|
46
|
+
def support_logger_non_integer_levels?
|
47
|
+
logger.version >= "1.3.0"
|
48
|
+
end
|
49
|
+
|
50
|
+
##
|
51
|
+
# @api public
|
52
|
+
#
|
53
|
+
# @return [Boolean]
|
54
|
+
# @note Expected to be called from app entry points like `initializers` in Rails.
|
55
|
+
#
|
56
|
+
def require_alias
|
57
|
+
require "convenient_service/alias"
|
58
|
+
end
|
59
|
+
|
60
|
+
##
|
61
|
+
# @api public
|
62
|
+
#
|
63
|
+
# @return [Boolean]
|
64
|
+
# @note Expected to be called from app entry points like `initializers` in Rails.
|
65
|
+
#
|
66
|
+
def require_assigns_attributes_in_constructor_using_active_model_attribute_assignment
|
67
|
+
##
|
68
|
+
# - https://edgeguides.rubyonrails.org/active_model_basics.html
|
69
|
+
# - https://api.rubyonrails.org/classes/ActiveModel.html
|
70
|
+
# - https://github.com/rails/rails/tree/main/activemodel
|
71
|
+
#
|
72
|
+
require "active_model"
|
73
|
+
|
74
|
+
require "convenient_service/common/plugins/assigns_attributes_in_constructor/using_active_model_attribute_assignment"
|
75
|
+
end
|
76
|
+
|
77
|
+
##
|
78
|
+
# @api public
|
79
|
+
#
|
80
|
+
# @return [Boolean]
|
81
|
+
# @note Expected to be called from app entry points like `initializers` in Rails.
|
82
|
+
#
|
83
|
+
def require_assigns_attributes_in_constructor_using_dry_initializer
|
84
|
+
##
|
85
|
+
# - https://dry-rb.org/gems/dry-initializer/main
|
86
|
+
# - https://github.com/dry-rb/dry-initializer
|
87
|
+
#
|
88
|
+
require "dry-initializer"
|
89
|
+
|
90
|
+
require "convenient_service/common/plugins/assigns_attributes_in_constructor/using_dry_initializer"
|
91
|
+
end
|
92
|
+
|
93
|
+
##
|
94
|
+
# @api public
|
95
|
+
#
|
96
|
+
# @return [Boolean]
|
97
|
+
# @note Expected to be called from app entry points like `initializers` in Rails.
|
98
|
+
#
|
99
|
+
def require_can_utilize_finite_loop
|
100
|
+
require "convenient_service/common/plugins/can_utilize_finite_loop"
|
101
|
+
end
|
102
|
+
|
103
|
+
##
|
104
|
+
# @api public
|
105
|
+
#
|
106
|
+
# @return [Boolean]
|
107
|
+
# @note Expected to be called from app entry points like `initializers` in Rails.
|
108
|
+
#
|
109
|
+
def require_has_attributes_using_active_model_attributes
|
110
|
+
##
|
111
|
+
# - https://edgeguides.rubyonrails.org/active_model_basics.html
|
112
|
+
# - https://api.rubyonrails.org/classes/ActiveModel.html
|
113
|
+
# - https://github.com/rails/rails/tree/main/activemodel
|
114
|
+
#
|
115
|
+
require "active_model"
|
116
|
+
|
117
|
+
require "convenient_service/common/plugins/has_attributes/using_active_model_attributes"
|
118
|
+
end
|
119
|
+
|
120
|
+
##
|
121
|
+
# @api public
|
122
|
+
#
|
123
|
+
# @return [Boolean]
|
124
|
+
# @note Expected to be called from app entry points like `initializers` in Rails.
|
125
|
+
#
|
126
|
+
def require_amazing_print_inspect
|
127
|
+
##
|
128
|
+
# - https://github.com/amazing-print/amazing_print
|
129
|
+
#
|
130
|
+
require "amazing_print"
|
131
|
+
|
132
|
+
require "convenient_service/service/plugins/has_amazing_print_inspect"
|
133
|
+
require "convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_amazing_print_inspect"
|
134
|
+
require "convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/plugins/has_amazing_print_inspect"
|
135
|
+
require "convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message/plugins/has_amazing_print_inspect"
|
136
|
+
require "convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/plugins/has_amazing_print_inspect"
|
137
|
+
require "convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/code/plugins/has_amazing_print_inspect"
|
138
|
+
require "convenient_service/service/plugins/can_have_steps/entities/step/plugins/has_amazing_print_inspect"
|
139
|
+
require "convenient_service/service/configs/amazing_print_inspect"
|
140
|
+
require "convenient_service/service/configs/amazing_print_inspect/aliases"
|
141
|
+
end
|
142
|
+
|
143
|
+
##
|
144
|
+
# @api public
|
145
|
+
#
|
146
|
+
# @return [Boolean]
|
147
|
+
# @note Expected to be called from app entry points like `initializers` in Rails.
|
148
|
+
#
|
149
|
+
def require_awesome_print_inspect
|
150
|
+
##
|
151
|
+
# - https://github.com/awesome-print/awesome_print
|
152
|
+
#
|
153
|
+
require "awesome_print"
|
154
|
+
|
155
|
+
require "convenient_service/service/plugins/has_awesome_print_inspect"
|
156
|
+
require "convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_awesome_print_inspect"
|
157
|
+
require "convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/plugins/has_awesome_print_inspect"
|
158
|
+
require "convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message/plugins/has_awesome_print_inspect"
|
159
|
+
require "convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/plugins/has_awesome_print_inspect"
|
160
|
+
require "convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/code/plugins/has_awesome_print_inspect"
|
161
|
+
require "convenient_service/service/plugins/can_have_steps/entities/step/plugins/has_awesome_print_inspect"
|
162
|
+
require "convenient_service/service/configs/awesome_print_inspect"
|
163
|
+
require "convenient_service/service/configs/awesome_print_inspect/aliases"
|
164
|
+
end
|
165
|
+
|
166
|
+
##
|
167
|
+
# @api public
|
168
|
+
#
|
169
|
+
# @return [Boolean]
|
170
|
+
# @note Expected to be called from app entry points like `initializers` in Rails.
|
171
|
+
#
|
172
|
+
# @see https://userdocs.convenientservice.org/troubleshooting/i18n_translate_wrong_number_of_arguments
|
173
|
+
#
|
174
|
+
def require_has_j_send_result_params_validations_using_active_model_validations
|
175
|
+
##
|
176
|
+
# - https://edgeguides.rubyonrails.org/active_model_basics.html
|
177
|
+
# - https://api.rubyonrails.org/classes/ActiveModel.html
|
178
|
+
# - https://github.com/rails/rails/tree/main/activemodel
|
179
|
+
#
|
180
|
+
require "active_model"
|
181
|
+
|
182
|
+
require "convenient_service/service/plugins/has_j_send_result_params_validations/using_active_model_validations"
|
183
|
+
end
|
184
|
+
|
185
|
+
##
|
186
|
+
# @api public
|
187
|
+
#
|
188
|
+
# @return [Boolean]
|
189
|
+
# @note Expected to be called from app entry points like `initializers` in Rails.
|
190
|
+
#
|
191
|
+
def require_has_j_send_result_params_validations_using_dry_validation
|
192
|
+
##
|
193
|
+
# - https://dry-rb.org/gems/dry-validation/main/
|
194
|
+
# - https://github.com/dry-rb/dry-validation
|
195
|
+
#
|
196
|
+
require "dry-validation"
|
197
|
+
|
198
|
+
require "convenient_service/service/plugins/has_j_send_result_params_validations/using_dry_validation"
|
199
|
+
end
|
200
|
+
|
201
|
+
##
|
202
|
+
# @api public
|
203
|
+
#
|
204
|
+
# @return [Boolean]
|
205
|
+
# @note Expected to be called from app entry points like `initializers` in Rails.
|
206
|
+
#
|
207
|
+
def require_rescues_result_unhandled_exceptions
|
208
|
+
require "convenient_service/service/plugins/rescues_result_unhandled_exceptions"
|
209
|
+
end
|
210
|
+
|
211
|
+
##
|
212
|
+
# @api private
|
213
|
+
#
|
214
|
+
# @return [Boolean]
|
215
|
+
# @note Expected to be called from app entry points like `initializers` in Rails.
|
216
|
+
#
|
217
|
+
def require_wraps_result_in_db_transaction
|
218
|
+
##
|
219
|
+
# - https://edgeguides.rubyonrails.org/active_record_basics.html
|
220
|
+
# - https://api.rubyonrails.org/classes/ActiveRecord.html
|
221
|
+
# - https://github.com/rails/rails/tree/main/activerecord
|
222
|
+
#
|
223
|
+
require "active_record"
|
224
|
+
|
225
|
+
require "convenient_service/service/plugins/wraps_result_in_db_transaction"
|
226
|
+
end
|
227
|
+
|
228
|
+
##
|
229
|
+
# @api private
|
230
|
+
#
|
231
|
+
# @return [Boolean]
|
232
|
+
# @note Expected to be called from `irb`, `pry`, `spec_helper.rb`, etc.
|
233
|
+
#
|
234
|
+
# @internal
|
235
|
+
# NOTE: `byebug` has C extensions, that is why it is NOT supported in JRuby.
|
236
|
+
# - https://github.com/deivid-rodriguez/byebug/tree/master/ext/byebug
|
237
|
+
# - https://github.com/deivid-rodriguez/byebug/issues/179#issuecomment-152727003
|
238
|
+
#
|
239
|
+
def require_development_tools(amazing_print: false, awesome_print: true)
|
240
|
+
##
|
241
|
+
# - https://github.com/awesome-print/awesome_print
|
242
|
+
#
|
243
|
+
require "awesome_print" if awesome_print
|
244
|
+
|
245
|
+
##
|
246
|
+
# - https://github.com/amazing-print/amazing_print
|
247
|
+
#
|
248
|
+
require "amazing_print" if amazing_print
|
249
|
+
|
250
|
+
##
|
251
|
+
# - https://github.com/gsamokovarov/break
|
252
|
+
#
|
253
|
+
require "break"
|
254
|
+
|
255
|
+
##
|
256
|
+
# - https://github.com/deivid-rodriguez/byebug
|
257
|
+
#
|
258
|
+
require "byebug" if ruby.mri?
|
259
|
+
|
260
|
+
##
|
261
|
+
# - https://github.com/ruby/debug
|
262
|
+
#
|
263
|
+
require "debug" if ruby.mri?
|
264
|
+
|
265
|
+
##
|
266
|
+
# - https://ruby-doc.org/stdlib-2.7.0/libdoc/ostruct/rdoc/OpenStruct.html
|
267
|
+
# - https://github.com/ruby/ostruct
|
268
|
+
#
|
269
|
+
require "ostruct"
|
270
|
+
|
271
|
+
##
|
272
|
+
# - https://github.com/janlelis/paint
|
273
|
+
#
|
274
|
+
require "paint"
|
275
|
+
|
276
|
+
##
|
277
|
+
# - https://github.com/rouge-ruby/rouge
|
278
|
+
#
|
279
|
+
require "rouge"
|
280
|
+
|
281
|
+
##
|
282
|
+
# - https://ruby-doc.org/stdlib-2.7.0/libdoc/tempfile/rdoc/Tempfile.html
|
283
|
+
# - https://github.com/ruby/tempfile
|
284
|
+
#
|
285
|
+
require "tempfile"
|
286
|
+
|
287
|
+
##
|
288
|
+
# - https://gist.github.com/marian13/5dade20a431d7254db30e543167058ce
|
289
|
+
#
|
290
|
+
require "convenient_service/dependencies/extractions/byebug_syntax_highlighting" if ruby.mri?
|
291
|
+
|
292
|
+
require "convenient_service/dependencies/extractions/b" if ruby.mri?
|
293
|
+
|
294
|
+
##
|
295
|
+
#
|
296
|
+
#
|
297
|
+
require "convenient_service/dependencies/extractions/ce"
|
298
|
+
|
299
|
+
##
|
300
|
+
#
|
301
|
+
#
|
302
|
+
require "convenient_service/dependencies/extractions/ds"
|
303
|
+
end
|
304
|
+
|
305
|
+
##
|
306
|
+
# @api private
|
307
|
+
#
|
308
|
+
# @return [Boolean]
|
309
|
+
# @note Expected to be called from `spec_helper.rb`.
|
310
|
+
#
|
311
|
+
def require_test_tools
|
312
|
+
##
|
313
|
+
# - https://github.com/faker-ruby/faker
|
314
|
+
#
|
315
|
+
require "faker"
|
316
|
+
|
317
|
+
##
|
318
|
+
# - https://ruby-doc.org/stdlib-2.7.0/libdoc/ostruct/rdoc/OpenStruct.html
|
319
|
+
# - https://github.com/ruby/ostruct
|
320
|
+
#
|
321
|
+
require "ostruct"
|
322
|
+
|
323
|
+
##
|
324
|
+
# - https://ruby-doc.org/stdlib-2.7.0/libdoc/tempfile/rdoc/Tempfile.html
|
325
|
+
# - https://github.com/ruby/tempfile
|
326
|
+
#
|
327
|
+
require "tempfile"
|
328
|
+
end
|
329
|
+
|
330
|
+
##
|
331
|
+
# @api public
|
332
|
+
#
|
333
|
+
# Loads RSpec extensions like `be_success` matcher, `stub_service` helper, etc.
|
334
|
+
#
|
335
|
+
# @return [Boolean]
|
336
|
+
# @note Expected to be called from `spec_helper.rb`.
|
337
|
+
#
|
338
|
+
def require_rspec_extentions
|
339
|
+
require "rspec/expectations"
|
340
|
+
require "rspec/matchers"
|
341
|
+
require "rspec/mocks"
|
342
|
+
|
343
|
+
require "convenient_service/rspec"
|
344
|
+
end
|
345
|
+
|
346
|
+
##
|
347
|
+
# @api private
|
348
|
+
#
|
349
|
+
# Loads standard config examples.
|
350
|
+
#
|
351
|
+
# @param version [String]
|
352
|
+
# @return [Boolean]
|
353
|
+
#
|
354
|
+
def require_standard_examples(version: "")
|
355
|
+
##
|
356
|
+
# - https://ruby-doc.org/stdlib-2.7.0/libdoc/date/rdoc/Date.html
|
357
|
+
# - https://ruby-doc.org/stdlib-2.7.0/libdoc/date/rdoc/DateTime.html
|
358
|
+
# - https://github.com/ruby/date
|
359
|
+
#
|
360
|
+
require "date"
|
361
|
+
|
362
|
+
##
|
363
|
+
# - https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html
|
364
|
+
# - https://github.com/flori/json
|
365
|
+
#
|
366
|
+
require "json"
|
367
|
+
|
368
|
+
##
|
369
|
+
# - https://github.com/jfelchner/ruby-progressbar
|
370
|
+
#
|
371
|
+
require "progressbar"
|
372
|
+
|
373
|
+
##
|
374
|
+
# - https://ruby-doc.org/stdlib-2.7.0/libdoc/webrick/rdoc/WEBrick.html
|
375
|
+
# - https://github.com/ruby/webrick
|
376
|
+
#
|
377
|
+
require "webrick"
|
378
|
+
|
379
|
+
##
|
380
|
+
# - https://ruby-doc.org/stdlib-2.7.0/libdoc/uri/rdoc/URI.html
|
381
|
+
# - https://github.com/ruby/uri
|
382
|
+
#
|
383
|
+
require "uri"
|
384
|
+
|
385
|
+
require ::File.join("convenient_service", "examples", "standard", version, "cowsay")
|
386
|
+
require ::File.join("convenient_service", "examples", "standard", version, "date_time")
|
387
|
+
require ::File.join("convenient_service", "examples", "standard", version, "factorial")
|
388
|
+
require ::File.join("convenient_service", "examples", "standard", version, "gemfile")
|
389
|
+
require ::File.join("convenient_service", "examples", "standard", version, "request_params")
|
390
|
+
require ::File.join("convenient_service", "examples", "standard", version, "comprehensive_suite") if version.empty?
|
391
|
+
end
|
392
|
+
|
393
|
+
##
|
394
|
+
# @api private
|
395
|
+
#
|
396
|
+
# Loads rails config examples.
|
397
|
+
#
|
398
|
+
# @param version [String]
|
399
|
+
# @return [Boolean]
|
400
|
+
#
|
401
|
+
def require_rails_examples(version: "")
|
402
|
+
##
|
403
|
+
# - https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html
|
404
|
+
# - https://github.com/flori/json
|
405
|
+
#
|
406
|
+
require "json"
|
407
|
+
|
408
|
+
##
|
409
|
+
# - https://github.com/jfelchner/ruby-progressbar
|
410
|
+
#
|
411
|
+
require "progressbar"
|
412
|
+
|
413
|
+
##
|
414
|
+
# - https://ruby-doc.org/stdlib-2.7.0/libdoc/webrick/rdoc/WEBrick.html
|
415
|
+
# - https://github.com/ruby/webrick
|
416
|
+
#
|
417
|
+
require "webrick"
|
418
|
+
|
419
|
+
require ::File.join("convenient_service", "examples", "rails", version, "gemfile")
|
420
|
+
end
|
421
|
+
|
422
|
+
##
|
423
|
+
# @api private
|
424
|
+
#
|
425
|
+
# Loads dry config examples.
|
426
|
+
#
|
427
|
+
# @param version [String]
|
428
|
+
# @return [Boolean]
|
429
|
+
#
|
430
|
+
def require_dry_examples(version: "")
|
431
|
+
##
|
432
|
+
# - https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html
|
433
|
+
# - https://github.com/flori/json
|
434
|
+
#
|
435
|
+
require "json"
|
436
|
+
|
437
|
+
##
|
438
|
+
# - https://github.com/jfelchner/ruby-progressbar
|
439
|
+
#
|
440
|
+
require "progressbar"
|
441
|
+
|
442
|
+
##
|
443
|
+
# - https://ruby-doc.org/stdlib-2.7.0/libdoc/webrick/rdoc/WEBrick.html
|
444
|
+
# - https://github.com/ruby/webrick
|
445
|
+
#
|
446
|
+
require "webrick"
|
447
|
+
|
448
|
+
require ::File.join("convenient_service", "examples", "dry", version, "gemfile")
|
449
|
+
end
|
450
|
+
|
451
|
+
##
|
452
|
+
# @api private
|
453
|
+
#
|
454
|
+
# @return [ConvenientService::Dependencies::Queries::Ruby]
|
455
|
+
#
|
456
|
+
def ruby
|
457
|
+
Ruby
|
458
|
+
end
|
459
|
+
|
460
|
+
##
|
461
|
+
# @api private
|
462
|
+
#
|
463
|
+
# @return [ConvenientService::Dependencies::Queries::RSpec]
|
464
|
+
#
|
465
|
+
def rspec
|
466
|
+
Gems::RSpec
|
467
|
+
end
|
468
|
+
|
469
|
+
##
|
470
|
+
# @api private
|
471
|
+
#
|
472
|
+
# @return [ConvenientService::Dependencies::Queries::Gems::ActiveModel]
|
473
|
+
#
|
474
|
+
def active_model
|
475
|
+
Gems::ActiveModel
|
476
|
+
end
|
477
|
+
|
478
|
+
##
|
479
|
+
# @api private
|
480
|
+
#
|
481
|
+
# @return [ConvenientService::Dependencies::Queries::Gems::Logger]
|
482
|
+
#
|
483
|
+
def logger
|
484
|
+
Gems::Logger
|
485
|
+
end
|
486
|
+
|
487
|
+
##
|
488
|
+
# @api private
|
489
|
+
#
|
490
|
+
# @return [ConvenientService::Dependencies::Queries::Gems::Paint]
|
491
|
+
#
|
492
|
+
def paint
|
493
|
+
Gems::Paint
|
494
|
+
end
|
495
|
+
|
496
|
+
##
|
497
|
+
# @api private
|
498
|
+
#
|
499
|
+
# @return [String]
|
500
|
+
#
|
501
|
+
# @internal
|
502
|
+
# IMPORTANT: `appraisal_name` MUST NOT be used inside the lib folder.
|
503
|
+
#
|
504
|
+
# NOTE: Previous appraisal name detection logic was relying on a a fact that `appraisals` gem sets `BUNDLE_GEMFILE` env variable.
|
505
|
+
# - https://github.com/thoughtbot/appraisal/blob/v2.4.1/lib/appraisal/command.rb#L36
|
506
|
+
#
|
507
|
+
# When `BUNDLE_GEMFILE` was an empty string, then `APPRAISAL_NAME` was resolved to an empty string as well. For example:
|
508
|
+
# ::ENV["BUNDLE_GEMFILE"]
|
509
|
+
# .to_s
|
510
|
+
# .then(&::File.method(:basename))
|
511
|
+
# .then { |name| name.end_with?(".gemfile") ? name.delete_suffix(".gemfile") : "" }
|
512
|
+
#
|
513
|
+
# Now, appraisal name detection logic is based on `ENV["APPRAISAL_NAME"]` passed for Taskfile.
|
514
|
+
#
|
515
|
+
#
|
516
|
+
# @internal
|
517
|
+
# TODO: Add direct specs.
|
518
|
+
#
|
519
|
+
def appraisal_name
|
520
|
+
::ENV["APPRAISAL_NAME"].to_s
|
521
|
+
end
|
522
|
+
|
523
|
+
##
|
524
|
+
# @api private
|
525
|
+
#
|
526
|
+
# @return [String]
|
527
|
+
#
|
528
|
+
# @internal
|
529
|
+
# TODO: Add direct specs.
|
530
|
+
#
|
531
|
+
def appraisal_name_for_coverage
|
532
|
+
appraisal_name.empty? ? "without_appraisal" : appraisal_name
|
533
|
+
end
|
534
|
+
end
|
535
|
+
end
|
536
|
+
end
|