avm-tools 0.116.1 → 0.116.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/launcher/instances/settings.rb +7 -3
- data/lib/avm/projects/stereotypes.rb +2 -2
- data/lib/avm/ruby/bundler/incompatible_parser/depends_on.rb +1 -1
- data/lib/avm/ruby/bundler/incompatible_parser/gem_conflict.rb +1 -1
- data/lib/avm/ruby/bundler/incompatible_parser/in_gemfile.rb +1 -1
- data/lib/avm/ruby/bundler/incompatible_parser/version_requirement.rb +1 -1
- data/lib/avm/ruby/bundler/incompatible_parser.rb +1 -1
- data/lib/avm/tools/runner/app_src/ruby/bundler/gemfile_lock/git.rb +1 -1
- data/lib/avm/tools/runner/app_src/test.rb +2 -2
- data/lib/avm/tools/runner/git/deploy.rb +4 -4
- data/lib/avm/tools/runner/git/dirty_files.rb +1 -1
- data/lib/avm/tools/runner/git/revisions_test.rb +1 -1
- data/lib/avm/tools/runner/ruby/rubocop.rb +2 -2
- data/lib/avm/tools/version.rb +1 -1
- data/sub/avm/avm.gemspec +2 -2
- data/sub/avm/lib/avm/instances/base/auto_values/mailer.rb +2 -2
- data/sub/avm/lib/avm/registry/base.rb +2 -2
- data/sub/avm/lib/avm/rspec/shared_examples/not_in_avm_registry.rb +1 -1
- data/sub/avm/lib/avm/sources/tests/builder.rb +1 -1
- data/sub/avm/lib/avm/version.rb +1 -1
- data/sub/avm-eac_rails_base1/avm-eac_rails_base1.gemspec +1 -1
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/version.rb +1 -1
- data/sub/avm-eac_rails_base1/template/avm/eac_rails_base1/systemd_unit/tasks_scheduler_command.sh +1 -1
- data/sub/avm-eac_redmine_base0/avm-eac_redmine_base0.gemspec +1 -1
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/core_update.rb +3 -3
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/docker_image.rb +17 -2
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
- data/sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/instances/docker_image/Dockerfile.template +2 -8
- data/sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/instances/docker_image/Dockerfile_apache_setup +8 -0
- data/sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/instances/docker_image/start.sh.template +1 -1
- data/sub/avm-eac_ruby_base1/avm-eac_ruby_base1.gemspec +1 -1
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/patches/i18n.rb +1 -1
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/configured.rb +31 -0
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/envvar.rb +17 -0
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/gemfile.rb +41 -0
- data/{lib/avm/ruby → sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1}/rubocop.rb +2 -2
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/tester.rb +1 -1
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update/sub_update.rb +1 -1
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/version.rb +1 -1
- data/sub/avm-files/avm-files.gemspec +1 -1
- data/sub/avm-files/lib/avm/files/appendable.rb +1 -1
- data/sub/avm-files/lib/avm/files/formatter/formats/ruby.rb +2 -2
- data/sub/avm-files/lib/avm/files/version.rb +1 -1
- data/sub/eac_cli/eac_cli.gemspec +1 -1
- data/sub/eac_cli/lib/eac_cli/old_configs/entry_reader.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/old_configs/read_entry_options.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/parser.rb +2 -2
- data/sub/eac_cli/lib/eac_cli/runner_with/help/builder.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/runner_with/subcommands.rb +4 -4
- data/sub/eac_cli/lib/eac_cli/runner_with_set.rb +2 -2
- data/sub/eac_cli/lib/eac_cli/version.rb +1 -1
- data/sub/eac_config/eac_config.gemspec +1 -1
- data/sub/eac_config/lib/eac_config/entry.rb +1 -1
- data/sub/eac_config/lib/eac_config/envvars_node/entry.rb +1 -1
- data/sub/eac_config/lib/eac_config/paths_hash/node.rb +1 -1
- data/sub/eac_config/lib/eac_config/version.rb +1 -1
- data/sub/eac_fs/eac_fs.gemspec +1 -1
- data/sub/eac_fs/lib/eac_fs/version.rb +1 -1
- data/sub/eac_git/eac_git.gemspec +1 -1
- data/sub/eac_git/lib/eac_git/local/remote.rb +2 -2
- data/sub/eac_git/lib/eac_git/local.rb +1 -1
- data/sub/eac_git/lib/eac_git/version.rb +1 -1
- data/sub/eac_rest/eac_rest.gemspec +1 -1
- data/sub/eac_rest/lib/eac_rest/api.rb +14 -3
- data/sub/eac_rest/lib/eac_rest/request.rb +22 -1
- data/sub/eac_rest/lib/eac_rest/response.rb +41 -1
- data/sub/eac_rest/lib/eac_rest/version.rb +1 -1
- data/sub/eac_ruby_base0/eac_ruby_base0.gemspec +1 -1
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/application.rb +2 -2
- data/sub/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
- data/sub/eac_ruby_gems_utils/eac_ruby_gems_utils.gemspec +1 -1
- data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/version_file.rb +2 -2
- data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +1 -1
- data/sub/eac_ruby_utils/eac_ruby_utils.gemspec +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/custom_format.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/gems_registry/gem.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/gems_registry.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +16 -4
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb +12 -2
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb +6 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/ruby/on_clean_environment.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp/{temp_spec.rb → directory_spec.rb} +0 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp_spec.rb +4 -4
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/listable_spec.rb +169 -106
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb +52 -17
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/listable_spec.rb +5 -3
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/simple_cache_spec.rb +5 -3
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub_spec.rb +3 -3
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/settings_provider_spec.rb +21 -18
- data/sub/eac_ruby_utils/spec/locales/pt-BR.yml +3 -0
- data/sub/eac_templates/eac_templates.gemspec +1 -1
- data/sub/eac_templates/lib/eac_templates/directory.rb +1 -1
- data/sub/eac_templates/lib/eac_templates/version.rb +1 -1
- metadata +16 -9
- data/lib/avm/ruby/rubocop/_configured.rb +0 -29
- data/lib/avm/ruby/rubocop/_envvar.rb +0 -15
- data/lib/avm/ruby/rubocop/_gemfile.rb +0 -39
@@ -19,12 +19,12 @@ module EacCli
|
|
19
19
|
|
20
20
|
def alternatives_parsed(error)
|
21
21
|
alternatives.select { |a| error == a.error? }.map(&:parsed).reverse
|
22
|
-
|
22
|
+
.inject(::EacRubyUtils::Struct.new) { |a, e| a.merge(e) }
|
23
23
|
end
|
24
24
|
|
25
25
|
def alternatives_uncached
|
26
26
|
definition.alternatives
|
27
|
-
|
27
|
+
.map { |alternative| ::EacCli::Parser::Alternative.new(alternative, argv) }
|
28
28
|
end
|
29
29
|
|
30
30
|
def first_error_uncached
|
@@ -54,7 +54,7 @@ module EacCli
|
|
54
54
|
def options_section
|
55
55
|
"Options:\n" +
|
56
56
|
definition.alternatives.flat_map(&:options)
|
57
|
-
|
57
|
+
.map { |option| IDENT + option_definition(option) + "\n" }.join
|
58
58
|
end
|
59
59
|
|
60
60
|
def usage_section
|
@@ -17,7 +17,7 @@ module EacCli
|
|
17
17
|
common_concern do
|
18
18
|
include ::EacCli::Runner
|
19
19
|
runner_definition.singleton_class
|
20
|
-
|
20
|
+
.include(::EacCli::RunnerWith::Subcommands::DefinitionConcern)
|
21
21
|
end
|
22
22
|
|
23
23
|
EXTRA_AVAILABLE_SUBCOMMANDS_METHOD_NAME = :extra_available_subcommands
|
@@ -28,9 +28,9 @@ module EacCli
|
|
28
28
|
|
29
29
|
def available_subcommands_auto
|
30
30
|
self.class.constants
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
.map { |name| [name.to_s.underscore.gsub('_', '-'), self.class.const_get(name)] }
|
32
|
+
.select { |c| ::EacCli::RunnerWith::Subcommands.runner?(c[1]) }
|
33
|
+
.to_h.with_indifferent_access
|
34
34
|
end
|
35
35
|
|
36
36
|
def available_subcommands_extra
|
@@ -32,8 +32,8 @@ module EacCli
|
|
32
32
|
|
33
33
|
def key_to_module(key)
|
34
34
|
namespace_set.lazy
|
35
|
-
|
36
|
-
|
35
|
+
.map { |namespace| key_to_module_in_namespace(namespace, key) }
|
36
|
+
.find(&:present?) ||
|
37
37
|
raise("Not module found with key \"#{key}\" (Namespaces: #{namespace_set})")
|
38
38
|
end
|
39
39
|
|
@@ -12,7 +12,7 @@ module EacConfig
|
|
12
12
|
class << self
|
13
13
|
def entry_path_to_envvar_name(path)
|
14
14
|
::EacConfig::EntryPath.assert(path).parts.join('_').gsub(/[^a-z0-9_]/i, '')
|
15
|
-
|
15
|
+
.gsub(/\A_+/, '').gsub(/_+\z/, '').gsub(/_{2,}/, '_').upcase
|
16
16
|
end
|
17
17
|
|
18
18
|
def from_value(string)
|
data/sub/eac_fs/eac_fs.gemspec
CHANGED
data/sub/eac_git/eac_git.gemspec
CHANGED
@@ -16,5 +16,5 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.add_dependency 'parseconfig', '~> 1.0', '>= 1.0.8'
|
17
17
|
|
18
18
|
s.add_development_dependency 'aranha-parsers', '~> 0.8', '>= 0.8.2'
|
19
|
-
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.
|
19
|
+
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5.1'
|
20
20
|
end
|
@@ -19,8 +19,8 @@ module EacGit
|
|
19
19
|
# @return [String, nil]
|
20
20
|
def url
|
21
21
|
local.command('remote', 'get-url', name)
|
22
|
-
|
23
|
-
|
22
|
+
.execute!(exit_outputs: { NO_SUCH_REMOTE_CODE => nil })
|
23
|
+
.if_present(nil, &:strip)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -110,7 +110,7 @@ module EacGit
|
|
110
110
|
# @return [Array<EacGit::Local::Subrepo>]
|
111
111
|
def subrepos
|
112
112
|
command('subrepo', '-q', 'status').execute!.split("\n").map(&:strip).select(&:present?)
|
113
|
-
|
113
|
+
.map { |subpath| subrepo(subpath) }
|
114
114
|
end
|
115
115
|
|
116
116
|
def to_s
|
@@ -8,11 +8,14 @@ module EacRest
|
|
8
8
|
# * self.issue_get_url_suffix(provider_issue_id)
|
9
9
|
class Api
|
10
10
|
require_sub __FILE__, include_modules: true
|
11
|
-
|
11
|
+
attr_accessor :ssl_verify
|
12
|
+
common_constructor :root_url, :username, :password, default: [nil, nil] do
|
13
|
+
self.ssl_verify = true
|
14
|
+
end
|
12
15
|
|
13
16
|
def request(service_url_suffix, headers = {}, &body_data_proc)
|
14
17
|
r = ::EacRest::Request.new(build_service_url(service_url_suffix),
|
15
|
-
body_data_proc)
|
18
|
+
body_data_proc).ssl_verify(ssl_verify)
|
16
19
|
headers.each { |name, value| r = r.header(name, value) }
|
17
20
|
r = r.autenticate(username, password) if username.present?
|
18
21
|
r
|
@@ -28,12 +31,20 @@ module EacRest
|
|
28
31
|
|
29
32
|
# @return [Addressable::URI]
|
30
33
|
def build_service_url(suffix)
|
31
|
-
|
34
|
+
r = ::Addressable::URI.parse(suffix)
|
35
|
+
return r if r.scheme.present?
|
36
|
+
|
37
|
+
s = build_service_url_suffix(suffix)
|
32
38
|
r = ::Addressable::URI.parse(root_url)
|
33
39
|
r.path += s.path
|
34
40
|
r.query_values = r.query_values(::Array).if_present([]) +
|
35
41
|
s.query_values(::Array).if_present([])
|
36
42
|
r
|
37
43
|
end
|
44
|
+
|
45
|
+
# @return [Addressable::URI]
|
46
|
+
def build_service_url_suffix(suffix)
|
47
|
+
::Addressable::URI.parse(suffix)
|
48
|
+
end
|
38
49
|
end
|
39
50
|
end
|
@@ -7,11 +7,13 @@ require 'ostruct'
|
|
7
7
|
|
8
8
|
module EacRest
|
9
9
|
class Request
|
10
|
+
BOOLEAN_MODIFIERS = %w[ssl_verify ssl_verify_peer ssl_verify_host].freeze
|
10
11
|
COMMON_MODIFIERS = %w[auth body_data verb].freeze
|
11
12
|
HASH_MODIFIERS = %w[header].freeze
|
12
|
-
MODIFIERS = COMMON_MODIFIERS + HASH_MODIFIERS.map(&:pluralize)
|
13
|
+
MODIFIERS = COMMON_MODIFIERS + BOOLEAN_MODIFIERS + HASH_MODIFIERS.map(&:pluralize)
|
13
14
|
|
14
15
|
enable_immutable
|
16
|
+
immutable_accessor(*BOOLEAN_MODIFIERS, type: :boolean)
|
15
17
|
immutable_accessor(*COMMON_MODIFIERS, type: :common)
|
16
18
|
immutable_accessor(*HASH_MODIFIERS, type: :hash)
|
17
19
|
|
@@ -56,6 +58,25 @@ module EacRest
|
|
56
58
|
curl.headers.merge!(headers)
|
57
59
|
end
|
58
60
|
|
61
|
+
def build_curl_ssl_verify(curl)
|
62
|
+
return if ssl_verify?.nil?
|
63
|
+
|
64
|
+
curl.ssl_verify_host = ssl_verify?
|
65
|
+
curl.ssl_verify_peer = ssl_verify?
|
66
|
+
end
|
67
|
+
|
68
|
+
def build_curl_ssl_verify_peer(curl)
|
69
|
+
return if ssl_verify_peer?.nil?
|
70
|
+
|
71
|
+
curl.ssl_verify_peer = ssl_verify_peer?
|
72
|
+
end
|
73
|
+
|
74
|
+
def build_curl_ssl_verify_host(curl)
|
75
|
+
return if ssl_verify_host?.nil?
|
76
|
+
|
77
|
+
curl.ssl_verify_peer = ssl_verify_host?
|
78
|
+
end
|
79
|
+
|
59
80
|
def build_curl_verb(curl)
|
60
81
|
curl.set(
|
61
82
|
:customrequest,
|
@@ -6,6 +6,18 @@ require 'json'
|
|
6
6
|
|
7
7
|
module EacRest
|
8
8
|
class Response < ::StandardError
|
9
|
+
HEADER_LINE_PARSER = /\A([^:]+):(.*)\z/.to_parser do |m|
|
10
|
+
[m[1].strip, m[2].strip]
|
11
|
+
end
|
12
|
+
|
13
|
+
# https://www.w3.org/wiki/LinkHeader
|
14
|
+
LINKS_HEADER_NAME = 'Link'
|
15
|
+
|
16
|
+
# https://www.w3.org/wiki/LinkHeader
|
17
|
+
LINK_PARSER = /\A\<(.+)\>\s*;\s*rel\s*=\s*\"(.*)\"\z/.to_parser do |m|
|
18
|
+
[m[2], m[1]]
|
19
|
+
end
|
20
|
+
|
9
21
|
common_constructor :curl, :body_data_proc
|
10
22
|
|
11
23
|
def body_data
|
@@ -23,7 +35,7 @@ module EacRest
|
|
23
35
|
body_data
|
24
36
|
end
|
25
37
|
|
26
|
-
delegate :body_str,
|
38
|
+
delegate :body_str, to: :performed_curl
|
27
39
|
|
28
40
|
def body_str_or_raise
|
29
41
|
raise_unless_200
|
@@ -31,6 +43,26 @@ module EacRest
|
|
31
43
|
body_str
|
32
44
|
end
|
33
45
|
|
46
|
+
def header(name)
|
47
|
+
hash_search(headers, name)
|
48
|
+
end
|
49
|
+
|
50
|
+
def headers
|
51
|
+
performed_curl.header_str.each_line.map(&:strip)[1..-1].reject(&:blank?)
|
52
|
+
.map { |header_line| HEADER_LINE_PARSER.parse!(header_line) }
|
53
|
+
.to_h
|
54
|
+
end
|
55
|
+
|
56
|
+
def link(rel)
|
57
|
+
hash_search(links, rel)
|
58
|
+
end
|
59
|
+
|
60
|
+
def links
|
61
|
+
header(LINKS_HEADER_NAME).if_present({}) do |v|
|
62
|
+
v.split(',').map { |w| LINK_PARSER.parse!(w.strip) }.to_h
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
34
66
|
def raise_unless_200
|
35
67
|
return nil if status == 200
|
36
68
|
|
@@ -57,6 +89,14 @@ module EacRest
|
|
57
89
|
Hash.from_xml(body_str)
|
58
90
|
end
|
59
91
|
|
92
|
+
def hash_search(hash, key)
|
93
|
+
key = key.to_s.downcase
|
94
|
+
hash.each do |k, v|
|
95
|
+
return v if k.to_s.downcase == key
|
96
|
+
end
|
97
|
+
nil
|
98
|
+
end
|
99
|
+
|
60
100
|
def perform
|
61
101
|
@perform ||= begin
|
62
102
|
curl.perform || raise("CURL perform failed for #{url}")
|
@@ -17,5 +17,5 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.add_dependency 'eac_ruby_gems_utils', '~> 0.9', '~> 0.9.6'
|
18
18
|
s.add_dependency 'eac_ruby_utils', '~> 0.70'
|
19
19
|
|
20
|
-
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.
|
20
|
+
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5.1'
|
21
21
|
end
|
@@ -23,7 +23,7 @@ module EacRubyBase0
|
|
23
23
|
delegate :version, to: :self_gem
|
24
24
|
|
25
25
|
def all_gems
|
26
|
-
|
26
|
+
sub_gems + [self_gem]
|
27
27
|
end
|
28
28
|
|
29
29
|
# @return [EacCli::Config]
|
@@ -75,7 +75,7 @@ CODE
|
|
75
75
|
::EacRubyGemsUtils::Gem.new(gemspec_dir)
|
76
76
|
end
|
77
77
|
|
78
|
-
def
|
78
|
+
def sub_gems_uncached
|
79
79
|
r = []
|
80
80
|
vendor_dir.children.each do |c|
|
81
81
|
vgem = ::EacRubyGemsUtils::Gem.new(c)
|
@@ -19,5 +19,5 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.add_dependency 'addressable', '~> 2.6'
|
20
20
|
s.add_dependency 'filesize'
|
21
21
|
s.add_dependency 'net-ssh', '~> 4.2'
|
22
|
-
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.
|
22
|
+
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5.1'
|
23
23
|
end
|
@@ -16,7 +16,7 @@ module EacRubyUtils
|
|
16
16
|
# @raise [ArgumentError]
|
17
17
|
def variableize(string, validate = true)
|
18
18
|
r = ::ActiveSupport::Inflector.transliterate(string).gsub(/[^_a-z0-9]/i, '_')
|
19
|
-
|
19
|
+
.gsub(/_+/, '_').gsub(/_\z/, '').gsub(/\A_/, '').downcase
|
20
20
|
m = VARIABLE_NAME_PATTERN.match(r)
|
21
21
|
return r if m
|
22
22
|
return nil unless validate
|
@@ -1,8 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'eac_ruby_utils/listable/value'
|
4
|
+
|
3
5
|
module EacRubyUtils
|
4
6
|
module Listable
|
5
7
|
class List
|
8
|
+
BLANK_VALUE = nil
|
9
|
+
BLANK_KEY = :__blank
|
10
|
+
|
6
11
|
attr_reader :item
|
7
12
|
|
8
13
|
def initialize(lists, item, labels)
|
@@ -12,6 +17,10 @@ module EacRubyUtils
|
|
12
17
|
apply_constants
|
13
18
|
end
|
14
19
|
|
20
|
+
def blank_value
|
21
|
+
@blank_value ||= ::EacRubyUtils::Listable::Value.new(self, BLANK_VALUE, BLANK_KEY, false)
|
22
|
+
end
|
23
|
+
|
15
24
|
def each_value(&block)
|
16
25
|
values.each(&block)
|
17
26
|
end
|
@@ -34,7 +43,7 @@ module EacRubyUtils
|
|
34
43
|
end
|
35
44
|
|
36
45
|
def hash_keys_validate!(hash, error_class = ::StandardError)
|
37
|
-
hash.
|
46
|
+
hash.each_key { |key| value_validate!(key, error_class) }
|
38
47
|
hash
|
39
48
|
end
|
40
49
|
|
@@ -42,11 +51,14 @@ module EacRubyUtils
|
|
42
51
|
"eac_ruby_utils.listable.#{class_i18n_key}.#{item}"
|
43
52
|
end
|
44
53
|
|
54
|
+
# @return [EacRubyUtils::Listable::Value, nil]
|
45
55
|
def instance_value(instance)
|
46
56
|
v = instance.send(item)
|
57
|
+
return blank_value if v.blank?
|
47
58
|
return @values[v] if @values.key?(v)
|
48
59
|
|
49
|
-
raise "List value unkown: #{v} (Source: #{@lists.source}, Item: #{item}
|
60
|
+
raise "List value unkown: \"#{v}\" (Source: #{@lists.source}, Item: #{item}, Instance: " \
|
61
|
+
"#{instance.to_debug}, Values: #{@values.keys})"
|
50
62
|
end
|
51
63
|
|
52
64
|
def value_valid?(value)
|
@@ -70,7 +82,7 @@ module EacRubyUtils
|
|
70
82
|
end
|
71
83
|
|
72
84
|
def find_list_by_method(method)
|
73
|
-
@values.
|
85
|
+
@values.each_value do |v|
|
74
86
|
return v if method.to_s == "value_#{v.key}"
|
75
87
|
end
|
76
88
|
nil
|
@@ -81,7 +93,7 @@ module EacRubyUtils
|
|
81
93
|
end
|
82
94
|
|
83
95
|
def apply_constants
|
84
|
-
@values.
|
96
|
+
@values.each_value do |v|
|
85
97
|
@lists.source.const_set(v.constant_name, v.value)
|
86
98
|
end
|
87
99
|
end
|
@@ -7,10 +7,11 @@ module EacRubyUtils
|
|
7
7
|
class Value
|
8
8
|
attr_reader :value, :key
|
9
9
|
|
10
|
-
def initialize(list, value, key)
|
10
|
+
def initialize(list, value, key, translation_required = true)
|
11
11
|
@list = list
|
12
12
|
@value = value
|
13
13
|
@key = key
|
14
|
+
@translation_required = translation_required
|
14
15
|
end
|
15
16
|
|
16
17
|
def to_s
|
@@ -29,10 +30,19 @@ module EacRubyUtils
|
|
29
30
|
translate('description')
|
30
31
|
end
|
31
32
|
|
33
|
+
def translation_required?
|
34
|
+
@translation_required
|
35
|
+
end
|
36
|
+
|
32
37
|
private
|
33
38
|
|
34
39
|
def translate(translate_key)
|
35
|
-
|
40
|
+
full_translate_key = "#{@list.i18n_key}.#{@key}.#{translate_key}"
|
41
|
+
if !::I18n.exists?(full_translate_key) && !translation_required?
|
42
|
+
''
|
43
|
+
else
|
44
|
+
::I18n.t(full_translate_key)
|
45
|
+
end
|
36
46
|
end
|
37
47
|
end
|
38
48
|
end
|
@@ -36,7 +36,7 @@ module EacRubyUtils
|
|
36
36
|
return nil unless executable.exist?
|
37
37
|
|
38
38
|
TIMEDATECTL_TIMEZONE_LINE_PATTERN.if_match(executable.command.execute!) { |m| m[1] }
|
39
|
-
|
39
|
+
.if_present { |v| ::ActiveSupport::TimeZone[v] }
|
40
40
|
end
|
41
41
|
|
42
42
|
# @return [ActiveSupport::TimeZone]
|
@@ -12,7 +12,7 @@ module EacRubyUtils
|
|
12
12
|
|
13
13
|
def on_clean_envvars(*start_with_vars)
|
14
14
|
old_values = envvars_starting_with(start_with_vars)
|
15
|
-
old_values.
|
15
|
+
old_values.each_key { |k| ENV.delete(k) }
|
16
16
|
yield
|
17
17
|
ensure
|
18
18
|
old_values&.each { |k, v| ENV[k] = v }
|
File without changes
|
@@ -4,7 +4,7 @@ require 'eac_ruby_utils/fs/temp'
|
|
4
4
|
|
5
5
|
RSpec.describe ::EacRubyUtils::Fs::Temp do
|
6
6
|
describe '#on_file' do
|
7
|
-
it do
|
7
|
+
it do # rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
|
8
8
|
temp_path = nil
|
9
9
|
described_class.on_file do |path|
|
10
10
|
temp_path = path
|
@@ -15,7 +15,7 @@ RSpec.describe ::EacRubyUtils::Fs::Temp do
|
|
15
15
|
expect(temp_path).not_to exist
|
16
16
|
end
|
17
17
|
|
18
|
-
it 'not fail if already removed' do
|
18
|
+
it 'not fail if already removed' do # rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
|
19
19
|
temp_path = nil
|
20
20
|
described_class.on_file do |path|
|
21
21
|
temp_path = path
|
@@ -29,7 +29,7 @@ RSpec.describe ::EacRubyUtils::Fs::Temp do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
describe '#on_directory' do
|
32
|
-
it do
|
32
|
+
it do # rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
|
33
33
|
temp_path = nil
|
34
34
|
described_class.on_directory do |path|
|
35
35
|
temp_path = path
|
@@ -38,7 +38,7 @@ RSpec.describe ::EacRubyUtils::Fs::Temp do
|
|
38
38
|
expect(temp_path).not_to exist
|
39
39
|
end
|
40
40
|
|
41
|
-
it 'not fail if already removed' do
|
41
|
+
it 'not fail if already removed' do # rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
|
42
42
|
temp_path = nil
|
43
43
|
described_class.on_directory do |path|
|
44
44
|
temp_path = path
|