convenient_service 0.3.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dev/.tmuxinator.yml +17 -0
- data/CHANGELOG.md +22 -0
- data/README.md +8 -8
- data/Taskfile.yml +30 -0
- data/convenient_service.gemspec +1 -1
- data/lib/convenient_service/aliases.rb +5 -0
- data/lib/convenient_service/rspec/matchers/custom/results/base.rb +245 -0
- data/lib/convenient_service/rspec/matchers/custom/results/be_error.rb +3 -139
- data/lib/convenient_service/rspec/matchers/custom/results/be_failure.rb +3 -106
- data/lib/convenient_service/rspec/matchers/custom/results/be_not_error.rb +20 -0
- data/lib/convenient_service/rspec/matchers/custom/results/be_not_failure.rb +20 -0
- data/lib/convenient_service/rspec/matchers/custom/results/be_not_success.rb +20 -0
- data/lib/convenient_service/rspec/matchers/custom/results/be_success.rb +3 -112
- data/lib/convenient_service/rspec/matchers/custom/results.rb +6 -0
- data/lib/convenient_service/rspec/matchers/results/be_not_error.rb +15 -0
- data/lib/convenient_service/rspec/matchers/results/be_not_failure.rb +15 -0
- data/lib/convenient_service/rspec/matchers/results/be_not_success.rb +15 -0
- data/lib/convenient_service/rspec/matchers/results.rb +8 -0
- data/lib/convenient_service/service/plugins/has_result/constants.rb +1 -4
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/data.rb +8 -0
- data/lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/status.rb +4 -0
- data/lib/convenient_service/service/plugins/has_result_method_steps/middleware.rb +1 -4
- data/lib/convenient_service/service/plugins/has_result_steps/concern.rb +8 -2
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method_caller.rb +1 -1
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method_key.rb +1 -1
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method_name.rb +1 -1
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/define_method_in_container.rb +15 -8
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities.rb +0 -1
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/errors.rb +15 -1
- data/lib/convenient_service/service/plugins/has_result_steps/entities/step/concern/instance_methods.rb +10 -0
- data/lib/convenient_service/support/dependency_container/commands/create_methods_module.rb +27 -0
- data/lib/convenient_service/support/dependency_container/commands/import_method.rb +111 -0
- data/lib/convenient_service/support/dependency_container/commands.rb +4 -0
- data/lib/convenient_service/support/dependency_container/constants.rb +15 -0
- data/lib/convenient_service/support/dependency_container/entities/method.rb +121 -0
- data/lib/convenient_service/support/dependency_container/entities/method_collection.rb +98 -0
- data/lib/convenient_service/support/dependency_container/entities/namespace.rb +69 -0
- data/lib/convenient_service/support/dependency_container/entities/namespace_collection.rb +103 -0
- data/lib/convenient_service/support/dependency_container/entities.rb +6 -0
- data/lib/convenient_service/support/dependency_container/errors.rb +49 -0
- data/lib/convenient_service/support/dependency_container/export.rb +30 -0
- data/lib/convenient_service/support/dependency_container/import.rb +30 -0
- data/lib/convenient_service/support/dependency_container.rb +9 -0
- data/lib/convenient_service/support/gems/rspec.rb +9 -2
- data/lib/convenient_service/support/not_passed.rb +7 -0
- data/lib/convenient_service/support/raw_value.rb +52 -0
- data/lib/convenient_service/support.rb +3 -0
- data/lib/convenient_service/utils/module/fetch_own_const.rb +88 -0
- data/lib/convenient_service/utils/module/include_module.rb +38 -0
- data/lib/convenient_service/utils/module.rb +10 -0
- data/lib/convenient_service/utils/proc/conjunct.rb +1 -1
- data/lib/convenient_service/utils/string/split.rb +41 -0
- data/lib/convenient_service/utils/string.rb +5 -0
- data/lib/convenient_service/version.rb +1 -1
- data/lib/convenient_service.rb +6 -0
- metadata +33 -8
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/values/raw.rb +0 -48
- data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/values.rb +0 -3
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
4
|
+
# @example Two args form (works as GetOwnConst).
|
5
|
+
# module Test
|
6
|
+
# end
|
7
|
+
#
|
8
|
+
# ConvenientService::Utils::Module::FetchOwnConst.call(Test, :File)
|
9
|
+
# # => nil, not File from Ruby Core.
|
10
|
+
#
|
11
|
+
# module Test
|
12
|
+
# class File
|
13
|
+
# end
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# ConvenientService::Utils::Module::FetchOwnConst.call(Test, :File)
|
17
|
+
# # => Test::File
|
18
|
+
#
|
19
|
+
# @example Two args + block form.
|
20
|
+
# module Test
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# ConvenientService::Utils::Module::FetchOwnConst.call(Test, :File) { Class.new }
|
24
|
+
# # => Test::File, just created.
|
25
|
+
#
|
26
|
+
# module Test
|
27
|
+
# class File
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# ConvenientService::Utils::Module::FetchOwnConst.call(Test, :File)
|
32
|
+
# # => Test::File, already existing.
|
33
|
+
#
|
34
|
+
module ConvenientService
|
35
|
+
module Utils
|
36
|
+
module Module
|
37
|
+
class FetchOwnConst < Support::Command
|
38
|
+
##
|
39
|
+
# @!attribute [r] mod
|
40
|
+
# @return [Class, Module]
|
41
|
+
#
|
42
|
+
attr_reader :mod
|
43
|
+
|
44
|
+
##
|
45
|
+
# @!attribute [r] const_name
|
46
|
+
# @return [Symbol]
|
47
|
+
#
|
48
|
+
attr_reader :const_name
|
49
|
+
|
50
|
+
##
|
51
|
+
# @!attribute [r] fallback_block
|
52
|
+
# @return [Proc, nil]
|
53
|
+
#
|
54
|
+
attr_reader :fallback_block
|
55
|
+
|
56
|
+
##
|
57
|
+
# @param mod [Class, Module]
|
58
|
+
# @param const_name [Symbol]
|
59
|
+
# @param fallback_block [Proc]
|
60
|
+
# @return [void]
|
61
|
+
#
|
62
|
+
def initialize(mod, const_name, &fallback_block)
|
63
|
+
@mod = mod
|
64
|
+
@const_name = const_name
|
65
|
+
@fallback_block = fallback_block
|
66
|
+
end
|
67
|
+
|
68
|
+
##
|
69
|
+
# @return [Object] Value of own const. Can be any type.
|
70
|
+
#
|
71
|
+
# @internal
|
72
|
+
# TODO: Wrap by mutex?
|
73
|
+
#
|
74
|
+
def call
|
75
|
+
##
|
76
|
+
# NOTE: > If `inherit` is `false`, the lookup only checks the constants in the receiver:
|
77
|
+
# https://ruby-doc.org/core-3.0.0/Module.html#method-i-const_defined-3F
|
78
|
+
#
|
79
|
+
return mod.const_get(const_name, false) if mod.const_defined?(const_name, false)
|
80
|
+
|
81
|
+
return mod.const_set(const_name, fallback_block.call) if fallback_block
|
82
|
+
|
83
|
+
nil
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Utils
|
5
|
+
module Module
|
6
|
+
class IncludeModule < Support::Command
|
7
|
+
##
|
8
|
+
# @!attribute [r] mod
|
9
|
+
# @return [Module]
|
10
|
+
#
|
11
|
+
attr_reader :mod
|
12
|
+
|
13
|
+
##
|
14
|
+
# @!attribute [r] other_mod
|
15
|
+
# @return [Module]
|
16
|
+
#
|
17
|
+
attr_reader :other_mod
|
18
|
+
|
19
|
+
##
|
20
|
+
# @param mod [Module]
|
21
|
+
# @param other_mod [Module]
|
22
|
+
# @return [void]
|
23
|
+
#
|
24
|
+
def initialize(mod, other_mod)
|
25
|
+
@mod = mod
|
26
|
+
@other_mod = other_mod
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
# @return [Boolean]
|
31
|
+
#
|
32
|
+
def call
|
33
|
+
mod.included_modules.include?(other_mod)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "module/class_method_defined"
|
4
|
+
require_relative "module/fetch_own_const"
|
4
5
|
require_relative "module/get_own_instance_method"
|
5
6
|
require_relative "module/get_own_const"
|
6
7
|
require_relative "module/has_own_instance_method"
|
8
|
+
require_relative "module/include_module"
|
7
9
|
require_relative "module/instance_method_defined"
|
8
10
|
|
9
11
|
module ConvenientService
|
@@ -19,6 +21,10 @@ module ConvenientService
|
|
19
21
|
ClassMethodDefined.call(...)
|
20
22
|
end
|
21
23
|
|
24
|
+
def fetch_own_const(...)
|
25
|
+
FetchOwnConst.call(...)
|
26
|
+
end
|
27
|
+
|
22
28
|
def get_own_instance_method(...)
|
23
29
|
GetOwnInstanceMethod.call(...)
|
24
30
|
end
|
@@ -31,6 +37,10 @@ module ConvenientService
|
|
31
37
|
HasOwnInstanceMethod.call(...)
|
32
38
|
end
|
33
39
|
|
40
|
+
def include_module?(...)
|
41
|
+
IncludeModule.call(...)
|
42
|
+
end
|
43
|
+
|
34
44
|
def instance_method_defined?(...)
|
35
45
|
InstanceMethodDefined.call(...)
|
36
46
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module Utils
|
5
|
+
module String
|
6
|
+
class Split < Support::Command
|
7
|
+
##
|
8
|
+
# @!attribute [r] string
|
9
|
+
# @return [#to_s]
|
10
|
+
#
|
11
|
+
attr_reader :string
|
12
|
+
|
13
|
+
##
|
14
|
+
# @!attribute [r] delimiters
|
15
|
+
# @return [Array<String>]
|
16
|
+
#
|
17
|
+
attr_reader :delimiters
|
18
|
+
|
19
|
+
##
|
20
|
+
# @param string [Symbol, String]
|
21
|
+
# @param delimiters [Array<String>]
|
22
|
+
# @return [void]
|
23
|
+
#
|
24
|
+
def initialize(string, *delimiters)
|
25
|
+
@string = string
|
26
|
+
@delimiters = delimiters
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
# @return [String]
|
31
|
+
#
|
32
|
+
# @internal
|
33
|
+
# https://stackoverflow.com/a/51380514/12201472
|
34
|
+
#
|
35
|
+
def call
|
36
|
+
string.to_s.split(::Regexp.union(delimiters))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "string/camelize"
|
4
|
+
require_relative "string/split"
|
4
5
|
|
5
6
|
module ConvenientService
|
6
7
|
module Utils
|
@@ -9,6 +10,10 @@ module ConvenientService
|
|
9
10
|
def camelize(...)
|
10
11
|
Camelize.call(...)
|
11
12
|
end
|
13
|
+
|
14
|
+
def split(...)
|
15
|
+
Split.call(...)
|
16
|
+
end
|
12
17
|
end
|
13
18
|
end
|
14
19
|
end
|
data/lib/convenient_service.rb
CHANGED
@@ -29,3 +29,9 @@ require_relative "convenient_service/core"
|
|
29
29
|
require_relative "convenient_service/common"
|
30
30
|
require_relative "convenient_service/service"
|
31
31
|
require_relative "convenient_service/configs"
|
32
|
+
|
33
|
+
##
|
34
|
+
# @internal
|
35
|
+
# Convenient Service Aliases.
|
36
|
+
#
|
37
|
+
require_relative "convenient_service/aliases"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: convenient_service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marian Kostyk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appraisal
|
@@ -182,16 +182,16 @@ dependencies:
|
|
182
182
|
name: rubocop
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
|
-
- - "
|
185
|
+
- - "~>"
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version:
|
187
|
+
version: 1.40.0
|
188
188
|
type: :development
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
|
-
- - "
|
192
|
+
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
|
-
version:
|
194
|
+
version: 1.40.0
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
196
|
name: rubocop-rspec
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -301,6 +301,7 @@ executables: []
|
|
301
301
|
extensions: []
|
302
302
|
extra_rdoc_files: []
|
303
303
|
files:
|
304
|
+
- ".dev/.tmuxinator.yml"
|
304
305
|
- ".dockerignore"
|
305
306
|
- ".gem_release.yml"
|
306
307
|
- ".github/issue_template.md"
|
@@ -330,6 +331,7 @@ files:
|
|
330
331
|
- docker/3.1/Dockerfile
|
331
332
|
- env.rb
|
332
333
|
- lib/convenient_service.rb
|
334
|
+
- lib/convenient_service/aliases.rb
|
333
335
|
- lib/convenient_service/common.rb
|
334
336
|
- lib/convenient_service/common/plugins.rb
|
335
337
|
- lib/convenient_service/common/plugins/aliases.rb
|
@@ -529,8 +531,12 @@ files:
|
|
529
531
|
- lib/convenient_service/rspec/matchers/custom/include_module.rb
|
530
532
|
- lib/convenient_service/rspec/matchers/custom/prepend_module.rb
|
531
533
|
- lib/convenient_service/rspec/matchers/custom/results.rb
|
534
|
+
- lib/convenient_service/rspec/matchers/custom/results/base.rb
|
532
535
|
- lib/convenient_service/rspec/matchers/custom/results/be_error.rb
|
533
536
|
- lib/convenient_service/rspec/matchers/custom/results/be_failure.rb
|
537
|
+
- lib/convenient_service/rspec/matchers/custom/results/be_not_error.rb
|
538
|
+
- lib/convenient_service/rspec/matchers/custom/results/be_not_failure.rb
|
539
|
+
- lib/convenient_service/rspec/matchers/custom/results/be_not_success.rb
|
534
540
|
- lib/convenient_service/rspec/matchers/custom/results/be_success.rb
|
535
541
|
- lib/convenient_service/rspec/matchers/delegate_to.rb
|
536
542
|
- lib/convenient_service/rspec/matchers/extend_module.rb
|
@@ -544,6 +550,9 @@ files:
|
|
544
550
|
- lib/convenient_service/rspec/matchers/results.rb
|
545
551
|
- lib/convenient_service/rspec/matchers/results/be_error.rb
|
546
552
|
- lib/convenient_service/rspec/matchers/results/be_failure.rb
|
553
|
+
- lib/convenient_service/rspec/matchers/results/be_not_error.rb
|
554
|
+
- lib/convenient_service/rspec/matchers/results/be_not_failure.rb
|
555
|
+
- lib/convenient_service/rspec/matchers/results/be_not_success.rb
|
547
556
|
- lib/convenient_service/rspec/matchers/results/be_success.rb
|
548
557
|
- lib/convenient_service/service.rb
|
549
558
|
- lib/convenient_service/service/plugins.rb
|
@@ -660,8 +669,6 @@ files:
|
|
660
669
|
- lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/directions/output.rb
|
661
670
|
- lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/key.rb
|
662
671
|
- lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/name.rb
|
663
|
-
- lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/values.rb
|
664
|
-
- lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/values/raw.rb
|
665
672
|
- lib/convenient_service/service/plugins/has_result_steps/entities/method/errors.rb
|
666
673
|
- lib/convenient_service/service/plugins/has_result_steps/entities/service.rb
|
667
674
|
- lib/convenient_service/service/plugins/has_result_steps/entities/service/class_methods.rb
|
@@ -696,12 +703,27 @@ files:
|
|
696
703
|
- lib/convenient_service/support/concern.rb
|
697
704
|
- lib/convenient_service/support/copyable.rb
|
698
705
|
- lib/convenient_service/support/delegate.rb
|
706
|
+
- lib/convenient_service/support/dependency_container.rb
|
707
|
+
- lib/convenient_service/support/dependency_container/commands.rb
|
708
|
+
- lib/convenient_service/support/dependency_container/commands/create_methods_module.rb
|
709
|
+
- lib/convenient_service/support/dependency_container/commands/import_method.rb
|
710
|
+
- lib/convenient_service/support/dependency_container/constants.rb
|
711
|
+
- lib/convenient_service/support/dependency_container/entities.rb
|
712
|
+
- lib/convenient_service/support/dependency_container/entities/method.rb
|
713
|
+
- lib/convenient_service/support/dependency_container/entities/method_collection.rb
|
714
|
+
- lib/convenient_service/support/dependency_container/entities/namespace.rb
|
715
|
+
- lib/convenient_service/support/dependency_container/entities/namespace_collection.rb
|
716
|
+
- lib/convenient_service/support/dependency_container/errors.rb
|
717
|
+
- lib/convenient_service/support/dependency_container/export.rb
|
718
|
+
- lib/convenient_service/support/dependency_container/import.rb
|
699
719
|
- lib/convenient_service/support/finite_loop.rb
|
700
720
|
- lib/convenient_service/support/gems.rb
|
701
721
|
- lib/convenient_service/support/gems/active_model.rb
|
702
722
|
- lib/convenient_service/support/gems/rspec.rb
|
703
723
|
- lib/convenient_service/support/middleware.rb
|
704
724
|
- lib/convenient_service/support/middleware/stack_builder.rb
|
725
|
+
- lib/convenient_service/support/not_passed.rb
|
726
|
+
- lib/convenient_service/support/raw_value.rb
|
705
727
|
- lib/convenient_service/support/ruby.rb
|
706
728
|
- lib/convenient_service/support/version.rb
|
707
729
|
- lib/convenient_service/support/version/null_version.rb
|
@@ -724,9 +746,11 @@ files:
|
|
724
746
|
- lib/convenient_service/utils/method/defined.rb
|
725
747
|
- lib/convenient_service/utils/module.rb
|
726
748
|
- lib/convenient_service/utils/module/class_method_defined.rb
|
749
|
+
- lib/convenient_service/utils/module/fetch_own_const.rb
|
727
750
|
- lib/convenient_service/utils/module/get_own_const.rb
|
728
751
|
- lib/convenient_service/utils/module/get_own_instance_method.rb
|
729
752
|
- lib/convenient_service/utils/module/has_own_instance_method.rb
|
753
|
+
- lib/convenient_service/utils/module/include_module.rb
|
730
754
|
- lib/convenient_service/utils/module/instance_method_defined.rb
|
731
755
|
- lib/convenient_service/utils/object.rb
|
732
756
|
- lib/convenient_service/utils/object/instance_variable_fetch.rb
|
@@ -736,6 +760,7 @@ files:
|
|
736
760
|
- lib/convenient_service/utils/proc/exec_config.rb
|
737
761
|
- lib/convenient_service/utils/string.rb
|
738
762
|
- lib/convenient_service/utils/string/camelize.rb
|
763
|
+
- lib/convenient_service/utils/string/split.rb
|
739
764
|
- lib/convenient_service/version.rb
|
740
765
|
- logo.png
|
741
766
|
homepage: https://github.com/marian13/convenient_service
|
data/lib/convenient_service/service/plugins/has_result_steps/entities/method/entities/values/raw.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ConvenientService
|
4
|
-
module Service
|
5
|
-
module Plugins
|
6
|
-
module HasResultSteps
|
7
|
-
module Entities
|
8
|
-
class Method
|
9
|
-
module Entities
|
10
|
-
module Values
|
11
|
-
##
|
12
|
-
# TODO: Specs.
|
13
|
-
#
|
14
|
-
class Raw
|
15
|
-
def initialize(object)
|
16
|
-
@object = object
|
17
|
-
end
|
18
|
-
|
19
|
-
class << self
|
20
|
-
def wrap(object)
|
21
|
-
new(object)
|
22
|
-
end
|
23
|
-
|
24
|
-
private :new
|
25
|
-
end
|
26
|
-
|
27
|
-
def unwrap
|
28
|
-
object
|
29
|
-
end
|
30
|
-
|
31
|
-
def ==(other)
|
32
|
-
return unless other.instance_of?(self.class)
|
33
|
-
|
34
|
-
object == other.object
|
35
|
-
end
|
36
|
-
|
37
|
-
protected
|
38
|
-
|
39
|
-
attr_reader :object
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|