avm-tools 0.87.0 → 0.91.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/{eac_writings_base1.rb → eac_asciidoctor_base0.rb} +1 -1
  3. data/lib/avm/{eac_writings_base1 → eac_asciidoctor_base0}/apache_host.rb +1 -1
  4. data/lib/avm/{eac_writings_base1 → eac_asciidoctor_base0}/build.rb +5 -3
  5. data/lib/avm/{eac_writings_base1 → eac_asciidoctor_base0}/build/file.rb +4 -4
  6. data/lib/avm/{eac_writings_base1 → eac_asciidoctor_base0}/deploy.rb +6 -6
  7. data/lib/avm/{eac_writings_base1 → eac_asciidoctor_base0}/instance.rb +1 -1
  8. data/lib/avm/{eac_writings_base1 → eac_asciidoctor_base0}/project.rb +1 -1
  9. data/lib/avm/eac_rails_base1/runner/log.rb +43 -0
  10. data/lib/avm/eac_rails_base1/runner_with/bundle.rb +2 -32
  11. data/lib/avm/eac_rails_base1/runner_with/rails_environment.rb +47 -0
  12. data/lib/avm/eac_webapp_base0/deploy.rb +16 -4
  13. data/lib/avm/eac_webapp_base0/deploy/appended_directories.rb +1 -1
  14. data/lib/avm/eac_webapp_base0/deploy/git_info.rb +1 -1
  15. data/lib/avm/eac_webapp_base0/instance.rb +2 -0
  16. data/lib/avm/eac_webapp_base0/runner/deploy.rb +13 -21
  17. data/lib/avm/executables.rb +1 -1
  18. data/lib/avm/instances/base/auto_values/filesystem.rb +12 -0
  19. data/lib/avm/instances/runner.rb +3 -5
  20. data/lib/avm/tools/runner/{eac_writings_base1.rb → eac_asciidoctor_base0.rb} +2 -2
  21. data/lib/avm/tools/runner/eac_webapp_base0.rb +14 -0
  22. data/lib/avm/tools/runner/git/deploy.rb +1 -1
  23. data/lib/avm/tools/runner/instance.rb +3 -6
  24. data/lib/avm/tools/runner/instance/info.rb +4 -7
  25. data/lib/avm/tools/runner/local_project/{eac_writings_base1.rb → eac_asciidoctor_base0.rb} +2 -2
  26. data/lib/avm/tools/runner/local_project/{eac_writings_base1 → eac_asciidoctor_base0}/build.rb +5 -9
  27. data/lib/avm/tools/version.rb +1 -1
  28. data/vendor/eac_cli/lib/eac_cli/runner.rb +0 -48
  29. data/vendor/eac_cli/lib/eac_cli/runner/after_class_methods.rb +29 -0
  30. data/vendor/eac_cli/lib/eac_cli/runner/instance_methods.rb +31 -0
  31. data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +1 -1
  32. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  33. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb +42 -0
  34. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel.rb +4 -0
  35. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel/nyi.rb +8 -0
  36. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  37. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/local_time_zone_spec.rb +17 -0
  38. metadata +41 -14
  39. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/default_time_zone_set.rb +0 -5
  40. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/local_time_zone.rb +0 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df3208595cdaefa7e6f51a5a14518064df146b2081e32365e3ad746326e844bb
4
- data.tar.gz: 367b039c49b3ff3e9a8083bafe1c889656e924403014efbeec2f3032ccfe0247
3
+ metadata.gz: 5f5aa5e8fb2a459dbf2a43a6db6c3c3e2010eafeb38f22986c2ce25f7ed59fe8
4
+ data.tar.gz: a277ee83c3e5e91ad98d6427294b82f2a3183a3cf7f65e2cecd924bd8f179c74
5
5
  SHA512:
6
- metadata.gz: 1e1aa08cda713c6600a551681f4f2d986e939675ba41bd5f270497f9dba564213906ae71890ce9ea00285a289d8edc626d70bd91aa31e2a381524bc19404d58b
7
- data.tar.gz: 25c272f9097b2d48cf1d88ece314eef1361527644942c3b0e1e862709f60e155ac4db9a31b823432f72abd478eaec9f4218503932228a8bf0c44c30b3a3ee46b
6
+ metadata.gz: cfdf75803e0dbb82f59c7b385d8eb2947400ad05cc5e92acae171a3312e939808ec4d8b8d23423fde9c30176a21b48d79615cfd3ff403cf91a88361d5a926bbd
7
+ data.tar.gz: fb6d6065157b1668e96cc612c068cee618901bdf7003b30569c85c7344cd6628da679376801804d30bea0c9ce7f62f0e773501e25942a24ca6a517acbda07c6f
@@ -3,7 +3,7 @@
3
3
  require 'eac_ruby_utils/core_ext'
4
4
 
5
5
  module Avm
6
- module EacWritingsBase1
6
+ module EacAsciidoctorBase0
7
7
  require_sub __FILE__
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@
3
3
  require 'avm/eac_webapp_base0/apache_host'
4
4
 
5
5
  module Avm
6
- module EacWritingsBase1
6
+ module EacAsciidoctorBase0
7
7
  class ApacheHost < ::Avm::EacWebappBase0::ApacheHost
8
8
  def document_root
9
9
  instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH)
@@ -4,7 +4,7 @@ require 'eac_ruby_utils/core_ext'
4
4
  require 'eac_ruby_utils/fs/clearable_directory'
5
5
 
6
6
  module Avm
7
- module EacWritingsBase1
7
+ module EacAsciidoctorBase0
8
8
  class Build
9
9
  require_sub __FILE__
10
10
  enable_console_speaker
@@ -15,6 +15,8 @@ module Avm
15
15
  self.options = self.class.lists.option.hash_keys_validate!(options.symbolize_keys)
16
16
  end
17
17
 
18
+ SOURCE_EXTNAMES = %w[.adoc .asc].freeze
19
+
18
20
  def run
19
21
  infov 'Files to build', source_files.count
20
22
  target_directory.clear
@@ -34,9 +36,9 @@ module Avm
34
36
  def source_files_uncached
35
37
  r = []
36
38
  project.root.children.each do |child|
37
- next unless child.extname == '.asc'
39
+ next unless SOURCE_EXTNAMES.include?(child.extname)
38
40
 
39
- r << ::Avm::EacWritingsBase1::Build::File.new(self, child.basename)
41
+ r << ::Avm::EacAsciidoctorBase0::Build::File.new(self, child.basename)
40
42
  end
41
43
  r
42
44
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/executables'
3
+ require 'asciidoctor'
4
4
 
5
5
  module Avm
6
- module EacWritingsBase1
6
+ module EacAsciidoctorBase0
7
7
  class Build
8
8
  class File
9
9
  enable_console_speaker
@@ -11,8 +11,8 @@ module Avm
11
11
 
12
12
  def run
13
13
  infov 'Building', subpath
14
- target_path.parent.mkpath
15
- ::Avm::Executables.asciidoc.command('--out-file', target_path, source_path).system!
14
+ ::Asciidoctor.convert_file source_path.to_path,
15
+ to_file: target_path.to_path, safe: :unsafe, mkdirs: true
16
16
  end
17
17
 
18
18
  def source_path
@@ -1,23 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/eac_webapp_base0/deploy'
4
- require 'avm/eac_writings_base1/project'
5
- require 'avm/eac_writings_base1/build'
4
+ require 'avm/eac_asciidoctor_base0/project'
5
+ require 'avm/eac_asciidoctor_base0/build'
6
6
 
7
7
  module Avm
8
- module EacWritingsBase1
8
+ module EacAsciidoctorBase0
9
9
  class Deploy < ::Avm::EacWebappBase0::Deploy
10
10
  def build_content
11
- ::Avm::EacWritingsBase1::Build.new(
11
+ ::Avm::EacAsciidoctorBase0::Build.new(
12
12
  project,
13
- ::Avm::EacWritingsBase1::Build::OPTION_TARGET_DIRECTORY => build_dir
13
+ ::Avm::EacAsciidoctorBase0::Build::OPTION_TARGET_DIRECTORY => build_dir
14
14
  ).run
15
15
  end
16
16
 
17
17
  private
18
18
 
19
19
  def project_uncached
20
- ::Avm::EacWritingsBase1::Project.new(
20
+ ::Avm::EacAsciidoctorBase0::Project.new(
21
21
  instance.source_instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH)
22
22
  )
23
23
  end
@@ -3,7 +3,7 @@
3
3
  require 'avm/eac_webapp_base0/instance'
4
4
 
5
5
  module Avm
6
- module EacWritingsBase1
6
+ module EacAsciidoctorBase0
7
7
  class Instance < ::Avm::EacWebappBase0::Instance
8
8
  FILES_UNITS = {}.freeze
9
9
  end
@@ -3,7 +3,7 @@
3
3
  require 'eac_ruby_utils/core_ext'
4
4
 
5
5
  module Avm
6
- module EacWritingsBase1
6
+ module EacAsciidoctorBase0
7
7
  class Project
8
8
  common_constructor :root do
9
9
  self.root = root.to_pathname
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_rails_base1/runner_with/rails_environment'
4
+ require 'avm/eac_webapp_base0/runner'
5
+
6
+ module Avm
7
+ module EacRailsBase1
8
+ class Runner < ::Avm::EacWebappBase0::Runner
9
+ class Log
10
+ runner_with :help, ::Avm::EacRailsBase1::RunnerWith::RailsEnvironment do
11
+ desc 'Read application\'s log.'
12
+ bool_opt '-f', '--follow', 'Output appended data as the log grows.'
13
+ end
14
+
15
+ def run
16
+ start_banner
17
+ tail_command.system
18
+ end
19
+
20
+ private
21
+
22
+ def log_path
23
+ ::File.join(rails_instance.read_entry('fs_path'), 'log', "#{rails_environment}.log")
24
+ end
25
+
26
+ def start_banner
27
+ infov 'Environment', rails_environment
28
+ infov 'Log path', log_path
29
+ end
30
+
31
+ def tail_command
32
+ rails_instance.host_env.command(*tail_command_args)
33
+ end
34
+
35
+ def tail_command_args
36
+ r = %w[tail]
37
+ r << '--follow' if parsed.follow?
38
+ r + [log_path]
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,29 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/eac_rails_base1/instance'
4
+ require 'avm/eac_rails_base1/runner_with/rails_environment'
4
5
  require 'eac_cli/runner'
5
6
 
6
7
  module Avm
7
8
  module EacRailsBase1
8
9
  module RunnerWith
9
10
  module Bundle
10
- DEFAULT_RAILS_ENVIRONMENT_CONSTANT = 'DEFAULT_RAILS_ENVIRONMENT'
11
-
12
11
  common_concern do
13
- include ::EacCli::Runner
14
-
15
- runner_definition do
16
- arg_opt '-e', '--environment', 'Specifies the environment for the runner to operate' \
17
- ' (test/development/production). Default: "development".'
18
- end
19
- end
20
-
21
- module ClassMethods
22
- def default_rails_environment
23
- const_get(DEFAULT_RAILS_ENVIRONMENT_CONSTANT)
24
- rescue ::NameError
25
- ::Avm::EacRailsBase1::Instance::DEFAULT_RAILS_ENVIRONMENT
26
- end
12
+ include ::Avm::EacRailsBase1::RunnerWith::RailsEnvironment
27
13
  end
28
14
 
29
15
  def bundle_command
@@ -35,22 +21,6 @@ module Avm
35
21
  infov 'Rails environment', rails_environment
36
22
  bundle_command.system!
37
23
  end
38
-
39
- def default_rails_environment
40
- self.class.default_rails_environment
41
- end
42
-
43
- def rails_instance
44
- if respond_to?(:runner_context)
45
- runner_context.call(:instance)
46
- else
47
- context(:instance)
48
- end
49
- end
50
-
51
- def rails_environment
52
- parsed.environment.presence || default_rails_environment
53
- end
54
24
  end
55
25
  end
56
26
  end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_rails_base1/instance'
4
+ require 'eac_cli/runner'
5
+
6
+ module Avm
7
+ module EacRailsBase1
8
+ module RunnerWith
9
+ module RailsEnvironment
10
+ DEFAULT_RAILS_ENVIRONMENT_CONSTANT = 'DEFAULT_RAILS_ENVIRONMENT'
11
+
12
+ common_concern do
13
+ include ::EacCli::Runner
14
+
15
+ runner_definition do
16
+ arg_opt '-e', '--environment', 'Specifies the environment for the runner to operate' \
17
+ ' (test/development/production). Default: "development".'
18
+ end
19
+ end
20
+
21
+ module ClassMethods
22
+ def default_rails_environment
23
+ const_get(DEFAULT_RAILS_ENVIRONMENT_CONSTANT)
24
+ rescue ::NameError
25
+ ::Avm::EacRailsBase1::Instance::DEFAULT_RAILS_ENVIRONMENT
26
+ end
27
+ end
28
+
29
+ def default_rails_environment
30
+ self.class.default_rails_environment
31
+ end
32
+
33
+ def rails_environment
34
+ parsed.environment.presence || default_rails_environment
35
+ end
36
+
37
+ def rails_instance
38
+ if respond_to?(:runner_context)
39
+ runner_context.call(:instance)
40
+ else
41
+ context(:instance)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -17,10 +17,16 @@ module Avm
17
17
 
18
18
  enable_console_speaker
19
19
  enable_simple_cache
20
- common_constructor :instance, :options, default: [{}]
20
+ enable_listable
21
+ lists.add_symbol :option, :appended_directories, :no_request_test, :reference
22
+ common_constructor :instance, :options, default: [{}] do
23
+ self.options = ::Avm::EacWebappBase0::Deploy.lists.option
24
+ .hash_keys_validate!(options.symbolize_keys)
25
+ end
21
26
 
22
- JOBS = %w[create_build_dir build_content append_instance_content write_on_target
23
- setup_files_units assert_instance_branch request_test].freeze
27
+ REQUEST_TEST_JOB = 'request_test'
28
+ JOBS = (%w[create_build_dir build_content append_instance_content write_on_target
29
+ setup_files_units assert_instance_branch] + [REQUEST_TEST_JOB]).freeze
24
30
  define_callbacks(*JOBS)
25
31
 
26
32
  def run
@@ -67,8 +73,14 @@ module Avm
67
73
 
68
74
  private
69
75
 
76
+ def jobs
77
+ r = JOBS.dup
78
+ r.delete(REQUEST_TEST_JOB) if options[OPTION_NO_REQUEST_TEST]
79
+ r
80
+ end
81
+
70
82
  def run_jobs
71
- JOBS.each do |job|
83
+ jobs.each do |job|
72
84
  run_callbacks job do
73
85
  send(job)
74
86
  end
@@ -17,7 +17,7 @@ module Avm
17
17
  end
18
18
 
19
19
  def appended_directories_from_options
20
- options[:appended_directories] || []
20
+ options[OPTION_APPENDED_DIRECTORIES] || []
21
21
  end
22
22
  end
23
23
  end
@@ -18,7 +18,7 @@ module Avm
18
18
  end
19
19
 
20
20
  def git_reference
21
- options[:reference] || DEFAULT_REFERENCE
21
+ options[OPTION_REFERENCE] || DEFAULT_REFERENCE
22
22
  end
23
23
 
24
24
  def git_reference_found_uncached
@@ -11,6 +11,8 @@ module Avm
11
11
  class Instance < ::Avm::Instances::Base
12
12
  include ::Avm::Postgresql::InstanceWith
13
13
 
14
+ FILES_UNITS = [].freeze
15
+
14
16
  def stereotype_name
15
17
  self.class.name.desconstantize.demodulize
16
18
  end
@@ -2,34 +2,25 @@
2
2
 
3
3
  require 'avm/instances/runner'
4
4
  require 'avm/path_string'
5
- require 'eac_ruby_utils/console/docopt_runner'
6
- require 'eac_ruby_utils/console/speaker'
5
+ require 'eac_cli/core_ext'
7
6
 
8
7
  module Avm
9
8
  module EacWebappBase0
10
9
  class Runner < ::Avm::Instances::Runner
11
- class Deploy < ::EacRubyUtils::Console::DocoptRunner
12
- include ::EacRubyUtils::Console::Speaker
13
-
14
- DOC = <<~DOCOPT
15
- Deploy for instance.
16
-
17
- Usage:
18
- __PROGRAM__ [options]
19
- __PROGRAM__ -h | --help
20
-
21
- Options:
22
- -h --help Show this screen.
23
- -r --reference=<git-reference> Git reference to deploy.
24
- -a --append-dirs=<append-dirs> Append directories to deploy (List separated by ":").
25
- DOCOPT
10
+ class Deploy
11
+ runner_with :help do
12
+ desc 'Deploy for instance.'
13
+ arg_opt '-r', '--reference', 'Git reference to deploy.'
14
+ arg_opt '-a', '--append-dirs', 'Append directories to deploy (List separated by ":").'
15
+ bool_opt '-T', '--no-request-test', 'Do not test web interface after deploy.'
16
+ end
26
17
 
27
18
  def deploy_class
28
- context(:stereotype_module).const_get('Deploy')
19
+ runner_context.call(:stereotype_module).const_get('Deploy')
29
20
  end
30
21
 
31
22
  def run
32
- result = deploy_class.new(context(:instance), deploy_options).run
23
+ result = deploy_class.new(runner_context.call(:instance), deploy_options).run
33
24
  if result.error?
34
25
  fatal_error result.to_s
35
26
  else
@@ -38,8 +29,9 @@ module Avm
38
29
  end
39
30
 
40
31
  def deploy_options
41
- { reference: options.fetch('--reference'),
42
- appended_directories: ::Avm::PathString.paths(options.fetch('--append-dirs')) }
32
+ { reference: parsed.reference,
33
+ appended_directories: ::Avm::PathString.paths(parsed.append_dirs),
34
+ no_request_test: parsed.no_request_test? }
43
35
  end
44
36
  end
45
37
  end
@@ -14,7 +14,7 @@ module Avm
14
14
 
15
15
  private
16
16
 
17
- %w[asciidoc docker file git latex php-cs-fixer tidy yapf xdg-open].each do |program|
17
+ %w[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
@@ -20,12 +20,24 @@ module Avm
20
20
  end
21
21
 
22
22
  def auto_fs_url
23
+ auto_fs_url_with_ssh || auto_fs_url_without_ssh
24
+ end
25
+
26
+ def auto_fs_url_with_ssh
23
27
  read_entry_optional('ssh.url').if_present do |ssh_url|
24
28
  read_entry_optional('fs_path').if_present do |fs_path|
25
29
  "#{ssh_url}#{fs_path}"
26
30
  end
27
31
  end
28
32
  end
33
+
34
+ def auto_fs_url_without_ssh
35
+ return nil if read_entry_optional('ssh.url').present?
36
+
37
+ read_entry_optional('fs_path').if_present do |fs_path|
38
+ "file://#{fs_path}"
39
+ end
40
+ end
29
41
  end
30
42
  end
31
43
  end
@@ -1,11 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_cli/core_ext'
4
- require 'eac_ruby_utils/console/docopt_runner'
5
4
 
6
5
  module Avm
7
6
  module Instances
8
- class Runner < ::EacRubyUtils::Console::DocoptRunner
7
+ class Runner
9
8
  class << self
10
9
  def instance_class
11
10
  ::Avm.const_get(stereotype_name).const_get('Instance')
@@ -20,9 +19,8 @@ module Avm
20
19
  end
21
20
  end
22
21
 
23
- runner_with
24
22
  description = "Utilities for #{stereotype_name} instances."
25
- runner_definition do
23
+ runner_with :help, :subcommands do
26
24
  desc description
27
25
  pos_arg 'instance-id'
28
26
  subcommands
@@ -33,7 +31,7 @@ module Avm
33
31
  private
34
32
 
35
33
  def instance_uncached
36
- self.class.instance_class.by_id(options.fetch('<instance-id>'))
34
+ self.class.instance_class.by_id(parsed.instance_id)
37
35
  end
38
36
  end
39
37
  end
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/eac_webapp_base0/runner'
4
- require 'avm/eac_writings_base1'
4
+ require 'avm/eac_asciidoctor_base0'
5
5
  require 'eac_ruby_utils/console/docopt_runner'
6
6
 
7
7
  module Avm
8
8
  module Tools
9
9
  class Runner
10
- class EacWritingsBase1 < ::Avm::EacWebappBase0::Runner
10
+ class EacAsciidoctorBase0 < ::Avm::EacWebappBase0::Runner
11
11
  require_sub __FILE__
12
12
  end
13
13
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_webapp_base0/runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Tools
8
+ class Runner
9
+ class EacWebappBase0 < ::Avm::EacWebappBase0::Runner
10
+ require_sub __FILE__
11
+ end
12
+ end
13
+ end
14
+ end
@@ -15,7 +15,7 @@ module Avm
15
15
  arg_opt '-a', '--append-dirs', 'Append directories to deploy (List separated by ":").'
16
16
  arg_opt '-i', '--instance', 'Read entries from instance with id=<instance-id>.'
17
17
  arg_opt '-r', '--reference', "Reference (default: #{DEFAULT_REFERENCE})."
18
- pos_arg :target_url
18
+ pos_arg :target_url, optional: true
19
19
  end
20
20
 
21
21
  def run
@@ -2,16 +2,13 @@
2
2
 
3
3
  require 'avm/instances/base'
4
4
  require 'eac_cli/core_ext'
5
- require 'eac_ruby_utils/console/docopt_runner'
6
5
 
7
6
  module Avm
8
7
  module Tools
9
8
  class Runner
10
- class Instance < ::EacRubyUtils::Console::DocoptRunner
9
+ class Instance
11
10
  require_sub __FILE__
12
- runner_with
13
-
14
- runner_definition do
11
+ runner_with :help, :subcommands do
15
12
  desc 'Utilities for generic instances.'
16
13
  pos_arg :instance_id
17
14
  subcommands
@@ -20,7 +17,7 @@ module Avm
20
17
  private
21
18
 
22
19
  def instance_uncached
23
- ::Avm::Instances::Base.by_id(options['<instance_id>'])
20
+ ::Avm::Instances::Base.by_id(parsed.instance_id)
24
21
  end
25
22
  end
26
23
  end
@@ -2,16 +2,13 @@
2
2
 
3
3
  require 'avm/instances/entry_keys'
4
4
  require 'eac_cli/core_ext'
5
- require 'eac_ruby_utils/console/docopt_runner'
6
5
 
7
6
  module Avm
8
7
  module Tools
9
8
  class Runner
10
- class Instance < ::EacRubyUtils::Console::DocoptRunner
11
- class Info < ::EacRubyUtils::Console::DocoptRunner
12
- runner_with
13
-
14
- runner_definition do
9
+ class Instance
10
+ class Info
11
+ runner_with :help do
15
12
  desc 'Show info about a instance.'
16
13
  end
17
14
 
@@ -35,7 +32,7 @@ module Avm
35
32
  end
36
33
 
37
34
  def instance
38
- context(:instance)
35
+ runner_context.call(:instance)
39
36
  end
40
37
  end
41
38
  end
@@ -7,11 +7,11 @@ module Avm
7
7
  module Tools
8
8
  class Runner
9
9
  class LocalProject
10
- class EacWritingsBase1
10
+ class EacAsciidoctorBase0
11
11
  require_sub __FILE__
12
12
 
13
13
  runner_with :help, :subcommands do
14
- desc 'EacWritingsBase0 utitilies for local projects.'
14
+ desc 'EacAsciidoctorBase0 utitilies for local projects.'
15
15
  subcommands
16
16
  end
17
17
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/eac_writings_base1/build'
4
- require 'avm/eac_writings_base1/project'
3
+ require 'avm/eac_asciidoctor_base0/build'
4
+ require 'avm/eac_asciidoctor_base0/project'
5
5
  require 'eac_cli/core_ext'
6
6
  require 'eac_ruby_utils/console/docopt_runner'
7
7
 
@@ -9,7 +9,7 @@ module Avm
9
9
  module Tools
10
10
  class Runner
11
11
  class LocalProject
12
- class EacWritingsBase1
12
+ class EacAsciidoctorBase0
13
13
  class Build
14
14
  runner_with :help do
15
15
  desc 'Build the project'
@@ -24,8 +24,8 @@ module Avm
24
24
  private
25
25
 
26
26
  def build_uncached
27
- ::Avm::EacWritingsBase1::Build.new(runner_context.call(:project),
28
- target_directory: parsed.target_dir)
27
+ ::Avm::EacAsciidoctorBase0::Build.new(runner_context.call(:project),
28
+ target_directory: parsed.target_dir)
29
29
  end
30
30
 
31
31
  def default_target_directory
@@ -36,10 +36,6 @@ module Avm
36
36
  runner_context.call(:project_banner)
37
37
  infov 'Target directory', build.target_directory
38
38
  end
39
- #
40
- # def target_directory_uncached
41
- # .if_present(default_target_directory).to_pathname
42
- # end
43
39
  end
44
40
  end
45
41
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.87.0'
5
+ VERSION = '0.91.0'
6
6
  end
7
7
  end
@@ -47,53 +47,5 @@ module EacCli
47
47
  include ActiveSupport::Callbacks
48
48
  define_callbacks :run
49
49
  end
50
-
51
- module AfterClassMethods
52
- def create(*runner_context_args)
53
- r = new
54
- r.runner_context = ::EacCli::Runner::Context.new(r, *runner_context_args)
55
- r
56
- end
57
-
58
- def run(*runner_context_args)
59
- r = create(*runner_context_args)
60
- r.run_run
61
- r
62
- end
63
-
64
- def runner_definition(&block)
65
- @runner_definition ||= super_runner_definition
66
- @runner_definition.instance_eval(&block) if block
67
- @runner_definition
68
- end
69
-
70
- def super_runner_definition
71
- superclass.try(:runner_definition).if_present(&:dup) || ::EacCli::Definition.new
72
- end
73
- end
74
-
75
- module InstanceMethods
76
- def run_run
77
- parsed
78
- run_callbacks(:run) { run }
79
- rescue ::EacCli::Runner::Exit # rubocop:disable Lint/SuppressedException
80
- # Do nothing
81
- end
82
-
83
- def runner_context
84
- return @runner_context if @runner_context
85
-
86
- raise 'Context was required, but was not set yet'
87
- end
88
-
89
- def runner_context=(new_runner_context)
90
- @runner_context = new_runner_context
91
- @parsed = nil
92
- end
93
-
94
- def parsed
95
- @parsed ||= ::EacCli::Parser.new(self.class.runner_definition, runner_context.argv).parsed
96
- end
97
- end
98
50
  end
99
51
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacCli
4
+ module Runner
5
+ module AfterClassMethods
6
+ def create(*runner_context_args)
7
+ r = new
8
+ r.runner_context = ::EacCli::Runner::Context.new(r, *runner_context_args)
9
+ r
10
+ end
11
+
12
+ def run(*runner_context_args)
13
+ r = create(*runner_context_args)
14
+ r.run_run
15
+ r
16
+ end
17
+
18
+ def runner_definition(&block)
19
+ @runner_definition ||= super_runner_definition
20
+ @runner_definition.instance_eval(&block) if block
21
+ @runner_definition
22
+ end
23
+
24
+ def super_runner_definition
25
+ superclass.try(:runner_definition).if_present(&:dup) || ::EacCli::Definition.new
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacCli
4
+ module Runner
5
+ module InstanceMethods
6
+ def run_run
7
+ parsed
8
+ run_callbacks(:run) { run }
9
+ rescue ::EacCli::Parser::Error => e
10
+ $stderr.write("#{e}\n")
11
+ rescue ::EacCli::Runner::Exit # rubocop:disable Lint/SuppressedException
12
+ # Do nothing
13
+ end
14
+
15
+ def runner_context
16
+ return @runner_context if @runner_context
17
+
18
+ raise 'Context was required, but was not set yet'
19
+ end
20
+
21
+ def runner_context=(new_runner_context)
22
+ @runner_context = new_runner_context
23
+ @parsed = nil
24
+ end
25
+
26
+ def parsed
27
+ @parsed ||= ::EacCli::Parser.new(self.class.runner_definition, runner_context.argv).parsed
28
+ end
29
+ end
30
+ end
31
+ end
@@ -40,7 +40,7 @@ module EacCli
40
40
  end
41
41
 
42
42
  def help_extra_text
43
- (['Subcommands:'] + available_subcommands.keys.map { |s| " #{s}" })
43
+ (['Subcommands:'] + available_subcommands.keys.sort.map { |s| " #{s}" })
44
44
  .map { |v| "#{v}\n" }.join
45
45
  end
46
46
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.12.5'
4
+ VERSION = '0.12.6'
5
5
  end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/object/blank'
4
+ require 'active_support/values/time_zone'
5
+
6
+ module EacRubyUtils
7
+ module LocalTimeZone
8
+ DEBIAN_CONFIG_PATH = '/etc/timezone'
9
+
10
+ class << self
11
+ TIMEDATECTL_TIMEZONE_LINE_PATTERN = %r{\s*Time zone:\s*(\S+/\S+)\s}.freeze
12
+
13
+ def auto
14
+ %w[tz_env debian_config offset].lazy.map { |s| send("by_#{s}") }.find(&:present?)
15
+ end
16
+
17
+ def auto_set
18
+ ::Time.zone = auto
19
+ end
20
+
21
+ def by_debian_config
22
+ path = ::Pathname.new(DEBIAN_CONFIG_PATH)
23
+ path.exist? ? path.read.strip.presence : nil
24
+ end
25
+
26
+ def by_offset
27
+ ::ActiveSupport::TimeZone[::Time.now.getlocal.gmt_offset].name
28
+ end
29
+
30
+ def by_timedatectl
31
+ executable = ::EacRubyUtils::Envs.local.executable('timedatectl', '--version')
32
+ return nil unless executable.exist?
33
+
34
+ TIMEDATECTL_TIMEZONE_LINE_PATTERN.if_match(executable.command.execute!) { |m| m[1] }
35
+ end
36
+
37
+ def by_tz_env
38
+ ENV['TZ'].presence
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+ ::EacRubyUtils.require_sub(__FILE__)
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kernel
4
+ # Raise exception with text "Not yet implemented".
5
+ def nyi
6
+ raise "Not yet implemented (Called in #{caller.first})"
7
+ end
8
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.57.1'
4
+ VERSION = '0.58.1'
5
5
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/local_time_zone'
4
+
5
+ RSpec.describe(::EacRubyUtils::LocalTimeZone) do
6
+ describe '#auto' do
7
+ context 'when TZ environment variable is set' do
8
+ let(:expected_time_zone) { 'America/Sao_Paulo' }
9
+
10
+ before do
11
+ ENV['TZ'] = expected_time_zone
12
+ end
13
+
14
+ it { expect(described_class.auto).to eq(expected_time_zone) }
15
+ end
16
+ end
17
+ 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.87.0
4
+ version: 0.91.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: 2021-01-10 00:00:00.000000000 Z
11
+ date: 2021-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -24,6 +24,26 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: asciidoctor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 2.0.12
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '2.0'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 2.0.12
27
47
  - !ruby/object:Gem::Dependency
28
48
  name: clipboard
29
49
  requirement: !ruby/object:Gem::Requirement
@@ -290,6 +310,13 @@ files:
290
310
  - lib/avm/docker/image.rb
291
311
  - lib/avm/docker/registry.rb
292
312
  - lib/avm/docker/runner.rb
313
+ - lib/avm/eac_asciidoctor_base0.rb
314
+ - lib/avm/eac_asciidoctor_base0/apache_host.rb
315
+ - lib/avm/eac_asciidoctor_base0/build.rb
316
+ - lib/avm/eac_asciidoctor_base0/build/file.rb
317
+ - lib/avm/eac_asciidoctor_base0/deploy.rb
318
+ - lib/avm/eac_asciidoctor_base0/instance.rb
319
+ - lib/avm/eac_asciidoctor_base0/project.rb
293
320
  - lib/avm/eac_rails_base0.rb
294
321
  - lib/avm/eac_rails_base0/apache_host.rb
295
322
  - lib/avm/eac_rails_base0/apache_path.rb
@@ -301,8 +328,10 @@ files:
301
328
  - lib/avm/eac_rails_base1/runner.rb
302
329
  - lib/avm/eac_rails_base1/runner/bundle.rb
303
330
  - lib/avm/eac_rails_base1/runner/code_runner.rb
331
+ - lib/avm/eac_rails_base1/runner/log.rb
304
332
  - lib/avm/eac_rails_base1/runner/rails_server.rb
305
333
  - lib/avm/eac_rails_base1/runner_with/bundle.rb
334
+ - lib/avm/eac_rails_base1/runner_with/rails_environment.rb
306
335
  - lib/avm/eac_redmine_base0.rb
307
336
  - lib/avm/eac_redmine_base0/apache_host.rb
308
337
  - lib/avm/eac_redmine_base0/core_update.rb
@@ -346,13 +375,6 @@ files:
346
375
  - lib/avm/eac_writings_base0/project_build.rb
347
376
  - lib/avm/eac_writings_base0/project_build/chapters_content.rb
348
377
  - 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
356
378
  - lib/avm/executables.rb
357
379
  - lib/avm/files.rb
358
380
  - lib/avm/files/appendable.rb
@@ -496,15 +518,16 @@ files:
496
518
  - lib/avm/sync.rb
497
519
  - lib/avm/tools.rb
498
520
  - lib/avm/tools/runner.rb
521
+ - lib/avm/tools/runner/eac_asciidoctor_base0.rb
499
522
  - lib/avm/tools/runner/eac_rails_base0.rb
500
523
  - lib/avm/tools/runner/eac_rails_base0/apache_path.rb
501
524
  - lib/avm/tools/runner/eac_redmine_base0.rb
502
525
  - lib/avm/tools/runner/eac_redmine_base0/core_update.rb
503
526
  - lib/avm/tools/runner/eac_redmine_base0/docker.rb
504
527
  - lib/avm/tools/runner/eac_redmine_base0/project_rename.rb
528
+ - lib/avm/tools/runner/eac_webapp_base0.rb
505
529
  - lib/avm/tools/runner/eac_wordpress_base0.rb
506
530
  - lib/avm/tools/runner/eac_writings_base0.rb
507
- - lib/avm/tools/runner/eac_writings_base1.rb
508
531
  - lib/avm/tools/runner/files.rb
509
532
  - lib/avm/tools/runner/files/format.rb
510
533
  - lib/avm/tools/runner/files/rotate.rb
@@ -528,12 +551,12 @@ files:
528
551
  - lib/avm/tools/runner/launcher/projects.rb
529
552
  - lib/avm/tools/runner/launcher/publish.rb
530
553
  - lib/avm/tools/runner/local_project.rb
554
+ - lib/avm/tools/runner/local_project/eac_asciidoctor_base0.rb
555
+ - lib/avm/tools/runner/local_project/eac_asciidoctor_base0/build.rb
531
556
  - lib/avm/tools/runner/local_project/eac_writings_base0.rb
532
557
  - lib/avm/tools/runner/local_project/eac_writings_base0/build_chapters.rb
533
558
  - lib/avm/tools/runner/local_project/eac_writings_base0/build_single.rb
534
559
  - 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
537
560
  - lib/avm/tools/runner/local_project/info.rb
538
561
  - lib/avm/tools/runner/local_project/ruby.rb
539
562
  - lib/avm/tools/runner/local_project/ruby/bundler.rb
@@ -639,8 +662,10 @@ files:
639
662
  - vendor/eac_cli/lib/eac_cli/patches/object.rb
640
663
  - vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb
641
664
  - vendor/eac_cli/lib/eac_cli/runner.rb
665
+ - vendor/eac_cli/lib/eac_cli/runner/after_class_methods.rb
642
666
  - vendor/eac_cli/lib/eac_cli/runner/context.rb
643
667
  - vendor/eac_cli/lib/eac_cli/runner/exit.rb
668
+ - vendor/eac_cli/lib/eac_cli/runner/instance_methods.rb
644
669
  - vendor/eac_cli/lib/eac_cli/runner_with.rb
645
670
  - vendor/eac_cli/lib/eac_cli/runner_with/help.rb
646
671
  - vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb
@@ -995,6 +1020,7 @@ files:
995
1020
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/string_list.rb
996
1021
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/symbol_list.rb
997
1022
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb
1023
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb
998
1024
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/on_clean_ruby_environment.rb
999
1025
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/options_consumer.rb
1000
1026
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patch.rb
@@ -1009,6 +1035,8 @@ files:
1009
1035
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/hash.rb
1010
1036
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/hash/options_consumer.rb
1011
1037
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/hash/sym_keys_hash.rb
1038
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel.rb
1039
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel/nyi.rb
1012
1040
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module.rb
1013
1041
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/abstract_methods.rb
1014
1042
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/common_concern.rb
@@ -1033,8 +1061,6 @@ files:
1033
1061
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string.rb
1034
1062
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string/inflector.rb
1035
1063
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time.rb
1036
- - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/default_time_zone_set.rb
1037
- - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/local_time_zone.rb
1038
1064
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash.rb
1039
1065
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/entry_key_error.rb
1040
1066
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/node.rb
@@ -1079,6 +1105,7 @@ files:
1079
1105
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp_spec.rb
1080
1106
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb
1081
1107
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/listable_spec.rb
1108
+ - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/local_time_zone_spec.rb
1082
1109
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
1083
1110
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerable/boolean_combinations_spec.rb
1084
1111
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/current_spec.rb
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/patches/time/local_time_zone'
4
-
5
- ::Time.zone = ::Time.local_time_zone
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_support/core_ext/time/zones'
4
- require 'eac_ruby_utils/envs'
5
-
6
- class Time
7
- class << self
8
- TIMEDATECTL_TIMEZONE_LINE_PATTERN = %r{\s*Time zone:\s*(\S+/\S+)\s}.freeze
9
-
10
- def local_time_zone
11
- local_time_zone_by_timedatectl || local_time_zone_by_offset
12
- end
13
-
14
- def local_time_zone_by_timedatectl
15
- executable = ::EacRubyUtils::Envs.local.executable('timedatectl', '--version')
16
- return nil unless executable.exist?
17
-
18
- TIMEDATECTL_TIMEZONE_LINE_PATTERN.if_match(executable.command.execute!) { |m| m[1] }
19
- end
20
-
21
- def local_time_zone_by_offset
22
- ::ActiveSupport::TimeZone[::Time.now.getlocal.gmt_offset].name
23
- end
24
- end
25
- end