avm-tools 0.104.0 → 0.108.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/instances/entry.rb +3 -3
  3. data/lib/avm/launcher/context/instance_collector.rb +46 -0
  4. data/lib/avm/launcher/instances/runner_helper.rb +21 -15
  5. data/lib/avm/launcher/paths/logical.rb +5 -0
  6. data/lib/avm/patches/eac_ruby_gems_utils/gem.rb +2 -2
  7. data/lib/avm/ruby/rubocop/_configured.rb +2 -2
  8. data/lib/avm/tools/app_src.rb +68 -0
  9. data/lib/avm/tools/runner/app_src/info.rb +16 -2
  10. data/lib/avm/tools/runner/app_src/ruby/bundler/gemfile_lock/git.rb +62 -0
  11. data/lib/avm/tools/runner/app_src/ruby/bundler/gemfile_lock.rb +11 -41
  12. data/lib/avm/tools/runner/app_src/ruby/bundler/incompatible.rb +2 -4
  13. data/lib/avm/tools/runner/app_src.rb +2 -2
  14. data/lib/avm/tools/runner/config/load_path.rb +10 -5
  15. data/lib/avm/tools/runner/git/deploy.rb +2 -2
  16. data/lib/avm/tools/runner/launcher/instances.rb +7 -5
  17. data/lib/avm/tools/runner/launcher/projects.rb +2 -4
  18. data/lib/avm/tools/runner/launcher/publish.rb +2 -6
  19. data/lib/avm/tools/runner.rb +0 -4
  20. data/lib/avm/tools/version.rb +1 -1
  21. data/vendor/avm/avm.gemspec +3 -0
  22. data/{lib → vendor/avm/lib}/avm/data/instance/files_unit.rb +0 -0
  23. data/{lib → vendor/avm/lib}/avm/data/instance/package.rb +0 -0
  24. data/{lib → vendor/avm/lib}/avm/data/instance/unit.rb +0 -0
  25. data/{lib → vendor/avm/lib}/avm/data/instance.rb +0 -0
  26. data/{lib → vendor/avm/lib}/avm/data/package/dump.rb +0 -0
  27. data/{lib → vendor/avm/lib}/avm/data/package/load.rb +0 -0
  28. data/{lib → vendor/avm/lib}/avm/data/package.rb +0 -0
  29. data/{lib → vendor/avm/lib}/avm/data/unit.rb +0 -0
  30. data/vendor/avm/lib/avm/files/formatter/formats/base.rb +2 -2
  31. data/vendor/avm/lib/avm/files/formatter/formats/javascript.rb +1 -0
  32. data/vendor/avm/lib/avm/files/formatter/formats/php.rb +1 -0
  33. data/vendor/avm/lib/avm/files/formatter/formats/python.rb +1 -0
  34. data/vendor/avm/lib/avm/files/formatter/formats/xml.rb +1 -0
  35. data/vendor/avm/lib/avm/files/formatter/utf8_assert.rb +3 -1
  36. data/vendor/avm/lib/avm/git/issue/complete/test.rb +2 -2
  37. data/vendor/avm/lib/avm/git/revision_test.rb +2 -3
  38. data/vendor/avm/lib/avm/jobs/base.rb +62 -0
  39. data/vendor/avm/lib/avm/jobs/variables_source.rb +22 -0
  40. data/vendor/{avm-apps/lib/avm/apps.rb → avm/lib/avm/jobs.rb} +1 -1
  41. data/{lib → vendor/avm/lib}/avm/path_string.rb +0 -0
  42. data/vendor/avm/lib/avm/sources/base.rb +45 -0
  43. data/vendor/avm/lib/avm/sources/configuration/_locale.rb +16 -0
  44. data/vendor/avm/lib/avm/sources/configuration/_rubocop.rb +24 -0
  45. data/vendor/avm/lib/avm/sources/configuration/_tests.rb +27 -0
  46. data/vendor/avm/lib/avm/sources/configuration.rb +55 -0
  47. data/{lib/avm/eac_asciidoctor_base0.rb → vendor/avm/lib/avm/sources.rb} +1 -1
  48. data/{lib → vendor/avm/lib}/avm/sync.rb +0 -0
  49. data/vendor/avm/lib/avm/version.rb +1 -1
  50. data/vendor/avm/spec/lib/avm/git/auto_commit_path_spec.rb +4 -3
  51. data/vendor/avm/spec/lib/avm/git/commit/diff_tree_line_spec.rb +0 -1
  52. data/vendor/avm/spec/rubocop_spec.rb +1 -1
  53. data/vendor/avm/spec/spec_helper.rb +2 -17
  54. data/vendor/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/version.rb +1 -1
  55. data/vendor/avm-eac_asciidoctor_base0/spec/rubocop_spec.rb +1 -1
  56. data/vendor/avm-eac_asciidoctor_base0/spec/spec_helper.rb +2 -100
  57. data/vendor/avm-eac_rails_base1/lib/avm/eac_rails_base1/version.rb +1 -1
  58. data/vendor/avm-eac_rails_base1/spec/rubocop_spec.rb +1 -1
  59. data/vendor/avm-eac_rails_base1/spec/spec_helper.rb +2 -100
  60. data/vendor/avm-eac_redmine_base0/avm-eac_redmine_base0.gemspec +3 -1
  61. data/vendor/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/core_update.rb +3 -2
  62. data/vendor/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
  63. data/vendor/avm-eac_redmine_base0/spec/rubocop_spec.rb +1 -1
  64. data/vendor/avm-eac_redmine_base0/spec/spec_helper.rb +2 -100
  65. data/vendor/avm-eac_redmine_base0/template/avm/eac_redmine_base0/deploy/config/install.sh.template +1 -0
  66. data/vendor/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/apache_host.rb +2 -2
  67. data/vendor/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/apache_path.rb +2 -2
  68. data/vendor/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/deploy.rb +2 -2
  69. data/vendor/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/version.rb +1 -1
  70. data/vendor/avm-eac_webapp_base0/spec/rubocop_spec.rb +1 -1
  71. data/vendor/avm-eac_webapp_base0/spec/spec_helper.rb +2 -100
  72. data/vendor/eac_cli/eac_cli.gemspec +3 -3
  73. data/vendor/eac_cli/lib/eac_cli/config.rb +6 -3
  74. data/vendor/eac_cli/lib/eac_cli/definition/argument_option.rb +1 -1
  75. data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +9 -1
  76. data/vendor/eac_cli/lib/eac_cli/definition/boolean_option.rb +6 -0
  77. data/vendor/eac_cli/lib/eac_cli/runner_with/help/builder.rb +3 -3
  78. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  79. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +6 -5
  80. data/vendor/eac_cli/spec/rubocop_spec.rb +1 -1
  81. data/vendor/eac_cli/spec/spec_helper.rb +2 -101
  82. data/vendor/eac_config/eac_config.gemspec +2 -2
  83. data/vendor/eac_config/lib/eac_config/version.rb +1 -1
  84. data/vendor/eac_config/spec/rubocop_spec.rb +1 -1
  85. data/vendor/eac_config/spec/spec_helper.rb +2 -15
  86. data/vendor/eac_docker/eac_docker.gemspec +2 -2
  87. data/vendor/eac_docker/lib/eac_docker/container.rb +7 -3
  88. data/vendor/eac_docker/lib/eac_docker/images/templatized.rb +4 -0
  89. data/vendor/eac_docker/lib/eac_docker/rspec/setup.rb +17 -0
  90. data/vendor/eac_docker/lib/eac_docker/rspec.rb +2 -10
  91. data/vendor/eac_docker/lib/eac_docker/version.rb +1 -1
  92. data/vendor/eac_docker/spec/rubocop_spec.rb +1 -1
  93. data/vendor/eac_docker/spec/spec_helper.rb +2 -104
  94. data/vendor/{avm-apps → eac_fs}/Gemfile +0 -0
  95. data/vendor/eac_fs/eac_fs.gemspec +20 -0
  96. data/vendor/{eac_ruby_utils/lib/eac_ruby_utils/filesystem_cache.rb → eac_fs/lib/eac_fs/cache.rb} +7 -2
  97. data/{lib/avm → vendor/eac_fs/lib/eac_fs}/cached_download.rb +4 -4
  98. data/vendor/eac_fs/lib/eac_fs/file_info.rb +29 -0
  99. data/vendor/eac_fs/lib/eac_fs/patches/module/fs_cache.rb +10 -0
  100. data/vendor/eac_fs/lib/eac_fs/patches/module.rb +4 -0
  101. data/vendor/eac_fs/lib/eac_fs/patches/object/fs_cache.rb +15 -0
  102. data/vendor/eac_fs/lib/eac_fs/patches/object.rb +4 -0
  103. data/vendor/eac_fs/lib/eac_fs/patches/pathname/info.rb +12 -0
  104. data/vendor/eac_fs/lib/eac_fs/patches/pathname.rb +4 -0
  105. data/vendor/eac_fs/lib/eac_fs/patches.rb +4 -0
  106. data/vendor/eac_fs/lib/eac_fs/version.rb +5 -0
  107. data/vendor/eac_fs/lib/eac_fs.rb +7 -0
  108. data/vendor/{eac_ruby_utils/spec/lib/eac_ruby_utils/filesystem_cache_spec.rb → eac_fs/spec/lib/eac_fs/cache_spec.rb} +2 -2
  109. data/vendor/eac_fs/spec/rubocop_spec.rb +3 -0
  110. data/vendor/eac_fs/spec/spec_helper.rb +4 -0
  111. data/vendor/eac_git/eac_git.gemspec +3 -3
  112. data/vendor/eac_git/lib/eac_git/local/commit/archive.rb +1 -1
  113. data/vendor/eac_git/lib/eac_git/local/commit.rb +3 -3
  114. data/vendor/eac_git/lib/eac_git/local.rb +13 -0
  115. data/vendor/eac_git/lib/eac_git/rspec/setup.rb +23 -0
  116. data/vendor/eac_git/lib/eac_git/rspec.rb +1 -14
  117. data/vendor/eac_git/lib/eac_git/version.rb +1 -1
  118. data/vendor/eac_git/spec/rubocop_spec.rb +1 -1
  119. data/vendor/eac_git/spec/spec_helper.rb +2 -104
  120. data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +5 -4
  121. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +4 -4
  122. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/core_ext.rb +1 -0
  123. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +16 -7
  124. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  125. data/vendor/eac_ruby_base0/spec/rubocop_spec.rb +1 -1
  126. data/vendor/eac_ruby_base0/spec/spec_helper.rb +2 -101
  127. data/vendor/eac_ruby_gems_utils/eac_ruby_gems_utils.gemspec +2 -2
  128. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb +0 -5
  129. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +1 -1
  130. data/vendor/eac_ruby_gems_utils/spec/code/rubocop_check_spec.rb +1 -1
  131. data/vendor/eac_ruby_gems_utils/spec/spec_helper.rb +2 -101
  132. data/vendor/eac_ruby_utils/eac_ruby_utils.gemspec +1 -1
  133. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/compact.rb +22 -0
  134. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/executable.rb +15 -3
  135. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/gems_registry/gem.rb +75 -0
  136. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/gems_registry.rb +35 -0
  137. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/compact.rb +20 -0
  138. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string/delimited.rb +16 -0
  139. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/recursive_builder.rb +51 -0
  140. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/default_setup.rb +20 -0
  141. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup/conditionals.rb +17 -0
  142. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup.rb +12 -0
  143. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup_manager.rb +49 -0
  144. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/string_delimited.rb +70 -0
  145. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  146. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/compact_spec.rb +20 -0
  147. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/compact_spec.rb +20 -0
  148. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/string/delimited_spec.rb +34 -0
  149. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/recursive_builder_spec.rb +65 -0
  150. data/vendor/eac_ruby_utils/spec/rubocop_check_spec.rb +1 -1
  151. data/vendor/eac_ruby_utils/spec/spec_helper.rb +6 -6
  152. data/vendor/eac_templates/lib/eac_templates/patches/module/erb_template.rb +9 -0
  153. data/vendor/eac_templates/lib/eac_templates/patches/module.rb +4 -0
  154. data/vendor/eac_templates/lib/eac_templates/patches/object/erb_template.rb +9 -0
  155. data/vendor/eac_templates/lib/eac_templates/patches/object.rb +4 -0
  156. data/vendor/eac_templates/lib/eac_templates/patches.rb +4 -0
  157. data/vendor/eac_templates/lib/eac_templates/version.rb +1 -1
  158. data/vendor/eac_templates/spec/rubocop_spec.rb +1 -1
  159. data/vendor/eac_templates/spec/spec_helper.rb +2 -100
  160. metadata +72 -198
  161. data/lib/avm/app_src.rb +0 -61
  162. data/lib/avm/fs_cache.rb +0 -11
  163. data/lib/avm/patches/object/fs_cache.rb +0 -16
  164. data/vendor/avm/lib/avm/files/info.rb +0 -24
  165. data/vendor/avm-apps/avm-apps.gemspec +0 -18
  166. data/vendor/avm-apps/lib/avm/apps/config.rb +0 -19
  167. data/vendor/avm-apps/lib/avm/apps/jobs/base.rb +0 -64
  168. data/vendor/avm-apps/lib/avm/apps/jobs/variables_source.rb +0 -24
  169. data/vendor/avm-apps/lib/avm/apps/jobs.rb +0 -11
  170. data/vendor/avm-apps/lib/avm/apps/sources/configuration/_locale.rb +0 -18
  171. data/vendor/avm-apps/lib/avm/apps/sources/configuration/_rubocop.rb +0 -26
  172. data/vendor/avm-apps/lib/avm/apps/sources/configuration/_tests.rb +0 -29
  173. data/vendor/avm-apps/lib/avm/apps/sources/configuration.rb +0 -57
  174. data/vendor/avm-apps/lib/avm/apps/version.rb +0 -7
  175. data/vendor/avm-apps/spec/rubocop_spec.rb +0 -3
  176. data/vendor/avm-apps/spec/spec_helper.rb +0 -103
  177. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs_cache.rb +0 -12
  178. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/conditional.rb +0 -35
  179. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/stubbed_ssh.rb +0 -44
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/string/inflections'
4
+ require 'eac_ruby_utils/recursive_builder'
5
+ require 'eac_ruby_utils/simple_cache'
6
+
7
+ module EacRubyUtils
8
+ class GemsRegistry
9
+ class Gem
10
+ include ::Comparable
11
+ include ::EacRubyUtils::SimpleCache
12
+
13
+ attr_reader :registry, :gemspec
14
+
15
+ def initialize(registry, gemspec)
16
+ @registry = registry
17
+ @gemspec = gemspec
18
+ end
19
+
20
+ def depend_on(gem)
21
+ dependencies.lazy.map(&:name).include?(gem.gemspec.name)
22
+ end
23
+
24
+ def dependencies
25
+ @dependencies ||= dependencies_uncached # dependencies_uncached
26
+ end
27
+
28
+ def <=>(other)
29
+ sd = depend_on(other)
30
+ od = other.depend_on(self)
31
+ return 1 if sd && !od
32
+ return -1 if od && !sd
33
+
34
+ gemspec.name <=> other.gemspec.name
35
+ end
36
+
37
+ def found?
38
+ lib_file_found? && registered_module.is_a?(::Module)
39
+ end
40
+
41
+ def lib_file_found?
42
+ gemspec.require_paths.any? do |require_path|
43
+ ::Pathname.new(require_path).expand_path(gemspec.gem_dir).join(path_to_require + '.rb')
44
+ .file?
45
+ end
46
+ end
47
+
48
+ def registered_module
49
+ return nil unless lib_file_found?
50
+
51
+ require path_to_require
52
+ path_to_require.classify.constantize
53
+ end
54
+
55
+ # @return [String]
56
+ def path_to_require
57
+ gemspec.name.gsub('-', '/') + '/' + registry.module_suffix.underscore
58
+ end
59
+
60
+ private
61
+
62
+ def dependencies_uncached
63
+ ::EacRubyUtils::RecursiveBuilder
64
+ .new(gemspec) { |item| gem_item_dependencies(item) }
65
+ .result
66
+ end
67
+
68
+ def gem_item_dependencies(item)
69
+ ::Gem::Specification.find_by_name(item.name).dependencies
70
+ rescue ::Gem::MissingSpecError
71
+ []
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubygems'
4
+ require 'eac_ruby_utils/gems_registry/gem'
5
+
6
+ module EacRubyUtils
7
+ # Search in each gem for a class determined by registry and run the method "register" on each
8
+ # found.
9
+ #
10
+ # Example:
11
+ # * The module suffix is `TheClass`;
12
+ # * A gem with name "my-lib" is being analyzed
13
+ # * If a require for "my/lib/the_class" is succesful the class/module `My::Lib::TheClass` will
14
+ # be collected.
15
+ class GemsRegistry
16
+ attr_reader :module_suffix
17
+
18
+ def initialize(module_suffix)
19
+ @module_suffix = module_suffix
20
+ end
21
+
22
+ # @return [Array<EacRubyUtils::GemsRegistry::Gem>]
23
+ def registered
24
+ @registered ||= all_gems.select(&:found?)
25
+ end
26
+
27
+ private
28
+
29
+ # @return [Array<EacRubyUtils::GemsRegistry::Gem>]
30
+ def all_gems
31
+ ::Gem::Specification.map { |gemspec| ::EacRubyUtils::GemsRegistry::Gem.new(self, gemspec) }
32
+ .sort
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/compact'
4
+
5
+ class Object
6
+ # @return [EacRubyUtils::Compact]
7
+ def compact(*attributes)
8
+ ::EacRubyUtils::Compact.new(self, attributes)
9
+ end
10
+
11
+ # @return [Array]
12
+ def compact_to_a(*attributes)
13
+ compact(*attributes).to_a
14
+ end
15
+
16
+ # @return [Hash]
17
+ def compact_to_h(*attributes)
18
+ compact(*attributes).to_h
19
+ end
20
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/string_delimited'
4
+
5
+ class String
6
+ # @return [EacRubyUtils::StringDelimited]
7
+ def delimited(begin_delimiter, end_delimiter)
8
+ ::EacRubyUtils::StringDelimited.new(self, begin_delimiter, end_delimiter)
9
+ end
10
+
11
+ %w[inner outer without_inner without_outer].each do |method_suffix|
12
+ define_method "delimited_#{method_suffix}" do |begin_delimiter, end_delimiter|
13
+ delimited(begin_delimiter, end_delimiter).send(method_suffix)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/simple_cache'
4
+
5
+ module EacRubyUtils
6
+ class RecursiveBuilder
7
+ include ::EacRubyUtils::SimpleCache
8
+
9
+ attr_reader :root, :neighbors_block
10
+
11
+ def initialize(root, &neighbors_block)
12
+ @root = root
13
+ @neighbors_block = neighbors_block
14
+ end
15
+
16
+ private
17
+
18
+ attr_reader :added, :to_check
19
+
20
+ def result_uncached
21
+ @added = []
22
+ @to_check = []
23
+ item_try_add_to_check(root)
24
+ while check_next_item
25
+ # Do nothing
26
+ end
27
+ added
28
+ end
29
+
30
+ def item_try_add_to_check(item)
31
+ to_check << item unless item_added?(item)
32
+ end
33
+
34
+ def item_added?(item)
35
+ added.include?(item) || to_check.include?(item)
36
+ end
37
+
38
+ def check_next_item
39
+ return false unless to_check.any?
40
+
41
+ item = to_check.shift
42
+ added << item
43
+ item_neighborhs(item).each { |sub_item| item_try_add_to_check(sub_item) }
44
+ true
45
+ end
46
+
47
+ def item_neighborhs(item)
48
+ neighbors_block.call(item)
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/rspec/setup_manager'
4
+
5
+ module EacRubyUtils
6
+ module Rspec
7
+ class << self
8
+ # @return [EacRubyUtils::Rspec::SetupManager]
9
+ def default_setup
10
+ @default_setup ||
11
+ raise("Default instance was not set. Use #{self.class.name}.default_setup_create")
12
+ end
13
+
14
+ # @return [EacRubyUtils::Rspec::SetupManager]
15
+ def default_setup_create(app_root_path, rspec_config = nil)
16
+ @default_setup = ::EacRubyUtils::Rspec::SetupManager.create(app_root_path, rspec_config)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ module Rspec
5
+ module Setup
6
+ module Conditionals
7
+ def conditional(tag, &condition)
8
+ message = condition.call
9
+ return if message.blank?
10
+
11
+ puts("[WARN] Excluded tag: #{tag}: #{message}")
12
+ rspec_config.filter_run_excluding tag
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacRubyUtils
6
+ module Rspec
7
+ module Setup
8
+ extend ::ActiveSupport::Concern
9
+ require_sub __FILE__, include_modules: true
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/gems_registry'
4
+ require 'eac_ruby_utils/patches/object/if_respond'
5
+ require 'eac_ruby_utils/patches/object/to_pathname'
6
+
7
+ module EacRubyUtils
8
+ module Rspec
9
+ class SetupManager
10
+ GEMS_REGISTRY_SUFFIX = 'Rspec::Setup'
11
+
12
+ class << self
13
+ def create(app_root_path, rspec_config = nil)
14
+ if rspec_config
15
+ new(app_root_path, rspec_config)
16
+ else
17
+ ::RSpec.configure { |new_rspec_config| new(app_root_path, new_rspec_config) }
18
+ end
19
+ end
20
+ end
21
+
22
+ attr_reader :app_root_path, :rspec_config
23
+
24
+ def initialize(app_root_path, rspec_config)
25
+ @app_root_path = app_root_path.to_pathname
26
+ @rspec_config = rspec_config
27
+ include_registry
28
+ end
29
+
30
+ # @return [EacRubyUtils::GemsRegistry]
31
+ def gems_registry
32
+ @gems_registry ||= ::EacRubyUtils::GemsRegistry.new(GEMS_REGISTRY_SUFFIX)
33
+ end
34
+
35
+ protected
36
+
37
+ def include_registry
38
+ gems_registry.registered.each do |gem|
39
+ include_gem_registered(gem.registered_module)
40
+ end
41
+ end
42
+
43
+ # @param gem [EacRubyUtils::GemsRegistry::Gem]
44
+ def include_gem_registered(registered_module)
45
+ extend(registered_module)
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ class StringDelimited
5
+ attr_reader :string, :begin_delimiter, :end_delimiter
6
+
7
+ def initialize(string, begin_delimiter, end_delimiter)
8
+ @string = string
9
+ @begin_delimiter = begin_delimiter
10
+ @end_delimiter = end_delimiter
11
+ end
12
+
13
+ def inner
14
+ between_indexes(content_index, end_index).to_s
15
+ end
16
+
17
+ def outer
18
+ between_indexes(begin_index, after_end_index).to_s
19
+ end
20
+
21
+ def without_inner
22
+ without_join(
23
+ between_indexes(sos_index, content_index), between_indexes(end_index, eos_index)
24
+ )
25
+ end
26
+
27
+ def without_outer
28
+ without_join(
29
+ between_indexes(sos_index, begin_index),
30
+ between_indexes(after_end_index, eos_index)
31
+ )
32
+ end
33
+
34
+ private
35
+
36
+ def after_end_index
37
+ end_index.if_present { |v| v + end_delimiter.length }
38
+ end
39
+
40
+ def begin_index
41
+ string.index(begin_delimiter)
42
+ end
43
+
44
+ def between_indexes(a_begin_index, a_end_index)
45
+ a_begin_index && a_end_index ? string[a_begin_index, a_end_index - a_begin_index] : nil
46
+ end
47
+
48
+ def content_index
49
+ begin_index.if_present { |v| v + begin_delimiter.length }
50
+ end
51
+
52
+ def without_join(*strings)
53
+ return string if strings.any?(&:nil?)
54
+
55
+ strings.join('')
56
+ end
57
+
58
+ def end_index
59
+ content_index.if_present { |_v| string.index(end_delimiter, content_index) }
60
+ end
61
+
62
+ def sos_index
63
+ 0
64
+ end
65
+
66
+ def eos_index
67
+ string.length
68
+ end
69
+ end
70
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.69.1'
4
+ VERSION = '0.76.0'
5
5
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/compact'
4
+
5
+ ::RSpec.describe ::EacRubyUtils::Compact do
6
+ let(:object) { ::OpenStruct.new(a_attr: 'a_value', b_attr: 'b_value') }
7
+ let(:instance) { described_class.new(object, %w[a_attr b_attr]) }
8
+
9
+ describe '#to_a' do
10
+ it do
11
+ expect(instance.to_a).to eq(%w[a_value b_value])
12
+ end
13
+ end
14
+
15
+ describe '#to_h' do
16
+ it do
17
+ expect(instance.to_h).to eq(a_attr: 'a_value', b_attr: 'b_value')
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patches/object/compact'
4
+
5
+ ::RSpec.describe ::Object do
6
+ let(:instance) { ::OpenStruct.new(a_attr: 'a_value', b_attr: 'b_value') }
7
+ let(:attributes) { %w[a_attr b_attr] }
8
+
9
+ describe '#compact' do
10
+ it do
11
+ expect(instance.compact_to_a(*attributes)).to eq(%w[a_value b_value])
12
+ end
13
+ end
14
+
15
+ describe '#to_h' do
16
+ it do
17
+ expect(instance.compact_to_h(*attributes)).to eq(a_attr: 'a_value', b_attr: 'b_value')
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patches/string/delimited'
4
+
5
+ ::RSpec.describe ::String do
6
+ let(:instance) { 'A text with <b>content between</b> tags.' }
7
+
8
+ {
9
+ ['<b>', '</b>'] => {
10
+ 'inner' => 'content between',
11
+ 'without_inner' => 'A text with <b></b> tags.',
12
+ 'outer' => '<b>content between</b>',
13
+ 'without_outer' => 'A text with tags.'
14
+ },
15
+ ['<b>', '</br>'] => {
16
+ 'inner' => '',
17
+ 'without_inner' => 'A text with <b>content between</b> tags.',
18
+ 'outer' => '',
19
+ 'without_outer' => 'A text with <b>content between</b> tags.'
20
+ }
21
+ }.each do |delimiters, expected_values|
22
+ context "when delimiters are #{delimiters}" do
23
+ let(:bdel) { delimiters[0] }
24
+ let(:edel) { delimiters[1] }
25
+
26
+ expected_values.each do |method_suffix, expected_value|
27
+ method_name = "delimited_#{method_suffix}"
28
+ it "#{method_name} should return \"#{expected_value}\"" do
29
+ expect(instance.send(method_name, bdel, edel)).to eq(expected_value)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/recursive_builder'
4
+
5
+ RSpec.describe ::EacRubyUtils::RecursiveBuilder do
6
+ let(:item_class) do
7
+ ::Class.new do
8
+ class << self
9
+ def create(label, dependencies_keys)
10
+ item = new(label, dependencies_keys)
11
+ registry[item.label] = item
12
+ item
13
+ end
14
+
15
+ def registry
16
+ @registry ||= {}
17
+ end
18
+ end
19
+
20
+ attr_reader :label, :dependencies_keys
21
+
22
+ def initialize(label, dependencies_keys)
23
+ @label = label
24
+ @dependencies_keys = dependencies_keys.freeze
25
+ end
26
+
27
+ def dependencies
28
+ dependencies_keys.map { |key| self.class.registry.fetch(key) }
29
+ end
30
+
31
+ def to_s
32
+ label
33
+ end
34
+ end
35
+ end
36
+
37
+ items = [
38
+ [:a, %w[c], %w[a c]],
39
+ [:b, %w[a], %w[b a c]],
40
+ [:c, [], %w[c]],
41
+ [:d, %w[a b c e], %w[d a b c e]],
42
+ [:e, %w[c b], %w[e c b a]]
43
+ ]
44
+
45
+ items.each do |item|
46
+ let(item[0]) { item_class.create(item[0].to_s, item[1]) }
47
+ before { send(item[0]) }
48
+ end
49
+
50
+ describe '#result' do
51
+ items.each do |item|
52
+ context "when root is \"#{item[0]}\"" do
53
+ let(:root) { send(item[0]) }
54
+ let(:dependencies) { item[2].map { |d| send(d) } }
55
+ let(:builder) do
56
+ described_class.new(root, &:dependencies)
57
+ end
58
+
59
+ it "is #{item[2]}" do
60
+ expect(builder.result).to eq(dependencies)
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ::EacRubyGemSupport::Rspec.default.describe_rubocop
3
+ ::EacRubyUtils::Rspec.default_setup.describe_rubocop
@@ -3,13 +3,13 @@
3
3
  $LOAD_PATH.push File.expand_path('../lib', __dir__)
4
4
  require 'tmpdir'
5
5
 
6
+ require 'i18n'
7
+ ::I18n.load_path << ::File.join(__dir__, 'locales/pt-BR.yml')
8
+ ::I18n.locale = 'pt-BR'
9
+
6
10
  RSpec.configure do |config|
7
11
  config.example_status_persistence_file_path = ::File.join(::Dir.tmpdir, 'eac_ruby_utils_rspec')
8
12
 
9
- require 'eac_ruby_gem_support/rspec'
10
- ::EacRubyGemSupport::Rspec.setup(::File.expand_path('..', __dir__), config)
13
+ require 'eac_ruby_utils/rspec/default_setup'
14
+ ::EacRubyUtils::Rspec.default_setup_create(::File.expand_path('..', __dir__), config)
11
15
  end
12
-
13
- require 'i18n'
14
- ::I18n.load_path << ::File.join(__dir__, 'locales/pt-BR.yml')
15
- ::I18n.locale = 'pt-BR'
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'erb'
4
+
5
+ class Module
6
+ def erb_template(subpath, binding_obj)
7
+ ::ERB.new(template.child(subpath).path.read).result(binding_obj)
8
+ end
9
+ 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,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_templates/patches/module/erb_template'
4
+
5
+ class Object
6
+ def erb_template(subpath, binding_obj = nil)
7
+ self.class.erb_template(subpath, binding_obj || binding)
8
+ end
9
+ 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,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+ ::EacRubyUtils.require_sub __FILE__
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacTemplates
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
5
5
  end
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ::EacRubyGemSupport::Rspec.default.describe_rubocop
3
+ ::EacRubyUtils::Rspec.default_setup.describe_rubocop