servactory 1.6.7 → 1.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/servactory/configuration/factory.rb +4 -0
- data/lib/servactory/configuration/setup.rb +13 -0
- data/lib/servactory/inputs/input.rb +4 -10
- data/lib/servactory/inputs/option_helper.rb +15 -0
- data/lib/servactory/inputs/option_helpers_collection.rb +19 -0
- data/lib/servactory/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66de0357d02ad9ef590de1d516d1e6d0ea2f9d19d52479cb93e4e4922d6967e5
|
4
|
+
data.tar.gz: 83f630ec6486102357ef9d4b629dbc4e4f618e55325d97592b16b7530722299f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 292293afa0bfc8fba8d35605cfc80b6daa75865b3c1ad9d2d1807338c5e784bab0aa94d852b2be54d9157ca8ae44e0c0b2cf9141e92b26256d11d2c08d6ad1e2
|
7
|
+
data.tar.gz: 93ca03e6db127e20eb04a244e1c48c8596cf910328ab9148543c68da8068ba0cc12be24ed366996e1d72896c88ea474a9fa61f16e2c5d1c87bbbe6ccabc95fa6
|
@@ -19,6 +19,10 @@ module Servactory
|
|
19
19
|
Servactory.configuration.failure_class = failure_class
|
20
20
|
end
|
21
21
|
|
22
|
+
def input_option_helpers(input_option_helpers)
|
23
|
+
Servactory.configuration.input_option_helpers.merge(input_option_helpers)
|
24
|
+
end
|
25
|
+
|
22
26
|
def method_shortcuts(method_shortcuts)
|
23
27
|
Servactory.configuration.method_shortcuts.merge(method_shortcuts)
|
24
28
|
end
|
@@ -7,6 +7,7 @@ module Servactory
|
|
7
7
|
:internal_error_class,
|
8
8
|
:output_error_class,
|
9
9
|
:failure_class,
|
10
|
+
:input_option_helpers,
|
10
11
|
:method_shortcuts
|
11
12
|
|
12
13
|
def initialize
|
@@ -16,8 +17,20 @@ module Servactory
|
|
16
17
|
|
17
18
|
@failure_class = Servactory::Errors::Failure
|
18
19
|
|
20
|
+
@input_option_helpers = Servactory::Inputs::OptionHelpersCollection.new(default_input_option_helpers)
|
21
|
+
|
19
22
|
@method_shortcuts = Servactory::Methods::Shortcuts::Collection.new
|
20
23
|
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def default_input_option_helpers
|
28
|
+
Set[
|
29
|
+
Servactory::Inputs::OptionHelper.new(name: :optional, equivalent: { required: false }),
|
30
|
+
Servactory::Inputs::OptionHelper.new(name: :internal, equivalent: { internal: true }),
|
31
|
+
Servactory::Inputs::OptionHelper.new(name: :as_array, equivalent: { array: true })
|
32
|
+
]
|
33
|
+
end
|
21
34
|
end
|
22
35
|
end
|
23
36
|
end
|
@@ -5,13 +5,7 @@ module Servactory
|
|
5
5
|
class Input # rubocop:disable Metrics/ClassLength
|
6
6
|
ARRAY_DEFAULT_VALUE = ->(is: false, message: nil) { { is: is, message: message } }
|
7
7
|
|
8
|
-
|
9
|
-
optional: { required: false },
|
10
|
-
internal: { internal: true },
|
11
|
-
as_array: { array: true }
|
12
|
-
}.freeze
|
13
|
-
|
14
|
-
private_constant :ARRAY_DEFAULT_VALUE, :HELPER_LIBRARY
|
8
|
+
private_constant :ARRAY_DEFAULT_VALUE
|
15
9
|
|
16
10
|
attr_reader :name,
|
17
11
|
:internal_name
|
@@ -43,11 +37,11 @@ module Servactory
|
|
43
37
|
prepared_options = {}
|
44
38
|
|
45
39
|
helpers.each do |helper|
|
46
|
-
|
40
|
+
found_helper = Servactory.configuration.input_option_helpers.find_by(name: helper)
|
47
41
|
|
48
|
-
|
42
|
+
next if found_helper.blank?
|
49
43
|
|
50
|
-
prepared_options.merge!(found_helper)
|
44
|
+
prepared_options.merge!(found_helper.equivalent)
|
51
45
|
end
|
52
46
|
|
53
47
|
options.merge(prepared_options)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Servactory
|
4
|
+
module Inputs
|
5
|
+
class OptionHelpersCollection
|
6
|
+
# NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
|
7
|
+
extend Forwardable
|
8
|
+
def_delegators :@collection, :<<, :find, :merge
|
9
|
+
|
10
|
+
def initialize(collection)
|
11
|
+
@collection = collection
|
12
|
+
end
|
13
|
+
|
14
|
+
def find_by(name:)
|
15
|
+
find { |helper| helper.name == name }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/servactory/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: servactory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Sokolov
|
@@ -211,6 +211,8 @@ files:
|
|
211
211
|
- lib/servactory/inputs/dsl.rb
|
212
212
|
- lib/servactory/inputs/input.rb
|
213
213
|
- lib/servactory/inputs/option.rb
|
214
|
+
- lib/servactory/inputs/option_helper.rb
|
215
|
+
- lib/servactory/inputs/option_helpers_collection.rb
|
214
216
|
- lib/servactory/inputs/options_collection.rb
|
215
217
|
- lib/servactory/inputs/tools/check_errors.rb
|
216
218
|
- lib/servactory/inputs/tools/find_unnecessary.rb
|