avm-tools 0.71.0 → 0.75.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/{stereotypes/eac_rails_base0.rb → eac_rails_base0.rb} +1 -3
- data/lib/avm/eac_rails_base0/instance.rb +2 -5
- data/lib/avm/{rails/runners.rb → eac_rails_base1.rb} +2 -4
- data/lib/avm/{rails → eac_rails_base1}/instance.rb +8 -3
- data/lib/avm/eac_rails_base1/runner.rb +12 -0
- data/lib/avm/eac_rails_base1/runner/bundle.rb +28 -0
- data/lib/avm/eac_rails_base1/runner/code_runner.rb +28 -0
- data/lib/avm/eac_rails_base1/runner_with/bundle.rb +57 -0
- data/lib/avm/{stereotypes/rails.rb → eac_redmine_base0.rb} +2 -4
- data/lib/avm/eac_redmine_base0/instance.rb +2 -4
- data/lib/avm/{stereotypes/eac_ubuntu_base0.rb → eac_ubuntu_base0.rb} +1 -3
- data/lib/avm/{stereotypes/eac_webapp_base0.rb → eac_webapp_base0.rb} +1 -3
- data/lib/avm/eac_webapp_base0/deploy.rb +17 -40
- data/lib/avm/eac_webapp_base0/deploy/build.rb +48 -0
- data/lib/avm/eac_webapp_base0/deploy/git_info.rb +13 -0
- data/lib/avm/eac_webapp_base0/deploy/version.rb +4 -0
- data/lib/avm/eac_webapp_base0/deploy/write_on_target.rb +18 -0
- data/lib/avm/eac_webapp_base0/instance.rb +2 -2
- data/lib/avm/eac_webapp_base0/runner.rb +12 -0
- data/lib/avm/eac_webapp_base0/runner/apache_host.rb +2 -3
- data/lib/avm/eac_webapp_base0/runner/data.rb +1 -1
- data/lib/avm/eac_webapp_base0/runner/data/dump.rb +1 -1
- data/lib/avm/eac_webapp_base0/runner/data/load.rb +1 -1
- data/lib/avm/eac_webapp_base0/runner/deploy.rb +3 -16
- data/lib/avm/eac_wordpress_base0.rb +9 -0
- data/lib/avm/eac_wordpress_base0/apache_host.rb +25 -0
- data/lib/avm/eac_wordpress_base0/deploy.rb +10 -0
- data/lib/avm/eac_wordpress_base0/instance.rb +24 -0
- data/lib/avm/eac_writings_base0.rb +9 -0
- data/lib/avm/eac_writings_base0/apache_host.rb +17 -0
- data/lib/avm/eac_writings_base0/commons.rb +12 -0
- data/lib/avm/eac_writings_base0/deploy.rb +36 -0
- data/lib/avm/eac_writings_base0/file_build.rb +45 -0
- data/lib/avm/eac_writings_base0/file_build/base_stereotype.rb +19 -0
- data/lib/avm/eac_writings_base0/file_build/chapter_index.rb +23 -0
- data/lib/avm/eac_writings_base0/file_build/tex_source.rb +33 -0
- data/lib/avm/eac_writings_base0/instance.rb +11 -0
- data/lib/avm/eac_writings_base0/project.rb +33 -0
- data/lib/avm/eac_writings_base0/project_build.rb +117 -0
- data/lib/avm/eac_writings_base0/project_build/chapters_content.rb +47 -0
- data/lib/avm/eac_writings_base0/project_build/copy_files.rb +42 -0
- data/lib/avm/executables.rb +1 -1
- data/lib/avm/files/appendable.rb +55 -0
- data/lib/avm/files/appendable/file_content.rb +24 -0
- data/lib/avm/files/appendable/plain_directory.rb +25 -0
- data/lib/avm/files/appendable/resource_base.rb +13 -0
- data/lib/avm/files/appendable/tar_output_command.rb +26 -0
- data/lib/avm/files/appendable/templatized_directory.rb +28 -0
- data/lib/avm/files/appender.rb +11 -0
- data/lib/avm/files/deploy.rb +72 -0
- data/lib/avm/git/commit/deploy.rb +8 -61
- data/lib/avm/instances/application.rb +4 -0
- data/lib/avm/instances/base.rb +2 -1
- data/lib/avm/instances/base/auto_values.rb +2 -1
- data/lib/avm/instances/base/auto_values/access.rb +5 -4
- data/lib/avm/instances/base/auto_values/admin.rb +2 -2
- data/lib/avm/instances/base/auto_values/database.rb +1 -1
- data/lib/avm/instances/base/auto_values/filesystem.rb +6 -2
- data/lib/avm/instances/base/auto_values/mailer.rb +34 -0
- data/lib/avm/instances/base/auto_values/ruby.rb +1 -1
- data/lib/avm/instances/base/auto_values/system.rb +2 -2
- data/lib/avm/instances/entry.rb +7 -1
- data/lib/avm/instances/entry_keys.rb +42 -7
- data/lib/avm/instances/runner.rb +40 -0
- data/lib/avm/{stereotypes/postgresql.rb → postgresql.rb} +1 -3
- data/lib/avm/postgresql/instance.rb +63 -0
- data/lib/avm/postgresql/instance/data_unit.rb +39 -0
- data/lib/avm/postgresql/instance_with.rb +18 -0
- data/lib/avm/projects/stereotypes/git_subtree/publish.rb +2 -0
- data/lib/avm/projects/stereotypes/git_subtree/warp.rb +3 -0
- data/lib/avm/tools/runner.rb +3 -3
- data/lib/avm/tools/runner/eac_rails_base0.rb +5 -18
- data/lib/avm/tools/runner/eac_rails_base0/apache_path.rb +1 -1
- data/lib/avm/tools/runner/eac_rails_base0/bundle.rb +3 -3
- data/lib/avm/tools/runner/eac_rails_base0/rails_server.rb +7 -12
- data/lib/avm/tools/runner/eac_rails_base0/runner.rb +3 -3
- data/lib/avm/tools/runner/eac_redmine_base0.rb +5 -23
- data/lib/avm/tools/runner/eac_redmine_base0/core_update.rb +1 -1
- data/lib/avm/tools/runner/eac_redmine_base0/docker.rb +1 -1
- data/lib/avm/tools/runner/eac_redmine_base0/project_rename.rb +3 -3
- data/lib/avm/tools/runner/eac_wordpress_base0.rb +5 -24
- data/lib/avm/tools/runner/{eac_rails_base0/data.rb → eac_writings_base0.rb} +4 -4
- data/lib/avm/tools/runner/git/deploy.rb +1 -1
- data/lib/avm/tools/runner/instance.rb +28 -0
- data/lib/avm/tools/runner/instance/info.rb +44 -0
- data/lib/avm/tools/runner/local_project/eac_writings_base0.rb +35 -0
- data/lib/avm/tools/runner/local_project/eac_writings_base0/build_chapters.rb +48 -0
- data/lib/avm/tools/runner/local_project/eac_writings_base0/build_single.rb +37 -0
- data/lib/avm/tools/runner/local_project/eac_writings_base0/info.rb +36 -0
- data/lib/avm/tools/version.rb +1 -1
- data/template/avm/eac_rails_base0/deploy/config/envvars.d/email.yml.template +11 -0
- data/template/avm/{stereotypes/eac_ubuntu_base0 → eac_ubuntu_base0}/docker_image/Dockerfile +0 -0
- data/template/avm/{stereotypes/eac_wordpress_base0 → eac_wordpress_base0}/deploy/wp-config.php.template +0 -0
- data/template/avm/eac_writings_base0/commons/all.tex +5 -0
- data/template/avm/eac_writings_base0/commons/ebook.tex +11 -0
- data/template/avm/eac_writings_base0/commons/images.tex +11 -0
- data/template/avm/eac_writings_base0/commons/links.tex +2 -0
- data/template/avm/eac_writings_base0/commons/portuguese.tex +8 -0
- data/template/avm/eac_writings_base0/commons/source_code.tex +21 -0
- data/template/avm/eac_writings_base0/commons/source_code/java.tex +15 -0
- data/template/avm/eac_writings_base0/commons/utils.tex +6 -0
- data/template/avm/eac_writings_base0/deploy/index.html.template +9 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +12 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/blank_not_blank.rb +19 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb +43 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/file.rb +12 -31
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb +4 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/clearable_directory.rb +57 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash.rb +21 -58
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/entry_key_error.rb +8 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/node.rb +67 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/path_search.rb +39 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +4 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/blank_not_blank_spec.rb +16 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/configs_spec.rb +15 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/paths_hash_spec.rb +52 -13
- metadata +72 -35
- data/lib/avm/git/commit/deploy/appended.rb +0 -37
- data/lib/avm/git/commit/deploy/appended/base.rb +0 -17
- data/lib/avm/git/commit/deploy/appended/directory.rb +0 -32
- data/lib/avm/git/commit/deploy/appended/file_content.rb +0 -28
- data/lib/avm/rails/runners/bundle.rb +0 -35
- data/lib/avm/rails/runners/runner.rb +0 -48
- data/lib/avm/stereotypes/eac_redmine_base0.rb +0 -11
- data/lib/avm/stereotypes/eac_wordpress_base0/apache_host.rb +0 -27
- data/lib/avm/stereotypes/eac_wordpress_base0/deploy.rb +0 -12
- data/lib/avm/stereotypes/eac_wordpress_base0/instance.rb +0 -26
- data/lib/avm/stereotypes/postgresql/instance.rb +0 -65
- data/lib/avm/stereotypes/postgresql/instance/data_unit.rb +0 -41
- data/lib/avm/stereotypes/postgresql/instance_with.rb +0 -20
- data/lib/avm/tools/runner/eac_rails_base0/apache_host.rb +0 -16
- data/lib/avm/tools/runner/eac_rails_base0/deploy.rb +0 -15
- data/lib/avm/tools/runner/eac_redmine_base0/bundle.rb +0 -14
- data/lib/avm/tools/runner/eac_redmine_base0/data.rb +0 -27
- data/lib/avm/tools/runner/eac_redmine_base0/data/dump.rb +0 -16
- data/lib/avm/tools/runner/eac_redmine_base0/deploy.rb +0 -15
- data/lib/avm/tools/runner/eac_redmine_base0/runner.rb +0 -14
- data/lib/avm/tools/runner/eac_wordpress_base0/apache_host.rb +0 -17
- data/lib/avm/tools/runner/eac_wordpress_base0/data.rb +0 -15
- data/lib/avm/tools/runner/eac_wordpress_base0/deploy.rb +0 -15
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/eac_writings_base0/project_build'
|
4
|
+
require 'eac_cli/core_ext'
|
5
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Tools
|
9
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
10
|
+
class LocalProject < ::EacRubyUtils::Console::DocoptRunner
|
11
|
+
class EacWritingsBase0 < ::EacRubyUtils::Console::DocoptRunner
|
12
|
+
class BuildChapters
|
13
|
+
runner_with
|
14
|
+
|
15
|
+
runner_definition do
|
16
|
+
arg_opt '-o', '--output-dir', 'Output chapters to specific directory.'
|
17
|
+
end
|
18
|
+
|
19
|
+
def run
|
20
|
+
runner_context.call(:project_banner)
|
21
|
+
output_dir.mkpath
|
22
|
+
project.chapters.each_with_index do |c, i|
|
23
|
+
::Avm::EacWritingsBase0::ProjectBuild.new(project, chapter_build_options(c, i))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def chapter_build_options(chapter, index)
|
30
|
+
output_name = "#{(index + 1).to_s.rjust(3, '0')}_#{chapter}.pdf"
|
31
|
+
{ output_file: output_dir.join(output_name), chapter: chapter }
|
32
|
+
end
|
33
|
+
|
34
|
+
def output_dir_uncached
|
35
|
+
(
|
36
|
+
parsed.output_dir || project.default_output_dir.join('chapters')
|
37
|
+
).to_pathname
|
38
|
+
end
|
39
|
+
|
40
|
+
def project
|
41
|
+
runner_context.call(:project)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/eac_writings_base0/project_build'
|
4
|
+
require 'eac_cli/core_ext'
|
5
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Tools
|
9
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
10
|
+
class LocalProject < ::EacRubyUtils::Console::DocoptRunner
|
11
|
+
class EacWritingsBase0 < ::EacRubyUtils::Console::DocoptRunner
|
12
|
+
class BuildSingle
|
13
|
+
runner_with
|
14
|
+
runner_definition do
|
15
|
+
arg_opt '-s', '--source-dir', 'Write .tex source code in specific directory.'
|
16
|
+
arg_opt '-f', '--output-file', 'Output to specific file.'
|
17
|
+
arg_opt '-c', '--chapter', 'Write only the chapter <chapter>.'
|
18
|
+
bool_opt '-o', '--open', 'Open the file after build.'
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
runner_context.call(:project_banner)
|
23
|
+
infov 'Build options', build_options
|
24
|
+
::Avm::EacWritingsBase0::ProjectBuild.new(runner_context.call(:project), parsed)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def build_options
|
30
|
+
parsed.slice_fetch(:output_file, :open, :chapter, :source_dir)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/eac_writings_base0/project_build'
|
4
|
+
require 'eac_cli/core_ext'
|
5
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Tools
|
9
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
10
|
+
class LocalProject < ::EacRubyUtils::Console::DocoptRunner
|
11
|
+
class EacWritingsBase0 < ::EacRubyUtils::Console::DocoptRunner
|
12
|
+
class Info
|
13
|
+
runner_with
|
14
|
+
runner_definition do
|
15
|
+
desc 'Information about a loca EacRailsBase0 local project.'
|
16
|
+
end
|
17
|
+
|
18
|
+
def run
|
19
|
+
runner_context.call(:project_banner)
|
20
|
+
infov 'Chapters', project.chapters.count
|
21
|
+
project.chapters.each_with_index do |chapter, index|
|
22
|
+
infov " * #{index + 1}", chapter
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def project
|
29
|
+
runner_context.call(:project)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/avm/tools/version.rb
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
---
|
2
|
+
action_mailer_smtp_address: '%%MAILER.SMTP.ADDRESS%%'
|
3
|
+
action_mailer_smtp_port: '%%MAILER.SMTP.PORT%%'
|
4
|
+
action_mailer_smtp_domain: '%%MAILER.SMTP.DOMAIN%%'
|
5
|
+
action_mailer_smtp_username: '%%MAILER.SMTP.USERNAME%%'
|
6
|
+
action_mailer_smtp_password: '%%MAILER.SMTP.PASSWORD%%'
|
7
|
+
action_mailer_smtp_authentication: '%%MAILER.SMTP.AUTHENTICATION%%'
|
8
|
+
action_mailer_smtp_enable_starttls_auto: '%%MAILER.SMTP.STARTTLS_AUTO%%'
|
9
|
+
action_mailer_default_options_from: '%%MAILER.FROM%%'
|
10
|
+
action_mailer_default_options_reply_to: '%%MAILER.REPLY_TO%%'
|
11
|
+
action_mailer_default_url_host: '%%WEB.URL%%'
|
File without changes
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
\documentclass[a4paper,twoside,final,12pt,openany]{memoir}
|
2
|
+
\input{commons/all}
|
3
|
+
\setlength{\parindent}{0em}
|
4
|
+
\setlength{\parskip}{1em}
|
5
|
+
\setlrmarginsandblock{1cm}{1cm}{*}
|
6
|
+
\setulmarginsandblock{2cm}{2cm}{*}
|
7
|
+
\checkandfixthelayout
|
8
|
+
|
9
|
+
\newcommand{\chapref}[1] {
|
10
|
+
Cap. \ref{chap:#1} - \nameref{chap:#1}
|
11
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
\usepackage[utf8]{inputenc}
|
2
|
+
\usepackage[portuguese]{babel}
|
3
|
+
\usepackage{listings}
|
4
|
+
\lstset{
|
5
|
+
inputencoding=utf8,
|
6
|
+
extendedchars=true,
|
7
|
+
literate={á}{{\'a}}1 {à}{{\`a}}1 {ã}{{\~a}}1 {â}{{\^a}}1 {é}{{\'e}}1 {ê}{{\^e}}1 {ë}{{\"e}}1 {í}{{\'i}}1 {ç}{{\c{c}}}1 {Ç}{{\c{C}}}1 {õ}{{\~o}}1 {Õ}{{\~O}}1 {ó}{{\'o}}1 {ô}{{\^o}}1 {ú}{{\'u}}1
|
8
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
\usepackage[dvipsnames]{xcolor}
|
2
|
+
\usepackage{listings}
|
3
|
+
\usepackage{courier}
|
4
|
+
\usepackage[T1]{fontenc}
|
5
|
+
\usepackage{textcomp}
|
6
|
+
\definecolor{code_background}{rgb}{0.95,0.95,0.95}
|
7
|
+
\lstset{
|
8
|
+
backgroundcolor=\color{code_background},
|
9
|
+
breakatwhitespace=false,
|
10
|
+
breaklines=true,
|
11
|
+
basicstyle=\ttfamily\color{black},
|
12
|
+
commentstyle = \ttfamily\color{gray},
|
13
|
+
keywordstyle=\ttfamily\color{blue},
|
14
|
+
stringstyle=\color{orange},
|
15
|
+
showstringspaces=false,
|
16
|
+
frame=single,
|
17
|
+
basicstyle=\ttfamily\tiny,
|
18
|
+
columns=flexible,
|
19
|
+
upquote=true,
|
20
|
+
}
|
21
|
+
\input{commons/source_code/java}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
\lstloadlanguages{Java}
|
2
|
+
\newcommand{\java}[1] {
|
3
|
+
\lstinline[language=Java]{#1}
|
4
|
+
}
|
5
|
+
\newcommand{\javafile}[1] {
|
6
|
+
\begin{minipage}{\linewidth}
|
7
|
+
\lstinputlisting[language=Java,caption=$#1$]{#1}
|
8
|
+
\end{minipage}
|
9
|
+
}
|
10
|
+
\lstnewenvironment{javaenv} {
|
11
|
+
\lstset{language=Java}
|
12
|
+
\minipage\linewidth
|
13
|
+
} {
|
14
|
+
\endminipage
|
15
|
+
}
|
@@ -10,6 +10,7 @@ module EacRubyBase0
|
|
10
10
|
include ::EacCli::DefaultRunner
|
11
11
|
runner_definition do
|
12
12
|
bool_opt '-q', '--quiet', 'Quiet mode.'
|
13
|
+
bool_opt '-I', '--no-input', 'Fail if a input is requested.'
|
13
14
|
subcommands
|
14
15
|
alt do
|
15
16
|
bool_opt '-V', '--version', 'Show version.'
|
@@ -20,6 +21,7 @@ module EacRubyBase0
|
|
20
21
|
def run
|
21
22
|
on_speaker_node do |node|
|
22
23
|
node.stderr = ::StringIO.new if options.fetch('--quiet')
|
24
|
+
node.stdin = FailIfRequestInput.new if options.fetch('--no-input')
|
23
25
|
if options.fetch('--version')
|
24
26
|
show_version
|
25
27
|
else
|
@@ -35,5 +37,15 @@ module EacRubyBase0
|
|
35
37
|
def show_version
|
36
38
|
out("#{application_version}\n")
|
37
39
|
end
|
40
|
+
|
41
|
+
class FailIfRequestInput
|
42
|
+
enable_console_speaker
|
43
|
+
|
44
|
+
%w[gets noecho].each do |method|
|
45
|
+
define_method(method) do
|
46
|
+
raise "Input method requested (\"#{method}\") and option --no-input is set"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
38
50
|
end
|
39
51
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/object/blank'
|
4
|
+
require 'singleton'
|
5
|
+
|
6
|
+
module EacRubyUtils
|
7
|
+
# A blank string which returns +false+ for +blank?+ method.
|
8
|
+
class BlankNotBlank < String
|
9
|
+
include ::Singleton
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super('')
|
13
|
+
end
|
14
|
+
|
15
|
+
def blank?
|
16
|
+
false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/blank_not_blank'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
require 'eac_ruby_utils/paths_hash'
|
6
|
+
|
7
|
+
module EacRubyUtils
|
8
|
+
class Configs
|
9
|
+
class Base
|
10
|
+
enable_simple_cache
|
11
|
+
|
12
|
+
common_constructor :data, default: [{}] do
|
13
|
+
self.data = ::EacRubyUtils::PathsHash.new(data)
|
14
|
+
end
|
15
|
+
|
16
|
+
def []=(entry_key, entry_value)
|
17
|
+
write(entry_key, entry_value)
|
18
|
+
end
|
19
|
+
|
20
|
+
def [](entry_key)
|
21
|
+
read(entry_key)
|
22
|
+
end
|
23
|
+
|
24
|
+
def clear
|
25
|
+
replace({})
|
26
|
+
end
|
27
|
+
|
28
|
+
def read(entry_key)
|
29
|
+
return nil unless data.key?(entry_key)
|
30
|
+
|
31
|
+
data.fetch(entry_key).if_present(::EacRubyUtils::BlankNotBlank.instance)
|
32
|
+
end
|
33
|
+
|
34
|
+
def replace(new_data)
|
35
|
+
self.data = ::EacRubyUtils::PathsHash.new(new_data)
|
36
|
+
end
|
37
|
+
|
38
|
+
def write(entry_key, entry_value)
|
39
|
+
data[entry_key] = entry_value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -1,27 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'eac_ruby_utils/configs/base'
|
4
4
|
require 'yaml'
|
5
|
-
require 'eac_ruby_utils/patches/hash/sym_keys_hash'
|
6
|
-
require 'eac_ruby_utils/paths_hash'
|
7
|
-
require 'eac_ruby_utils/simple_cache'
|
8
5
|
|
9
6
|
module EacRubyUtils
|
10
7
|
class Configs
|
11
|
-
class File
|
12
|
-
include ::EacRubyUtils::SimpleCache
|
13
|
-
|
8
|
+
class File < ::EacRubyUtils::Configs::Base
|
14
9
|
attr_reader :path, :options
|
15
10
|
|
16
11
|
# Valid options: [:autosave]
|
17
12
|
def initialize(path, options = {})
|
18
13
|
@path = path
|
19
14
|
@options = options.to_sym_keys_hash.freeze
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
def clear
|
24
|
-
self.data = ::EacRubyUtils::PathsHash.new({})
|
15
|
+
super(raw_data_from_file)
|
25
16
|
end
|
26
17
|
|
27
18
|
def save
|
@@ -30,37 +21,27 @@ module EacRubyUtils
|
|
30
21
|
end
|
31
22
|
|
32
23
|
def load
|
33
|
-
|
34
|
-
::EacRubyUtils::PathsHash.new(YAML.load_file(path))
|
35
|
-
else
|
36
|
-
{}
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def []=(entry_key, entry_value)
|
41
|
-
write(entry_key, entry_value)
|
24
|
+
replace(raw_data_from_file)
|
42
25
|
end
|
43
26
|
|
44
27
|
def write(entry_key, entry_value)
|
45
|
-
|
28
|
+
super
|
46
29
|
save if autosave?
|
47
30
|
end
|
48
31
|
|
49
|
-
def [](entry_key)
|
50
|
-
read(entry_key)
|
51
|
-
end
|
52
|
-
|
53
|
-
def read(entry_key)
|
54
|
-
data[entry_key]
|
55
|
-
end
|
56
|
-
|
57
32
|
def autosave?
|
58
33
|
options[:autosave] ? true : false
|
59
34
|
end
|
60
35
|
|
61
36
|
private
|
62
37
|
|
63
|
-
|
38
|
+
def raw_data_from_file
|
39
|
+
if ::File.exist?(path) && ::File.size(path).positive?
|
40
|
+
::YAML.load_file(path)
|
41
|
+
else
|
42
|
+
{}
|
43
|
+
end
|
44
|
+
end
|
64
45
|
end
|
65
46
|
end
|
66
47
|
end
|
@@ -66,7 +66,10 @@ module EacRubyUtils
|
|
66
66
|
protected
|
67
67
|
|
68
68
|
def envvar_read_entry(entry_key)
|
69
|
-
|
69
|
+
env_entry_key = self.class.entry_key_to_envvar_name(entry_key)
|
70
|
+
return nil unless ENV.key?(env_entry_key)
|
71
|
+
|
72
|
+
ENV.fetch(env_entry_key).if_present(::EacRubyUtils::BlankNotBlank.instance)
|
70
73
|
end
|
71
74
|
|
72
75
|
def read_entry_from_console(entry_key, options)
|