eac_cli 0.23.0 → 0.25.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/lib/eac_cli/config/entry/options.rb +1 -1
- data/lib/eac_cli/config/entry/undefined.rb +1 -1
- data/lib/eac_cli/config/entry.rb +1 -1
- data/lib/eac_cli/config.rb +6 -3
- data/lib/eac_cli/enum.rb +45 -0
- data/lib/eac_cli/rspec/setup.rb +44 -0
- data/lib/eac_cli/rspec.rb +9 -0
- data/lib/eac_cli/speaker/constants.rb +13 -0
- data/lib/eac_cli/version.rb +1 -1
- metadata +10 -14
- data/lib/eac_cli/old_configs_bridge.rb +0 -39
- data/lib/eac_cli/speaker/_constants.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9958f4d1b81751a3898ceac31489c06a1a10f02d8a9aa373d8c15bc2708102f8
|
4
|
+
data.tar.gz: 9faa05710f123ac1642dbdc1d608b5ceae1e5ff4fe517345bdd47297065e9a81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de6e9f9a2ce9981d204ce3ba2ea921d72965a3422e18581f673fc89d12679d263a076cae32423bbba50d25d9c8c708c934f7d69a944de3863f79af1e432d9e11
|
7
|
+
data.tar.gz: 1eb5b7c3e24bb5280727c0ef61a445669884c4bcdcf96aacf9d302872ffdfb35c73ead41ddca845cdd7f4d93ca37d021cd9db8fe3dfe347586e45ced3ab37cfb
|
data/lib/eac_cli/config/entry.rb
CHANGED
data/lib/eac_cli/config.rb
CHANGED
@@ -3,16 +3,19 @@
|
|
3
3
|
require 'eac_ruby_utils/core_ext'
|
4
4
|
|
5
5
|
module EacCli
|
6
|
-
class Config
|
6
|
+
class Config < ::SimpleDelegator
|
7
7
|
require_sub __FILE__
|
8
|
-
attr_reader :sub
|
9
8
|
|
10
9
|
def initialize(sub_node)
|
11
|
-
|
10
|
+
super(sub_node)
|
12
11
|
end
|
13
12
|
|
14
13
|
def entry(path, options = {})
|
15
14
|
::EacCli::Config::Entry.new(self, path, options)
|
16
15
|
end
|
16
|
+
|
17
|
+
def sub
|
18
|
+
__getobj__
|
19
|
+
end
|
17
20
|
end
|
18
21
|
end
|
data/lib/eac_cli/enum.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/enum'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module EacCli
|
7
|
+
# A [EacRubyUtils::Enum] which each value is associated with one console color.
|
8
|
+
class Enum < ::EacRubyUtils::Enum
|
9
|
+
# Foreground color used in [to_bg_label]
|
10
|
+
TO_BG_LABEL_FG_COLOR = :light_white
|
11
|
+
|
12
|
+
attr_reader :color
|
13
|
+
|
14
|
+
def initialize(key, color)
|
15
|
+
super(key)
|
16
|
+
@color = color
|
17
|
+
end
|
18
|
+
|
19
|
+
delegate :to_s, to: :key
|
20
|
+
|
21
|
+
# @return [String]
|
22
|
+
def to_label
|
23
|
+
to_fg_label
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [String]
|
27
|
+
def to_fg_label
|
28
|
+
to_fg_bg_label(color)
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [String]
|
32
|
+
def to_bg_label
|
33
|
+
to_fg_bg_label(TO_BG_LABEL_FG_COLOR, color)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
# @return [String]
|
39
|
+
def to_fg_bg_label(fg_color, bg_color = nil)
|
40
|
+
colors = { color: fg_color }
|
41
|
+
bg_color.if_present { |v| colors[:background] = v }
|
42
|
+
::ColorizedString[to_s].colorize(colors)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/config/entry'
|
4
|
+
require 'eac_cli/speaker'
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
6
|
+
require 'eac_ruby_utils/speaker'
|
7
|
+
|
8
|
+
module EacCli
|
9
|
+
module Rspec
|
10
|
+
module Setup
|
11
|
+
def disable_input_request
|
12
|
+
disable_config_input_request
|
13
|
+
disable_speaker_input_request
|
14
|
+
end
|
15
|
+
|
16
|
+
def disable_config_input_request
|
17
|
+
rspec_config.before do
|
18
|
+
allow_any_instance_of(::EacCli::Config::Entry).to receive(:input_value) do |obj|
|
19
|
+
raise "Console input requested for entry (Path: #{obj.path})"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def disable_speaker_input_request
|
25
|
+
::RSpec.configure do |config|
|
26
|
+
config.around do |example|
|
27
|
+
::EacRubyUtils::Speaker.context.on(
|
28
|
+
::EacCli::Speaker.new(err_out: ::StringIO.new, out_out: ::StringIO.new,
|
29
|
+
in_in: FailIfRequestInput.new)
|
30
|
+
) { example.run }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class FailIfRequestInput
|
36
|
+
%w[gets noecho].each do |method|
|
37
|
+
define_method(method) do
|
38
|
+
raise "Input method requested: #{method}. Should not request input on RSpec."
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/by_reference'
|
4
|
+
|
5
|
+
module EacCli
|
6
|
+
class Speaker
|
7
|
+
module Constants
|
8
|
+
STDERR = ::EacRubyUtils::ByReference.new { $stderr }
|
9
|
+
STDIN = ::EacRubyUtils::ByReference.new { $stdin }
|
10
|
+
STDOUT = ::EacRubyUtils::ByReference.new { $stdout }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/eac_cli/version.rb
CHANGED
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.
|
4
|
+
version: 0.25.0
|
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: 2021-
|
11
|
+
date: 2021-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -30,34 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
34
|
-
- - ">="
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: 0.5.1
|
33
|
+
version: '0.7'
|
37
34
|
type: :runtime
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
38
|
- - "~>"
|
42
39
|
- !ruby/object:Gem::Version
|
43
|
-
version: '0.
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 0.5.1
|
40
|
+
version: '0.7'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: eac_ruby_utils
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
50
44
|
requirements:
|
51
45
|
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0.
|
47
|
+
version: '0.80'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
51
|
requirements:
|
58
52
|
- - "~>"
|
59
53
|
- !ruby/object:Gem::Version
|
60
|
-
version: '0.
|
54
|
+
version: '0.80'
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
56
|
name: eac_ruby_gem_support
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,12 +88,12 @@ files:
|
|
94
88
|
- lib/eac_cli/definition/boolean_option.rb
|
95
89
|
- lib/eac_cli/definition/help_formatter.rb
|
96
90
|
- lib/eac_cli/definition/positional_argument.rb
|
91
|
+
- lib/eac_cli/enum.rb
|
97
92
|
- lib/eac_cli/old_configs.rb
|
98
93
|
- lib/eac_cli/old_configs/entry_reader.rb
|
99
94
|
- lib/eac_cli/old_configs/password_entry_reader.rb
|
100
95
|
- lib/eac_cli/old_configs/read_entry_options.rb
|
101
96
|
- lib/eac_cli/old_configs/store_passwords_entry_reader.rb
|
102
|
-
- lib/eac_cli/old_configs_bridge.rb
|
103
97
|
- lib/eac_cli/parser.rb
|
104
98
|
- lib/eac_cli/parser/alternative.rb
|
105
99
|
- lib/eac_cli/parser/alternative/argv.rb
|
@@ -114,6 +108,8 @@ files:
|
|
114
108
|
- lib/eac_cli/patches.rb
|
115
109
|
- lib/eac_cli/patches/object.rb
|
116
110
|
- lib/eac_cli/patches/object/runner_with.rb
|
111
|
+
- lib/eac_cli/rspec.rb
|
112
|
+
- lib/eac_cli/rspec/setup.rb
|
117
113
|
- lib/eac_cli/runner.rb
|
118
114
|
- lib/eac_cli/runner/after_class_methods.rb
|
119
115
|
- lib/eac_cli/runner/context.rb
|
@@ -127,7 +123,7 @@ files:
|
|
127
123
|
- lib/eac_cli/runner_with/subcommands/definition_concern.rb
|
128
124
|
- lib/eac_cli/runner_with_set.rb
|
129
125
|
- lib/eac_cli/speaker.rb
|
130
|
-
- lib/eac_cli/speaker/
|
126
|
+
- lib/eac_cli/speaker/constants.rb
|
131
127
|
- lib/eac_cli/speaker/list.rb
|
132
128
|
- lib/eac_cli/speaker/options.rb
|
133
129
|
- lib/eac_cli/version.rb
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_cli/config'
|
4
|
-
require 'eac_config/envvars_node'
|
5
|
-
require 'eac_config/yaml_file_node'
|
6
|
-
require 'eac_ruby_utils/core_ext'
|
7
|
-
|
8
|
-
module EacCli
|
9
|
-
class OldConfigsBridge < ::EacCli::Config
|
10
|
-
ENTRY_KEY = 'core.store_passwords'
|
11
|
-
|
12
|
-
class << self
|
13
|
-
def new_configs_path(configs_key, options)
|
14
|
-
options[:storage_path] || ::File.join(ENV['HOME'], '.config', configs_key, 'settings.yml')
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def initialize(configs_key, options = {})
|
19
|
-
options.assert_argument(::Hash, 'options')
|
20
|
-
envvar_node = ::EacConfig::EnvvarsNode.new
|
21
|
-
file_node = ::EacConfig::YamlFileNode.new(self.class.new_configs_path(configs_key, options))
|
22
|
-
envvar_node.load_path.push(file_node.url)
|
23
|
-
envvar_node.write_node = file_node
|
24
|
-
super(envvar_node)
|
25
|
-
end
|
26
|
-
|
27
|
-
def read_entry(entry_key, options = {})
|
28
|
-
entry(entry_key, options).value
|
29
|
-
end
|
30
|
-
|
31
|
-
def read_password(entry_key, options = {})
|
32
|
-
entry(entry_key, options.merge(noecho: true, store: store_passwords?)).value
|
33
|
-
end
|
34
|
-
|
35
|
-
def store_passwords?
|
36
|
-
read_entry(ENTRY_KEY, bool: true)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/by_reference'
|
4
|
-
|
5
|
-
module EacCli
|
6
|
-
# https://github.com/fazibear/colorize
|
7
|
-
class Speaker
|
8
|
-
STDERR = ::EacRubyUtils::ByReference.new { $stderr }
|
9
|
-
STDIN = ::EacRubyUtils::ByReference.new { $stdin }
|
10
|
-
STDOUT = ::EacRubyUtils::ByReference.new { $stdout }
|
11
|
-
end
|
12
|
-
end
|