ehbrs_ruby_utils 0.44.3 → 0.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ehbrs_ruby_utils/bga/game/image.rb +0 -1
  3. data/lib/ehbrs_ruby_utils/bga/game.rb +0 -2
  4. data/lib/ehbrs_ruby_utils/bga/game_statistics/whatsapp_formatter/player_content.rb +0 -2
  5. data/lib/ehbrs_ruby_utils/bga/game_statistics/whatsapp_formatter/player_title.rb +0 -2
  6. data/lib/ehbrs_ruby_utils/bga/game_statistics/whatsapp_formatter.rb +0 -3
  7. data/lib/ehbrs_ruby_utils/bga/game_statistics.rb +0 -2
  8. data/lib/ehbrs_ruby_utils/bga/parsers/game_in_progress.rb +0 -3
  9. data/lib/ehbrs_ruby_utils/bga/parsers/game_stats/players.rb +0 -3
  10. data/lib/ehbrs_ruby_utils/bga/parsers/game_stats.rb +0 -3
  11. data/lib/ehbrs_ruby_utils/bga/parsers/table/active_players.rb +0 -3
  12. data/lib/ehbrs_ruby_utils/bga/parsers/table/ended_players.rb +0 -3
  13. data/lib/ehbrs_ruby_utils/bga/parsers/table/options.rb +0 -4
  14. data/lib/ehbrs_ruby_utils/bga/parsers/table.rb +1 -4
  15. data/lib/ehbrs_ruby_utils/bga/player.rb +0 -3
  16. data/lib/ehbrs_ruby_utils/bga/session/login.rb +1 -3
  17. data/lib/ehbrs_ruby_utils/bga/session/player.rb +0 -2
  18. data/lib/ehbrs_ruby_utils/bga/session/player_tables_on_game_in_progress.rb +1 -4
  19. data/lib/ehbrs_ruby_utils/bga/session/player_tables_on_game_stats.rb +2 -5
  20. data/lib/ehbrs_ruby_utils/bga/session/skip_trophies.rb +0 -2
  21. data/lib/ehbrs_ruby_utils/bga/session/table.rb +1 -5
  22. data/lib/ehbrs_ruby_utils/bga/session/user.rb +0 -2
  23. data/lib/ehbrs_ruby_utils/bga/session.rb +1 -4
  24. data/lib/ehbrs_ruby_utils/bga/table/option.rb +0 -3
  25. data/lib/ehbrs_ruby_utils/bga/table/player.rb +0 -3
  26. data/lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/base/format_option.rb +0 -3
  27. data/lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/base/format_player.rb +0 -2
  28. data/lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/base.rb +1 -3
  29. data/lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/beginning/format_player.rb +0 -3
  30. data/lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/beginning.rb +0 -3
  31. data/lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/ending/format_player.rb +0 -3
  32. data/lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/ending.rb +0 -3
  33. data/lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters.rb +0 -2
  34. data/lib/ehbrs_ruby_utils/bga/table.rb +4 -9
  35. data/lib/ehbrs_ruby_utils/bga/urls.rb +0 -3
  36. data/lib/ehbrs_ruby_utils/bga/whatsapp_formatter/option.rb +0 -2
  37. data/lib/ehbrs_ruby_utils/bga/whatsapp_formatter.rb +0 -2
  38. data/lib/ehbrs_ruby_utils/bga.rb +0 -2
  39. data/lib/ehbrs_ruby_utils/booking/parsers/list.rb +0 -3
  40. data/lib/ehbrs_ruby_utils/booking/processors/list/build_accommodation.rb +0 -2
  41. data/lib/ehbrs_ruby_utils/booking/processors/list.rb +0 -4
  42. data/lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb +0 -2
  43. data/lib/ehbrs_ruby_utils/circular_list_spreader/group_level.rb +1 -4
  44. data/lib/ehbrs_ruby_utils/circular_list_spreader/item_level.rb +0 -3
  45. data/lib/ehbrs_ruby_utils/circular_list_spreader/list/item_pair_spreadness.rb +0 -2
  46. data/lib/ehbrs_ruby_utils/circular_list_spreader/list.rb +0 -2
  47. data/lib/ehbrs_ruby_utils/circular_list_spreader.rb +0 -2
  48. data/lib/ehbrs_ruby_utils/cooking_book/build/base_page.rb +0 -2
  49. data/lib/ehbrs_ruby_utils/cooking_book/build/index_page.rb +0 -3
  50. data/lib/ehbrs_ruby_utils/cooking_book/build/recipe_page.rb +0 -3
  51. data/lib/ehbrs_ruby_utils/cooking_book/build.rb +0 -3
  52. data/lib/ehbrs_ruby_utils/cooking_book/project.rb +0 -3
  53. data/lib/ehbrs_ruby_utils/cooking_book/recipe/ingredient.rb +0 -3
  54. data/lib/ehbrs_ruby_utils/cooking_book/recipe/measure.rb +1 -5
  55. data/lib/ehbrs_ruby_utils/cooking_book/recipe/part.rb +0 -4
  56. data/lib/ehbrs_ruby_utils/cooking_book/recipe.rb +0 -3
  57. data/lib/ehbrs_ruby_utils/cooking_book.rb +0 -2
  58. data/lib/ehbrs_ruby_utils/core_ext.rb +0 -2
  59. data/lib/ehbrs_ruby_utils/executables.rb +2 -4
  60. data/lib/ehbrs_ruby_utils/finances/bb_browser/docker_image.rb +0 -1
  61. data/lib/ehbrs_ruby_utils/fs/compressed_package.rb +0 -2
  62. data/lib/ehbrs_ruby_utils/fs/iso_9660_file.rb +0 -3
  63. data/lib/ehbrs_ruby_utils/fs/selected/build.rb +0 -3
  64. data/lib/ehbrs_ruby_utils/fs/selected/build_file.rb +0 -2
  65. data/lib/ehbrs_ruby_utils/fs/selected.rb +0 -1
  66. data/lib/ehbrs_ruby_utils/fs/to_file_format.rb +5 -3
  67. data/lib/ehbrs_ruby_utils/fs/to_utf8_unix.rb +0 -2
  68. data/lib/ehbrs_ruby_utils/fs/to_windows_pt_br.rb +0 -3
  69. data/lib/ehbrs_ruby_utils/fs.rb +0 -2
  70. data/lib/ehbrs_ruby_utils/gjt1/manager.rb +1 -6
  71. data/lib/ehbrs_ruby_utils/gjt1.rb +0 -2
  72. data/lib/ehbrs_ruby_utils/mudslide/message.rb +0 -3
  73. data/lib/ehbrs_ruby_utils/mudslide.rb +0 -2
  74. data/lib/ehbrs_ruby_utils/music/lyrics_book/album.rb +0 -3
  75. data/lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb +1 -2
  76. data/lib/ehbrs_ruby_utils/music/lyrics_book/song.rb +0 -3
  77. data/lib/ehbrs_ruby_utils/music/lyrics_book.rb +0 -2
  78. data/lib/ehbrs_ruby_utils/music/ous/album.rb +0 -4
  79. data/lib/ehbrs_ruby_utils/music/ous/artist.rb +0 -4
  80. data/lib/ehbrs_ruby_utils/music/ous/category.rb +0 -3
  81. data/lib/ehbrs_ruby_utils/music/ous/node.rb +0 -2
  82. data/lib/ehbrs_ruby_utils/music/sort/files/base.rb +0 -2
  83. data/lib/ehbrs_ruby_utils/music/sort/files/factory.rb +0 -2
  84. data/lib/ehbrs_ruby_utils/music/sort/files/scanner.rb +0 -3
  85. data/lib/ehbrs_ruby_utils/music/sort/files.rb +0 -2
  86. data/lib/ehbrs_ruby_utils/music/sort.rb +0 -2
  87. data/lib/ehbrs_ruby_utils/music.rb +0 -2
  88. data/lib/ehbrs_ruby_utils/patches/object.rb +0 -1
  89. data/lib/ehbrs_ruby_utils/patches.rb +0 -1
  90. data/lib/ehbrs_ruby_utils/version.rb +1 -1
  91. data/lib/ehbrs_ruby_utils/vg/nds/organizer/base_file.rb +46 -0
  92. data/lib/ehbrs_ruby_utils/vg/nds/organizer/file_manager.rb +55 -0
  93. data/lib/ehbrs_ruby_utils/vg/nds/organizer/rom_file.rb +17 -0
  94. data/lib/ehbrs_ruby_utils/vg/nds/organizer/save_file.rb +25 -0
  95. data/lib/ehbrs_ruby_utils/vg/nds/organizer.rb +65 -0
  96. data/lib/ehbrs_ruby_utils/vg/patchers/applier_factory.rb +38 -0
  97. data/lib/ehbrs_ruby_utils/vg/patchers/base_applier.rb +33 -0
  98. data/lib/ehbrs_ruby_utils/vg/patchers/bps_applier.rb +10 -0
  99. data/lib/ehbrs_ruby_utils/vg/patchers/ips_applier.rb +17 -0
  100. data/lib/ehbrs_ruby_utils/vg/patchers/temp_files.rb +36 -0
  101. data/lib/ehbrs_ruby_utils/vg/patchers/vcdiff_applier.rb +17 -0
  102. data/lib/ehbrs_ruby_utils/vg/ps2/iso_file.rb +0 -3
  103. data/lib/ehbrs_ruby_utils/vg/ps2.rb +0 -2
  104. data/lib/ehbrs_ruby_utils/vg/wii/file_move.rb +0 -4
  105. data/lib/ehbrs_ruby_utils/vg/wii/game_file.rb +0 -5
  106. data/lib/ehbrs_ruby_utils/vg/wii/wit/image_format.rb +4 -8
  107. data/lib/ehbrs_ruby_utils/vg/wii/wit/parsers/dump.rb +1 -3
  108. data/lib/ehbrs_ruby_utils/vg/wii/wit/parsers/info.rb +0 -1
  109. data/lib/ehbrs_ruby_utils/vg/wii/wit/path.rb +0 -2
  110. data/lib/ehbrs_ruby_utils/vg/wii/wit.rb +0 -2
  111. data/lib/ehbrs_ruby_utils/vg/wii.rb +0 -2
  112. data/lib/ehbrs_ruby_utils/vg.rb +0 -2
  113. data/lib/ehbrs_ruby_utils/videos/convert_job.rb +0 -2
  114. data/lib/ehbrs_ruby_utils/videos/file.rb +0 -3
  115. data/lib/ehbrs_ruby_utils/videos/opensubtitles/parsers/episode.rb +0 -3
  116. data/lib/ehbrs_ruby_utils/videos/opensubtitles/parsers/title.rb +0 -3
  117. data/lib/ehbrs_ruby_utils/videos/opensubtitles/parsers.rb +0 -2
  118. data/lib/ehbrs_ruby_utils/videos/opensubtitles/processors/episode.rb +0 -5
  119. data/lib/ehbrs_ruby_utils/videos/opensubtitles/processors/subtitle.rb +0 -2
  120. data/lib/ehbrs_ruby_utils/videos/opensubtitles/processors/subtitles_provider.rb +0 -5
  121. data/lib/ehbrs_ruby_utils/videos/opensubtitles/processors/title.rb +0 -5
  122. data/lib/ehbrs_ruby_utils/videos/opensubtitles/processors.rb +0 -2
  123. data/lib/ehbrs_ruby_utils/videos/opensubtitles.rb +0 -2
  124. data/lib/ehbrs_ruby_utils/videos/quality.rb +0 -2
  125. data/lib/ehbrs_ruby_utils/videos/resolution.rb +0 -3
  126. data/lib/ehbrs_ruby_utils/videos/series/rename/directory_group.rb +0 -3
  127. data/lib/ehbrs_ruby_utils/videos/series/rename/file/basename_parser.rb +0 -2
  128. data/lib/ehbrs_ruby_utils/videos/series/rename/file/renamer.rb +0 -2
  129. data/lib/ehbrs_ruby_utils/videos/series/rename/file.rb +0 -2
  130. data/lib/ehbrs_ruby_utils/videos/series/rename/line_result.rb +0 -2
  131. data/lib/ehbrs_ruby_utils/videos/series/rename/results_builder.rb +0 -3
  132. data/lib/ehbrs_ruby_utils/videos/series/rename.rb +0 -2
  133. data/lib/ehbrs_ruby_utils/videos/series.rb +0 -2
  134. data/lib/ehbrs_ruby_utils/videos/stream.rb +0 -2
  135. data/lib/ehbrs_ruby_utils/videos/subtitles/sanitize/content_sanitizer.rb +0 -4
  136. data/lib/ehbrs_ruby_utils/videos/subtitles/sanitize/with_pattern_matcher.rb +0 -3
  137. data/lib/ehbrs_ruby_utils/videos/subtitles/sanitize/with_term_matcher.rb +0 -3
  138. data/lib/ehbrs_ruby_utils/videos/subtitles/sanitize.rb +0 -2
  139. data/lib/ehbrs_ruby_utils/videos.rb +0 -2
  140. data/lib/ehbrs_ruby_utils/videos2/convert_job.rb +0 -2
  141. data/lib/ehbrs_ruby_utils/videos2/extract/package.rb +0 -4
  142. data/lib/ehbrs_ruby_utils/videos2/extract/package_file.rb +0 -2
  143. data/lib/ehbrs_ruby_utils/videos2/extract.rb +0 -2
  144. data/lib/ehbrs_ruby_utils/videos2/profiles/base.rb +1 -0
  145. data/lib/ehbrs_ruby_utils/videos2/profiles/same_quality.rb +0 -2
  146. data/lib/ehbrs_ruby_utils/videos2/unsupported/check_result.rb +0 -2
  147. data/lib/ehbrs_ruby_utils/videos2/unsupported/check_set.rb +0 -2
  148. data/lib/ehbrs_ruby_utils/videos2/unsupported/check_support.rb +0 -3
  149. data/lib/ehbrs_ruby_utils/videos2/unsupported/checks/codec_extra_unsupported.rb +0 -2
  150. data/lib/ehbrs_ruby_utils/videos2/unsupported/checks/codec_unsupported.rb +0 -2
  151. data/lib/ehbrs_ruby_utils/videos2/unsupported/checks/invalid_extension.rb +0 -2
  152. data/lib/ehbrs_ruby_utils/videos2/unsupported/checks.rb +0 -2
  153. data/lib/ehbrs_ruby_utils/videos2/unsupported/file/fix.rb +0 -4
  154. data/lib/ehbrs_ruby_utils/videos2/unsupported/file.rb +0 -5
  155. data/lib/ehbrs_ruby_utils/videos2/unsupported/fix_profile.rb +0 -3
  156. data/lib/ehbrs_ruby_utils/videos2/unsupported/fixes/supported_codec.rb +0 -2
  157. data/lib/ehbrs_ruby_utils/videos2/unsupported/profiles/aoc.rb +0 -2
  158. data/lib/ehbrs_ruby_utils/videos2/unsupported/profiles/philco.rb +0 -2
  159. data/lib/ehbrs_ruby_utils/videos2/unsupported/profiles/samsung.rb +0 -3
  160. data/lib/ehbrs_ruby_utils/videos2/unsupported/profiles.rb +0 -2
  161. data/lib/ehbrs_ruby_utils/videos2/unsupported/search.rb +3 -4
  162. data/lib/ehbrs_ruby_utils/videos2/unsupported/track.rb +0 -2
  163. data/lib/ehbrs_ruby_utils/videos2.rb +0 -2
  164. data/lib/ehbrs_ruby_utils/web_utils/instance/finances/bills/consume/file.rb +0 -1
  165. data/lib/ehbrs_ruby_utils/web_utils/instance/finances/bills/consume.rb +0 -1
  166. data/lib/ehbrs_ruby_utils/web_utils/instance/finances/bills.rb +0 -1
  167. data/lib/ehbrs_ruby_utils/web_utils/instance/finances.rb +0 -1
  168. data/lib/ehbrs_ruby_utils/web_utils/instance/http_request.rb +1 -2
  169. data/lib/ehbrs_ruby_utils/web_utils/instance.rb +1 -1
  170. data/lib/ehbrs_ruby_utils/web_utils/request_error.rb +0 -2
  171. data/lib/ehbrs_ruby_utils/web_utils/videos/file/rename.rb +0 -2
  172. data/lib/ehbrs_ruby_utils/web_utils/videos/file.rb +0 -1
  173. data/lib/ehbrs_ruby_utils/web_utils/videos/files_list.rb +0 -2
  174. data/lib/ehbrs_ruby_utils/web_utils/videos.rb +0 -2
  175. data/lib/ehbrs_ruby_utils/web_utils.rb +0 -2
  176. data/lib/ehbrs_ruby_utils.rb +4 -2
  177. metadata +47 -42
@@ -1,5 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_ext'
4
3
  require 'eac_templates/patches'
5
- require 'ehbrs_ruby_utils/patches'
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/envs'
4
- require 'eac_ruby_utils/core_ext'
5
-
6
3
  module EhbrsRubyUtils
7
4
  module Executables
8
5
  class << self
@@ -18,7 +15,8 @@ module EhbrsRubyUtils
18
15
  '-?' => %w[rar],
19
16
  '-h' => %w[unzip],
20
17
  '-version' => %w[ffmpeg ffprobe],
21
- '--version' => %w[isoinfo tar wit]
18
+ '--version' => %w[flips isoinfo tar wit],
19
+ '-V' => %w[xdelta3]
22
20
  }.each do |validate_arg, commands|
23
21
  commands.each do |command|
24
22
  define_method("#{command}_uncached") do
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_docker/images/templatized'
4
- require 'ehbrs_ruby_utils/patches/object/template'
5
4
 
6
5
  module EhbrsRubyUtils
7
6
  module Finances
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_fs/file_info'
4
- require 'eac_ruby_utils/core_ext'
5
- require 'ehbrs_ruby_utils/executables'
6
4
 
7
5
  module EhbrsRubyUtils
8
6
  module Fs
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_ext'
4
- require 'ehbrs_ruby_utils/executables'
5
-
6
3
  module EhbrsRubyUtils
7
4
  module Fs
8
5
  class Iso9660File
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_ext'
4
- require 'ehbrs_ruby_utils/fs/selected/build_file'
5
-
6
3
  module EhbrsRubyUtils
7
4
  module Fs
8
5
  class Selected
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_ext'
4
-
5
3
  module EhbrsRubyUtils
6
4
  module Fs
7
5
  class Selected
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_fs/traverser'
4
- require 'eac_ruby_utils/core_ext'
5
4
 
6
5
  module EhbrsRubyUtils
7
6
  module Fs
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_fs/patches'
4
- require 'eac_ruby_utils/core_ext'
5
4
 
6
5
  module EhbrsRubyUtils
7
6
  module Fs
@@ -10,6 +9,8 @@ module EhbrsRubyUtils
10
9
  enable_simple_cache
11
10
  abstract_methods :convert, :convert?, :target_encoding
12
11
 
12
+ TEXT_MIME_TYPES = [%r{\Atext/\S+}, 'application/x-subrip'].freeze
13
+
13
14
  common_constructor(:file) do
14
15
  self.file = file.to_pathname
15
16
  end
@@ -32,7 +33,7 @@ module EhbrsRubyUtils
32
33
  end
33
34
  end
34
35
 
35
- def run
36
+ def run # rubocop:disable Naming/PredicateMethod
36
37
  return false unless convert?
37
38
 
38
39
  convert
@@ -75,8 +76,9 @@ module EhbrsRubyUtils
75
76
  r
76
77
  end
77
78
 
79
+ # @return [Boolean]
78
80
  def text?
79
- file.info.content_type.type == 'text'
81
+ TEXT_MIME_TYPES.any? { |e| e.match?(file.info.content_type.mime_type) }
80
82
  end
81
83
  end
82
84
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ehbrs_ruby_utils/fs/to_file_format'
4
-
5
3
  module EhbrsRubyUtils
6
4
  module Fs
7
5
  class ToUtf8Unix < ::EhbrsRubyUtils::Fs::ToFileFormat
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_ext'
4
- require 'ehbrs_ruby_utils/fs/to_file_format'
5
-
6
3
  module EhbrsRubyUtils
7
4
  module Fs
8
5
  class ToWindowsPtBr < ::EhbrsRubyUtils::Fs::ToFileFormat
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_ext'
4
-
5
3
  module EhbrsRubyUtils
6
4
  # Filesystem utilities.
7
5
  module Fs
@@ -1,15 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ehbrs_ruby_utils/bga/session'
4
- require 'ehbrs_ruby_utils/bga/game_statistics/whatsapp_formatter'
5
- require 'ehbrs_ruby_utils/executables'
6
- require 'ehbrs_ruby_utils/mudslide/message'
7
- require 'eac_ruby_utils/core_ext'
8
-
9
3
  module EhbrsRubyUtils
10
4
  module Gjt1
11
5
  class Manager
12
6
  include ::Singleton
7
+
13
8
  acts_as_abstract :bga_username, :bga_password, :whatsapp_recipient
14
9
 
15
10
  %w[beginning ending].each do |type|
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_ext'
4
-
5
3
  module EhbrsRubyUtils
6
4
  module Gjt1
7
5
  require_sub __FILE__
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_ext'
4
- require 'ehbrs_ruby_utils/executables'
5
-
6
3
  module EhbrsRubyUtils
7
4
  module Mudslide
8
5
  class Message
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_ext'
4
-
5
3
  module EhbrsRubyUtils
6
4
  module Mudslide
7
5
  require_sub __FILE__
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ehbrs_ruby_utils/core_ext'
4
- require 'ehbrs_ruby_utils/music/lyrics_book/resource'
5
-
6
3
  module EhbrsRubyUtils
7
4
  module Music
8
5
  class LyricsBook
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ehbrs_ruby_utils/core_ext'
4
-
5
3
  module EhbrsRubyUtils
6
4
  module Music
7
5
  class LyricsBook
@@ -19,6 +17,7 @@ module EhbrsRubyUtils
19
17
 
20
18
  enable_simple_cache
21
19
  include ::Comparable
20
+
22
21
  common_constructor :parent, :path
23
22
  attr_accessor :previous
24
23
 
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ehbrs_ruby_utils/core_ext'
4
- require 'ehbrs_ruby_utils/music/lyrics_book/resource'
5
-
6
3
  module EhbrsRubyUtils
7
4
  module Music
8
5
  class LyricsBook
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ehbrs_ruby_utils/core_ext'
4
-
5
3
  module EhbrsRubyUtils
6
4
  module Music
7
5
  class LyricsBook
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_ext'
4
- require 'ehbrs_ruby_utils/music/ous/artist'
5
- require 'ehbrs_ruby_utils/music/ous/node'
6
-
7
3
  module EhbrsRubyUtils
8
4
  module Music
9
5
  module Ous
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_ext'
4
- require 'ehbrs_ruby_utils/music/ous/category'
5
- require 'ehbrs_ruby_utils/music/ous/node'
6
-
7
3
  module EhbrsRubyUtils
8
4
  module Music
9
5
  module Ous
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_ext'
4
- require 'ehbrs_ruby_utils/music/ous/node'
5
-
6
3
  module EhbrsRubyUtils
7
4
  module Music
8
5
  module Ous
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_ext'
4
-
5
3
  module EhbrsRubyUtils
6
4
  module Music
7
5
  module Ous
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ehbrs_ruby_utils/core_ext'
4
-
5
3
  module EhbrsRubyUtils
6
4
  module Music
7
5
  module Sort
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ehbrs_ruby_utils/core_ext'
4
-
5
3
  module EhbrsRubyUtils
6
4
  module Music
7
5
  module Sort
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ehbrs_ruby_utils/core_ext'
4
- require 'ehbrs_ruby_utils/music/sort/files/factory'
5
-
6
3
  module EhbrsRubyUtils
7
4
  module Music
8
5
  module Sort
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ehbrs_ruby_utils/core_ext'
4
-
5
3
  module EhbrsRubyUtils
6
4
  module Music
7
5
  module Sort
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ehbrs_ruby_utils/core_ext'
4
-
5
3
  module EhbrsRubyUtils
6
4
  module Music
7
5
  module Sort
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_ext'
4
-
5
3
  module EhbrsRubyUtils
6
4
  module Music
7
5
  require_sub __FILE__
@@ -1,4 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/require_sub'
4
3
  EacRubyUtils.require_sub __FILE__
@@ -1,4 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/require_sub'
4
3
  EacRubyUtils.require_sub __FILE__
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EhbrsRubyUtils
4
- VERSION = '0.44.3'
4
+ VERSION = '0.46.0'
5
5
  end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EhbrsRubyUtils
4
+ module Vg
5
+ module Nds
6
+ class Organizer
7
+ class BaseFile
8
+ acts_as_abstract :target_path
9
+ enable_listable
10
+ enable_simple_cache
11
+ enable_speaker
12
+ lists.add_symbol :add_error, :duplicated, :unrecognized
13
+ common_constructor :file_manager, :source_path do
14
+ self.source_path = source_path.to_pathname.expand_path
15
+ end
16
+ delegate :runner, to: :file_manager
17
+ compare_by :id
18
+
19
+ def change?
20
+ source_path != target_path
21
+ end
22
+
23
+ def id
24
+ source_path.basename_noext.to_path
25
+ end
26
+
27
+ def perform
28
+ return unless change?
29
+
30
+ ::FileUtils.mv(source_path, target_path.assert_parent)
31
+ end
32
+
33
+ def show
34
+ puts "#{format_path(target_path, :green)} <= #{format_path(source_path, :yellow)}"
35
+ end
36
+
37
+ protected
38
+
39
+ def format_path(path, color)
40
+ path.relative_path_from(runner.runner.roms_root).to_path.colorize(color)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EhbrsRubyUtils
4
+ module Vg
5
+ module Nds
6
+ class Organizer
7
+ class FileManager
8
+ enable_simple_cache
9
+ common_constructor :runner
10
+
11
+ ROM_EXTNAMES = ['.nds'].freeze
12
+ SAVE_EXTNAMES = ['.sav'].freeze
13
+
14
+ def add_file(path)
15
+ if ROM_EXTNAMES.include?(path.extname)
16
+ add_to_set(:rom, path)
17
+ elsif SAVE_EXTNAMES.include?(path.extname)
18
+ add_to_set(:save, path)
19
+ else
20
+ ::EhbrsRubyUtils::Vg::Nds::Organizer::BaseFile::ADD_ERROR_UNRECOGNIZED
21
+ end
22
+ end
23
+
24
+ def find_rom(id)
25
+ roms.find { |s| s.id == id }
26
+ end
27
+
28
+ protected
29
+
30
+ def add_to_set(type, path)
31
+ set = send(type.to_s.pluralize)
32
+ file = ::EhbrsRubyUtils::Vg::Nds::Organizer.const_get("#{type}_file".camelize)
33
+ .new(self, path)
34
+ return ::BaseFile::ADD_ERROR_DUPLICATED if set.include?(file)
35
+
36
+ set.add(file)
37
+ nil
38
+ end
39
+
40
+ def roms
41
+ @roms ||= ::Set.new
42
+ end
43
+
44
+ def saves
45
+ @saves ||= ::Set.new
46
+ end
47
+
48
+ def to_change_files_uncached
49
+ (roms.to_a + saves.to_a).select(&:change?).sort_by { |f| [f.id, f.target_path] }
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EhbrsRubyUtils
4
+ module Vg
5
+ module Nds
6
+ class Organizer
7
+ class RomFile < ::EhbrsRubyUtils::Vg::Nds::Organizer::BaseFile
8
+ protected
9
+
10
+ def target_path_uncached
11
+ source_path
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EhbrsRubyUtils
4
+ module Vg
5
+ module Nds
6
+ class Organizer
7
+ class SaveFile < ::EhbrsRubyUtils::Vg::Nds::Organizer::BaseFile
8
+ SAVES_DIRECTORY_BASENAME = 'saves'.to_pathname
9
+
10
+ protected
11
+
12
+ def target_path_uncached
13
+ rom_file.if_present(source_path) do |v|
14
+ v.target_path.dirname.join(SAVES_DIRECTORY_BASENAME).join(source_path.basename)
15
+ end
16
+ end
17
+
18
+ def rom_file_uncached
19
+ file_manager.find_rom(id)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'find'
4
+
5
+ module EhbrsRubyUtils
6
+ module Vg
7
+ module Nds
8
+ class Organizer
9
+ enable_simple_cache
10
+ common_constructor :runner
11
+ delegate :confirm?, :roms_root, :show?, to: :runner
12
+
13
+ def add_files
14
+ self.errors = {}
15
+ reset_cache(:file_manager)
16
+ ::Find.find(roms_root) do |path|
17
+ pathname = path.to_pathname
18
+ next unless pathname.file?
19
+
20
+ file_manager.add_file(pathname).if_present do |error|
21
+ errors[pathname] = error
22
+ end
23
+ end
24
+ end
25
+
26
+ def clean_empty_directories
27
+ runner.infom 'Cleaning empty directories?'
28
+ return unless confirm?
29
+
30
+ roms_root.children.each do |child|
31
+ ::EacFs::Utils.remove_empty_directories(child)
32
+ end
33
+ end
34
+
35
+ def perform
36
+ file_manager.to_change_files.each do |file|
37
+ file.show if show?
38
+ file.perform if confirm?
39
+ end
40
+ end
41
+
42
+ def perform_all
43
+ add_files
44
+ show_changes if show?
45
+ perform
46
+ clean_empty_directories
47
+ end
48
+
49
+ def show_changes
50
+ file_manager.to_change_files.each(&:show)
51
+ runner.infov 'To change files', file_manager.to_change_files.count
52
+ end
53
+
54
+ protected
55
+
56
+ attr_writer :errors
57
+
58
+ # @return [FileManager]
59
+ def file_manager_uncached
60
+ ::EhbrsRubyUtils::Vg::Nds::Organizer::FileManager.new(self)
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EhbrsRubyUtils
4
+ module Vg
5
+ module Patchers
6
+ class ApplierFactory
7
+ APPLIERS_BY_TYPE = {
8
+ 'BPS patch file' => ::EhbrsRubyUtils::Vg::Patchers::BpsApplier,
9
+ 'IPS patch file' => ::EhbrsRubyUtils::Vg::Patchers::IpsApplier,
10
+ 'VCDIFF binary diff' => ::EhbrsRubyUtils::Vg::Patchers::VcdiffApplier
11
+ }.freeze
12
+
13
+ enable_simple_cache
14
+ common_constructor :patch_path do
15
+ self.patch_path = patch_path.to_pathname
16
+ end
17
+ delegate :apply, to: :applier_instance
18
+
19
+ # @return [String]
20
+ def patch_type
21
+ patch_path.info.description
22
+ end
23
+
24
+ protected
25
+
26
+ # @return [Class]
27
+ def applier_class_uncached
28
+ APPLIERS_BY_TYPE.fetch(patch_type)
29
+ end
30
+
31
+ # @return [Object]
32
+ def applier_instance_uncached
33
+ applier_class.new(patch_path)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EhbrsRubyUtils
4
+ module Vg
5
+ module Patchers
6
+ class BaseApplier
7
+ acts_as_abstract
8
+ common_constructor :patch_path
9
+
10
+ # @param source_path [Pathname]
11
+ # @param output_path [Pathname]
12
+ # @raise [RuntimeError] Se o arquivo de saída não é criado.
13
+ def apply(source_path, output_path)
14
+ source_path = source_path.to_pathname
15
+ output_path = output_path.to_pathname
16
+ command(source_path, output_path).system!
17
+
18
+ return if output_path.exist?
19
+
20
+ fatal_error("Applier returned without error, but output file \"#{output_path}\"" \
21
+ 'does not exist')
22
+ end
23
+
24
+ # @param source_path [Pathname]
25
+ # @param output_path [Pathname]
26
+ # @return [EacRubyUtils::Envs::Command]
27
+ def command(source_path, output_path)
28
+ raise_abstract_method __method__, source_path, output_path
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EhbrsRubyUtils
4
+ module Vg
5
+ module Patchers
6
+ class BpsApplier < ::EhbrsRubyUtils::Vg::Patchers::IpsApplier
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EhbrsRubyUtils
4
+ module Vg
5
+ module Patchers
6
+ class IpsApplier < ::EhbrsRubyUtils::Vg::Patchers::BaseApplier
7
+ # @param source_path [Pathname]
8
+ # @param output_path [Pathname]
9
+ # @return [EacRubyUtils::Envs::Command]
10
+ def command(source_path, output_path)
11
+ ::EhbrsRubyUtils::Executables.flips.command
12
+ .append(['--apply', patch_path, source_path, output_path])
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end