eac_cli 0.39.0 → 0.40.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4eb32e4256c41224161c945741a0f3d2b3118c1cadaa1f3803d06a963c014f73
4
- data.tar.gz: adbea33366cb3f15a78d034d9e6fe1e717ea04d1d7a5d00def1233eecc4ab10d
3
+ metadata.gz: c774c31dedbbb2c69f387f8b31ae0f38e90687b077a32efdabf5a4a657a12353
4
+ data.tar.gz: 87217fc7028a27c12a13045c87a5bd12c13f3acb183cf707b4c780dde8171ec4
5
5
  SHA512:
6
- metadata.gz: 3c45d3e0176a8f85691d7d64d54a4cfe7febeb25e982af587824afe84ce368515983dbb3a308aec46c0603340c2afeab6fccce914faaa4d2fc3fdce38177963c
7
- data.tar.gz: 864ed661fddcae5c1e7ee6f1b1b81b6d20d98d184d6c24cecd8a7641b0afa9a28aa39215764b43a3dd5d7316ad7dcae02cdfcdd42fb6af47a8aae67183e62773
6
+ metadata.gz: 5feea87d16a816c2a4e886c34ff756e68d611df4637e4bb7deea35b95f7e800c08964d7369c40832368f1cfb583ab80a1f49c626b52ac81eb5807ee5a13ceff5
7
+ data.tar.gz: 62153058635b53cd3fdda5406cf0d9e5c337fe8089c08232b1ee22672ceae3fa279e4ce95d370133f9bbc9d4d3bb5fa197c0232dad5ad701d362e2eb41c2d0d5
@@ -15,6 +15,10 @@ module EacCli
15
15
 
16
16
  def disable_config_input_request
17
17
  rspec_config.before do
18
+ # Fixes EacCli::Config::Entry does not implement #input_value error
19
+ ::EacCli::Config::Entry.define_method(:input_value) do
20
+ super
21
+ end
18
22
  allow_any_instance_of(::EacCli::Config::Entry).to receive(:input_value) do |obj|
19
23
  raise "Console input requested for entry (Path: #{obj.path})"
20
24
  end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacCli
6
+ module RunnerWith
7
+ module Confirmation
8
+ class InputResult
9
+ INPUT_NO_FOR_ONE = 'n'
10
+ INPUT_NO_FOR_ALL = 'N'
11
+ INPUT_YES_FOR_ONE = 'y'
12
+ INPUT_YES_FOR_ALL = 'Y'
13
+ INPUT_FOR_ONE = [INPUT_NO_FOR_ONE, INPUT_YES_FOR_ONE].freeze
14
+ INPUT_FOR_ALL = [INPUT_NO_FOR_ALL, INPUT_YES_FOR_ALL].freeze
15
+ INPUT_NO = [INPUT_NO_FOR_ONE, INPUT_NO_FOR_ALL].freeze
16
+ INPUT_YES = [INPUT_YES_FOR_ONE, INPUT_YES_FOR_ALL].freeze
17
+ INPUT_LIST = [INPUT_NO_FOR_ALL, INPUT_NO_FOR_ONE, INPUT_YES_FOR_ONE, INPUT_YES_FOR_ALL]
18
+ .freeze
19
+
20
+ class << self
21
+ enable_speaker
22
+
23
+ # @param message [String]
24
+ # @return [EacCli::RunnerWith::Confirmation::InputResult]
25
+ def by_message(message)
26
+ new(input(message, list: INPUT_LIST))
27
+ end
28
+ end
29
+
30
+ common_constructor :input_value
31
+
32
+ # @return [Boolean]
33
+ def confirm?
34
+ input_value_to_bool(INPUT_NO, INPUT_YES)
35
+ end
36
+
37
+ # @return [Boolean]
38
+ def for_all?
39
+ input_value_to_bool(INPUT_FOR_ONE, INPUT_FOR_ALL)
40
+ end
41
+
42
+ private
43
+
44
+ # @param false_list [Array<String>]
45
+ # @param true_list [Array<String>]
46
+ # @return [Boolean]
47
+ def input_value_to_bool(false_list, true_list)
48
+ return false if false_list.include?(input_value)
49
+ return true if true_list.include?(input_value)
50
+
51
+ ibr input_value
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -19,13 +19,13 @@ module EacCli
19
19
  end
20
20
 
21
21
  def confirm?(message = nil)
22
+ return for_all_answers.fetch(message) if for_all_answers.key?(message)
22
23
  return false if parsed.no?
23
24
  return true if parsed.yes?
24
25
 
25
- input(
26
- message || setting_value(:confirm_question_text, default: DEFAULT_CONFIRM_QUESTION_TEXT),
27
- bool: true
28
- )
26
+ r = confirm_input(message)
27
+ for_all_answers[message] = r.for_all?
28
+ r.confirm?
29
29
  rescue ::EacCli::Speaker::InputRequested => e
30
30
  fatal_error e.message
31
31
  end
@@ -39,6 +39,21 @@ module EacCli
39
39
  def cached_confirm_uncached?(message = nil)
40
40
  confirm?(message)
41
41
  end
42
+
43
+ # @param message [String, nil]
44
+ # @return [Boolean]
45
+ def confirm_input(message)
46
+ ::EacCli::RunnerWith::Confirmation::InputResult.by_message(
47
+ message || setting_value(:confirm_question_text, default: DEFAULT_CONFIRM_QUESTION_TEXT)
48
+ )
49
+ end
50
+
51
+ # @return [Hash<String, Boolean>]
52
+ def for_all_answers_uncached
53
+ {}
54
+ end
55
+
56
+ require_sub __FILE__
42
57
  end
43
58
  end
44
59
  end
@@ -29,7 +29,7 @@ module EacCli
29
29
 
30
30
  def initialize(values)
31
31
  @values = values.map do |v|
32
- ::OpenStruct.new(key: to_key(v.key), label: to_label(v.label), value: v.value) # rubocop:disable Style/OpenStructUse
32
+ ::OpenStruct.new(key: to_key(v.key), label: to_label(v.label), value: v.value) # rubocop:disable Style/OpenStructUse
33
33
  end
34
34
  end
35
35
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.39.0'
4
+ VERSION = '0.40.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.39.0
4
+ version: 0.40.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-18 00:00:00.000000000 Z
11
+ date: 2024-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '0.14'
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 0.14.1
42
+ version: 0.14.2
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,27 +49,21 @@ dependencies:
49
49
  version: '0.14'
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 0.14.1
52
+ version: 0.14.2
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: eac_ruby_utils
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: '0.119'
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: 0.119.2
59
+ version: '0.121'
63
60
  type: :runtime
64
61
  prerelease: false
65
62
  version_requirements: !ruby/object:Gem::Requirement
66
63
  requirements:
67
64
  - - "~>"
68
65
  - !ruby/object:Gem::Version
69
- version: '0.119'
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- version: 0.119.2
66
+ version: '0.121'
73
67
  - !ruby/object:Gem::Dependency
74
68
  name: tty-table
75
69
  requirement: !ruby/object:Gem::Requirement
@@ -159,6 +153,7 @@ files:
159
153
  - lib/eac_cli/runner/instance_methods.rb
160
154
  - lib/eac_cli/runner_with.rb
161
155
  - lib/eac_cli/runner_with/confirmation.rb
156
+ - lib/eac_cli/runner_with/confirmation/input_result.rb
162
157
  - lib/eac_cli/runner_with/help.rb
163
158
  - lib/eac_cli/runner_with/help/builder.rb
164
159
  - lib/eac_cli/runner_with/help/builder/alternative.rb