servactory 1.9.4 → 1.9.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c6d95c37b2eb4ab39f0a16db06fcd1e6cf6c48957ecd4877d85deb019b881e2
4
- data.tar.gz: 3ab4992dc15627edeb9f5745d560775e161e4e285c8a08ff89078bcb2abe88c7
3
+ metadata.gz: 024a5ab65e8e000967f41494655da939111a0a43b4f6d4a941b28daff015def8
4
+ data.tar.gz: 7ae8df0285b2d9510ddabcbb92d2f0b8061ac74490b0a129793c4a389027bcc2
5
5
  SHA512:
6
- metadata.gz: d00d1f0d3cf1bde448a10a6c3fe81c1e1a22a09f9c73793626fa1e037c1c933a09bfed784365146837daa397664cf1fb80164e972e46121b5003b21e3ab25bfe
7
- data.tar.gz: a0c6488d9815a7833f382e136f853ed405117d5459101195fb8801535beb3db7adf1860dd1a9b7c2a0eed6607e85b4f01bec6fa6804a0082110ca702c5d87a05
6
+ metadata.gz: 1a7541d4d78732b0dcbf549ca15460a96625c1e1a342bb5a6046f18f3e7b036eed2e1e2f44e90db3c70a25f2b0dfdc4ce755d7af1c73f5824d06b54e2329d8e4
7
+ data.tar.gz: 4cc045df6054d694587c2038de8e63a1e1eda45d93a8912ecdee2d6bfcd42b9955a196c6f8d2f49a9076b078c2dd248d816b6526307961e89fcb5e151c2c894c
@@ -10,7 +10,19 @@ module Servactory
10
10
  @collection_of_inputs = collection_of_inputs
11
11
  end
12
12
 
13
- def method_missing(name, *args, &block)
13
+ def only(*names)
14
+ @collection_of_inputs
15
+ .only(*names)
16
+ .to_h { |input| [input.internal_name, send(input.internal_name)] }
17
+ end
18
+
19
+ def except(*names)
20
+ @collection_of_inputs
21
+ .except(*names)
22
+ .to_h { |input| [input.internal_name, send(input.internal_name)] }
23
+ end
24
+
25
+ def method_missing(name, *_args)
14
26
  if name.to_s.end_with?("=")
15
27
  prepared_name = name.to_s.delete("=").to_sym
16
28
 
@@ -9,7 +9,19 @@ module Servactory
9
9
  @collection_of_internals = collection_of_internals
10
10
  end
11
11
 
12
- def method_missing(name, *args, &block)
12
+ def only(*names)
13
+ @collection_of_internals
14
+ .only(*names)
15
+ .to_h { |internal| [internal.name, send(internal.name)] }
16
+ end
17
+
18
+ def except(*names)
19
+ @collection_of_internals
20
+ .except(*names)
21
+ .to_h { |internal| [internal.name, send(internal.name)] }
22
+ end
23
+
24
+ def method_missing(name, *args)
13
25
  if name.to_s.end_with?("=")
14
26
  prepared_name = name.to_s.delete("=").to_sym
15
27
 
@@ -38,7 +50,7 @@ module Servactory
38
50
  value: value
39
51
  )
40
52
 
41
- @context.send(:assign_internal, internal.name, value)
53
+ @context.send(:assign_servactory_service_storage_internal, internal.name, value)
42
54
  end
43
55
 
44
56
  def getter_with(name:, &block) # rubocop:disable Lint/UnusedMethodArgument
@@ -47,7 +59,7 @@ module Servactory
47
59
 
48
60
  return yield if internal.nil?
49
61
 
50
- internal_value = @context.send(:fetch_internal, internal.name)
62
+ internal_value = @context.send(:fetch_servactory_service_storage_internal, internal.name)
51
63
 
52
64
  if name.to_s.end_with?("?")
53
65
  Servactory::Utils.query_attribute(internal_value)
@@ -9,7 +9,19 @@ module Servactory
9
9
  @collection_of_outputs = collection_of_outputs
10
10
  end
11
11
 
12
- def method_missing(name, *args, &block)
12
+ def only(*names)
13
+ @collection_of_outputs
14
+ .only(*names)
15
+ .to_h { |output| [output.name, send(output.name)] }
16
+ end
17
+
18
+ def except(*names)
19
+ @collection_of_outputs
20
+ .except(*names)
21
+ .to_h { |output| [output.name, send(output.name)] }
22
+ end
23
+
24
+ def method_missing(name, *args)
13
25
  if name.to_s.end_with?("=")
14
26
  prepared_name = name.to_s.delete("=").to_sym
15
27
 
@@ -38,7 +50,7 @@ module Servactory
38
50
  value: value
39
51
  )
40
52
 
41
- @context.send(:assign_output, output.name, value)
53
+ @context.send(:assign_servactory_service_storage_output, output.name, value)
42
54
  end
43
55
 
44
56
  def getter_with(name:, &block) # rubocop:disable Lint/UnusedMethodArgument
@@ -47,7 +59,7 @@ module Servactory
47
59
 
48
60
  return yield if output.nil?
49
61
 
50
- output_value = @context.send(:fetch_output, output.name)
62
+ output_value = @context.send(:fetch_servactory_service_storage_output, output.name)
51
63
 
52
64
  if name.to_s.end_with?("?")
53
65
  Servactory::Utils.query_attribute(output_value)
@@ -84,24 +84,24 @@ module Servactory
84
84
  )
85
85
  end
86
86
 
87
- def service_storage
88
- @service_storage ||= { internals: {}, outputs: {} }
87
+ def servactory_service_storage
88
+ @servactory_service_storage ||= { internals: {}, outputs: {} }
89
89
  end
90
90
 
91
- def assign_internal(key, value)
92
- service_storage[:internals].merge!({ key => value })
91
+ def assign_servactory_service_storage_internal(key, value)
92
+ servactory_service_storage[:internals].merge!({ key => value })
93
93
  end
94
94
 
95
- def fetch_internal(key)
96
- service_storage.fetch(:internals).fetch(key, nil)
95
+ def fetch_servactory_service_storage_internal(key)
96
+ servactory_service_storage.fetch(:internals).fetch(key, nil)
97
97
  end
98
98
 
99
- def assign_output(key, value)
100
- service_storage[:outputs].merge!({ key => value })
99
+ def assign_servactory_service_storage_output(key, value)
100
+ servactory_service_storage[:outputs].merge!({ key => value })
101
101
  end
102
102
 
103
- def fetch_output(key)
104
- service_storage.fetch(:outputs).fetch(key, nil)
103
+ def fetch_servactory_service_storage_output(key)
104
+ servactory_service_storage.fetch(:outputs).fetch(key, nil)
105
105
  end
106
106
  end
107
107
  end
@@ -3,12 +3,19 @@
3
3
  module Servactory
4
4
  module Inputs
5
5
  class Collection
6
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
7
6
  extend Forwardable
8
- def_delegators :@collection, :<<, :each, :map, :merge, :find
7
+ def_delegators :@collection, :<<, :filter, :each, :map, :to_h, :merge, :find
9
8
 
10
- def initialize(*)
11
- @collection = Set.new
9
+ def initialize(collection = Set.new)
10
+ @collection = collection
11
+ end
12
+
13
+ def only(*names)
14
+ Collection.new(filter { |input| names.include?(input.internal_name) })
15
+ end
16
+
17
+ def except(*names)
18
+ Collection.new(filter { |input| !names.include?(input.internal_name) })
12
19
  end
13
20
 
14
21
  def names
@@ -21,7 +21,7 @@ module Servactory
21
21
  collection_of_inputs << Input.new(
22
22
  name,
23
23
  *helpers,
24
- config: config,
24
+ option_helpers: config.input_option_helpers,
25
25
  **options
26
26
  )
27
27
  end
@@ -9,7 +9,7 @@ module Servactory
9
9
 
10
10
  attr_reader :name,
11
11
  :internal_name,
12
- :config
12
+ :option_helpers
13
13
 
14
14
  # rubocop:disable Style/KeywordParametersOrder
15
15
  def initialize(
@@ -17,12 +17,12 @@ module Servactory
17
17
  *helpers,
18
18
  as: nil,
19
19
  type:,
20
- config:,
20
+ option_helpers:,
21
21
  **options
22
22
  )
23
23
  @name = name
24
24
  @internal_name = as.present? ? as : name
25
- @config = config
25
+ @option_helpers = option_helpers
26
26
 
27
27
  options = apply_helpers_for_options(helpers: helpers, options: options) if helpers.present?
28
28
 
@@ -46,7 +46,7 @@ module Servactory
46
46
  prepared_options = {}
47
47
 
48
48
  helpers.each do |helper|
49
- found_helper = config.input_option_helpers.find_by(name: helper)
49
+ found_helper = option_helpers.find_by(name: helper)
50
50
 
51
51
  next if found_helper.blank?
52
52
 
@@ -3,7 +3,6 @@
3
3
  module Servactory
4
4
  module Inputs
5
5
  class OptionHelpersCollection
6
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
7
6
  extend Forwardable
8
7
  def_delegators :@collection, :<<, :find, :merge
9
8
 
@@ -3,7 +3,6 @@
3
3
  module Servactory
4
4
  module Inputs
5
5
  class OptionsCollection
6
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
7
6
  extend Forwardable
8
7
  def_delegators :@collection, :<<, :filter, :each, :map, :flat_map, :find
9
8
 
@@ -4,7 +4,6 @@ module Servactory
4
4
  module Inputs
5
5
  module Tools
6
6
  class CheckErrors
7
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
8
7
  extend Forwardable
9
8
  def_delegators :@collection, :merge, :reject, :first, :empty?
10
9
 
@@ -4,7 +4,6 @@ module Servactory
4
4
  module Inputs
5
5
  module Validations
6
6
  class Errors
7
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
8
7
  extend Forwardable
9
8
  def_delegators :@collection, :<<, :to_a
10
9
 
@@ -3,12 +3,19 @@
3
3
  module Servactory
4
4
  module Internals
5
5
  class Collection
6
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
7
6
  extend Forwardable
8
- def_delegators :@collection, :<<, :each, :map, :merge, :find
7
+ def_delegators :@collection, :<<, :filter, :each, :map, :to_h, :merge, :find
9
8
 
10
- def initialize(*)
11
- @collection = Set.new
9
+ def initialize(collection = Set.new)
10
+ @collection = collection
11
+ end
12
+
13
+ def only(*names)
14
+ Collection.new(filter { |internal| names.include?(internal.name) })
15
+ end
16
+
17
+ def except(*names)
18
+ Collection.new(filter { |internal| !names.include?(internal.name) })
12
19
  end
13
20
 
14
21
  def names
@@ -7,7 +7,7 @@ module Servactory
7
7
  :types,
8
8
  :required
9
9
 
10
- def initialize(name, type:, **options)
10
+ def initialize(name, type:, **_options)
11
11
  @name = name
12
12
  @types = Array(type)
13
13
 
@@ -4,7 +4,6 @@ module Servactory
4
4
  module Methods
5
5
  module AliasesForMake
6
6
  class Collection
7
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
8
7
  extend Forwardable
9
8
  def_delegators :@collection, :<<, :merge, :include?
10
9
 
@@ -3,7 +3,6 @@
3
3
  module Servactory
4
4
  module Methods
5
5
  class MethodCollection
6
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
7
6
  extend Forwardable
8
7
  def_delegators :@collection, :<<, :each, :sort_by
9
8
 
@@ -4,7 +4,6 @@ module Servactory
4
4
  module Methods
5
5
  module ShortcutsForMake
6
6
  class Collection
7
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
8
7
  extend Forwardable
9
8
  def_delegators :@collection, :<<, :each, :merge, :include?
10
9
 
@@ -3,7 +3,6 @@
3
3
  module Servactory
4
4
  module Methods
5
5
  class StageCollection
6
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
7
6
  extend Forwardable
8
7
  def_delegators :@collection, :<<, :each, :merge, :sort_by, :size, :empty?
9
8
 
@@ -3,12 +3,19 @@
3
3
  module Servactory
4
4
  module Outputs
5
5
  class Collection
6
- # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
7
6
  extend Forwardable
8
- def_delegators :@collection, :<<, :each, :map, :merge, :find
7
+ def_delegators :@collection, :<<, :filter, :each, :map, :to_h, :merge, :find
9
8
 
10
- def initialize(*)
11
- @collection = Set.new
9
+ def initialize(collection = Set.new)
10
+ @collection = collection
11
+ end
12
+
13
+ def only(*names)
14
+ Collection.new(filter { |internal| names.include?(internal.name) })
15
+ end
16
+
17
+ def except(*names)
18
+ Collection.new(filter { |internal| !names.include?(internal.name) })
12
19
  end
13
20
 
14
21
  def names
@@ -25,7 +25,7 @@ module Servactory
25
25
  define_singleton_method(:success?) { true }
26
26
  define_singleton_method(:failure?) { false }
27
27
 
28
- @context.send(:service_storage).fetch(:outputs).each_pair do |key, value|
28
+ @context.send(:servactory_service_storage).fetch(:outputs).each_pair do |key, value|
29
29
  define_singleton_method(:"#{key}?") { Servactory::Utils.query_attribute(value) }
30
30
  define_singleton_method(key) { value }
31
31
  end
@@ -13,7 +13,7 @@ module Servactory
13
13
 
14
14
  def initialize(attributes = {})
15
15
  attributes.each_pair do |name, value|
16
- service_storage[:outputs].merge!({ name => value })
16
+ servactory_service_storage[:outputs].merge!({ name => value })
17
17
  end
18
18
  end
19
19
 
@@ -21,8 +21,8 @@ module Servactory
21
21
 
22
22
  private
23
23
 
24
- def service_storage
25
- @service_storage ||= { outputs: {} }
24
+ def servactory_service_storage
25
+ @servactory_service_storage ||= { outputs: {} }
26
26
  end
27
27
  end
28
28
  end
@@ -4,7 +4,7 @@ module Servactory
4
4
  module VERSION
5
5
  MAJOR = 1
6
6
  MINOR = 9
7
- PATCH = 4
7
+ PATCH = 6
8
8
 
9
9
  STRING = [MAJOR, MINOR, PATCH].join(".")
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.4
4
+ version: 1.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-28 00:00:00.000000000 Z
11
+ date: 2023-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '7.0'
19
+ version: 7.0.8
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '7.0'
26
+ version: 7.0.8
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: i18n
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '13.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rbs
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 3.1.3
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 3.1.3
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rspec
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +170,14 @@ dependencies:
156
170
  requirements:
157
171
  - - "~>"
158
172
  - !ruby/object:Gem::Version
159
- version: '1.4'
173
+ version: '1.5'
160
174
  type: :development
161
175
  prerelease: false
162
176
  version_requirements: !ruby/object:Gem::Requirement
163
177
  requirements:
164
178
  - - "~>"
165
179
  - !ruby/object:Gem::Version
166
- version: '1.4'
180
+ version: '1.5'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: yard
169
183
  requirement: !ruby/object:Gem::Requirement