avm-tools 0.119.0 → 0.120.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/projects/stereotypes/ruby_gem/local_project_mixin.rb +3 -3
  3. data/lib/avm/tools/app_src.rb +1 -5
  4. data/lib/avm/tools/runner/app_src/ruby.rb +0 -1
  5. data/lib/avm/tools/version.rb +1 -1
  6. data/sub/avm-eac_rails_base0/lib/avm/eac_rails_base0/sources/base.rb +2 -2
  7. data/sub/avm-eac_rails_base0/lib/avm/eac_rails_base0/version.rb +1 -1
  8. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/base.rb +3 -3
  9. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
  10. metadata +6 -232
  11. data/lib/avm/patches/eac_ruby_gems_utils/gem.rb +0 -29
  12. data/lib/avm/patches/eac_ruby_gems_utils.rb +0 -4
  13. data/sub/avm/Gemfile +0 -5
  14. data/sub/avm/avm.gemspec +0 -26
  15. data/sub/avm/lib/avm/data/instance/files_unit.rb +0 -40
  16. data/sub/avm/lib/avm/data/instance/package.rb +0 -18
  17. data/sub/avm/lib/avm/data/instance/unit.rb +0 -17
  18. data/sub/avm/lib/avm/data/instance.rb +0 -11
  19. data/sub/avm/lib/avm/data/package/dump.rb +0 -119
  20. data/sub/avm/lib/avm/data/package/load.rb +0 -48
  21. data/sub/avm/lib/avm/data/package.rb +0 -42
  22. data/sub/avm/lib/avm/data/rotate.rb +0 -107
  23. data/sub/avm/lib/avm/data/unit.rb +0 -94
  24. data/sub/avm/lib/avm/docker/container.rb +0 -50
  25. data/sub/avm/lib/avm/docker/image.rb +0 -71
  26. data/sub/avm/lib/avm/docker/runner.rb +0 -125
  27. data/sub/avm/lib/avm/docker.rb +0 -9
  28. data/sub/avm/lib/avm/executables.rb +0 -24
  29. data/sub/avm/lib/avm/instances/application.rb +0 -29
  30. data/sub/avm/lib/avm/instances/base/auto_values/access.rb +0 -40
  31. data/sub/avm/lib/avm/instances/base/auto_values/admin.rb +0 -19
  32. data/sub/avm/lib/avm/instances/base/auto_values/data.rb +0 -26
  33. data/sub/avm/lib/avm/instances/base/auto_values/database.rb +0 -76
  34. data/sub/avm/lib/avm/instances/base/auto_values/filesystem.rb +0 -43
  35. data/sub/avm/lib/avm/instances/base/auto_values/mailer.rb +0 -34
  36. data/sub/avm/lib/avm/instances/base/auto_values/ruby.rb +0 -15
  37. data/sub/avm/lib/avm/instances/base/auto_values/source.rb +0 -15
  38. data/sub/avm/lib/avm/instances/base/auto_values/system.rb +0 -23
  39. data/sub/avm/lib/avm/instances/base/auto_values/web.rb +0 -46
  40. data/sub/avm/lib/avm/instances/base/auto_values.rb +0 -21
  41. data/sub/avm/lib/avm/instances/base/dockerizable.rb +0 -45
  42. data/sub/avm/lib/avm/instances/base/entry_keys.rb +0 -22
  43. data/sub/avm/lib/avm/instances/base.rb +0 -64
  44. data/sub/avm/lib/avm/instances/docker_image.rb +0 -15
  45. data/sub/avm/lib/avm/instances/entries.rb +0 -43
  46. data/sub/avm/lib/avm/instances/entry.rb +0 -60
  47. data/sub/avm/lib/avm/instances/entry_keys.rb +0 -60
  48. data/sub/avm/lib/avm/instances/runner.rb +0 -39
  49. data/sub/avm/lib/avm/instances.rb +0 -8
  50. data/sub/avm/lib/avm/jobs/base.rb +0 -63
  51. data/sub/avm/lib/avm/jobs/variables_source.rb +0 -22
  52. data/sub/avm/lib/avm/jobs.rb +0 -9
  53. data/sub/avm/lib/avm/launcher/errors/base.rb +0 -10
  54. data/sub/avm/lib/avm/launcher/errors/non_project.rb +0 -15
  55. data/sub/avm/lib/avm/launcher/paths/real.rb +0 -44
  56. data/sub/avm/lib/avm/launcher/publish/check_result.rb +0 -67
  57. data/sub/avm/lib/avm/path_string.rb +0 -27
  58. data/sub/avm/lib/avm/registry/base.rb +0 -67
  59. data/sub/avm/lib/avm/registry.rb +0 -29
  60. data/sub/avm/lib/avm/result.rb +0 -86
  61. data/sub/avm/lib/avm/rspec/setup.rb +0 -22
  62. data/sub/avm/lib/avm/rspec/shared_examples/in_avm_registry.rb +0 -11
  63. data/sub/avm/lib/avm/rspec/shared_examples/not_in_avm_registry.rb +0 -14
  64. data/sub/avm/lib/avm/rspec.rb +0 -9
  65. data/sub/avm/lib/avm/runners/base.rb +0 -27
  66. data/sub/avm/lib/avm/scms/base.rb +0 -46
  67. data/sub/avm/lib/avm/scms/commit.rb +0 -43
  68. data/sub/avm/lib/avm/scms/inflector.rb +0 -22
  69. data/sub/avm/lib/avm/self/docker_image.rb +0 -14
  70. data/sub/avm/lib/avm/self/instance/entry_keys.rb +0 -12
  71. data/sub/avm/lib/avm/self/instance.rb +0 -31
  72. data/sub/avm/lib/avm/sources/base/configuration.rb +0 -45
  73. data/sub/avm/lib/avm/sources/base/instance.rb +0 -28
  74. data/sub/avm/lib/avm/sources/base/parent.rb +0 -31
  75. data/sub/avm/lib/avm/sources/base/subs.rb +0 -55
  76. data/sub/avm/lib/avm/sources/base/subs_paths.rb +0 -32
  77. data/sub/avm/lib/avm/sources/base/testing.rb +0 -21
  78. data/sub/avm/lib/avm/sources/base.rb +0 -54
  79. data/sub/avm/lib/avm/sources/configuration/locale.rb +0 -18
  80. data/sub/avm/lib/avm/sources/configuration/rubocop.rb +0 -26
  81. data/sub/avm/lib/avm/sources/configuration/tests.rb +0 -29
  82. data/sub/avm/lib/avm/sources/configuration.rb +0 -59
  83. data/sub/avm/lib/avm/sources/tester.rb +0 -24
  84. data/sub/avm/lib/avm/sources/tests/builder.rb +0 -83
  85. data/sub/avm/lib/avm/sources/tests/performer.rb +0 -35
  86. data/sub/avm/lib/avm/sources/tests/result.rb +0 -15
  87. data/sub/avm/lib/avm/sources/tests/single.rb +0 -56
  88. data/sub/avm/lib/avm/sources/tests.rb +0 -11
  89. data/sub/avm/lib/avm/sources.rb +0 -9
  90. data/sub/avm/lib/avm/sync.rb +0 -94
  91. data/sub/avm/lib/avm/version.rb +0 -5
  92. data/sub/avm/lib/avm/version_number.rb +0 -45
  93. data/sub/avm/lib/avm.rb +0 -7
  94. data/sub/avm/spec/lib/avm/scms/base_spec.rb +0 -7
  95. data/sub/avm/spec/lib/avm/sources/base_spec.rb +0 -7
  96. data/sub/avm/spec/rubocop_spec.rb +0 -3
  97. data/sub/avm/spec/spec_helper.rb +0 -4
  98. data/sub/avm-eac_rails_base1/Gemfile +0 -5
  99. data/sub/avm-eac_rails_base1/avm-eac_rails_base1.gemspec +0 -21
  100. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/apache_host.rb +0 -17
  101. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instance.rb +0 -24
  102. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/bundle.rb +0 -26
  103. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/code_runner.rb +0 -26
  104. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/log.rb +0 -43
  105. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/logs/clear.rb +0 -26
  106. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/logs.rb +0 -18
  107. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/rails_server.rb +0 -32
  108. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/tasks_scheduler/systemd_unit.rb +0 -46
  109. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/tasks_scheduler.rb +0 -17
  110. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner.rb +0 -12
  111. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner_with/bundle.rb +0 -27
  112. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner_with/rails_environment.rb +0 -47
  113. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/sources/base.rb +0 -27
  114. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/systemd_unit/service.rb +0 -70
  115. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/systemd_unit/tasks_scheduler_command.rb +0 -29
  116. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/systemd_unit.rb +0 -57
  117. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/version.rb +0 -7
  118. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1.rb +0 -9
  119. data/sub/avm-eac_rails_base1/spec/rubocop_spec.rb +0 -3
  120. data/sub/avm-eac_rails_base1/spec/spec_helper.rb +0 -4
  121. data/sub/avm-eac_rails_base1/template/avm/eac_rails_base1/systemd_unit/tasks_scheduler.service +0 -12
  122. data/sub/avm-eac_rails_base1/template/avm/eac_rails_base1/systemd_unit/tasks_scheduler_command.sh +0 -6
  123. data/sub/avm-eac_ruby_base1/Gemfile +0 -5
  124. data/sub/avm-eac_ruby_base1/avm-eac_ruby_base1.gemspec +0 -22
  125. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/gemfile/add_or_replace_gem_line.rb +0 -56
  126. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/gemfile/dependency.rb +0 -19
  127. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/gemfile.rb +0 -34
  128. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/incompatible_parser/depends_on.rb +0 -25
  129. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/incompatible_parser/gem_conflict.rb +0 -44
  130. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/incompatible_parser/in_gemfile.rb +0 -17
  131. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/incompatible_parser/line_buffer.rb +0 -73
  132. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/incompatible_parser/line_factory.rb +0 -31
  133. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/incompatible_parser/line_parser_base.rb +0 -19
  134. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/incompatible_parser/version_requirement.rb +0 -26
  135. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/incompatible_parser.rb +0 -25
  136. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler.rb +0 -11
  137. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/configured.rb +0 -31
  138. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/envvar.rb +0 -17
  139. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/gemfile.rb +0 -41
  140. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop.rb +0 -55
  141. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/bundle_command.rb +0 -39
  142. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/bundler.rb +0 -39
  143. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/version_bump.rb +0 -23
  144. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base.rb +0 -55
  145. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/bundler/incompatible.rb +0 -76
  146. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/bundler.rb +0 -19
  147. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners.rb +0 -13
  148. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/tester.rb +0 -38
  149. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update/sub_update.rb +0 -56
  150. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update.rb +0 -52
  151. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources.rb +0 -11
  152. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/version.rb +0 -7
  153. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1.rb +0 -9
  154. data/sub/avm-eac_ruby_base1/locale/en.yml +0 -8
  155. data/sub/avm-eac_ruby_base1/locale/pt-BR.yml +0 -8
  156. data/sub/avm-eac_ruby_base1/spec/lib/avm/eac_ruby_base1/bundler/incompatible_parser_spec.rb +0 -7
  157. data/sub/avm-eac_ruby_base1/spec/lib/avm/eac_ruby_base1/bundler/incompatible_parser_spec_files/1.source.out +0 -192
  158. data/sub/avm-eac_ruby_base1/spec/lib/avm/eac_ruby_base1/bundler/incompatible_parser_spec_files/1.target.yaml +0 -300
  159. data/sub/avm-eac_ruby_base1/spec/lib/avm/eac_ruby_base1/bundler/incompatible_parser_spec_files/2.source.out +0 -245
  160. data/sub/avm-eac_ruby_base1/spec/lib/avm/eac_ruby_base1/bundler/incompatible_parser_spec_files/2.target.yaml +0 -355
  161. data/sub/avm-eac_ruby_base1/spec/lib/avm/eac_ruby_base1/sources/base_spec.rb +0 -7
  162. data/sub/avm-eac_ruby_base1/spec/rubocop_spec.rb +0 -3
  163. data/sub/avm-eac_ruby_base1/spec/spec_helper.rb +0 -4
  164. data/sub/eac_ruby_base0/Gemfile +0 -5
  165. data/sub/eac_ruby_base0/eac_ruby_base0.gemspec +0 -21
  166. data/sub/eac_ruby_base0/lib/eac_ruby_base0/application.rb +0 -87
  167. data/sub/eac_ruby_base0/lib/eac_ruby_base0/application_xdg.rb +0 -34
  168. data/sub/eac_ruby_base0/lib/eac_ruby_base0/core_ext.rb +0 -5
  169. data/sub/eac_ruby_base0/lib/eac_ruby_base0/jobs_runner.rb +0 -31
  170. data/sub/eac_ruby_base0/lib/eac_ruby_base0/patches/class/jobs_runner.rb +0 -10
  171. data/sub/eac_ruby_base0/lib/eac_ruby_base0/patches/class.rb +0 -4
  172. data/sub/eac_ruby_base0/lib/eac_ruby_base0/patches/object/runner_with.rb +0 -5
  173. data/sub/eac_ruby_base0/lib/eac_ruby_base0/patches/object.rb +0 -5
  174. data/sub/eac_ruby_base0/lib/eac_ruby_base0/patches.rb +0 -4
  175. data/sub/eac_ruby_base0/lib/eac_ruby_base0/rspec/setup.rb +0 -14
  176. data/sub/eac_ruby_base0/lib/eac_ruby_base0/rspec.rb +0 -9
  177. data/sub/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +0 -92
  178. data/sub/eac_ruby_base0/lib/eac_ruby_base0/runner_with/confirmation.rb +0 -42
  179. data/sub/eac_ruby_base0/lib/eac_ruby_base0/runner_with/filesystem_traverser.rb +0 -52
  180. data/sub/eac_ruby_base0/lib/eac_ruby_base0/runner_with/input.rb +0 -36
  181. data/sub/eac_ruby_base0/lib/eac_ruby_base0/runner_with/output.rb +0 -58
  182. data/sub/eac_ruby_base0/lib/eac_ruby_base0/runner_with.rb +0 -9
  183. data/sub/eac_ruby_base0/lib/eac_ruby_base0/version.rb +0 -5
  184. data/sub/eac_ruby_base0/lib/eac_ruby_base0.rb +0 -7
  185. data/sub/eac_ruby_base0/spec/lib/eac_ruby_base0/runner_with/confirmation_spec.rb +0 -42
  186. data/sub/eac_ruby_base0/spec/lib/eac_ruby_base0/runner_with/output_spec.rb +0 -81
  187. data/sub/eac_ruby_base0/spec/rubocop_spec.rb +0 -3
  188. data/sub/eac_ruby_base0/spec/spec_helper.rb +0 -4
  189. data/sub/eac_ruby_gems_utils/Gemfile +0 -5
  190. data/sub/eac_ruby_gems_utils/LICENCE +0 -16
  191. data/sub/eac_ruby_gems_utils/README.rdoc +0 -3
  192. data/sub/eac_ruby_gems_utils/eac_ruby_gems_utils.gemspec +0 -31
  193. data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/command.rb +0 -33
  194. data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/version_file.rb +0 -41
  195. data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem.rb +0 -97
  196. data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb +0 -57
  197. data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/minitest.rb +0 -25
  198. data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple/decorated_gem.rb +0 -48
  199. data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple/result.rb +0 -25
  200. data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple.rb +0 -84
  201. data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/rspec.rb +0 -21
  202. data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests.rb +0 -9
  203. data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +0 -5
  204. data/sub/eac_ruby_gems_utils/lib/eac_ruby_gems_utils.rb +0 -7
  205. data/sub/eac_ruby_gems_utils/spec/code/rubocop_check_spec.rb +0 -3
  206. data/sub/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem/version_file_spec.rb +0 -14
  207. data/sub/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem/version_file_spec_files/a_version_file.rb +0 -7
  208. data/sub/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem_spec.rb +0 -20
  209. data/sub/eac_ruby_gems_utils/spec/spec_helper.rb +0 -4
  210. data/sub/eac_ruby_gems_utils/spec/support/mygem/Gemfile +0 -5
  211. data/sub/eac_ruby_gems_utils/spec/support/mygem/Gemfile.lock +0 -19
  212. data/sub/eac_ruby_gems_utils/spec/support/mygem/Rakefile +0 -14
  213. data/sub/eac_ruby_gems_utils/spec/support/mygem/exe/myrunner +0 -5
  214. data/sub/eac_ruby_gems_utils/spec/support/mygem/lib/mygem/version.rb +0 -5
  215. data/sub/eac_ruby_gems_utils/spec/support/mygem/lib/mygem.rb +0 -5
  216. data/sub/eac_ruby_gems_utils/spec/support/mygem/mygem.gemspec +0 -16
@@ -1,119 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/data/rotate'
4
- require 'eac_ruby_utils/core_ext'
5
- require 'minitar'
6
-
7
- module Avm
8
- module Data
9
- class Package
10
- class Dump
11
- enable_speaker
12
- enable_listable
13
-
14
- DEFAULT_EXPIRE_TIME = 1.day
15
- DEFAULT_FILE_EXTENSION = '.tar'
16
-
17
- attr_reader :package, :data_file_path, :existing
18
-
19
- lists.add_string :existing, :denied, :overwrite, :rotate, :rotate_expired
20
-
21
- def initialize(package, data_file_path, options = {})
22
- @package = package
23
- @data_file_path = data_file_path
24
- options = options.to_options_consumer
25
- @existing, @expire_time = options.consume(:existing, :expire_time)
26
- options.validate
27
- self.class.lists.existing.value_validate!(@existing)
28
- end
29
-
30
- def runnable?
31
- cannot_run_reason.blank?
32
- end
33
-
34
- def cannot_run_reason
35
- return nil if !data_file_exist? ||
36
- [EXISTING_OVERWRITE, EXISTING_ROTATE].include?(existing)
37
-
38
- if existing == EXISTING_DENIED
39
- 'Data exist and overwriting is denied'
40
- elsif existing == EXISTING_ROTATE_EXPIRED && !data_file_expired?
41
- 'Data exist and yet is not expired'
42
- end
43
- end
44
-
45
- def run
46
- raise "Cannot run: #{cannot_run_reason}" unless runnable?
47
-
48
- build_dir = dump_units_to_build_directory
49
- package_file = create_package_file(build_dir)
50
- rotate
51
- move_download_to_final_dest(package_file)
52
- end
53
-
54
- def data_file_exist?
55
- ::File.exist?(data_file_path)
56
- end
57
-
58
- def data_file_time
59
- data_file_exist? ? ::Time.now - ::File.mtime(data_file_path) : nil
60
- end
61
-
62
- def data_file_expired?
63
- data_file_time.if_present(false) { |v| v >= expire_time }
64
- end
65
-
66
- def expire_time
67
- @expire_time || DEFAULT_EXPIRE_TIME
68
- end
69
-
70
- private
71
-
72
- def download
73
- infom 'Downloading dump...'
74
- download_path = find_download_path
75
- dump_command.system!(output_file: download_path)
76
- fatal_error "File \"#{download_path}\" not saved" unless ::File.exist?(download_path)
77
- fatal_error "File \"#{download_path}\" is empty" if ::File.zero?(download_path)
78
- download_path
79
- end
80
-
81
- def move_download_to_final_dest(download_path)
82
- ::FileUtils.mkdir_p(::File.dirname(data_file_path))
83
- ::FileUtils.mv(download_path, data_file_path)
84
- end
85
-
86
- def rotate
87
- return unless data_file_exist?
88
- return unless existing == EXISTING_ROTATE
89
-
90
- infom "Rotating \"#{data_file_path}\"..."
91
- ::Avm::Data::Rotate.new(data_file_path).run
92
- end
93
-
94
- def new_build_path
95
- f = ::Tempfile.new(self.class.name.parameterize + '-download')
96
- path = f.path
97
- f.close
98
- f.unlink
99
- path
100
- end
101
-
102
- def dump_units_to_build_directory
103
- dir = ::Dir.mktmpdir
104
- package.dump_units_to_directory(dir)
105
- dir
106
- end
107
-
108
- def create_package_file(build_dir)
109
- package_path = new_build_path
110
- infom "Creating package \"#{package_path}\" from \"#{build_dir}\"..."
111
- Dir.chdir(build_dir) do
112
- ::Minitar.pack('.', File.open(::File.expand_path(package_path), 'wb'))
113
- end
114
- package_path
115
- end
116
- end
117
- end
118
- end
119
- end
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'minitar'
5
-
6
- module Avm
7
- module Data
8
- class Package
9
- class Load
10
- enable_speaker
11
-
12
- attr_reader :package, :data_file_path
13
-
14
- def initialize(package, data_file_path)
15
- @package = package
16
- @data_file_path = data_file_path
17
- end
18
-
19
- def runnable?
20
- cannot_run_reason.blank?
21
- end
22
-
23
- def cannot_run_reason
24
- return nil if data_file_exist?
25
-
26
- "Data file \"#{data_file_path}\" does not exist"
27
- end
28
-
29
- def run
30
- raise "Cannot run: #{cannot_run_reason}" unless runnable?
31
-
32
- build_dir = extract_packages_to_build_directory
33
- package.load_units_from_directory(build_dir)
34
- end
35
-
36
- def data_file_exist?
37
- ::File.exist?(data_file_path)
38
- end
39
-
40
- def extract_packages_to_build_directory
41
- dir = ::Dir.mktmpdir
42
- ::Minitar.unpack(data_file_path, dir)
43
- dir
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/data/package/dump'
4
- require 'avm/data/package/load'
5
-
6
- module Avm
7
- module Data
8
- class Package
9
- attr_reader :units
10
-
11
- def initialize(options)
12
- @units = {}
13
- options = options.to_options_consumer
14
- units = options.consume(:units)
15
- options.validate
16
- units.if_present do |v|
17
- v.each { |identifier, unit| add_unit(identifier, unit) }
18
- end
19
- end
20
-
21
- def add_unit(identifier, unit)
22
- @units[identifier.to_sym] = unit
23
- end
24
-
25
- def dump(data_path, options = {})
26
- ::Avm::Data::Package::Dump.new(self, data_path, options)
27
- end
28
-
29
- def load(data_path)
30
- ::Avm::Data::Package::Load.new(self, data_path)
31
- end
32
-
33
- def dump_units_to_directory(directory)
34
- @units.each { |identifier, unit| unit.dump_to_directory(directory, identifier) }
35
- end
36
-
37
- def load_units_from_directory(directory)
38
- @units.each { |identifier, unit| unit.load_from_directory(directory, identifier) }
39
- end
40
- end
41
- end
42
- end
@@ -1,107 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_support/core_ext/object/blank'
4
- require 'eac_ruby_utils/simple_cache'
5
-
6
- module Avm
7
- module Data
8
- class Rotate
9
- include ::EacRubyUtils::SimpleCache
10
-
11
- attr_reader :options, :source_path
12
-
13
- def initialize(source_path, options = {})
14
- @source_path = source_path
15
- @options = options
16
- end
17
-
18
- def run
19
- validate_msg = validate
20
- return validate_msg if validate_msg.present?
21
-
22
- ::FileUtils.mv(source_path, target_path)
23
- check_space_limit
24
- nil
25
- end
26
-
27
- def space_limit
28
- r = options[:space_limit].try(:to_i)
29
- return r if r.present? && r.positive?
30
-
31
- r
32
- end
33
-
34
- def space_used
35
- rotated_files.inject(0) { |a, e| a + ::File.size(e) }
36
- end
37
-
38
- def rotated_files
39
- ::Dir["#{dirname}/#{source_basename_without_extension}*#{source_extension}"]
40
- end
41
-
42
- def oldest_rotated_file
43
- rotated_files.min_by { |file| [::File.mtime(file)] }
44
- end
45
-
46
- private
47
-
48
- def check_space_limit
49
- return unless space_limit
50
-
51
- while space_used > space_limit
52
- file = oldest_rotated_file
53
- unless file
54
- raise 'oldest_rotated_file returned nil ' \
55
- "(Limit: #{space_limit}, used: #{space_used})"
56
- end
57
- ::File.delete(file)
58
- end
59
- end
60
-
61
- def validate
62
- return "Source file \"#{source_path}\" does not exist" unless ::File.exist?(source_path)
63
- return "File \"#{source_path}\" is already rotated" if source_rotated?
64
-
65
- nil
66
- end
67
-
68
- def source_rotated?
69
- source_basename_without_extension.match(/[PN]\d{4}\z/)
70
- end
71
-
72
- def source_extension_uncached
73
- file_extension(::File.basename(source_path))
74
- end
75
-
76
- def source_basename_without_extension
77
- ::File.basename(source_path, source_extension)
78
- end
79
-
80
- def target_path_uncached
81
- ::File.join(dirname, target_basename)
82
- end
83
-
84
- def dirname
85
- ::File.dirname(source_path)
86
- end
87
-
88
- def target_basename
89
- source_basename_without_extension + target_suffix + source_extension
90
- end
91
-
92
- def target_suffix
93
- return '_UNKNOWN_MTIME' unless ::File.exist?(source_path)
94
-
95
- t = ::File.mtime(source_path)
96
- t.strftime('_%Y-%m-%d_%H-%M-%S_') + t.strftime('%z').gsub(/\A\+/, 'P').gsub(/\A\-/, 'N')
97
- end
98
-
99
- def file_extension(basename)
100
- extension = ::File.extname(basename)
101
- return '' if extension.blank?
102
-
103
- file_extension(::File.basename(basename, extension)) + extension
104
- end
105
- end
106
- end
107
- end
@@ -1,94 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'active_support/callbacks'
5
-
6
- module Avm
7
- module Data
8
- class Unit
9
- include ::ActiveSupport::Callbacks
10
-
11
- define_callbacks :dump, :load
12
- enable_speaker
13
-
14
- %w[dump load].each do |action|
15
- method_name = "#{action}_command"
16
- class_eval <<~CODE, __FILE__, __LINE__ + 1
17
- # Should be overrided.
18
- # @return [EacRubyUtils::Envs::Command]
19
- def #{method_name}
20
- fail "\\"#{method_name}\\" is a abstract method. Override in #{singleton_class}."
21
- end
22
- CODE
23
-
24
- # Callbacks
25
- %w[before after].each do |callback|
26
- method = "#{callback}_#{action}"
27
- class_eval <<~CODE, __FILE__, __LINE__ + 1
28
- def self.#{method}(callback_method = nil, &block)
29
- if callback_method
30
- set_callback :#{action}, :#{callback}, callback_method
31
- else
32
- set_callback :#{action}, :#{callback}, &block
33
- end
34
- self
35
- end
36
-
37
- def #{method}(callback_method = nil, &block)
38
- singleton_class.#{method}(callback_method, &block)
39
- self
40
- end
41
- CODE
42
- end
43
- end
44
-
45
- def extension
46
- singleton_class.const_get('EXTENSION')
47
- rescue NameError
48
- ''
49
- end
50
-
51
- def name
52
- self.class
53
- end
54
-
55
- def load_from_directory(directory, identifier)
56
- load(unit_on_directory_path(directory, identifier))
57
- end
58
-
59
- def dump_to_directory(directory, identifier)
60
- dump(unit_on_directory_path(directory, identifier))
61
- end
62
-
63
- def dump(data_path)
64
- run_callbacks :dump do
65
- infom "Dumping unit \"#{name}\" to \"#{data_path}\"..."
66
- do_dump(data_path)
67
- end
68
- end
69
-
70
- def load(data_path)
71
- run_callbacks :load do
72
- infom "Loading unit \"#{name}\" from \"#{data_path}\"..."
73
- do_load(data_path)
74
- end
75
- end
76
-
77
- protected
78
-
79
- def do_dump(data_path)
80
- dump_command.execute!(output_file: data_path)
81
- end
82
-
83
- def do_load(data_path)
84
- load_command.execute!(input_file: data_path)
85
- end
86
-
87
- private
88
-
89
- def unit_on_directory_path(directory, identifier)
90
- ::File.join(directory, "#{identifier}#{extension}")
91
- end
92
- end
93
- end
94
- end
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_docker/executables'
4
- require 'eac_ruby_utils/core_ext'
5
-
6
- module Avm
7
- module Docker
8
- class Container
9
- enable_speaker
10
- common_constructor :instance
11
-
12
- def remove
13
- ::EacDocker::Executables.docker.command.append(
14
- ['rm', '--force', instance.docker_container_name]
15
- ).system!
16
- end
17
-
18
- def run(options = {})
19
- infov 'Container name', instance.docker_container_name
20
- infov 'Container exist?', instance.docker_container_exist?
21
- remove if options[:clear] && instance.docker_container_exist?
22
- if instance.docker_container_exist?
23
- run_start
24
- else
25
- run_run(options)
26
- end
27
- end
28
-
29
- def run_run(options)
30
- infom "\"docker run #{instance.docker_container_name}...\""
31
- ::EacDocker::Executables.docker.command.append(run_run_arguments(options)).system!
32
- end
33
-
34
- def run_start
35
- infom "\"docker start #{instance.docker_container_name}...\""
36
- ::EacDocker::Executables.docker.command.append(run_start_arguments).system!
37
- end
38
-
39
- def run_run_arguments(options)
40
- entrypoint_args = options[:entrypoint_args].if_present([])
41
- ['run', '-it', '--name', instance.docker_container_name] + instance.docker_run_arguments +
42
- [instance.docker_image.tag] + entrypoint_args
43
- end
44
-
45
- def run_start_arguments
46
- ['start', '-ai', instance.docker_container_name]
47
- end
48
- end
49
- end
50
- end
@@ -1,71 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/version'
4
- require 'eac_ruby_utils/core_ext'
5
- require 'eac_docker/images/templatized'
6
-
7
- module Avm
8
- module Docker
9
- class Image < ::EacDocker::Images::Templatized
10
- attr_reader :registry
11
- attr_accessor :snapshot
12
- attr_accessor :version
13
-
14
- def initialize(registry)
15
- @registry = registry
16
- self.snapshot = true
17
- self.version = true
18
- end
19
-
20
- def build(extra_args = [])
21
- nyi "Extra args: #{extra_args}" if extra_args.any?
22
-
23
- provide
24
- end
25
-
26
- def generator_version
27
- ::Avm::VERSION
28
- end
29
-
30
- def push
31
- ::EacDocker::Executables.docker.command.append(['push', tag]).system!
32
- end
33
-
34
- def read_entry(path, options = {})
35
- method = path.gsub('.', '_')
36
- return send(method) if respond_to?(path, true)
37
- return instance.read_entry(path, options) if respond_to?(:instance)
38
-
39
- raise "Method \"#{method}\" not found for entry \"#{path}\""
40
- end
41
-
42
- def run(instance)
43
- run_run(instance) if container_exist?(instance)
44
- end
45
-
46
- def tag
47
- r = tag_name
48
- r += ":#{tag_version}" if tag_version.present?
49
- r
50
- end
51
-
52
- def tag_name
53
- return registry.name if registry.name.present?
54
-
55
- raise 'Registry name is blank'
56
- end
57
-
58
- def tag_version
59
- [tag_version_version, stereotype_tag].reject(&:blank?).join('_')
60
- end
61
-
62
- def tag_version_version
63
- return nil unless version
64
-
65
- r = generator_version
66
- r += '-snapshot' if snapshot
67
- r
68
- end
69
- end
70
- end
71
- end
@@ -1,125 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_docker/registry'
4
- require 'eac_ruby_utils/core_ext'
5
-
6
- module Avm
7
- module Docker
8
- class Runner
9
- DOCKER_DEFAULT_REGISTRY_METHOD = :docker_default_registry
10
-
11
- enable_speaker
12
- enable_simple_cache
13
-
14
- runner_with :help do
15
- desc 'Manipulate Docker images.'
16
- bool_opt '-I', '--image-name', 'Output image name.'
17
- arg_opt '-n', '--registry-name', 'Docker registry\'s name.'
18
- bool_opt '-p', '--push', 'Push the image to Docker registry.'
19
- bool_opt '-r', '--run', 'Run or start a container with builded image.'
20
- arg_opt '-B', '--build-arg', 'Argument for "docker build".', repeat: true
21
- arg_opt '-E', '--entrypoint-arg', 'Argument for entrypoint on "docker run"', repeat: true
22
- bool_opt '-c', '--clear', 'Remove container if exist before run.'
23
- bool_opt '-S', '--no-snapshot', 'Does not add "-snapshot" to image tag.'
24
- bool_opt '-V', '--no-version', 'Does not add version to image tag.'
25
- end
26
-
27
- def run
28
- setup
29
- banner
30
- build
31
- output_image_name
32
- push
33
- container_run
34
- end
35
-
36
- private
37
-
38
- def setup
39
- instance.docker_image_options = {
40
- registry: registry,
41
- snapshot: snapshot?,
42
- version: version?
43
- }
44
- end
45
-
46
- def banner
47
- infov 'Registry name', registry
48
- infov 'Version?', version?
49
- infov 'Snapshot?', snapshot?
50
- infov 'Image name', docker_image.tag
51
- infov 'Build arguments', build_args
52
- infov 'Entrypoint arguments', entrypoint_args
53
- end
54
-
55
- def build
56
- docker_image.build(build_args)
57
- success 'Docker image builded'
58
- end
59
-
60
- def build_args
61
- parsed.build_arg
62
- end
63
-
64
- def docker_container
65
- instance.docker_container
66
- end
67
-
68
- def docker_image
69
- instance.docker_image
70
- end
71
-
72
- def entrypoint_args
73
- parsed.entrypoint_arg
74
- end
75
-
76
- def push
77
- docker_image.push if parsed.push?
78
- end
79
-
80
- def container_run
81
- return unless parsed.run?
82
-
83
- docker_container.run(
84
- entrypoint_args: entrypoint_args,
85
- clear: parsed.clear?
86
- )
87
- end
88
-
89
- def output_image_name
90
- return unless parsed.image_name
91
-
92
- out(docker_image.tag.to_s.strip + "\n")
93
- end
94
-
95
- def registry_uncached
96
- registry_from_option || registry_from_instance || registry_from_default ||
97
- fatal_error('No registry defined')
98
- end
99
-
100
- def registry_from_option
101
- parsed.registry_name.if_present { |v| ::EacDocker::Registry.new(v) }
102
- end
103
-
104
- def registry_from_instance
105
- instance.docker_registry_optional.if_present { |v| ::EacDocker::Registry.new(v) }
106
- end
107
-
108
- def registry_from_default
109
- if_respond(DOCKER_DEFAULT_REGISTRY_METHOD, nil)
110
- end
111
-
112
- def snapshot?
113
- !parsed.no_snapshot?
114
- end
115
-
116
- def version?
117
- !parsed.no_version?
118
- end
119
-
120
- def instance
121
- runner_context.call(:instance)
122
- end
123
- end
124
- end
125
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module Avm
6
- module Docker
7
- require_sub __FILE__
8
- end
9
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/envs'
4
- require 'eac_ruby_utils/simple_cache'
5
-
6
- module Avm
7
- module Executables
8
- class << self
9
- include ::EacRubyUtils::SimpleCache
10
-
11
- def env
12
- ::EacRubyUtils::Envs.local
13
- end
14
-
15
- private
16
-
17
- %w[file git js-beautify latex php-cs-fixer tidy yapf xdg-open].each do |program|
18
- define_method(program.underscore + '_uncached') do
19
- env.executable(program, '--version')
20
- end
21
- end
22
- end
23
- end
24
- end