ehbrs-tools 0.27.0 → 0.28.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +91 -38
  4. data/lib/ehbrs/tools/runner/fs/selected.rb +2 -6
  5. data/lib/ehbrs/tools/runner/music/lyrics.rb +3 -4
  6. data/lib/ehbrs/tools/runner/music/lyrics_book.rb +41 -0
  7. data/lib/ehbrs/tools/runner/music/selected.rb +6 -6
  8. data/lib/ehbrs/tools/runner/vg/wii.rb +2 -2
  9. data/lib/ehbrs/tools/runner/videos/series/rename.rb +1 -1
  10. data/lib/ehbrs/tools/version.rb +1 -1
  11. data/lib/ehbrs/user_dirs.rb +2 -2
  12. data/lib/ehbrs/videos/unsupported/search.rb +2 -2
  13. data/spec/lib/ehbrs/tools/runner/fs/used_space_spec.rb +2 -1
  14. data/vendor/aranha-parsers/aranha-parsers.gemspec +1 -0
  15. data/vendor/aranha-parsers/lib/aranha/parsers/base.rb +3 -1
  16. data/vendor/aranha-parsers/lib/aranha/parsers/html/node/default/numeric_support.rb +70 -0
  17. data/vendor/aranha-parsers/lib/aranha/parsers/html/node/default/string_support.rb +77 -0
  18. data/vendor/aranha-parsers/lib/aranha/parsers/html/node/default.rb +2 -94
  19. data/vendor/aranha-parsers/lib/aranha/parsers/json/base.rb +20 -0
  20. data/vendor/aranha-parsers/lib/aranha/parsers/json.rb +11 -0
  21. data/vendor/aranha-parsers/lib/aranha/parsers/source_address/http_get.rb +12 -15
  22. data/vendor/aranha-parsers/lib/aranha/parsers/version.rb +1 -1
  23. data/vendor/eac_cli/lib/eac_cli/config.rb +6 -3
  24. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  25. data/vendor/eac_fs/Gemfile +5 -0
  26. data/vendor/eac_fs/eac_fs.gemspec +20 -0
  27. data/vendor/{eac_ruby_utils/lib/eac_ruby_utils/filesystem_cache.rb → eac_fs/lib/eac_fs/cache.rb} +7 -2
  28. data/vendor/eac_fs/lib/eac_fs/cached_download.rb +39 -0
  29. data/vendor/eac_fs/lib/eac_fs/file_info.rb +29 -0
  30. data/vendor/eac_fs/lib/eac_fs/patches/module/fs_cache.rb +10 -0
  31. data/vendor/eac_fs/lib/eac_fs/patches/module.rb +4 -0
  32. data/vendor/eac_fs/lib/eac_fs/patches/object/fs_cache.rb +17 -0
  33. data/vendor/eac_fs/lib/eac_fs/patches/object.rb +4 -0
  34. data/vendor/eac_fs/lib/eac_fs/patches/pathname/info.rb +12 -0
  35. data/vendor/eac_fs/lib/eac_fs/patches/pathname.rb +4 -0
  36. data/vendor/eac_fs/lib/eac_fs/patches.rb +4 -0
  37. data/vendor/eac_fs/lib/eac_fs/traversable.rb +45 -0
  38. data/vendor/eac_fs/lib/eac_fs/traverser.rb +76 -0
  39. data/vendor/eac_fs/lib/eac_fs/version.rb +5 -0
  40. data/vendor/eac_fs/lib/eac_fs.rb +7 -0
  41. 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
  42. data/vendor/eac_fs/spec/rubocop_spec.rb +3 -0
  43. data/vendor/eac_fs/spec/spec_helper.rb +4 -0
  44. data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +2 -1
  45. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +5 -5
  46. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/core_ext.rb +1 -0
  47. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +16 -7
  48. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/confirmation.rb +0 -1
  49. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/filesystem_traverser.rb +2 -2
  50. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  51. data/vendor/eac_ruby_gems_utils/Gemfile +5 -0
  52. data/vendor/eac_ruby_gems_utils/LICENCE +16 -0
  53. data/vendor/eac_ruby_gems_utils/README.rdoc +3 -0
  54. data/vendor/eac_ruby_gems_utils/eac_ruby_gems_utils.gemspec +30 -0
  55. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/command.rb +33 -0
  56. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/version_file.rb +41 -0
  57. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem.rb +97 -0
  58. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb +57 -0
  59. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/minitest.rb +25 -0
  60. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple/decorated_gem.rb +48 -0
  61. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple/result.rb +25 -0
  62. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple.rb +84 -0
  63. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/rspec.rb +21 -0
  64. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests.rb +9 -0
  65. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +5 -0
  66. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils.rb +7 -0
  67. data/vendor/eac_ruby_gems_utils/spec/code/rubocop_check_spec.rb +3 -0
  68. data/vendor/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem/version_file_spec.rb +14 -0
  69. data/vendor/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem/version_file_spec_files/a_version_file.rb +7 -0
  70. data/vendor/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem_spec.rb +20 -0
  71. data/vendor/eac_ruby_gems_utils/spec/spec_helper.rb +4 -0
  72. data/vendor/eac_ruby_gems_utils/spec/support/mygem/Gemfile +5 -0
  73. data/vendor/eac_ruby_gems_utils/spec/support/mygem/Gemfile.lock +19 -0
  74. data/vendor/eac_ruby_gems_utils/spec/support/mygem/Rakefile +14 -0
  75. data/vendor/eac_ruby_gems_utils/spec/support/mygem/exe/myrunner +5 -0
  76. data/vendor/eac_ruby_gems_utils/spec/support/mygem/lib/mygem/version.rb +5 -0
  77. data/vendor/eac_ruby_gems_utils/spec/support/mygem/lib/mygem.rb +5 -0
  78. data/vendor/eac_ruby_gems_utils/spec/support/mygem/mygem.gemspec +16 -0
  79. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/abstract_methods.rb +7 -0
  80. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/core_ext.rb +1 -0
  81. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/gems_registry/gem.rb +4 -0
  82. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/gems_registry.rb +1 -1
  83. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/class/abstract.rb +9 -0
  84. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/class/self_included_modules.rb +7 -0
  85. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/i18n_translate.rb +32 -0
  86. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/call_if_proc.rb +11 -0
  87. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/i18n_translate.rb +13 -0
  88. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/speaker/receiver.rb +10 -10
  89. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  90. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/class/abstract_spec.rb +25 -0
  91. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/class/self_included_modules_spec.rb +30 -0
  92. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/call_if_proc_spec.rb +11 -0
  93. data/vendor/eac_templates/Gemfile +5 -0
  94. data/vendor/eac_templates/eac_templates.gemspec +19 -0
  95. data/vendor/eac_templates/lib/eac_templates/directory.rb +108 -0
  96. data/vendor/eac_templates/lib/eac_templates/file.rb +48 -0
  97. data/vendor/eac_templates/lib/eac_templates/patches/module/erb_template.rb +9 -0
  98. data/vendor/eac_templates/lib/eac_templates/patches/module/template.rb +10 -0
  99. data/vendor/eac_templates/lib/eac_templates/patches/module.rb +4 -0
  100. data/vendor/eac_templates/lib/eac_templates/patches/object/erb_template.rb +9 -0
  101. data/vendor/eac_templates/lib/eac_templates/patches/object/template.rb +9 -0
  102. data/vendor/eac_templates/lib/eac_templates/patches/object.rb +4 -0
  103. data/vendor/eac_templates/lib/eac_templates/patches.rb +4 -0
  104. data/vendor/eac_templates/lib/eac_templates/searcher.rb +53 -0
  105. data/vendor/eac_templates/lib/eac_templates/variable_not_found_error.rb +5 -0
  106. data/vendor/eac_templates/lib/eac_templates/variable_providers/base.rb +21 -0
  107. data/vendor/eac_templates/lib/eac_templates/variable_providers/config_reader.rb +27 -0
  108. data/vendor/eac_templates/lib/eac_templates/variable_providers/entries_reader.rb +23 -0
  109. data/vendor/eac_templates/lib/eac_templates/variable_providers/generic.rb +23 -0
  110. data/vendor/eac_templates/lib/eac_templates/variable_providers/hash.rb +27 -0
  111. data/vendor/eac_templates/lib/eac_templates/variable_providers.rb +23 -0
  112. data/vendor/eac_templates/lib/eac_templates/version.rb +5 -0
  113. data/vendor/eac_templates/lib/eac_templates.rb +7 -0
  114. data/vendor/eac_templates/spec/lib/eac_templates/file_spec.rb +35 -0
  115. data/vendor/eac_templates/spec/lib/eac_templates/file_spec_files/expected_content +2 -0
  116. data/vendor/eac_templates/spec/lib/eac_templates/file_spec_files/source.template +2 -0
  117. data/vendor/eac_templates/spec/lib/eac_templates/searcher_spec.rb +30 -0
  118. data/vendor/eac_templates/spec/lib/eac_templates/searcher_spec_files/path1/subdir1/file1.template +1 -0
  119. data/vendor/eac_templates/spec/lib/eac_templates/searcher_spec_files/path1/subdir1/file2 +1 -0
  120. data/vendor/eac_templates/spec/lib/eac_templates/searcher_spec_files/path2/subdir1/file3.template +1 -0
  121. data/vendor/eac_templates/spec/lib/object/template_spec.rb +23 -0
  122. data/vendor/eac_templates/spec/lib/object/template_spec_files/path/my_stub_with_template +1 -0
  123. data/vendor/eac_templates/spec/rubocop_spec.rb +3 -0
  124. data/vendor/eac_templates/spec/spec_helper.rb +4 -0
  125. data/vendor/ehbrs_ruby_utils/ehbrs_ruby_utils.gemspec +1 -0
  126. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/core_ext.rb +5 -0
  127. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/fs/compressed_package.rb +2 -2
  128. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/fs/selected/build.rb +1 -1
  129. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/fs/selected/build_file.rb +1 -1
  130. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/fs/selected.rb +13 -3
  131. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music/lyrics_book/album.rb +42 -0
  132. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb +64 -0
  133. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music/lyrics_book/song.rb +68 -0
  134. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music/lyrics_book.rb +65 -0
  135. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/patches/object.rb +4 -0
  136. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/patches.rb +4 -0
  137. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb +1 -1
  138. data/vendor/ehbrs_ruby_utils/template/ehbrs_ruby_utils/music/lyrics_book/album/inner.html.erb +3 -0
  139. data/vendor/ehbrs_ruby_utils/template/ehbrs_ruby_utils/music/lyrics_book/custom_style.css +15 -0
  140. data/vendor/ehbrs_ruby_utils/template/ehbrs_ruby_utils/music/lyrics_book/index.html.erb +14 -0
  141. data/vendor/ehbrs_ruby_utils/template/ehbrs_ruby_utils/music/lyrics_book/main.html.erb +24 -0
  142. data/vendor/ehbrs_ruby_utils/template/ehbrs_ruby_utils/music/lyrics_book/resource/main.html.erb +8 -0
  143. data/vendor/ehbrs_ruby_utils/template/ehbrs_ruby_utils/music/lyrics_book/song/inner.html.erb +9 -0
  144. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider.rb +4 -0
  145. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider_search.rb +1 -1
  146. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/providers_data.xml +2 -1
  147. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/version.rb +1 -1
  148. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__michael_jackson_thriller.target.yaml +1 -1
  149. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__milton_nascimento_rouxinol.target.yaml +1 -1
  150. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__michael_jackson_thriller.source.html +18 -18
  151. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__michael_jackson_thriller.target.yaml +1 -1
  152. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__milton_nascimento_rouxinol.source.html +18 -18
  153. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__milton_nascimento_rouxinol.target.yaml +1 -1
  154. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyrics_com__milton_nascimento_rouxinol.target.yaml +1 -3
  155. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__michael_jackson_thriller.target.yaml +1 -1
  156. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__milton_nascimento_rouxinol.target.yaml +1 -1
  157. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsreg_com__milton_nascimento_rouxinol.source.html +3 -3
  158. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsreg_com__milton_nascimento_rouxinol.target.yaml +1 -1
  159. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__michael_jackson_thriller.source.html +3 -3
  160. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__michael_jackson_thriller.target.yaml +1 -1
  161. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__milton_nascimento_rouxinol.source.html +3 -3
  162. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__milton_nascimento_rouxinol.target.yaml +1 -1
  163. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/songlyrics_com__michael_jackson_thriller.source.html +15 -12
  164. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/songlyrics_com__michael_jackson_thriller.target.yaml +1 -1
  165. metadata +107 -10
  166. data/lib/ehbrs/patches/module/erb_template.rb +0 -11
  167. data/lib/ehbrs/patches/object/erb_template.rb +0 -9
  168. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traversable.rb +0 -47
  169. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traverser.rb +0 -72
  170. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs_cache.rb +0 -12
  171. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/on_clean_ruby_environment.rb +0 -12
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'eac_cli/runner'
4
4
  require 'eac_ruby_utils/core_ext'
5
- require 'eac_ruby_utils/fs/traversable'
6
5
 
7
6
  module EacRubyBase0
8
7
  module RunnerWith
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'eac_cli/runner'
4
4
  require 'eac_ruby_utils/core_ext'
5
- require 'eac_ruby_utils/fs/traversable'
5
+ require 'eac_fs/traversable'
6
6
  require 'eac_ruby_utils/settings_provider'
7
7
 
8
8
  module EacRubyBase0
@@ -12,7 +12,7 @@ module EacRubyBase0
12
12
 
13
13
  common_concern do
14
14
  include ::EacCli::Runner
15
- include ::EacRubyUtils::Fs::Traversable
15
+ include ::EacFs::Traversable
16
16
  enable_settings_provider
17
17
  include TopMethods
18
18
  runner_definition do
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyBase0
4
- VERSION = '0.10.1'
4
+ VERSION = '0.13.1'
5
5
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
@@ -0,0 +1,16 @@
1
+ Copyright (c) 2020 Eduardo Henrique Bogoni
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
4
+ associated documentation files (the "Software"), to deal in the Software without restriction,
5
+ including without limitation the rights to use, copy, modify, merge, publish, distribute,
6
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
7
+ furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice (including the next paragraph) shall be
10
+ included in all copies or substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
13
+ NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
16
+ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ = E.A.C.'s Ruby Gems Utils.
2
+
3
+ Utilities for Ruby\'s gems development.
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
+
5
+ # Maintain your gem's version:
6
+ require 'eac_ruby_gems_utils/version'
7
+
8
+ # Describe your gem and declare its dependencies:
9
+ Gem::Specification.new do |s|
10
+ s.name = 'eac_ruby_gems_utils'
11
+ s.version = ::EacRubyGemsUtils::VERSION
12
+ s.authors = ['Esquilo Azul Company']
13
+ s.summary = 'Utilities for Ruby gems development.'
14
+ s.license = 'MIT'
15
+ s.homepage = 'https://github.com/esquilo-azul/eac_ruby_gems_utils'
16
+ s.metadata = { 'source_code_uri' => s.homepage }
17
+
18
+ s.extra_rdoc_files = ['README.rdoc']
19
+ s.rdoc_options = ['--charset=UTF-8']
20
+
21
+ s.require_paths = ['lib']
22
+ s.files = Dir['{lib}/**/*', 'Gemfile']
23
+ s.test_files = Dir['{spec}/**/*', '.rspec']
24
+
25
+ s.add_dependency 'bundler'
26
+ s.add_dependency 'eac_ruby_utils', '~> 0.70'
27
+
28
+ # Tests
29
+ s.add_development_dependency 'eac_ruby_gem_support', '~> 0.3'
30
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/ruby/command'
5
+ require 'delegate'
6
+
7
+ module EacRubyGemsUtils
8
+ class Gem
9
+ class Command < ::EacRubyUtils::Ruby::Command
10
+ attr_reader :gem
11
+
12
+ def initialize(gem, command_args, extra_options = {})
13
+ @gem = gem
14
+ super(command_args, extra_options.merge(host_env: gem.host_env))
15
+ end
16
+
17
+ # Changes current directory to the gem's directory.
18
+ def chdir_root
19
+ chdir(gem.root.to_path)
20
+ end
21
+
22
+ def envvar_gemfile
23
+ envvar('BUNDLE_GEMFILE', gem.gemfile_path.to_path)
24
+ end
25
+
26
+ protected
27
+
28
+ def duplicate(command, extra_options)
29
+ self.class.new(gem, command, extra_options)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacRubyGemsUtils
6
+ class Gem
7
+ class VersionFile
8
+ common_constructor :path
9
+
10
+ VERSION_LINE_PATTERN = /\A(\s*)VERSION\s*=\s*[\'\"]([^\'\"]+)[\'\"](\s*)\z/.freeze
11
+
12
+ def value
13
+ path.read.each_line.lazy.map { |line| line_value(line) }.find { |v| v }
14
+ end
15
+
16
+ def value=(new_value)
17
+ path.write(new_value_content(new_value))
18
+ end
19
+
20
+ private
21
+
22
+ # @return Version found in line, nil otherwise.
23
+ def line_value(line)
24
+ VERSION_LINE_PATTERN.if_match(line.rstrip, false) { |m| ::Gem::Version.new(m[2]) }
25
+ end
26
+
27
+ def new_value_content(new_value)
28
+ path.read.each_line
29
+ .map { |line| new_value_line(line, new_value) }
30
+ .join
31
+ end
32
+
33
+ def new_value_line(line, new_value)
34
+ m = VERSION_LINE_PATTERN.match(line)
35
+ return line unless m
36
+
37
+ "#{m[1]}VERSION = '#{new_value}'#{m[3]}"
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,97 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/envs'
5
+ require 'rubygems'
6
+
7
+ module EacRubyGemsUtils
8
+ class Gem
9
+ require_sub __FILE__
10
+ enable_simple_cache
11
+
12
+ GEMSPEC_EXTNAME = '.gemspec'
13
+
14
+ common_constructor :root, :host_env, default: [nil] do
15
+ @root = ::Pathname.new(root).expand_path
16
+ self.host_env ||= ::EacRubyUtils::Envs.local
17
+ end
18
+
19
+ def to_s
20
+ name
21
+ end
22
+
23
+ def bundle(*args)
24
+ ::EacRubyGemsUtils::Gem::Command.new(self, %w[bundle] + args).envvar_gemfile
25
+ end
26
+
27
+ # @return A [Pathname] array with relative paths from root listed in gemspec's .file directive.
28
+ def files
29
+ gemspec.files.map(&:to_pathname)
30
+ end
31
+
32
+ def gemfile_lock_gem_version(gem_name)
33
+ gemfile_lock_content.specs.find { |gem| gem.name == gem_name }.if_present(&:version)
34
+ end
35
+
36
+ def gemfile_lock_content
37
+ ::Bundler::LockfileParser.new(::Bundler.read_file(gemfile_lock_path))
38
+ end
39
+
40
+ def name
41
+ name_by_gemspec || name_by_path
42
+ end
43
+
44
+ def name_by_gemspec
45
+ gemspec_path.if_present { |v| v.basename(GEMSPEC_EXTNAME).to_path }
46
+ end
47
+
48
+ def name_by_path
49
+ fullname = root.basename.to_s
50
+ /\A(.+)(?:-\d+(?:\.\d+)*)\z/.if_match(fullname, false) { |m| m[1] }.if_present(fullname)
51
+ end
52
+
53
+ def namespace_parts
54
+ name.split('-')
55
+ end
56
+
57
+ def rake(*args)
58
+ raise "File \"#{rakefile_path}\" does not exist" unless rakefile_path.exist?
59
+
60
+ bundle('exec', 'rake', '--rakefile', rakefile_path, *args)
61
+ end
62
+
63
+ def version
64
+ version_file.value
65
+ end
66
+
67
+ private
68
+
69
+ def gemfile_path_uncached
70
+ root.join('Gemfile')
71
+ end
72
+
73
+ def gemfile_lock_path_uncached
74
+ gemfile_path.basename_sub { |b| "#{b}.lock" }
75
+ end
76
+
77
+ def gemspec_uncached
78
+ ::Gem::Specification.load(gemspec_path.to_path)
79
+ end
80
+
81
+ def gemspec_path_uncached
82
+ ::Pathname.glob("#{root.to_path}/*#{GEMSPEC_EXTNAME}").first
83
+ end
84
+
85
+ def rakefile_path_uncached
86
+ root.join('Rakefile')
87
+ end
88
+
89
+ def version_file_uncached
90
+ ::EacRubyGemsUtils::Gem::VersionFile.new(version_file_path)
91
+ end
92
+
93
+ def version_file_path_uncached
94
+ root.join('lib', *namespace_parts, 'version.rb')
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/fs/logs'
5
+ require 'eac_ruby_utils/listable'
6
+
7
+ module EacRubyGemsUtils
8
+ module Tests
9
+ class Base
10
+ include ::EacRubyUtils::Listable
11
+
12
+ enable_simple_cache
13
+ lists.add_string :result, :failed, :nonexistent, :successful
14
+
15
+ common_constructor :gem
16
+
17
+ def elegible?
18
+ dependency_present? && gem.root.join(test_directory).exist?
19
+ end
20
+
21
+ def dependency_present?
22
+ gem.gemfile_path.exist? && gem.gemfile_lock_gem_version(dependency_gem).present?
23
+ end
24
+
25
+ def name
26
+ self.class.name.demodulize.gsub(/Test\z/, '')
27
+ end
28
+
29
+ def to_s
30
+ "#{gem}[#{name}]"
31
+ end
32
+
33
+ private
34
+
35
+ def logs_uncached
36
+ ::EacRubyUtils::Fs::Logs.new.add(:stdout).add(:stderr)
37
+ end
38
+
39
+ def result_uncached
40
+ return RESULT_NONEXISTENT unless elegible?
41
+
42
+ exec_run_with_log ? RESULT_SUCCESSFUL : RESULT_FAILED
43
+ end
44
+
45
+ def exec_run
46
+ gem.bundle('exec', *bundle_exec_args).chdir_root.execute
47
+ end
48
+
49
+ def exec_run_with_log
50
+ r = exec_run
51
+ logs[:stdout].write(r[:stdout])
52
+ logs[:stderr].write(r[:stderr])
53
+ r[:exit_code].zero?
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_gems_utils/tests/base'
4
+
5
+ module EacRubyGemsUtils
6
+ module Tests
7
+ class Minitest < ::EacRubyGemsUtils::Tests::Base
8
+ def bundle_exec_args
9
+ %w[rake test]
10
+ end
11
+
12
+ def dependency_gem
13
+ 'minitest'
14
+ end
15
+
16
+ def elegible?
17
+ super && gem.rakefile_path.exist?
18
+ end
19
+
20
+ def test_directory
21
+ 'test'
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacRubyGemsUtils
6
+ module Tests
7
+ class Multiple
8
+ class DecoratedGem < ::SimpleDelegator
9
+ enable_speaker
10
+
11
+ def prepare
12
+ return unless gemfile_path.exist?
13
+
14
+ log('running "bundle install"...')
15
+ return if bundle('install').execute.fetch(:exit_code).zero?
16
+
17
+ unless can_remove_gemfile_lock?
18
+ raise '"bundle install" failed and the Gemfile.lock is part of gem' \
19
+ '(Should be changed by developer)'
20
+ end
21
+
22
+ prepare_with_removable_gemfile_lock
23
+ end
24
+
25
+ def tests
26
+ [::EacRubyGemsUtils::Tests::Minitest.new(__getobj__),
27
+ ::EacRubyGemsUtils::Tests::Rspec.new(__getobj__)]
28
+ end
29
+
30
+ private
31
+
32
+ def log(message)
33
+ infov self, message
34
+ end
35
+
36
+ def prepare_with_removable_gemfile_lock
37
+ log('"bundle install" failed, removing Gemfile.lock and trying again...')
38
+ gemfile_lock_path.unlink if gemfile_lock_path.exist?
39
+ bundle('install').execute!
40
+ end
41
+
42
+ def can_remove_gemfile_lock?
43
+ !files.include?(gemfile_lock_path.relative_path_from(root))
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyGemsUtils
4
+ module Tests
5
+ class Multiple
6
+ class Result
7
+ common_constructor :result
8
+
9
+ COLORS = {
10
+ ::EacRubyGemsUtils::Tests::Base::RESULT_FAILED => :red,
11
+ ::EacRubyGemsUtils::Tests::Base::RESULT_NONEXISTENT => :white,
12
+ ::EacRubyGemsUtils::Tests::Base::RESULT_SUCCESSFUL => :green
13
+ }.freeze
14
+
15
+ def tag
16
+ result.to_s.send(color)
17
+ end
18
+
19
+ def color
20
+ COLORS.fetch(result)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_gems_utils/tests/minitest'
4
+ require 'eac_ruby_gems_utils/tests/rspec'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module EacRubyGemsUtils
8
+ module Tests
9
+ class Multiple
10
+ require_sub __FILE__
11
+ enable_speaker
12
+ enable_simple_cache
13
+ common_constructor :gems, :options, default: [{}]
14
+ set_callback :initialize, :after, :run
15
+
16
+ def ok?
17
+ failed_tests.none?
18
+ end
19
+
20
+ def only
21
+ options[:only]
22
+ end
23
+
24
+ private
25
+
26
+ def all_tests_uncached
27
+ decorated_gems.flat_map(&:tests)
28
+ end
29
+
30
+ def clear_logs
31
+ all_tests.each do |test|
32
+ test.logs.remove_all
33
+ end
34
+ end
35
+
36
+ def prepare_all_gems
37
+ infom 'Preparing all gems...'
38
+ decorated_gems.each(&:prepare)
39
+ end
40
+
41
+ def decorated_gems_uncached
42
+ r = gems
43
+ r = r.select { |gem| only.include?(gem.name) } if only.present?
44
+ r.map { |gem| DecoratedGem.new(gem) }
45
+ end
46
+
47
+ def failed_tests_uncached
48
+ all_tests.select { |r| r.result == ::EacRubyGemsUtils::Tests::Base::RESULT_FAILED }
49
+ end
50
+
51
+ def final_results_banner
52
+ if failed_tests.any?
53
+ warn 'Some test did not pass:'
54
+ failed_tests.each do |test|
55
+ infov ' * Test', test
56
+ info test.logs.truncate_all
57
+ end
58
+ else
59
+ success 'All tests passed'
60
+ end
61
+ end
62
+
63
+ def run
64
+ start_banner
65
+ prepare_all_gems
66
+ test_all_gems
67
+ final_results_banner
68
+ ensure
69
+ clear_logs
70
+ end
71
+
72
+ def start_banner
73
+ infov 'Gems to test', decorated_gems.count
74
+ end
75
+
76
+ def test_all_gems
77
+ infom 'Running tests...'
78
+ all_tests.each do |test|
79
+ infov test, Result.new(test.result).tag
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_gems_utils/tests/base'
4
+
5
+ module EacRubyGemsUtils
6
+ module Tests
7
+ class Rspec < ::EacRubyGemsUtils::Tests::Base
8
+ def bundle_exec_args
9
+ %w[rspec]
10
+ end
11
+
12
+ def dependency_gem
13
+ 'rspec-core'
14
+ end
15
+
16
+ def test_directory
17
+ 'spec'
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacRubyGemsUtils
6
+ module Tests
7
+ require_sub(__FILE__)
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyGemsUtils
4
+ VERSION = '0.9.8'
5
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacRubyGemsUtils
6
+ require_sub(__FILE__)
7
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ ::EacRubyUtils::Rspec.default_setup.describe_rubocop
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_gems_utils/gem'
4
+
5
+ ::RSpec.describe ::EacRubyGemsUtils::Gem::VersionFile do
6
+ let(:stubs_dir) { ::Pathname.new(__dir__).join('version_file_spec_files') }
7
+ let(:stub_file) { stubs_dir.join('a_version_file.rb') }
8
+ let(:instance) { described_class.new(stub_file) }
9
+ let(:target_version) { ::Gem::Version.new('0.69.1') }
10
+
11
+ describe '#value' do
12
+ it { expect(instance.value).to eq(target_version) }
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Tools
5
+ VERSION = '0.69.1'
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_gems_utils/gem'
4
+
5
+ ::RSpec.describe ::EacRubyGemsUtils::Gem do
6
+ let(:mygem_path) { ::Pathname.new(__dir__).expand_path.parent.parent.join('support', 'mygem') }
7
+ let(:mygem) { described_class.new(mygem_path) }
8
+
9
+ describe '#bundle' do
10
+ specify do
11
+ expect(mygem.bundle('exec', 'myrunner').execute!).to include('My Runner')
12
+ end
13
+ end
14
+
15
+ describe '#rake' do
16
+ specify do
17
+ expect(mygem.rake('mygem:stub').execute!).to include('Stub!')
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/rspec/default_setup'
4
+ ::EacRubyUtils::Rspec.default_setup_create(::File.expand_path('..', __dir__))
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
@@ -0,0 +1,19 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mygem (1.0.0)
5
+ rake
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ rake (13.0.1)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ mygem!
17
+
18
+ BUNDLED WITH
19
+ 2.2.25
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ namespace :mygem do
10
+ desc 'A stub task.'
11
+ task :stub do
12
+ puts 'Stub!'
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ $LOAD_PATH.unshift("#{__dir__}/../lib")
5
+ puts 'My Runner'
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mygem
4
+ VERSION = '1.0.0'
5
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mygem
4
+ require 'mygem/version'
5
+ end