eac_ruby_utils 0.9.0 → 0.10.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_ruby_utils/console/configs.rb +29 -4
- data/lib/eac_ruby_utils/console/docopt_runner/_doc.rb +1 -1
- data/lib/eac_ruby_utils/console/docopt_runner/_settings.rb +2 -2
- data/lib/eac_ruby_utils/console/speaker.rb +1 -1
- data/lib/eac_ruby_utils/patches/object/asserts.rb +5 -2
- data/lib/eac_ruby_utils/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50b84cf497dba566fde8efbde41a76b69ff81620a858245a7b2fd02d9d62c2f0
|
4
|
+
data.tar.gz: '084a436c1f32672730d9369e06985b95b85f600d263e2ff1f92c24a90f04fcdf'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa0100d893665b4a59995d0ccb16702629154ce247cb4c8d9bdce5b970cdf8dca9b89089bdabc0ef7263a7a80eced31bc05f9ef9fd66b25549d0cebae8c3f61d
|
7
|
+
data.tar.gz: bd97c8a6d1bf93cfed0ee45e789ef8f1551a1538fc9ec23f1f9aea46a7df2958ff58d032867c087d6f39976775249068b1a3a1109dd9524558ad9312835e6f6a
|
@@ -8,6 +8,18 @@ module EacRubyUtils
|
|
8
8
|
class Configs
|
9
9
|
include ::EacRubyUtils::Console::Speaker
|
10
10
|
|
11
|
+
class << self
|
12
|
+
def entry_key_to_envvar_name(entry_key)
|
13
|
+
path = if entry_key.is_a?(::Array)
|
14
|
+
entry_key
|
15
|
+
else
|
16
|
+
::EacRubyUtils::PathsHash.parse_entry_key(entry_key)
|
17
|
+
end
|
18
|
+
path.join('_').gsub(/[^a-z0-9_]/i, '').gsub(/\A_+/, '').gsub(/_+\z/, '')
|
19
|
+
.gsub(/_{2,}/, '_').upcase
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
11
23
|
STORE_PASSWORDS_KEY = 'core.store_passwords'
|
12
24
|
|
13
25
|
attr_reader :configs
|
@@ -26,12 +38,14 @@ module EacRubyUtils
|
|
26
38
|
end
|
27
39
|
|
28
40
|
def read_entry(entry_key, options = {})
|
41
|
+
unless options[:noenv]
|
42
|
+
envvar_value = envvar_read_entry(entry_key)
|
43
|
+
return envvar_value if envvar_value.present?
|
44
|
+
end
|
29
45
|
stored_value = configs.read_entry(entry_key)
|
30
46
|
return stored_value if stored_value
|
31
|
-
options
|
32
|
-
|
33
|
-
configs.write_entry(entry_key, entry_value)
|
34
|
-
entry_value
|
47
|
+
return read_entry_from_console(entry_key, options) unless options[:noinput]
|
48
|
+
raise "No value found for entry \"#{entry_key}\""
|
35
49
|
end
|
36
50
|
|
37
51
|
def store_passwords?
|
@@ -44,6 +58,17 @@ module EacRubyUtils
|
|
44
58
|
|
45
59
|
protected
|
46
60
|
|
61
|
+
def envvar_read_entry(entry_key)
|
62
|
+
ENV[self.class.entry_key_to_envvar_name(entry_key)]
|
63
|
+
end
|
64
|
+
|
65
|
+
def read_entry_from_console(entry_key, options)
|
66
|
+
options[:before_input].call if options[:before_input].present?
|
67
|
+
entry_value = looped_entry_value_from_input(entry_key, options)
|
68
|
+
configs.write_entry(entry_key, entry_value)
|
69
|
+
entry_value
|
70
|
+
end
|
71
|
+
|
47
72
|
def store_password_banner
|
48
73
|
infom 'Do you wanna to store passwords?'
|
49
74
|
infom "Warning: the passwords will be store in clear text in \"#{configs.storage_path}\""
|
@@ -30,9 +30,9 @@ module EacRubyUtils
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
def setting_constant(key,
|
33
|
+
def setting_constant(key, fullname = false)
|
34
34
|
name = key.to_s.underscore.upcase
|
35
|
-
name = "#{self.class.name}::#{name}"
|
35
|
+
name = "#{self.class.name}::#{name}" if fullname
|
36
36
|
name
|
37
37
|
end
|
38
38
|
end
|
@@ -1,8 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Object
|
4
|
-
|
5
|
-
|
4
|
+
# Raises a ArgumentError if +self+ is not a +klass+.
|
5
|
+
#
|
6
|
+
# @return +self+
|
7
|
+
def assert_argument(klass, argument_name = 'unknown_argument_name')
|
8
|
+
return self if is_a?(klass)
|
6
9
|
raise ::ArgumentError,
|
7
10
|
"Argument \"#{argument_name}\" is not a #{klass}" \
|
8
11
|
"(Actual class: #{self.class}, actual value: #{self})"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eac_ruby_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.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: 2019-
|
11
|
+
date: 2019-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|