convenient_service 0.20.0 → 0.21.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/README.md +8 -4
- data/lib/convenient_service/aliases.rb +113 -1
- data/lib/convenient_service/common/plugins/aliases.rb +69 -0
- data/lib/convenient_service/common/plugins/can_have_callbacks/entities/type_collection.rb +2 -2
- data/lib/convenient_service/common/plugins/has_instance_proxy/entities/instance_proxy.rb +8 -8
- data/lib/convenient_service/common.rb +14 -0
- data/lib/convenient_service/config.rb +8 -0
- data/lib/convenient_service/core/aliases.rb +84 -0
- data/lib/convenient_service/dependencies/built_in.rb +15 -1
- data/lib/convenient_service/dependencies/only_queries.rb +0 -6
- data/lib/convenient_service/dependencies/queries/gems/minitest.rb +55 -0
- data/lib/convenient_service/dependencies/queries/gems/rspec.rb +1 -1
- data/lib/convenient_service/dependencies/queries/gems.rb +2 -0
- data/lib/convenient_service/dependencies/queries/ruby.rb +2 -2
- data/lib/convenient_service/dependencies/queries.rb +67 -16
- data/lib/convenient_service/dependencies.rb +6 -6
- data/lib/convenient_service/extras/alias.rb +4 -1
- data/lib/convenient_service/feature/configs/standard.rb +34 -13
- data/lib/convenient_service/feature/core.rb +41 -0
- data/lib/convenient_service/feature/plugins/aliases.rb +29 -0
- data/lib/convenient_service/feature/plugins/can_have_rspec_stubbed_entries/concern.rb +34 -0
- data/lib/convenient_service/{rspec/helpers/classes/stub_entry/entities.rb → feature/plugins/can_have_rspec_stubbed_entries.rb} +1 -2
- data/lib/convenient_service/feature/plugins/can_have_stubbed_entries/commands/delete_feature_stubbed_entry.rb +71 -0
- data/lib/convenient_service/feature/plugins/can_have_stubbed_entries/commands/fetch_all_features_stubbed_entries_cache.rb +16 -2
- data/lib/convenient_service/feature/plugins/can_have_stubbed_entries/commands/fetch_feature_stubbed_entries_cache.rb +1 -1
- data/lib/convenient_service/feature/plugins/can_have_stubbed_entries/commands.rb +2 -0
- data/lib/convenient_service/feature/plugins/can_have_stubbed_entries/concern.rb +23 -0
- data/lib/convenient_service/feature/plugins/can_have_stubbed_entries/entities/feature_stub.rb +123 -0
- data/lib/convenient_service/feature/plugins/can_have_stubbed_entries/entities/feature_unstub.rb +122 -0
- data/lib/convenient_service/feature/plugins/can_have_stubbed_entries/entities/value_mock.rb +118 -0
- data/lib/convenient_service/feature/plugins/can_have_stubbed_entries/entities/value_unmock.rb +88 -0
- data/lib/convenient_service/feature/plugins/can_have_stubbed_entries/entities.rb +12 -0
- data/lib/convenient_service/feature/plugins/can_have_stubbed_entries.rb +1 -14
- data/lib/convenient_service/feature/plugins/has_amazing_print_inspect/concern.rb +34 -0
- data/lib/convenient_service/feature/{configs/standard/commands.rb → plugins/has_amazing_print_inspect.rb} +1 -2
- data/lib/convenient_service/feature/plugins/has_awesome_print_inspect/concern.rb +34 -0
- data/lib/convenient_service/{rspec/helpers/classes/stub_service/entities.rb → feature/plugins/has_awesome_print_inspect.rb} +1 -2
- data/lib/convenient_service/feature/plugins/has_inspect/concern.rb +27 -0
- data/lib/convenient_service/{service/configs/standard/commands.rb → feature/plugins/has_inspect.rb} +1 -2
- data/lib/convenient_service/feature/plugins.rb +1 -0
- data/lib/convenient_service/feature.rb +16 -0
- data/lib/convenient_service/logger.rb +11 -12
- data/lib/convenient_service/rspec/helpers/classes.rb +0 -2
- data/lib/convenient_service/rspec/helpers/stub_entry.rb +23 -5
- data/lib/convenient_service/rspec/helpers/stub_service.rb +79 -11
- data/lib/convenient_service/rspec/matchers/classes/cache_its_value.rb +2 -1
- data/lib/convenient_service/rspec/matchers/classes/delegate_to.rb +3 -5
- data/lib/convenient_service/rspec/matchers/classes/include_config.rb +4 -0
- data/lib/convenient_service/service/configs/aliases.rb +42 -0
- data/lib/convenient_service/service/configs/standard/aliases.rb +24 -0
- data/lib/convenient_service/service/configs/standard/v1.rb +17 -0
- data/lib/convenient_service/service/configs/standard.rb +50 -25
- data/lib/convenient_service/service/core.rb +39 -0
- data/lib/convenient_service/service/plugins/aliases.rb +48 -0
- data/lib/convenient_service/service/plugins/can_have_rollbacks/middleware.rb +33 -2
- data/lib/convenient_service/service/plugins/can_have_rspec_stubbed_results/concern.rb +34 -0
- data/lib/convenient_service/service/plugins/can_have_rspec_stubbed_results.rb +8 -0
- data/lib/convenient_service/service/plugins/can_have_stubbed_results/commands/delete_service_stubbed_result.rb +63 -0
- data/lib/convenient_service/service/plugins/can_have_stubbed_results/commands/fetch_all_services_stubbed_results_cache.rb +15 -10
- data/lib/convenient_service/service/plugins/can_have_stubbed_results/commands/fetch_service_stubbed_results_cache.rb +3 -3
- data/lib/convenient_service/service/plugins/can_have_stubbed_results/commands.rb +2 -0
- data/lib/convenient_service/service/plugins/can_have_stubbed_results/concern.rb +25 -0
- data/lib/convenient_service/service/plugins/can_have_stubbed_results/entities/result_mock.rb +254 -0
- data/lib/convenient_service/service/plugins/can_have_stubbed_results/entities/result_unmock.rb +82 -0
- data/lib/convenient_service/service/plugins/can_have_stubbed_results/entities/service_stub.rb +135 -0
- data/lib/convenient_service/service/plugins/can_have_stubbed_results/entities/service_unstub.rb +113 -0
- data/lib/convenient_service/service/plugins/can_have_stubbed_results/entities.rb +12 -0
- data/lib/convenient_service/service/plugins/can_have_stubbed_results.rb +1 -14
- data/lib/convenient_service/service/plugins/forbids_convenient_service_entities_as_constructor_arguments/exceptions.rb +84 -0
- data/lib/convenient_service/service/plugins/forbids_convenient_service_entities_as_constructor_arguments/middleware.rb +84 -32
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/concern.rb +42 -2
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_called/exceptions.rb +3 -2
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/concern/instance_methods.rb +5 -0
- data/lib/convenient_service/service.rb +16 -0
- data/lib/convenient_service/specification.rb +42 -12
- data/lib/convenient_service/support/backtrace_cleaner.rb +6 -7
- data/lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb +4 -0
- data/lib/convenient_service/support/middleware/stack_builder/entities/builders/ruby_middleware.rb +4 -0
- data/lib/convenient_service/support/unique_value.rb +4 -1
- data/lib/convenient_service/support.rb +13 -0
- data/lib/convenient_service/utils/array/find_last.rb +18 -9
- data/lib/convenient_service/utils/class/display_name.rb +9 -9
- data/lib/convenient_service/utils/enumerable/find_last.rb +48 -0
- data/lib/convenient_service/utils/enumerable.rb +20 -0
- data/lib/convenient_service/utils/hash/assert_valid_keys.rb +4 -4
- data/lib/convenient_service/utils/hash/except.rb +5 -4
- data/lib/convenient_service/utils/hash/triple_equality_compare.rb +8 -8
- data/lib/convenient_service/utils/kernel/silence_warnings.rb +4 -4
- data/lib/convenient_service/utils/module/fetch_own_const.rb +36 -31
- data/lib/convenient_service/utils/module/get_namespace.rb +26 -21
- data/lib/convenient_service/utils/module/get_own_const.rb +21 -16
- data/lib/convenient_service/utils/object/clamp_class.rb +50 -47
- data/lib/convenient_service/utils/object/duck_class.rb +84 -81
- data/lib/convenient_service/utils/object/get_own_method.rb +1 -1
- data/lib/convenient_service/utils/object/instance_variable_delete.rb +0 -3
- data/lib/convenient_service/utils/object/instance_variable_fetch.rb +0 -3
- data/lib/convenient_service/utils/object/memoize_including_falsy_values.rb +0 -3
- data/lib/convenient_service/utils/object/resolve_type.rb +13 -11
- data/lib/convenient_service/utils/object/safe_send.rb +2 -0
- data/lib/convenient_service/utils/string/enclose.rb +11 -11
- data/lib/convenient_service/utils/string/tab.rb +60 -0
- data/lib/convenient_service/utils/string.rb +5 -0
- data/lib/convenient_service/utils.rb +9 -0
- data/lib/convenient_service/version.rb +8 -1
- data/lib/convenient_service.rb +232 -14
- metadata +37 -754
- data/lib/convenient_service/feature/configs/standard/commands/is_feature.rb +0 -39
- data/lib/convenient_service/feature/configs/standard/commands/is_feature_class.rb +0 -41
- data/lib/convenient_service/rspec/helpers/classes/stub_entry/constants.rb +0 -25
- data/lib/convenient_service/rspec/helpers/classes/stub_entry/entities/stubbed_feature.rb +0 -128
- data/lib/convenient_service/rspec/helpers/classes/stub_entry/entities/value_spec.rb +0 -79
- data/lib/convenient_service/rspec/helpers/classes/stub_entry.rb +0 -48
- data/lib/convenient_service/rspec/helpers/classes/stub_service/constants.rb +0 -25
- data/lib/convenient_service/rspec/helpers/classes/stub_service/entities/result_spec.rb +0 -211
- data/lib/convenient_service/rspec/helpers/classes/stub_service/entities/stubbed_service.rb +0 -119
- data/lib/convenient_service/rspec/helpers/classes/stub_service.rb +0 -43
- data/lib/convenient_service/service/configs/standard/commands/is_service.rb +0 -39
- data/lib/convenient_service/service/configs/standard/commands/is_service_class.rb +0 -41
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# @author Marian Kostyk <mariankostyk13895@gmail.com>
|
|
5
|
+
# @license LGPLv3 <https://www.gnu.org/licenses/lgpl-3.0.html>
|
|
6
|
+
##
|
|
7
|
+
|
|
8
|
+
module ConvenientService
|
|
9
|
+
module Feature
|
|
10
|
+
module Plugins
|
|
11
|
+
module CanHaveStubbedEntries
|
|
12
|
+
module Entities
|
|
13
|
+
class FeatureStub
|
|
14
|
+
##
|
|
15
|
+
# @param feature_class [Class<ConvenientService::Feature>]
|
|
16
|
+
# @param entry_name [Symbol, String]
|
|
17
|
+
# @return [void]
|
|
18
|
+
#
|
|
19
|
+
# @internal
|
|
20
|
+
# NOTE: `@arguments = nil` means "match any arguments".
|
|
21
|
+
#
|
|
22
|
+
def initialize(feature_class:, entry_name:)
|
|
23
|
+
@feature_class = feature_class
|
|
24
|
+
@entry_name = entry_name
|
|
25
|
+
@arguments = nil
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
##
|
|
29
|
+
# @return [ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::FeatureStub]
|
|
30
|
+
#
|
|
31
|
+
def with_arguments(...)
|
|
32
|
+
@arguments = Support::Arguments.new(...)
|
|
33
|
+
|
|
34
|
+
self
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
##
|
|
38
|
+
# @return [ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::FeatureStub]
|
|
39
|
+
#
|
|
40
|
+
# @internal
|
|
41
|
+
# NOTE: `@arguments = nil` means "match any arguments".
|
|
42
|
+
#
|
|
43
|
+
def with_any_arguments(...)
|
|
44
|
+
@arguments = nil
|
|
45
|
+
|
|
46
|
+
self
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
##
|
|
50
|
+
# @return [ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::FeatureStub]
|
|
51
|
+
#
|
|
52
|
+
def without_arguments
|
|
53
|
+
@arguments = Support::Arguments.null_arguments
|
|
54
|
+
|
|
55
|
+
self
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
##
|
|
59
|
+
# @param value_mock [ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::ValueMock]
|
|
60
|
+
# @return [ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::FeatureStub]
|
|
61
|
+
#
|
|
62
|
+
def to(value_mock)
|
|
63
|
+
@value_mock = value_mock.for(feature_class, entry_name, arguments)
|
|
64
|
+
|
|
65
|
+
@value_mock.register
|
|
66
|
+
|
|
67
|
+
self
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
##
|
|
71
|
+
# @param value [Object] Can be any type.
|
|
72
|
+
# @return [ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::ValueMock]
|
|
73
|
+
#
|
|
74
|
+
def to_return_value(value)
|
|
75
|
+
@value_mock = Entities::ValueMock.new(value: value, feature_class: feature_class, entry_name: entry_name, arguments: arguments)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
##
|
|
79
|
+
# @param other [Object] Can be any type.
|
|
80
|
+
# @return [Boolean, nil]
|
|
81
|
+
#
|
|
82
|
+
def ==(other)
|
|
83
|
+
return unless other.instance_of?(self.class)
|
|
84
|
+
|
|
85
|
+
return false if feature_class != other.feature_class
|
|
86
|
+
return false if entry_name != other.entry_name
|
|
87
|
+
return false if arguments != other.arguments
|
|
88
|
+
return false if value_mock != other.value_mock
|
|
89
|
+
|
|
90
|
+
true
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
protected
|
|
94
|
+
|
|
95
|
+
##
|
|
96
|
+
# @!attribute [r] feature_class
|
|
97
|
+
# @return [Class<ConvenientService::Feature>]
|
|
98
|
+
#
|
|
99
|
+
attr_reader :feature_class
|
|
100
|
+
|
|
101
|
+
##
|
|
102
|
+
# @!attribute [r] entry_name
|
|
103
|
+
# @return [Symbol, String]
|
|
104
|
+
#
|
|
105
|
+
attr_reader :entry_name
|
|
106
|
+
|
|
107
|
+
##
|
|
108
|
+
# @!attribute [r] arguments
|
|
109
|
+
# @return [ConvenientService::Support::Arguments]
|
|
110
|
+
#
|
|
111
|
+
attr_reader :arguments
|
|
112
|
+
|
|
113
|
+
##
|
|
114
|
+
# @!attribute [r] value_mock
|
|
115
|
+
# @return [ConvenientService::RSpec::Helpers::Classes::StubEntry::Entities::ValueMock]
|
|
116
|
+
#
|
|
117
|
+
attr_reader :value_mock
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
data/lib/convenient_service/feature/plugins/can_have_stubbed_entries/entities/feature_unstub.rb
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# @author Marian Kostyk <mariankostyk13895@gmail.com>
|
|
5
|
+
# @license LGPLv3 <https://www.gnu.org/licenses/lgpl-3.0.html>
|
|
6
|
+
##
|
|
7
|
+
|
|
8
|
+
module ConvenientService
|
|
9
|
+
module Feature
|
|
10
|
+
module Plugins
|
|
11
|
+
module CanHaveStubbedEntries
|
|
12
|
+
module Entities
|
|
13
|
+
class FeatureUnstub
|
|
14
|
+
##
|
|
15
|
+
# @param feature_class [Class<ConvenientService::Feature>]
|
|
16
|
+
# @param entry_name [Symbol, String]
|
|
17
|
+
# @return [void]
|
|
18
|
+
#
|
|
19
|
+
# @internal
|
|
20
|
+
# NOTE: `@arguments = nil` means "match any arguments".
|
|
21
|
+
#
|
|
22
|
+
def initialize(feature_class:, entry_name:)
|
|
23
|
+
@feature_class = feature_class
|
|
24
|
+
@entry_name = entry_name
|
|
25
|
+
@arguments = nil
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
##
|
|
29
|
+
# @return [ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::FeatureUnstub]
|
|
30
|
+
#
|
|
31
|
+
def with_arguments(...)
|
|
32
|
+
@arguments = Support::Arguments.new(...)
|
|
33
|
+
|
|
34
|
+
self
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
##
|
|
38
|
+
# @return [ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::FeatureUnstub]
|
|
39
|
+
#
|
|
40
|
+
# @internal
|
|
41
|
+
# NOTE: `@arguments = nil` means "match any arguments".
|
|
42
|
+
#
|
|
43
|
+
def with_any_arguments(...)
|
|
44
|
+
@arguments = nil
|
|
45
|
+
|
|
46
|
+
self
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
##
|
|
50
|
+
# @return [ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::FeatureUnstub]
|
|
51
|
+
#
|
|
52
|
+
def without_arguments
|
|
53
|
+
@arguments = Support::Arguments.null_arguments
|
|
54
|
+
|
|
55
|
+
self
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
##
|
|
59
|
+
# @param value_unmock [ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::ValueUnmock]
|
|
60
|
+
# @return [ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::FeatureUnstub]
|
|
61
|
+
#
|
|
62
|
+
def to(value_unmock)
|
|
63
|
+
@value_unmock = value_unmock.for(feature_class, entry_name, arguments)
|
|
64
|
+
|
|
65
|
+
@value_unmock.register
|
|
66
|
+
|
|
67
|
+
self
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
##
|
|
71
|
+
# @return [ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::ValueUnmock]
|
|
72
|
+
#
|
|
73
|
+
def to_return_value_mock
|
|
74
|
+
@value_unmock = Entities::ValueUnmock.new(feature_class: feature_class, entry_name: entry_name, arguments: arguments)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
##
|
|
78
|
+
# @param other [Object] Can be any type.
|
|
79
|
+
# @return [Boolean, nil]
|
|
80
|
+
#
|
|
81
|
+
def ==(other)
|
|
82
|
+
return unless other.instance_of?(self.class)
|
|
83
|
+
|
|
84
|
+
return false if feature_class != other.feature_class
|
|
85
|
+
return false if entry_name != other.entry_name
|
|
86
|
+
return false if arguments != other.arguments
|
|
87
|
+
return false if value_unmock != other.value_unmock
|
|
88
|
+
|
|
89
|
+
true
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
protected
|
|
93
|
+
|
|
94
|
+
##
|
|
95
|
+
# @!attribute [r] feature_class
|
|
96
|
+
# @return [Class<ConvenientService::Feature>]
|
|
97
|
+
#
|
|
98
|
+
attr_reader :feature_class
|
|
99
|
+
|
|
100
|
+
##
|
|
101
|
+
# @!attribute [r] entry_name
|
|
102
|
+
# @return [Symbol, String]
|
|
103
|
+
#
|
|
104
|
+
attr_reader :entry_name
|
|
105
|
+
|
|
106
|
+
##
|
|
107
|
+
# @!attribute [r] arguments
|
|
108
|
+
# @return [ConvenientService::Support::Arguments]
|
|
109
|
+
#
|
|
110
|
+
attr_reader :arguments
|
|
111
|
+
|
|
112
|
+
##
|
|
113
|
+
# @!attribute [r] value_unmock
|
|
114
|
+
# @return [ConvenientService::RSpec::Helpers::Classes::StubEntry::Entities::ValueMock]
|
|
115
|
+
#
|
|
116
|
+
attr_reader :value_unmock
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# @author Marian Kostyk <mariankostyk13895@gmail.com>
|
|
5
|
+
# @license LGPLv3 <https://www.gnu.org/licenses/lgpl-3.0.html>
|
|
6
|
+
##
|
|
7
|
+
|
|
8
|
+
module ConvenientService
|
|
9
|
+
module Feature
|
|
10
|
+
module Plugins
|
|
11
|
+
module CanHaveStubbedEntries
|
|
12
|
+
module Entities
|
|
13
|
+
class ValueMock
|
|
14
|
+
##
|
|
15
|
+
# @!attribute [r] value
|
|
16
|
+
# @return [Object] Can be any type.
|
|
17
|
+
#
|
|
18
|
+
attr_reader :value
|
|
19
|
+
|
|
20
|
+
##
|
|
21
|
+
# @param value [Object] Can be any type.
|
|
22
|
+
# @param feature_class [Class<ConvenientService::Feature>]
|
|
23
|
+
# @param entry_name [Symbol, String]
|
|
24
|
+
# @param arguments [ConvenientService::Support::Arguments]
|
|
25
|
+
# @return [void]
|
|
26
|
+
#
|
|
27
|
+
def initialize(value:, feature_class: nil, entry_name: nil, arguments: nil)
|
|
28
|
+
@value = value
|
|
29
|
+
@feature_class = feature_class
|
|
30
|
+
@entry_name = entry_name
|
|
31
|
+
@arguments = arguments
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
##
|
|
35
|
+
# @param feature_class [Class<ConvenientService::Feature>]
|
|
36
|
+
# @param entry_name [Symbol, String]
|
|
37
|
+
# @param arguments [ConvenientService::Support::Arguments]
|
|
38
|
+
# @return [ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::ValueMock]
|
|
39
|
+
#
|
|
40
|
+
def for(feature_class, entry_name, arguments)
|
|
41
|
+
self.class.new(value: value, feature_class: feature_class, entry_name: entry_name, arguments: arguments)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
##
|
|
45
|
+
# @param block [Proc, nil]
|
|
46
|
+
# @return [ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::ValueMock]
|
|
47
|
+
#
|
|
48
|
+
def register(&block)
|
|
49
|
+
Commands::SetFeatureStubbedEntry[feature: feature_class, entry: entry_name, arguments: arguments, value: value]
|
|
50
|
+
|
|
51
|
+
return self unless block
|
|
52
|
+
|
|
53
|
+
begin
|
|
54
|
+
yield
|
|
55
|
+
ensure
|
|
56
|
+
Commands::DeleteFeatureStubbedEntry[feature: feature_class, entry: entry_name, arguments: arguments]
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
##
|
|
61
|
+
# @return [ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::ValueMock]
|
|
62
|
+
#
|
|
63
|
+
alias_method :apply, :register
|
|
64
|
+
|
|
65
|
+
##
|
|
66
|
+
# @return [ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::ValueMock]
|
|
67
|
+
#
|
|
68
|
+
def unregister
|
|
69
|
+
Commands::DeleteFeatureStubbedEntry[feature: feature_class, entry: entry_name, arguments: arguments]
|
|
70
|
+
|
|
71
|
+
self
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
##
|
|
75
|
+
# @return [ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::ValueMock]
|
|
76
|
+
#
|
|
77
|
+
alias_method :revert, :unregister
|
|
78
|
+
|
|
79
|
+
##
|
|
80
|
+
# @param other [Object] Can be any type.
|
|
81
|
+
# @return [Boolean, nil]
|
|
82
|
+
#
|
|
83
|
+
def ==(other)
|
|
84
|
+
return unless other.instance_of?(self.class)
|
|
85
|
+
|
|
86
|
+
return false if value != other.value
|
|
87
|
+
return false if feature_class != other.feature_class
|
|
88
|
+
return false if entry_name != other.entry_name
|
|
89
|
+
return false if arguments != other.arguments
|
|
90
|
+
|
|
91
|
+
true
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
protected
|
|
95
|
+
|
|
96
|
+
##
|
|
97
|
+
# @!attribute [r] feature_class
|
|
98
|
+
# @return [Class<ConvenientService::Feature>]
|
|
99
|
+
#
|
|
100
|
+
attr_reader :feature_class
|
|
101
|
+
|
|
102
|
+
##
|
|
103
|
+
# @!attribute [r] entry_name
|
|
104
|
+
# @return [Symbol, String]
|
|
105
|
+
#
|
|
106
|
+
attr_reader :entry_name
|
|
107
|
+
|
|
108
|
+
##
|
|
109
|
+
# @!attribute [r] arguments
|
|
110
|
+
# @return [ConvenientService::Support::Arguments]
|
|
111
|
+
#
|
|
112
|
+
attr_reader :arguments
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# @author Marian Kostyk <mariankostyk13895@gmail.com>
|
|
5
|
+
# @license LGPLv3 <https://www.gnu.org/licenses/lgpl-3.0.html>
|
|
6
|
+
##
|
|
7
|
+
|
|
8
|
+
module ConvenientService
|
|
9
|
+
module Feature
|
|
10
|
+
module Plugins
|
|
11
|
+
module CanHaveStubbedEntries
|
|
12
|
+
module Entities
|
|
13
|
+
class ValueUnmock
|
|
14
|
+
##
|
|
15
|
+
# @param feature_class [Class<ConvenientService::Feature>]
|
|
16
|
+
# @param entry_name [Symbol, String]
|
|
17
|
+
# @param arguments [ConvenientService::Support::Arguments]
|
|
18
|
+
# @return [void]
|
|
19
|
+
#
|
|
20
|
+
def initialize(feature_class: nil, entry_name: nil, arguments: nil)
|
|
21
|
+
@feature_class = feature_class
|
|
22
|
+
@entry_name = entry_name
|
|
23
|
+
@arguments = arguments
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
##
|
|
27
|
+
# @param feature_class [Class<ConvenientService::Feature>]
|
|
28
|
+
# @param entry_name [Symbol, String]
|
|
29
|
+
# @param arguments [ConvenientService::Support::Arguments]
|
|
30
|
+
# @return [ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::ValueUnmock]
|
|
31
|
+
#
|
|
32
|
+
def for(feature_class, entry_name, arguments)
|
|
33
|
+
self.class.new(feature_class: feature_class, entry_name: entry_name, arguments: arguments)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
##
|
|
37
|
+
# @return [ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::ValueUnmock]
|
|
38
|
+
#
|
|
39
|
+
def register
|
|
40
|
+
Commands::DeleteFeatureStubbedEntry[feature: feature_class, entry: entry_name, arguments: arguments]
|
|
41
|
+
|
|
42
|
+
self
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
##
|
|
46
|
+
# @return [ConvenientService::Feature::Plugins::CanHaveStubbedEntries::Entities::ValueUnmock]
|
|
47
|
+
#
|
|
48
|
+
alias_method :apply, :register
|
|
49
|
+
|
|
50
|
+
##
|
|
51
|
+
# @param other [Object] Can be any type.
|
|
52
|
+
# @return [Boolean, nil]
|
|
53
|
+
#
|
|
54
|
+
def ==(other)
|
|
55
|
+
return unless other.instance_of?(self.class)
|
|
56
|
+
|
|
57
|
+
return false if feature_class != other.feature_class
|
|
58
|
+
return false if entry_name != other.entry_name
|
|
59
|
+
return false if arguments != other.arguments
|
|
60
|
+
|
|
61
|
+
true
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
protected
|
|
65
|
+
|
|
66
|
+
##
|
|
67
|
+
# @!attribute [r] feature_class
|
|
68
|
+
# @return [Class<ConvenientService::Feature>]
|
|
69
|
+
#
|
|
70
|
+
attr_reader :feature_class
|
|
71
|
+
|
|
72
|
+
##
|
|
73
|
+
# @!attribute [r] entry_name
|
|
74
|
+
# @return [Symbol, String]
|
|
75
|
+
#
|
|
76
|
+
attr_reader :entry_name
|
|
77
|
+
|
|
78
|
+
##
|
|
79
|
+
# @!attribute [r] arguments
|
|
80
|
+
# @return [ConvenientService::Support::Arguments]
|
|
81
|
+
#
|
|
82
|
+
attr_reader :arguments
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# @author Marian Kostyk <mariankostyk13895@gmail.com>
|
|
5
|
+
# @license LGPLv3 <https://www.gnu.org/licenses/lgpl-3.0.html>
|
|
6
|
+
##
|
|
7
|
+
|
|
8
|
+
require_relative "entities/feature_stub"
|
|
9
|
+
require_relative "entities/feature_unstub"
|
|
10
|
+
|
|
11
|
+
require_relative "entities/value_mock"
|
|
12
|
+
require_relative "entities/value_unmock"
|
|
@@ -7,18 +7,5 @@
|
|
|
7
7
|
|
|
8
8
|
require_relative "can_have_stubbed_entries/commands"
|
|
9
9
|
require_relative "can_have_stubbed_entries/concern"
|
|
10
|
+
require_relative "can_have_stubbed_entries/entities"
|
|
10
11
|
require_relative "can_have_stubbed_entries/middleware"
|
|
11
|
-
|
|
12
|
-
module ConvenientService
|
|
13
|
-
module Feature
|
|
14
|
-
module Plugins
|
|
15
|
-
module CanHaveStubbedEntries
|
|
16
|
-
class << self
|
|
17
|
-
def set_feature_stubbed_entry(feature, entry, arguments, value)
|
|
18
|
-
Commands::SetFeatureStubbedEntry[feature: feature, entry: entry, arguments: arguments, value: value]
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# @author Marian Kostyk <mariankostyk13895@gmail.com>
|
|
5
|
+
# @license LGPLv3 <https://www.gnu.org/licenses/lgpl-3.0.html>
|
|
6
|
+
##
|
|
7
|
+
|
|
8
|
+
module ConvenientService
|
|
9
|
+
module Feature
|
|
10
|
+
module Plugins
|
|
11
|
+
module HasAmazingPrintInspect
|
|
12
|
+
module Concern
|
|
13
|
+
include Support::Concern
|
|
14
|
+
|
|
15
|
+
instance_methods do
|
|
16
|
+
##
|
|
17
|
+
# @return [String]
|
|
18
|
+
#
|
|
19
|
+
def inspect
|
|
20
|
+
metadata = {
|
|
21
|
+
ConvenientService: {
|
|
22
|
+
entity: "Feature",
|
|
23
|
+
name: Utils::Class.display_name(self.class)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
metadata.ai
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# @author Marian Kostyk <mariankostyk13895@gmail.com>
|
|
5
|
+
# @license LGPLv3 <https://www.gnu.org/licenses/lgpl-3.0.html>
|
|
6
|
+
##
|
|
7
|
+
|
|
8
|
+
module ConvenientService
|
|
9
|
+
module Feature
|
|
10
|
+
module Plugins
|
|
11
|
+
module HasAwesomePrintInspect
|
|
12
|
+
module Concern
|
|
13
|
+
include Support::Concern
|
|
14
|
+
|
|
15
|
+
instance_methods do
|
|
16
|
+
##
|
|
17
|
+
# @return [String]
|
|
18
|
+
#
|
|
19
|
+
def inspect
|
|
20
|
+
metadata = {
|
|
21
|
+
ConvenientService: {
|
|
22
|
+
entity: "Feature",
|
|
23
|
+
name: Utils::Class.display_name(self.class)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
metadata.ai
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# @author Marian Kostyk <mariankostyk13895@gmail.com>
|
|
5
|
+
# @license LGPLv3 <https://www.gnu.org/licenses/lgpl-3.0.html>
|
|
6
|
+
##
|
|
7
|
+
|
|
8
|
+
module ConvenientService
|
|
9
|
+
module Feature
|
|
10
|
+
module Plugins
|
|
11
|
+
module HasInspect
|
|
12
|
+
module Concern
|
|
13
|
+
include Support::Concern
|
|
14
|
+
|
|
15
|
+
instance_methods do
|
|
16
|
+
##
|
|
17
|
+
# @return [String]
|
|
18
|
+
#
|
|
19
|
+
def inspect
|
|
20
|
+
"<#{Utils::Class.display_name(self.class)}>"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -8,3 +8,19 @@
|
|
|
8
8
|
require_relative "feature/core"
|
|
9
9
|
require_relative "feature/plugins"
|
|
10
10
|
require_relative "feature/configs"
|
|
11
|
+
|
|
12
|
+
module ConvenientService
|
|
13
|
+
##
|
|
14
|
+
# Intermediate module/namespace to access core, plugins and configs that can be applied only to features.
|
|
15
|
+
#
|
|
16
|
+
# @api public
|
|
17
|
+
# @since 1.0.0
|
|
18
|
+
# @return [Module]
|
|
19
|
+
#
|
|
20
|
+
# @note Feature core expected to be used via {ConvenientService::Feature::Core}.
|
|
21
|
+
# @note Feature configs expected to be used via {ConvenientService::Feature::Standard::Config} alias.
|
|
22
|
+
# @note Feature plugins expected to be used via {ConvenientService::Plugins::Feature} alias.
|
|
23
|
+
#
|
|
24
|
+
module Feature
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -5,18 +5,17 @@
|
|
|
5
5
|
# @license LGPLv3 <https://www.gnu.org/licenses/lgpl-3.0.html>
|
|
6
6
|
##
|
|
7
7
|
|
|
8
|
-
##
|
|
9
|
-
# @example Usage.
|
|
10
|
-
#
|
|
11
|
-
# ConvenientService::Logger.instance
|
|
12
|
-
# ConvenientService::Logger.instance.level = ::Logger::WARN
|
|
13
|
-
# ConvenientService::Logger.instance.warn { "log message" }
|
|
14
|
-
#
|
|
15
|
-
# @see https://ruby-doc.org/stdlib-2.7.0/libdoc/logger/rdoc/Logger.html
|
|
16
|
-
# @see https://newbedev.com/ruby-create-singleton-with-parameters
|
|
17
|
-
#
|
|
18
8
|
module ConvenientService
|
|
19
9
|
##
|
|
10
|
+
# @example Usage.
|
|
11
|
+
#
|
|
12
|
+
# ConvenientService::Logger.instance
|
|
13
|
+
# ConvenientService::Logger.instance.level = ::Logger::WARN
|
|
14
|
+
# ConvenientService::Logger.instance.warn { "log message" }
|
|
15
|
+
#
|
|
16
|
+
# @see https://ruby-doc.org/stdlib-2.7.0/libdoc/logger/rdoc/Logger.html
|
|
17
|
+
# @see https://newbedev.com/ruby-create-singleton-with-parameters
|
|
18
|
+
#
|
|
20
19
|
# @internal
|
|
21
20
|
# TODO: Custom matcher to track log messages.
|
|
22
21
|
# TODO: Fallback for logging methods. Just like with `#clean` in backtrace cleaner.
|
|
@@ -115,9 +114,9 @@ module ConvenientService
|
|
|
115
114
|
#
|
|
116
115
|
def level=(severity)
|
|
117
116
|
if Dependencies.support_logger_non_integer_levels?
|
|
118
|
-
super
|
|
117
|
+
super
|
|
119
118
|
elsif severity.instance_of?(::Integer)
|
|
120
|
-
super
|
|
119
|
+
super
|
|
121
120
|
else
|
|
122
121
|
::Warning.warn <<~MESSAGE
|
|
123
122
|
`ConvenientService.logger.level` is reset from `#{severity}` to `Logger::INFO`.
|