avm-tools 0.82.1 → 0.86.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/avm/eac_writings_base1.rb +9 -0
- data/lib/avm/eac_writings_base1/apache_host.rb +17 -0
- data/lib/avm/eac_writings_base1/build.rb +45 -0
- data/lib/avm/eac_writings_base1/build/file.rb +28 -0
- data/lib/avm/eac_writings_base1/deploy.rb +26 -0
- data/lib/avm/eac_writings_base1/instance.rb +11 -0
- data/lib/avm/eac_writings_base1/project.rb +13 -0
- data/lib/avm/executables.rb +1 -1
- data/lib/avm/instances/base/auto_values/database.rb +10 -0
- data/lib/avm/instances/entry_keys.rb +1 -1
- data/lib/avm/projects/stereotypes/git/update.rb +42 -0
- data/lib/avm/projects/stereotypes/git/update/subrepo.rb +85 -0
- data/lib/avm/tools/runner/eac_writings_base1.rb +15 -0
- data/lib/avm/tools/runner/local_project/eac_writings_base0.rb +3 -4
- data/lib/avm/tools/runner/local_project/eac_writings_base0/build_chapters.rb +2 -4
- data/lib/avm/tools/runner/local_project/eac_writings_base0/build_single.rb +2 -3
- data/lib/avm/tools/runner/local_project/eac_writings_base0/info.rb +2 -3
- data/lib/avm/tools/runner/local_project/eac_writings_base1.rb +32 -0
- data/lib/avm/tools/runner/local_project/eac_writings_base1/build.rb +48 -0
- data/lib/avm/tools/version.rb +1 -1
- data/template/avm/eac_rails_base0/deploy/config/database.yml.template +3 -2
- data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +3 -1
- data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +5 -0
- data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
- data/vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +29 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +16 -6
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +2 -99
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_initialize.rb +29 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/instance_initialize.rb +53 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/super_args.rb +54 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb +10 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_sub.rb +2 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +14 -4
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +30 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d94c38f057d3459362f2f15eba68de92e72a7141f03a5c029e920db648eb34b
|
4
|
+
data.tar.gz: 2719a55cb7b994c496349331e4b5a40a11307e4fe92d889914d3005836d68398
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54d1c5271e6d30791bbc6a9cd6084f21ef2e171f3b64e21c315aa41f4bf2f289ae4c8725f74280a0f008d4a6fb32ce85f71fcf3f5e83d46a5ef14d48dc7a6174
|
7
|
+
data.tar.gz: 2c717894f623ab3bfd4b8b489c01adf8cc564a638c374fa1f7dbc5f9be715461ae4b1f8847b22d48a383e51775754eac408d8f6273260ff32dd1837acd5b30dd
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/eac_webapp_base0/apache_host'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module EacWritingsBase1
|
7
|
+
class ApacheHost < ::Avm::EacWebappBase0::ApacheHost
|
8
|
+
def document_root
|
9
|
+
instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH)
|
10
|
+
end
|
11
|
+
|
12
|
+
def extra_content
|
13
|
+
''
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/fs/clearable_directory'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module EacWritingsBase1
|
8
|
+
class Build
|
9
|
+
require_sub __FILE__
|
10
|
+
enable_console_speaker
|
11
|
+
enable_simple_cache
|
12
|
+
enable_listable
|
13
|
+
lists.add_symbol :option, :target_directory
|
14
|
+
common_constructor :project, :options, default: [{}] do
|
15
|
+
self.options = self.class.lists.option.hash_keys_validate!(options.symbolize_keys)
|
16
|
+
end
|
17
|
+
|
18
|
+
def run
|
19
|
+
infov 'Files to build', source_files.count
|
20
|
+
target_directory.clear
|
21
|
+
source_files.each(&:run)
|
22
|
+
end
|
23
|
+
|
24
|
+
def default_target_directory
|
25
|
+
project.root.join('build')
|
26
|
+
end
|
27
|
+
|
28
|
+
def target_directory
|
29
|
+
::EacRubyUtils::Fs::ClearableDirectory.new(
|
30
|
+
options[OPTION_TARGET_DIRECTORY] || default_target_directory
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def source_files_uncached
|
35
|
+
r = []
|
36
|
+
project.root.children.each do |child|
|
37
|
+
next unless child.extname == '.asc'
|
38
|
+
|
39
|
+
r << ::Avm::EacWritingsBase1::Build::File.new(self, child.basename)
|
40
|
+
end
|
41
|
+
r
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/executables'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module EacWritingsBase1
|
7
|
+
class Build
|
8
|
+
class File
|
9
|
+
enable_console_speaker
|
10
|
+
common_constructor :build, :subpath
|
11
|
+
|
12
|
+
def run
|
13
|
+
infov 'Building', subpath
|
14
|
+
target_path.parent.mkpath
|
15
|
+
::Avm::Executables.asciidoc.command('--out-file', target_path, source_path).system!
|
16
|
+
end
|
17
|
+
|
18
|
+
def source_path
|
19
|
+
build.project.root.join(subpath)
|
20
|
+
end
|
21
|
+
|
22
|
+
def target_path
|
23
|
+
build.target_directory.join(subpath).basename_sub('.*') { |b| "#{b}.html" }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/eac_webapp_base0/deploy'
|
4
|
+
require 'avm/eac_writings_base1/project'
|
5
|
+
require 'avm/eac_writings_base1/build'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module EacWritingsBase1
|
9
|
+
class Deploy < ::Avm::EacWebappBase0::Deploy
|
10
|
+
def build_content
|
11
|
+
::Avm::EacWritingsBase1::Build.new(
|
12
|
+
project,
|
13
|
+
::Avm::EacWritingsBase1::Build::OPTION_TARGET_DIRECTORY => build_dir
|
14
|
+
).run
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def project_uncached
|
20
|
+
::Avm::EacWritingsBase1::Project.new(
|
21
|
+
instance.source_instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH)
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/avm/executables.rb
CHANGED
@@ -14,7 +14,7 @@ module Avm
|
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
|
-
%w[docker file git latex php-cs-fixer tidy yapf xdg-open].each do |program|
|
17
|
+
%w[asciidoc docker file git latex php-cs-fixer tidy yapf xdg-open].each do |program|
|
18
18
|
define_method(program.underscore + '_uncached') do
|
19
19
|
env.executable(program, '--version')
|
20
20
|
end
|
@@ -8,6 +8,7 @@ module Avm
|
|
8
8
|
module AutoValues
|
9
9
|
module Database
|
10
10
|
DEFAULT_HOSTNAME = '127.0.0.1'
|
11
|
+
DEFAULT_LIMIT = 5
|
11
12
|
DEFAULT_PORTS = {
|
12
13
|
'postgresql' => 5432,
|
13
14
|
'mysql' => 3306,
|
@@ -15,6 +16,7 @@ module Avm
|
|
15
16
|
'sqlserver' => 1433
|
16
17
|
}.freeze
|
17
18
|
DEFAULT_SYSTEM = 'postgresql'
|
19
|
+
DEFAULT_TIMEOUT = 5000
|
18
20
|
|
19
21
|
def auto_database_name
|
20
22
|
inherited_entry_value(::Avm::Instances::EntryKeys::DATABASE_ID,
|
@@ -25,6 +27,10 @@ module Avm
|
|
25
27
|
database_auto_common('hostname') || DEFAULT_HOSTNAME
|
26
28
|
end
|
27
29
|
|
30
|
+
def auto_database_limit
|
31
|
+
database_auto_common('limit') || DEFAULT_LIMIT
|
32
|
+
end
|
33
|
+
|
28
34
|
def auto_database_password
|
29
35
|
database_auto_common('password')
|
30
36
|
end
|
@@ -41,6 +47,10 @@ module Avm
|
|
41
47
|
database_auto_common('system') || DEFAULT_SYSTEM
|
42
48
|
end
|
43
49
|
|
50
|
+
def auto_database_timeout
|
51
|
+
database_auto_common('timeout') || DEFAULT_TIMEOUT
|
52
|
+
end
|
53
|
+
|
44
54
|
private
|
45
55
|
|
46
56
|
def database_auto_common(suffix)
|
@@ -41,7 +41,7 @@ module Avm
|
|
41
41
|
|
42
42
|
{
|
43
43
|
'' => %w[fs_path host_id source_instance_id],
|
44
|
-
database: %w[id hostname name password port system username],
|
44
|
+
database: %w[id hostname limit name password port system timeout username],
|
45
45
|
mailer: {
|
46
46
|
'' => %w[id from reply_to],
|
47
47
|
smtp: %w[address port domain username password authentication starttls_auto]
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'avm/patches/class/i18n'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Projects
|
8
|
+
module Stereotypes
|
9
|
+
class Git
|
10
|
+
class Update
|
11
|
+
require_sub __FILE__
|
12
|
+
enable_simple_cache
|
13
|
+
enable_console_speaker
|
14
|
+
common_constructor :instance
|
15
|
+
|
16
|
+
delegate :git_repo, to: :instance
|
17
|
+
|
18
|
+
def run
|
19
|
+
clean_all
|
20
|
+
selected_subrepos.map do |f|
|
21
|
+
infov 'Subrepo', f
|
22
|
+
on_speaker_node do |node|
|
23
|
+
node.stderr_line_prefix = ' '
|
24
|
+
::Avm::Projects::Stereotypes::Git::Update::Subrepo.new(self, f).run
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def selected_subrepos_uncached
|
30
|
+
git_repo.command('subrepo', '-q', 'status').execute!.split("\n").map(&:strip)
|
31
|
+
.select(&:present?).map(&:to_pathname)
|
32
|
+
end
|
33
|
+
|
34
|
+
def clean_all
|
35
|
+
infom 'Cleaning'
|
36
|
+
git_repo.command('subrepo', 'clean', '--all').execute!
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_launcher/git/base'
|
4
|
+
require 'avm/git/commit'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Projects
|
8
|
+
module Stereotypes
|
9
|
+
class Git
|
10
|
+
class Update
|
11
|
+
class Subrepo
|
12
|
+
TRANSLATE_CLASS = self
|
13
|
+
|
14
|
+
require_sub __FILE__, include_modules: true
|
15
|
+
enable_simple_cache
|
16
|
+
enable_console_speaker
|
17
|
+
common_constructor :parent_update, :subpath do
|
18
|
+
self.subpath = subpath.to_pathname
|
19
|
+
end
|
20
|
+
|
21
|
+
delegate :git_repo, :instance, to: :parent_update
|
22
|
+
|
23
|
+
def run
|
24
|
+
run_banner
|
25
|
+
if base_commit.sha1 == pull_commit.sha1
|
26
|
+
infom 'No new commit (No changes)'
|
27
|
+
elsif fix_message.present?
|
28
|
+
on_fix_message_present
|
29
|
+
else
|
30
|
+
warn 'No fix message found'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def base_commit_uncached
|
37
|
+
::Avm::Git::Commit.new(git_repo, git_repo.rev_parse('HEAD'))
|
38
|
+
end
|
39
|
+
|
40
|
+
def on_fix_message_present
|
41
|
+
infom 'Fixing message...'
|
42
|
+
infov 'Message', fix_message
|
43
|
+
git_repo.command('commit', '--amend', '-m', fix_message).execute!
|
44
|
+
end
|
45
|
+
|
46
|
+
def pull_commit_uncached
|
47
|
+
base_commit
|
48
|
+
infom 'Pulling subrepo...'
|
49
|
+
git_repo.command('subrepo', 'pull', '--force', subpath).execute!
|
50
|
+
::Avm::Git::Commit.new(
|
51
|
+
::EacLauncher::Git::Base.new(git_repo.root_path.to_path),
|
52
|
+
git_repo.rev_parse('HEAD')
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
def run_banner
|
57
|
+
infov 'Base SHA1', base_commit.sha1
|
58
|
+
infov 'Pull SHA1', pull_commit.sha1
|
59
|
+
end
|
60
|
+
|
61
|
+
def fix_message
|
62
|
+
TRANSLATE_CLASS.translate(
|
63
|
+
fix_message_translate_key, subpath: subpath, name: subpath.basename,
|
64
|
+
__locale: instance.locale
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
def fix_message_translate_key
|
69
|
+
if gitrepo_only_changed?
|
70
|
+
:gitrepo_only_changed_fix_message
|
71
|
+
else
|
72
|
+
:content_updated_fix_message
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def gitrepo_only_changed?
|
77
|
+
pull_commit.files.count == 1 &&
|
78
|
+
::File.basename(pull_commit.files.first.path) == '.gitrepo'
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/eac_webapp_base0/runner'
|
4
|
+
require 'avm/eac_writings_base1'
|
5
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Tools
|
9
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
10
|
+
class EacWritingsBase1 < ::Avm::EacWebappBase0::Runner
|
11
|
+
require_sub __FILE__
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -8,12 +8,11 @@ module Avm
|
|
8
8
|
module Tools
|
9
9
|
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
10
10
|
class LocalProject < ::EacRubyUtils::Console::DocoptRunner
|
11
|
-
class EacWritingsBase0
|
11
|
+
class EacWritingsBase0
|
12
12
|
require_sub __FILE__
|
13
|
-
runner_with
|
14
13
|
enable_simple_cache
|
15
14
|
|
16
|
-
|
15
|
+
runner_with :help, :subcommands do
|
17
16
|
desc 'EacWritingsBase0 utitilies for local projects.'
|
18
17
|
subcommands
|
19
18
|
end
|
@@ -26,7 +25,7 @@ module Avm
|
|
26
25
|
private
|
27
26
|
|
28
27
|
def project_uncached
|
29
|
-
::Avm::EacWritingsBase0::Project.new(
|
28
|
+
::Avm::EacWritingsBase0::Project.new(runner_context.call(:instance_path))
|
30
29
|
end
|
31
30
|
end
|
32
31
|
end
|
@@ -8,11 +8,9 @@ module Avm
|
|
8
8
|
module Tools
|
9
9
|
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
10
10
|
class LocalProject < ::EacRubyUtils::Console::DocoptRunner
|
11
|
-
class EacWritingsBase0
|
11
|
+
class EacWritingsBase0
|
12
12
|
class BuildChapters
|
13
|
-
runner_with
|
14
|
-
|
15
|
-
runner_definition do
|
13
|
+
runner_with :help do
|
16
14
|
arg_opt '-o', '--output-dir', 'Output chapters to specific directory.'
|
17
15
|
end
|
18
16
|
|
@@ -8,10 +8,9 @@ module Avm
|
|
8
8
|
module Tools
|
9
9
|
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
10
10
|
class LocalProject < ::EacRubyUtils::Console::DocoptRunner
|
11
|
-
class EacWritingsBase0
|
11
|
+
class EacWritingsBase0
|
12
12
|
class BuildSingle
|
13
|
-
runner_with
|
14
|
-
runner_definition do
|
13
|
+
runner_with :help do
|
15
14
|
arg_opt '-s', '--source-dir', 'Write .tex source code in specific directory.'
|
16
15
|
arg_opt '-f', '--output-file', 'Output to specific file.'
|
17
16
|
arg_opt '-c', '--chapter', 'Write only the chapter <chapter>.'
|
@@ -8,10 +8,9 @@ module Avm
|
|
8
8
|
module Tools
|
9
9
|
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
10
10
|
class LocalProject < ::EacRubyUtils::Console::DocoptRunner
|
11
|
-
class EacWritingsBase0
|
11
|
+
class EacWritingsBase0
|
12
12
|
class Info
|
13
|
-
runner_with
|
14
|
-
runner_definition do
|
13
|
+
runner_with :help do
|
15
14
|
desc 'Information about a loca EacRailsBase0 local project.'
|
16
15
|
end
|
17
16
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Tools
|
8
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
9
|
+
class LocalProject < ::EacRubyUtils::Console::DocoptRunner
|
10
|
+
class EacWritingsBase1
|
11
|
+
require_sub __FILE__
|
12
|
+
|
13
|
+
runner_with :help, :subcommands do
|
14
|
+
desc 'EacWritingsBase0 utitilies for local projects.'
|
15
|
+
subcommands
|
16
|
+
end
|
17
|
+
|
18
|
+
def project_banner
|
19
|
+
infov 'Project', project.name
|
20
|
+
infov 'Path', project.root
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def project_uncached
|
26
|
+
::Avm::EacWritingsBase0::Project.new(runner_context.call(:instance_path))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/eac_writings_base1/build'
|
4
|
+
require 'avm/eac_writings_base1/project'
|
5
|
+
require 'eac_cli/core_ext'
|
6
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
7
|
+
|
8
|
+
module Avm
|
9
|
+
module Tools
|
10
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
11
|
+
class LocalProject < ::EacRubyUtils::Console::DocoptRunner
|
12
|
+
class EacWritingsBase1
|
13
|
+
class Build
|
14
|
+
runner_with :help do
|
15
|
+
desc 'Build the project'
|
16
|
+
arg_opt '-d', '--target-dir', 'Directory to build'
|
17
|
+
end
|
18
|
+
|
19
|
+
def run
|
20
|
+
start_banner
|
21
|
+
build.run
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def build_uncached
|
27
|
+
::Avm::EacWritingsBase1::Build.new(runner_context.call(:project),
|
28
|
+
target_directory: parsed.target_dir)
|
29
|
+
end
|
30
|
+
|
31
|
+
def default_target_directory
|
32
|
+
runner_context.call(:project).root.join('build')
|
33
|
+
end
|
34
|
+
|
35
|
+
def start_banner
|
36
|
+
runner_context.call(:project_banner)
|
37
|
+
infov 'Target directory', build.target_directory
|
38
|
+
end
|
39
|
+
#
|
40
|
+
# def target_directory_uncached
|
41
|
+
# .if_present(default_target_directory).to_pathname
|
42
|
+
# end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/avm/tools/version.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
default: &default
|
2
2
|
adapter: %%DATABASE.SYSTEM%%
|
3
|
-
pool:
|
4
|
-
timeout:
|
3
|
+
pool: %%DATABASE.LIMIT%%
|
4
|
+
timeout: %%DATABASE.TIMEOUT%%
|
5
5
|
encoding: unicode
|
6
6
|
username: %%DATABASE.USERNAME%%
|
7
7
|
password: %%DATABASE.PASSWORD%%
|
8
8
|
host: %%DATABASE.HOSTNAME%%
|
9
9
|
port: %%DATABASE.PORT%%
|
10
|
+
reconnect: true
|
10
11
|
|
11
12
|
development: &development
|
12
13
|
<<: *default
|
@@ -27,7 +27,9 @@ module EacCli
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def help_text
|
30
|
-
::EacCli::Docopt::DocBuilder.new(self.class.runner_definition).to_s
|
30
|
+
r = ::EacCli::Docopt::DocBuilder.new(self.class.runner_definition).to_s
|
31
|
+
r += help_extra_text if respond_to?(:help_extra_text)
|
32
|
+
r
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
@@ -31,6 +31,11 @@ module EacCli
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
def help_extra_text
|
35
|
+
(['Subcommands:'] + available_subcommands.keys.map { |s| " #{s}" })
|
36
|
+
.map { |v| "#{v}\n" }.join
|
37
|
+
end
|
38
|
+
|
34
39
|
def method_missing(method_name, *arguments, &block)
|
35
40
|
return run_with_subcommand(*arguments, &block) if
|
36
41
|
run_with_subcommand_alias_run?(method_name)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'eac_cli/runner'
|
4
|
+
require 'eac_cli/runner_with/help'
|
4
5
|
require 'eac_cli/runner_with/subcommands'
|
5
6
|
|
6
7
|
RSpec.describe ::EacCli::RunnerWith::Subcommands do
|
@@ -53,4 +54,32 @@ RSpec.describe ::EacCli::RunnerWith::Subcommands do
|
|
53
54
|
expect { instance.run }.to raise_error(::EacCli::Parser::Error)
|
54
55
|
end
|
55
56
|
end
|
57
|
+
|
58
|
+
context 'with help' do
|
59
|
+
let(:instance) { parent_runner.create(%w[--help]) }
|
60
|
+
let(:expected_output) do
|
61
|
+
<<~OUTPUT
|
62
|
+
A stub root runner.
|
63
|
+
|
64
|
+
Usage:
|
65
|
+
__PROGRAM__ [options] __SUBCOMMANDS__ [<subcommand_args>...]
|
66
|
+
__PROGRAM__ --help
|
67
|
+
|
68
|
+
Options:
|
69
|
+
-r --root-var=<value> A root variable.
|
70
|
+
-h --help Show help.
|
71
|
+
|
72
|
+
Subcommands:
|
73
|
+
child-cmd
|
74
|
+
OUTPUT
|
75
|
+
end
|
76
|
+
|
77
|
+
before do
|
78
|
+
parent_runner.include(::EacCli::RunnerWith::Help)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'show help text' do
|
82
|
+
expect { instance.run_run }.to output(expected_output).to_stdout_from_any_process
|
83
|
+
end
|
84
|
+
end
|
56
85
|
end
|
@@ -17,15 +17,25 @@ module EacRubyUtils
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def run
|
20
|
-
setup = self
|
21
20
|
a_module.extend(::ActiveSupport::Concern)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
include_or_prepend(:included, :include)
|
22
|
+
include_or_prepend(:prepended, :prepend)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def include_or_prepend(module_method, class_setup_method)
|
28
|
+
setup = self
|
29
|
+
a_module.send(module_method, *a_module_method_args(module_method)) do
|
30
|
+
::EacRubyUtils::CommonConcern::ClassSetup.new(setup, self, class_setup_method).run
|
27
31
|
end
|
28
32
|
end
|
33
|
+
|
34
|
+
def a_module_method_args(module_method)
|
35
|
+
method_arity = a_module.method(module_method).arity
|
36
|
+
method_arity = -method_arity - 1 if method_arity.negative?
|
37
|
+
method_arity.times.map { |_n| a_module }
|
38
|
+
end
|
29
39
|
end
|
30
40
|
end
|
31
41
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'active_support/callbacks'
|
4
4
|
require 'eac_ruby_utils/arguments_consumer'
|
5
|
+
require 'eac_ruby_utils/common_constructor/class_initialize'
|
5
6
|
require 'ostruct'
|
6
7
|
|
7
8
|
module EacRubyUtils
|
@@ -76,111 +77,13 @@ module EacRubyUtils
|
|
76
77
|
end
|
77
78
|
|
78
79
|
def setup_class_initialize(klass)
|
79
|
-
common_constructor = self
|
80
80
|
klass.include(::ActiveSupport::Callbacks)
|
81
81
|
klass.define_callbacks :initialize
|
82
|
-
|
83
|
-
Initialize.new(common_constructor, args, self).run
|
84
|
-
super(*SuperArgs.new(common_constructor, args, self).result)
|
85
|
-
end
|
82
|
+
::EacRubyUtils::CommonConstructor::ClassInitialize.new(self, klass).run
|
86
83
|
end
|
87
84
|
|
88
85
|
def super_args
|
89
86
|
options[:super_args]
|
90
87
|
end
|
91
|
-
|
92
|
-
class Initialize
|
93
|
-
attr_reader :common_constructor, :args, :object
|
94
|
-
|
95
|
-
def initialize(common_constructor, args, object)
|
96
|
-
@common_constructor = common_constructor
|
97
|
-
@args = args
|
98
|
-
@object = object
|
99
|
-
end
|
100
|
-
|
101
|
-
def run
|
102
|
-
validate_args_count
|
103
|
-
object.run_callbacks :initialize do
|
104
|
-
object_attributes_set
|
105
|
-
object_after_callback
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
private
|
110
|
-
|
111
|
-
def arg_value(arg_name)
|
112
|
-
arg_index = common_constructor.args.index(arg_name)
|
113
|
-
if arg_index < args.count
|
114
|
-
args[arg_index]
|
115
|
-
else
|
116
|
-
common_constructor.default_values[arg_index - common_constructor.args_count_min]
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def object_after_callback
|
121
|
-
return unless common_constructor.after_set_block
|
122
|
-
|
123
|
-
object.instance_eval(&common_constructor.after_set_block)
|
124
|
-
end
|
125
|
-
|
126
|
-
def object_attributes_set
|
127
|
-
common_constructor.args.each do |arg_name|
|
128
|
-
object.send("#{arg_name}=", arg_value(arg_name))
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
def validate_args_count
|
133
|
-
return if common_constructor.args_count.include?(args.count)
|
134
|
-
|
135
|
-
raise ArgumentError, "#{object.class}.initialize: wrong number of arguments" \
|
136
|
-
" (given #{args.count}, expected #{common_constructor.args_count})"
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
class SuperArgs
|
141
|
-
attr_reader :common_constructor, :args, :object
|
142
|
-
|
143
|
-
def initialize(common_constructor, args, object)
|
144
|
-
@common_constructor = common_constructor
|
145
|
-
@args = args
|
146
|
-
@object = object
|
147
|
-
end
|
148
|
-
|
149
|
-
def auto_result
|
150
|
-
r = []
|
151
|
-
sub_args.each do |name, value|
|
152
|
-
i = super_arg_index(name)
|
153
|
-
r[i] = value if i
|
154
|
-
end
|
155
|
-
r
|
156
|
-
end
|
157
|
-
|
158
|
-
def result
|
159
|
-
result_from_options || auto_result
|
160
|
-
end
|
161
|
-
|
162
|
-
def result_from_options
|
163
|
-
return unless common_constructor.super_args
|
164
|
-
|
165
|
-
object.instance_exec(&common_constructor.super_args)
|
166
|
-
end
|
167
|
-
|
168
|
-
def sub_args
|
169
|
-
common_constructor.args.each_with_index.map do |name, index|
|
170
|
-
[name, args[index]]
|
171
|
-
end.to_h
|
172
|
-
end
|
173
|
-
|
174
|
-
def super_arg_index(name)
|
175
|
-
super_method.parameters.each_with_index do |arg, index|
|
176
|
-
return index if arg[1] == name
|
177
|
-
end
|
178
|
-
nil
|
179
|
-
end
|
180
|
-
|
181
|
-
def super_method
|
182
|
-
object.class.superclass ? object.class.superclass.instance_method(:initialize) : nil
|
183
|
-
end
|
184
|
-
end
|
185
88
|
end
|
186
89
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/common_constructor/instance_initialize'
|
4
|
+
require 'eac_ruby_utils/common_constructor/super_args'
|
5
|
+
|
6
|
+
module EacRubyUtils
|
7
|
+
class CommonConstructor
|
8
|
+
class ClassInitialize
|
9
|
+
attr_reader :common_constructor, :klass
|
10
|
+
|
11
|
+
def initialize(common_constructor, klass)
|
12
|
+
@common_constructor = common_constructor
|
13
|
+
@klass = klass
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
class_initialize = self
|
18
|
+
klass.send(:define_method, :initialize) do |*args|
|
19
|
+
::EacRubyUtils::CommonConstructor::InstanceInitialize.new(
|
20
|
+
class_initialize.common_constructor, args, self
|
21
|
+
).run
|
22
|
+
super(*::EacRubyUtils::CommonConstructor::SuperArgs.new(
|
23
|
+
class_initialize, args, self
|
24
|
+
).result)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacRubyUtils
|
4
|
+
class CommonConstructor
|
5
|
+
class InstanceInitialize
|
6
|
+
attr_reader :common_constructor, :args, :object
|
7
|
+
|
8
|
+
def initialize(common_constructor, args, object)
|
9
|
+
@common_constructor = common_constructor
|
10
|
+
@args = args
|
11
|
+
@object = object
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
validate_args_count
|
16
|
+
object.run_callbacks :initialize do
|
17
|
+
object_attributes_set
|
18
|
+
object_after_callback
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def arg_value(arg_name)
|
25
|
+
arg_index = common_constructor.args.index(arg_name)
|
26
|
+
if arg_index < args.count
|
27
|
+
args[arg_index]
|
28
|
+
else
|
29
|
+
common_constructor.default_values[arg_index - common_constructor.args_count_min]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def object_after_callback
|
34
|
+
return unless common_constructor.after_set_block
|
35
|
+
|
36
|
+
object.instance_eval(&common_constructor.after_set_block)
|
37
|
+
end
|
38
|
+
|
39
|
+
def object_attributes_set
|
40
|
+
common_constructor.args.each do |arg_name|
|
41
|
+
object.send("#{arg_name}=", arg_value(arg_name))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def validate_args_count
|
46
|
+
return if common_constructor.args_count.include?(args.count)
|
47
|
+
|
48
|
+
raise ArgumentError, "#{object.class}.initialize: wrong number of arguments" \
|
49
|
+
" (given #{args.count}, expected #{common_constructor.args_count})"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/module/delegation'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
class CommonConstructor
|
7
|
+
class SuperArgs
|
8
|
+
attr_reader :class_initialize, :args, :object
|
9
|
+
delegate :common_constructor, to: :class_initialize
|
10
|
+
|
11
|
+
def initialize(class_initialize, args, object)
|
12
|
+
@class_initialize = class_initialize
|
13
|
+
@args = args
|
14
|
+
@object = object
|
15
|
+
end
|
16
|
+
|
17
|
+
def auto_result
|
18
|
+
r = []
|
19
|
+
sub_args.each do |name, value|
|
20
|
+
i = super_arg_index(name)
|
21
|
+
r[i] = value if i
|
22
|
+
end
|
23
|
+
r
|
24
|
+
end
|
25
|
+
|
26
|
+
def result
|
27
|
+
result_from_options || auto_result
|
28
|
+
end
|
29
|
+
|
30
|
+
def result_from_options
|
31
|
+
return unless common_constructor.super_args
|
32
|
+
|
33
|
+
object.instance_exec(&common_constructor.super_args)
|
34
|
+
end
|
35
|
+
|
36
|
+
def sub_args
|
37
|
+
common_constructor.args.each_with_index.map do |name, index|
|
38
|
+
[name, args[index]]
|
39
|
+
end.to_h
|
40
|
+
end
|
41
|
+
|
42
|
+
def super_arg_index(name)
|
43
|
+
super_method.parameters.each_with_index do |arg, index|
|
44
|
+
return index if arg[1] == name
|
45
|
+
end
|
46
|
+
nil
|
47
|
+
end
|
48
|
+
|
49
|
+
def super_method
|
50
|
+
class_initialize.klass.superclass&.instance_method(:initialize)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -38,7 +38,7 @@ module EacRubyUtils
|
|
38
38
|
def run_with_subcommand
|
39
39
|
if subcommand_name
|
40
40
|
check_valid_subcommand
|
41
|
-
|
41
|
+
subcommand_run
|
42
42
|
else
|
43
43
|
run_without_subcommand
|
44
44
|
end
|
@@ -52,6 +52,15 @@ module EacRubyUtils
|
|
52
52
|
)
|
53
53
|
end
|
54
54
|
|
55
|
+
def subcommand_run
|
56
|
+
if !subcommand.is_a?(::EacRubyUtils::Console::DocoptRunner) &&
|
57
|
+
subcommand.respond_to?(:run_run)
|
58
|
+
subcommand.run_run
|
59
|
+
else
|
60
|
+
subcommand.run
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
55
64
|
def target_doc
|
56
65
|
super.gsub(SUBCOMMANDS_MACRO,
|
57
66
|
"#{target_doc_subcommand_arg} [#{SUBCOMMAND_ARGS_ARG}...]") +
|
@@ -19,7 +19,7 @@ RSpec.describe ::EacRubyUtils::CommonConcern do
|
|
19
19
|
|
20
20
|
module InstanceMethods # rubocop:disable RSpec/LeakyConstantDeclaration
|
21
21
|
def my_instance_method
|
22
|
-
'
|
22
|
+
'from_module'
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -31,8 +31,8 @@ RSpec.describe ::EacRubyUtils::CommonConcern do
|
|
31
31
|
attr_accessor :valor
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
'
|
34
|
+
def my_instance_method
|
35
|
+
'from_class'
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -48,7 +48,17 @@ RSpec.describe ::EacRubyUtils::CommonConcern do
|
|
48
48
|
stub_class.include stub_module
|
49
49
|
end
|
50
50
|
|
51
|
-
it { expect(stub_class_instance.my_instance_method).to eq('
|
51
|
+
it { expect(stub_class_instance.my_instance_method).to eq('from_class') }
|
52
|
+
it { expect(stub_class_instance.class.my_class_method).to eq('class') }
|
53
|
+
it { expect(stub_class_instance.class.valor).to eq('changed') }
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when prepended' do
|
57
|
+
before do
|
58
|
+
stub_class.prepend stub_module
|
59
|
+
end
|
60
|
+
|
61
|
+
it { expect(stub_class_instance.my_instance_method).to eq('from_module') }
|
52
62
|
it { expect(stub_class_instance.class.my_class_method).to eq('class') }
|
53
63
|
it { expect(stub_class_instance.class.valor).to eq('changed') }
|
54
64
|
end
|
@@ -92,4 +92,34 @@ RSpec.describe ::EacRubyUtils::CommonConstructor do
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
95
|
+
|
96
|
+
context 'with class hierarchy mixed with and without common_constructor' do
|
97
|
+
let(:klass_0) do
|
98
|
+
described_class.new(:a_param).setup_class(::Class.new)
|
99
|
+
end
|
100
|
+
|
101
|
+
let(:klass_1) do
|
102
|
+
::Class.new(klass_0) do
|
103
|
+
def initialize(a_param)
|
104
|
+
super(a_param)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
let(:klass_2) do
|
110
|
+
::Class.new(klass_1)
|
111
|
+
end
|
112
|
+
|
113
|
+
let(:klass_3) do
|
114
|
+
described_class.new(:a_param).setup_class(::Class.new(klass_2))
|
115
|
+
end
|
116
|
+
|
117
|
+
4.times.each do |i|
|
118
|
+
context "wit #{i}-th class" do
|
119
|
+
let(:class_instance) { send("klass_#{i}").new(:a) }
|
120
|
+
|
121
|
+
it { expect(class_instance.a_param).to eq(:a) }
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
95
125
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avm-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.86.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esquilo Azul Company
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aranha-parsers
|
@@ -346,6 +346,13 @@ files:
|
|
346
346
|
- lib/avm/eac_writings_base0/project_build.rb
|
347
347
|
- lib/avm/eac_writings_base0/project_build/chapters_content.rb
|
348
348
|
- lib/avm/eac_writings_base0/project_build/copy_files.rb
|
349
|
+
- lib/avm/eac_writings_base1.rb
|
350
|
+
- lib/avm/eac_writings_base1/apache_host.rb
|
351
|
+
- lib/avm/eac_writings_base1/build.rb
|
352
|
+
- lib/avm/eac_writings_base1/build/file.rb
|
353
|
+
- lib/avm/eac_writings_base1/deploy.rb
|
354
|
+
- lib/avm/eac_writings_base1/instance.rb
|
355
|
+
- lib/avm/eac_writings_base1/project.rb
|
349
356
|
- lib/avm/executables.rb
|
350
357
|
- lib/avm/files.rb
|
351
358
|
- lib/avm/files/appendable.rb
|
@@ -453,6 +460,8 @@ files:
|
|
453
460
|
- lib/avm/projects/stereotypes/git.rb
|
454
461
|
- lib/avm/projects/stereotypes/git/local_project_mixin.rb
|
455
462
|
- lib/avm/projects/stereotypes/git/publish.rb
|
463
|
+
- lib/avm/projects/stereotypes/git/update.rb
|
464
|
+
- lib/avm/projects/stereotypes/git/update/subrepo.rb
|
456
465
|
- lib/avm/projects/stereotypes/git/warp.rb
|
457
466
|
- lib/avm/projects/stereotypes/git_subrepo.rb
|
458
467
|
- lib/avm/projects/stereotypes/git_subrepo/publish.rb
|
@@ -495,6 +504,7 @@ files:
|
|
495
504
|
- lib/avm/tools/runner/eac_redmine_base0/project_rename.rb
|
496
505
|
- lib/avm/tools/runner/eac_wordpress_base0.rb
|
497
506
|
- lib/avm/tools/runner/eac_writings_base0.rb
|
507
|
+
- lib/avm/tools/runner/eac_writings_base1.rb
|
498
508
|
- lib/avm/tools/runner/files.rb
|
499
509
|
- lib/avm/tools/runner/files/format.rb
|
500
510
|
- lib/avm/tools/runner/files/rotate.rb
|
@@ -522,6 +532,8 @@ files:
|
|
522
532
|
- lib/avm/tools/runner/local_project/eac_writings_base0/build_chapters.rb
|
523
533
|
- lib/avm/tools/runner/local_project/eac_writings_base0/build_single.rb
|
524
534
|
- lib/avm/tools/runner/local_project/eac_writings_base0/info.rb
|
535
|
+
- lib/avm/tools/runner/local_project/eac_writings_base1.rb
|
536
|
+
- lib/avm/tools/runner/local_project/eac_writings_base1/build.rb
|
525
537
|
- lib/avm/tools/runner/local_project/info.rb
|
526
538
|
- lib/avm/tools/runner/local_project/ruby.rb
|
527
539
|
- lib/avm/tools/runner/local_project/ruby/bundler.rb
|
@@ -910,6 +922,9 @@ files:
|
|
910
922
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/class_setup.rb
|
911
923
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb
|
912
924
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb
|
925
|
+
- vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_initialize.rb
|
926
|
+
- vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/instance_initialize.rb
|
927
|
+
- vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/super_args.rb
|
913
928
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/configs.rb
|
914
929
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
|
915
930
|
- vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/file.rb
|