ehbrs-tools 0.25.1 → 0.28.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +60 -22
  3. data/lib/ehbrs/{core_ext.rb → tools/core_ext.rb} +0 -0
  4. data/lib/ehbrs/tools/runner/finances/bb_browser.rb +1 -1
  5. data/lib/ehbrs/tools/runner/fs/selected.rb +19 -26
  6. data/lib/ehbrs/tools/runner/music/lyrics.rb +68 -0
  7. data/lib/ehbrs/tools/runner/music/lyrics_book.rb +41 -0
  8. data/lib/ehbrs/tools/runner/music/selected.rb +6 -6
  9. data/lib/ehbrs/tools/runner/web_utils/videos/upload.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/extract/package.rb +2 -2
  13. data/lib/ehbrs/videos/extract/package_file.rb +0 -1
  14. data/spec/lib/ehbrs/tools/runner/fs/used_space_spec.rb +2 -1
  15. data/vendor/aranha-parsers/aranha-parsers.gemspec +1 -0
  16. data/vendor/aranha-parsers/lib/aranha/parsers/rspec/setup.rb +1 -1
  17. data/vendor/aranha-parsers/lib/aranha/parsers/rspec/{source_target_fixtures_example.rb → shared_examples/source_target_fixtures.rb} +0 -0
  18. data/vendor/aranha-parsers/lib/aranha/parsers/source_address/fetch_content_error.rb +10 -0
  19. data/vendor/aranha-parsers/lib/aranha/parsers/source_address/http_get.rb +15 -2
  20. data/vendor/aranha-parsers/lib/aranha/parsers/version.rb +1 -1
  21. data/vendor/eac_cli/lib/eac_cli/definition/argument_option.rb +1 -1
  22. data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +9 -1
  23. data/vendor/eac_cli/lib/eac_cli/definition/boolean_option.rb +6 -0
  24. data/vendor/eac_cli/lib/eac_cli/runner_with/help/builder.rb +3 -3
  25. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  26. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +6 -5
  27. data/vendor/eac_fs/Gemfile +5 -0
  28. data/vendor/eac_fs/eac_fs.gemspec +20 -0
  29. data/vendor/{eac_ruby_utils/lib/eac_ruby_utils/filesystem_cache.rb → eac_fs/lib/eac_fs/cache.rb} +7 -2
  30. data/vendor/eac_fs/lib/eac_fs/file_info.rb +24 -0
  31. data/vendor/eac_fs/lib/eac_fs/patches/module/fs_cache.rb +10 -0
  32. data/vendor/eac_fs/lib/eac_fs/patches/module.rb +4 -0
  33. data/vendor/eac_fs/lib/eac_fs/patches/object/fs_cache.rb +10 -0
  34. data/vendor/eac_fs/lib/eac_fs/patches/object.rb +4 -0
  35. data/vendor/eac_fs/lib/eac_fs/patches/pathname/info.rb +12 -0
  36. data/vendor/eac_fs/lib/eac_fs/patches/pathname.rb +4 -0
  37. data/vendor/eac_fs/lib/eac_fs/patches.rb +4 -0
  38. data/vendor/eac_fs/lib/eac_fs/version.rb +5 -0
  39. data/vendor/eac_fs/lib/eac_fs.rb +7 -0
  40. 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
  41. data/vendor/eac_fs/spec/rubocop_spec.rb +3 -0
  42. data/vendor/eac_fs/spec/spec_helper.rb +4 -0
  43. data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +2 -1
  44. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +3 -3
  45. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/core_ext.rb +1 -0
  46. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +16 -7
  47. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  48. data/vendor/eac_ruby_gems_utils/Gemfile +5 -0
  49. data/vendor/eac_ruby_gems_utils/LICENCE +16 -0
  50. data/vendor/eac_ruby_gems_utils/README.rdoc +3 -0
  51. data/vendor/eac_ruby_gems_utils/eac_ruby_gems_utils.gemspec +30 -0
  52. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/command.rb +33 -0
  53. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/version_file.rb +41 -0
  54. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem.rb +97 -0
  55. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb +58 -0
  56. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/minitest.rb +25 -0
  57. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple/decorated_gem.rb +48 -0
  58. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple/result.rb +25 -0
  59. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple.rb +84 -0
  60. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/rspec.rb +21 -0
  61. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests.rb +9 -0
  62. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +5 -0
  63. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils.rb +7 -0
  64. data/vendor/eac_ruby_gems_utils/spec/code/rubocop_check_spec.rb +3 -0
  65. data/vendor/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem/version_file_spec.rb +14 -0
  66. data/vendor/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem/version_file_spec_files/a_version_file.rb +7 -0
  67. data/vendor/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem_spec.rb +20 -0
  68. data/vendor/eac_ruby_gems_utils/spec/spec_helper.rb +4 -0
  69. data/vendor/eac_ruby_gems_utils/spec/support/mygem/Gemfile +5 -0
  70. data/vendor/eac_ruby_gems_utils/spec/support/mygem/Gemfile.lock +19 -0
  71. data/vendor/eac_ruby_gems_utils/spec/support/mygem/Rakefile +14 -0
  72. data/vendor/eac_ruby_gems_utils/spec/support/mygem/exe/myrunner +5 -0
  73. data/vendor/eac_ruby_gems_utils/spec/support/mygem/lib/mygem/version.rb +5 -0
  74. data/vendor/eac_ruby_gems_utils/spec/support/mygem/lib/mygem.rb +5 -0
  75. data/vendor/eac_ruby_gems_utils/spec/support/mygem/mygem.gemspec +16 -0
  76. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/compact.rb +22 -0
  77. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/compact.rb +20 -0
  78. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string/delimited.rb +16 -0
  79. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/string_delimited.rb +70 -0
  80. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  81. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/compact_spec.rb +20 -0
  82. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/compact_spec.rb +20 -0
  83. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/string/delimited_spec.rb +34 -0
  84. data/vendor/eac_templates/Gemfile +5 -0
  85. data/vendor/eac_templates/eac_templates.gemspec +19 -0
  86. data/vendor/eac_templates/lib/eac_templates/directory.rb +108 -0
  87. data/vendor/eac_templates/lib/eac_templates/file.rb +48 -0
  88. data/vendor/eac_templates/lib/eac_templates/patches/module/erb_template.rb +9 -0
  89. data/vendor/eac_templates/lib/eac_templates/patches/module/template.rb +10 -0
  90. data/vendor/eac_templates/lib/eac_templates/patches/module.rb +4 -0
  91. data/vendor/eac_templates/lib/eac_templates/patches/object/erb_template.rb +9 -0
  92. data/vendor/eac_templates/lib/eac_templates/patches/object/template.rb +9 -0
  93. data/vendor/eac_templates/lib/eac_templates/patches/object.rb +4 -0
  94. data/vendor/eac_templates/lib/eac_templates/patches.rb +4 -0
  95. data/vendor/eac_templates/lib/eac_templates/searcher.rb +53 -0
  96. data/vendor/eac_templates/lib/eac_templates/variable_not_found_error.rb +5 -0
  97. data/vendor/eac_templates/lib/eac_templates/variable_providers/base.rb +21 -0
  98. data/vendor/eac_templates/lib/eac_templates/variable_providers/config_reader.rb +27 -0
  99. data/vendor/eac_templates/lib/eac_templates/variable_providers/entries_reader.rb +23 -0
  100. data/vendor/eac_templates/lib/eac_templates/variable_providers/generic.rb +23 -0
  101. data/vendor/eac_templates/lib/eac_templates/variable_providers/hash.rb +27 -0
  102. data/vendor/eac_templates/lib/eac_templates/variable_providers.rb +23 -0
  103. data/vendor/eac_templates/lib/eac_templates/version.rb +5 -0
  104. data/vendor/eac_templates/lib/eac_templates.rb +7 -0
  105. data/vendor/eac_templates/spec/lib/eac_templates/file_spec.rb +35 -0
  106. data/vendor/eac_templates/spec/lib/eac_templates/file_spec_files/expected_content +2 -0
  107. data/vendor/eac_templates/spec/lib/eac_templates/file_spec_files/source.template +2 -0
  108. data/vendor/eac_templates/spec/lib/eac_templates/searcher_spec.rb +30 -0
  109. data/vendor/eac_templates/spec/lib/eac_templates/searcher_spec_files/path1/subdir1/file1.template +1 -0
  110. data/vendor/eac_templates/spec/lib/eac_templates/searcher_spec_files/path1/subdir1/file2 +1 -0
  111. data/vendor/eac_templates/spec/lib/eac_templates/searcher_spec_files/path2/subdir1/file3.template +1 -0
  112. data/vendor/eac_templates/spec/lib/object/template_spec.rb +23 -0
  113. data/vendor/eac_templates/spec/lib/object/template_spec_files/path/my_stub_with_template +1 -0
  114. data/vendor/eac_templates/spec/rubocop_spec.rb +3 -0
  115. data/vendor/eac_templates/spec/spec_helper.rb +4 -0
  116. data/vendor/ehbrs_ruby_utils/ehbrs_ruby_utils.gemspec +4 -0
  117. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/core_ext.rb +5 -0
  118. data/{lib/ehbrs → vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils}/fs/compressed_package.rb +1 -1
  119. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/fs/selected/build.rb +41 -0
  120. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/fs/selected/build_file.rb +27 -0
  121. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/fs/selected.rb +35 -0
  122. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/fs.rb +10 -0
  123. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music/lyrics_book/album.rb +42 -0
  124. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb +64 -0
  125. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music/lyrics_book/song.rb +68 -0
  126. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music/lyrics_book.rb +65 -0
  127. data/{lib/ehbrs/fs.rb → vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music.rb} +2 -2
  128. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/patches/object.rb +4 -0
  129. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/patches.rb +4 -0
  130. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb +1 -1
  131. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container.rb +31 -0
  132. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb +1 -1
  133. data/vendor/ehbrs_ruby_utils/template/ehbrs_ruby_utils/music/lyrics_book/album/inner.html.erb +3 -0
  134. data/vendor/ehbrs_ruby_utils/template/ehbrs_ruby_utils/music/lyrics_book/custom_style.css +15 -0
  135. data/vendor/ehbrs_ruby_utils/template/ehbrs_ruby_utils/music/lyrics_book/index.html.erb +14 -0
  136. data/vendor/ehbrs_ruby_utils/template/ehbrs_ruby_utils/music/lyrics_book/main.html.erb +24 -0
  137. data/vendor/ehbrs_ruby_utils/template/ehbrs_ruby_utils/music/lyrics_book/resource/main.html.erb +8 -0
  138. data/vendor/ehbrs_ruby_utils/template/ehbrs_ruby_utils/music/lyrics_book/song/inner.html.erb +9 -0
  139. data/vendor/ultimate_lyrics/Gemfile +5 -0
  140. data/vendor/ultimate_lyrics/bin/download_parser_spec_files.rb +94 -0
  141. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/field.rb +83 -0
  142. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/lyrics.rb +13 -0
  143. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/parser.rb +28 -0
  144. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider/exclude_item.rb +17 -0
  145. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider/extract_item.rb +21 -0
  146. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider/item.rb +48 -0
  147. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider/replace_fields.rb +13 -0
  148. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider/rule.rb +52 -0
  149. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider/url_format.rb +21 -0
  150. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider.rb +96 -0
  151. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider_search.rb +43 -0
  152. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/providers_data.xml +356 -0
  153. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/song_metadata/field.rb +24 -0
  154. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/song_metadata.rb +28 -0
  155. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/version.rb +5 -0
  156. data/vendor/ultimate_lyrics/lib/ultimate_lyrics.rb +7 -0
  157. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec.rb +20 -0
  158. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__michael_jackson_thriller.source.html +8 -0
  159. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__michael_jackson_thriller.target.yaml +3 -0
  160. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__michael_jackson_thriller.url +1 -0
  161. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__milton_nascimento_rouxinol.source.html +8 -0
  162. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__milton_nascimento_rouxinol.target.yaml +3 -0
  163. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__milton_nascimento_rouxinol.url +1 -0
  164. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__michael_jackson_thriller.source.html +193 -0
  165. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__michael_jackson_thriller.target.yaml +3 -0
  166. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__michael_jackson_thriller.url +1 -0
  167. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__milton_nascimento_rouxinol.source.html +193 -0
  168. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__milton_nascimento_rouxinol.target.yaml +3 -0
  169. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__milton_nascimento_rouxinol.url +1 -0
  170. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyrics_com__michael_jackson_thriller.source.html +87 -0
  171. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyrics_com__michael_jackson_thriller.target.yaml +36 -0
  172. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyrics_com__michael_jackson_thriller.url +1 -0
  173. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyrics_com__milton_nascimento_rouxinol.source.html +4 -0
  174. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyrics_com__milton_nascimento_rouxinol.target.yaml +3 -0
  175. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyrics_com__milton_nascimento_rouxinol.url +1 -0
  176. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__michael_jackson_thriller.source.html +2 -0
  177. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__michael_jackson_thriller.target.yaml +3 -0
  178. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__michael_jackson_thriller.url +1 -0
  179. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__milton_nascimento_rouxinol.source.html +2 -0
  180. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__milton_nascimento_rouxinol.target.yaml +3 -0
  181. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__milton_nascimento_rouxinol.url +1 -0
  182. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsreg_com__milton_nascimento_rouxinol.source.html +101 -0
  183. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsreg_com__milton_nascimento_rouxinol.target.yaml +3 -0
  184. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsreg_com__milton_nascimento_rouxinol.url +1 -0
  185. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__michael_jackson_thriller.source.html +29 -0
  186. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__michael_jackson_thriller.target.yaml +3 -0
  187. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__michael_jackson_thriller.url +1 -0
  188. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__milton_nascimento_rouxinol.source.html +29 -0
  189. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__milton_nascimento_rouxinol.target.yaml +3 -0
  190. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__milton_nascimento_rouxinol.url +1 -0
  191. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/songlyrics_com__michael_jackson_thriller.source.html +1301 -0
  192. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/songlyrics_com__michael_jackson_thriller.target.yaml +3 -0
  193. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/songlyrics_com__michael_jackson_thriller.url +1 -0
  194. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/provider_search_spec.rb +72 -0
  195. data/vendor/ultimate_lyrics/spec/rubocop_spec.rb +3 -0
  196. data/vendor/ultimate_lyrics/spec/spec_helper.rb +4 -0
  197. data/vendor/ultimate_lyrics/ultimate_lyrics.gemspec +21 -0
  198. metadata +170 -13
  199. data/lib/ehbrs/patches/module/erb_template.rb +0 -11
  200. data/lib/ehbrs/patches/object/erb_template.rb +0 -9
  201. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs_cache.rb +0 -12
@@ -0,0 +1,108 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_templates/file'
4
+
5
+ module EacTemplates
6
+ class Directory
7
+ TEMPLATE_EXTNAME = '.template'
8
+
9
+ attr_reader :path
10
+
11
+ def initialize(path)
12
+ @path = path.is_a?(::Pathname) ? path : ::Pathname.new(path.to_s)
13
+ end
14
+
15
+ def apply(variables_source, directory)
16
+ TemplateNode.new(self, '.', directory, variables_source).apply
17
+ end
18
+
19
+ def child(subpath)
20
+ child_path = ::File.join(path, subpath)
21
+ return ::EacTemplates::File.new(child_path) if ::File.file?(child_path)
22
+ return ::EacTemplates::Directory.new(child_path) if ::File.directory?(child_path)
23
+
24
+ raise "Child \"#{subpath}\" from \"#{path}\" not found"
25
+ end
26
+
27
+ def children
28
+ path.children.map do |path_child|
29
+ child(path_child.basename.to_path)
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def apply_fs_object(source_relative, target)
36
+ if ::File.directory?(source_absolute(source_relative))
37
+ apply_directory(source_relative, target)
38
+ elsif ::File.file?(source_absolute(source_relative))
39
+ end
40
+ end
41
+
42
+ def source_absolute(source_relative)
43
+ ::File.expand_path(source_relative, path)
44
+ end
45
+
46
+ class TemplateNode
47
+ attr_reader :source_directory, :source_relative, :target_root_directory, :variables_source
48
+
49
+ def initialize(source_directory, source_relative, target_root_directory, variables_source)
50
+ @source_directory = source_directory
51
+ @source_relative = source_relative
52
+ @target_root_directory = target_root_directory
53
+ @variables_source = variables_source
54
+ end
55
+
56
+ def apply
57
+ if file?
58
+ apply_file
59
+ elsif directory?
60
+ apply_directory
61
+ else
62
+ raise "Unknown filesystem type: #{source_absolute}"
63
+ end
64
+ end
65
+
66
+ private
67
+
68
+ def apply_directory
69
+ ::FileUtils.mkdir_p(target_absolute)
70
+ Dir.entries(source_absolute).each do |entry|
71
+ child(entry).apply unless %w[. ..].include?(entry)
72
+ end
73
+ end
74
+
75
+ def apply_file
76
+ if ::File.extname(source_absolute) == TEMPLATE_EXTNAME
77
+ ::EacTemplates::File.new(source_absolute).apply_to_file(
78
+ variables_source, target_absolute
79
+ )
80
+ else
81
+ ::FileUtils.cp(source_absolute, target_absolute)
82
+ end
83
+ end
84
+
85
+ def child(entry)
86
+ TemplateNode.new(source_directory, ::File.join(source_relative, entry),
87
+ target_root_directory, variables_source)
88
+ end
89
+
90
+ def file?
91
+ ::File.file?(source_absolute)
92
+ end
93
+
94
+ def directory?
95
+ ::File.directory?(source_absolute)
96
+ end
97
+
98
+ def source_absolute
99
+ ::File.expand_path(source_relative, source_directory.path)
100
+ end
101
+
102
+ def target_absolute
103
+ ::File.expand_path(source_relative, target_root_directory)
104
+ .gsub(/#{::Regexp.quote(TEMPLATE_EXTNAME)}\z/, '')
105
+ end
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_templates/variable_providers'
5
+
6
+ module EacTemplates
7
+ class File
8
+ VARIABLE_DELIMITER = ::Regexp.quote('%%')
9
+ VARIABLE_PATTERN = /#{VARIABLE_DELIMITER}([a-z0-9\._]*)#{VARIABLE_DELIMITER}/i.freeze
10
+
11
+ enable_simple_cache
12
+ common_constructor :path do
13
+ self.path = path.to_pathname
14
+ end
15
+
16
+ # +variables_provider+ A [Hash] or object which responds to +read_entry(entry_name)+.
17
+ def apply(variables_source)
18
+ variables_provider = ::EacTemplates::VariableProviders.build(variables_source)
19
+ variables.inject(content) do |a, e|
20
+ a.gsub(variable_pattern(e), variables_provider.variable_value(e).to_s)
21
+ end
22
+ end
23
+
24
+ def apply_to_file(variables_source, output_file_path)
25
+ output_file_path.to_pathname.write(apply(variables_source))
26
+ end
27
+
28
+ private
29
+
30
+ def variables_uncached
31
+ content.scan(VARIABLE_PATTERN).map(&:first).map do |name|
32
+ sanitize_variable_name(name)
33
+ end.to_set
34
+ end
35
+
36
+ def content_uncached
37
+ path.read
38
+ end
39
+
40
+ def sanitize_variable_name(variable_name)
41
+ variable_name.to_s.downcase
42
+ end
43
+
44
+ def variable_pattern(name)
45
+ /#{VARIABLE_DELIMITER}#{::Regexp.quote(name)}#{VARIABLE_DELIMITER}/i
46
+ end
47
+ end
48
+ end
@@ -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,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/string/inflections'
4
+ require 'eac_templates/searcher'
5
+
6
+ class Module
7
+ def template
8
+ @template ||= ::EacTemplates::Searcher.default.template(name.underscore)
9
+ end
10
+ 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,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_templates/patches/module/template'
4
+
5
+ class Object
6
+ def template
7
+ self.class.template
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__
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/object/blank'
4
+ require 'eac_templates/directory'
5
+ require 'eac_templates/file'
6
+
7
+ module EacTemplates
8
+ class Searcher
9
+ class << self
10
+ def default
11
+ @default ||= new
12
+ end
13
+ end
14
+
15
+ def template(subpath, required = true)
16
+ path = template_path(subpath)
17
+ if path.blank?
18
+ return nil unless required
19
+
20
+ raise_template_not_found(subpath)
21
+ end
22
+ return ::EacTemplates::File.new(path) if ::File.file?(path)
23
+ return ::EacTemplates::Directory.new(path) if ::File.directory?(path)
24
+
25
+ raise 'Invalid branching'
26
+ end
27
+
28
+ # @return The absolute path of template if found, +nil+ otherwise.
29
+ def template_path(subpath)
30
+ included_paths.each do |included_path|
31
+ r = search_template_in_included_path(included_path, subpath)
32
+ return r if r
33
+ end
34
+ nil
35
+ end
36
+
37
+ def included_paths
38
+ @included_paths ||= ::Set.new
39
+ end
40
+
41
+ private
42
+
43
+ def raise_template_not_found(subpath)
44
+ raise "Template not found for subpath \"#{subpath}\"" \
45
+ " (Included paths: #{included_paths.to_a.join(::File::PATH_SEPARATOR)})"
46
+ end
47
+
48
+ def search_template_in_included_path(included_path, subpath)
49
+ path = ::File.join(included_path, subpath)
50
+ ::File.exist?(path) ? path : nil
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacTemplates
4
+ class VariableNotFoundError < StandardError; end
5
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_templates/variable_not_found_error'
4
+
5
+ module EacTemplates
6
+ module VariableProviders
7
+ class Base
8
+ attr_reader :source
9
+
10
+ def initialize(source)
11
+ @source = source
12
+ end
13
+
14
+ def variable_value(name)
15
+ return variable_fetch(name) if variable_exist?(name)
16
+
17
+ raise VariableNotFoundError, "Variable \"#{name}\" not found in #{source}"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_config/node'
4
+ require 'eac_templates/variable_providers/base'
5
+
6
+ module EacTemplates
7
+ module VariableProviders
8
+ class ConfigReader < ::EacTemplates::VariableProviders::Base
9
+ class << self
10
+ def accept?(variables_source)
11
+ return false unless variables_source.respond_to?(:entry)
12
+
13
+ entry = variables_source.entry(:any_value)
14
+ entry.respond_to?(:value) && entry.respond_to?(:found?)
15
+ end
16
+ end
17
+
18
+ def variable_exist?(name)
19
+ source.entry(name).found?
20
+ end
21
+
22
+ def variable_fetch(name)
23
+ source.entry(name).value
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_templates/variable_providers/base'
4
+
5
+ module EacTemplates
6
+ module VariableProviders
7
+ class EntriesReader < ::EacTemplates::VariableProviders::Base
8
+ class << self
9
+ def accept?(variables_source)
10
+ variables_source.respond_to?(:read_entry)
11
+ end
12
+ end
13
+
14
+ def variable_exist?(_name)
15
+ true
16
+ end
17
+
18
+ def variable_fetch(name)
19
+ source.read_entry(name)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_templates/variable_providers/base'
4
+
5
+ module EacTemplates
6
+ module VariableProviders
7
+ class Generic < ::EacTemplates::VariableProviders::Base
8
+ class << self
9
+ def accept?(variables_source)
10
+ variables_source.is_a?(::Object)
11
+ end
12
+ end
13
+
14
+ def variable_exist?(name)
15
+ source.respond_to?(name)
16
+ end
17
+
18
+ def variable_fetch(name)
19
+ source.send(name)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_templates/variable_providers/base'
4
+
5
+ module EacTemplates
6
+ module VariableProviders
7
+ class Hash < ::EacTemplates::VariableProviders::Base
8
+ class << self
9
+ def accept?(variables_source)
10
+ variables_source.is_a?(::Hash)
11
+ end
12
+ end
13
+
14
+ def initialize(source)
15
+ super(source.with_indifferent_access)
16
+ end
17
+
18
+ def variable_exist?(name)
19
+ source.key?(name)
20
+ end
21
+
22
+ def variable_fetch(name)
23
+ source.fetch(name)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacTemplates
6
+ module VariableProviders
7
+ require_sub __FILE__
8
+
9
+ PROVIDERS = %w[config_reader entries_reader hash generic].map do |name|
10
+ "eac_templates/variable_providers/#{name}".camelize.constantize
11
+ end
12
+
13
+ class << self
14
+ def build(variables_source)
15
+ PROVIDERS.each do |provider|
16
+ return provider.new(variables_source) if provider.accept?(variables_source)
17
+ end
18
+
19
+ raise "Variables provider not found for #{variables_source}"
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacTemplates
4
+ VERSION = '0.2.0'
5
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacTemplates
6
+ require_sub __FILE__
7
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_config/old_configs'
4
+ require 'eac_templates/file'
5
+
6
+ RSpec.describe ::EacTemplates::File do
7
+ let(:files_dir) { ::File.join(__dir__, 'file_spec_files') }
8
+ let(:source_path) { ::File.join(files_dir, 'source.template') }
9
+ let(:instance) { described_class.new(source_path) }
10
+ let(:expected_content) { ::File.read(::File.join(files_dir, 'expected_content')) }
11
+
12
+ describe '#apply' do
13
+ context 'when config is a hash' do
14
+ let(:config) { { name: 'Fulano de Tal', age: 33 } }
15
+
16
+ it { expect(instance.apply(config)).to eq(expected_content) }
17
+ end
18
+
19
+ context 'when config responds to read_entry' do
20
+ let(:config) { ::EacConfig::OldConfigs.new('rspec_describe_eac_ruby_utils_templates_file') }
21
+
22
+ before do
23
+ config.clear
24
+ config['name'] = 'Fulano de Tal'
25
+ config['age'] = '33'
26
+ end
27
+
28
+ it { expect(instance.apply(config)).to eq(expected_content) }
29
+ end
30
+ end
31
+
32
+ describe '#variables' do
33
+ it { expect(instance.variables).to eq(::Set.new(%w[name age])) }
34
+ end
35
+ end
@@ -0,0 +1,2 @@
1
+ Name: Fulano de Tal
2
+ Age: 33
@@ -0,0 +1,2 @@
1
+ Name: %%NAME%%
2
+ Age: %%AGE%%
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_templates/searcher'
4
+
5
+ RSpec.describe ::EacTemplates::Searcher do
6
+ let(:files_dir) { ::File.join(__dir__, 'searcher_spec_files') }
7
+ let(:instance) do
8
+ r = described_class.new
9
+ r.included_paths << ::File.join(files_dir, 'path1')
10
+ r.included_paths << ::File.join(files_dir, 'path2')
11
+ r
12
+ end
13
+
14
+ describe '#template' do
15
+ {
16
+ ::EacTemplates::Directory => %w[subdir1],
17
+ ::EacTemplates::File => %w[subdir1/file1.template subdir1/file2
18
+ subdir1/file3.template],
19
+ ::NilClass => %w[does_not_exist]
20
+ }.each do |klass, subpaths|
21
+ subpaths.each do |subpath|
22
+ context "when subpath is \"#{subpath}\"" do
23
+ it "returns a #{klass}'s instance" do
24
+ expect(instance.template(subpath, false)).to be_a(klass)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_templates/patches/object/template'
4
+
5
+ RSpec.describe ::Object do
6
+ class MyStubWithTemplate # rubocop:disable RSpec/LeakyConstantDeclaration
7
+ end
8
+
9
+ let(:instance) { ::MyStubWithTemplate.new }
10
+ let(:templates_path) { ::File.join(__dir__, 'template_spec_files', 'path') }
11
+
12
+ before do
13
+ ::EacTemplates::Searcher.default.included_paths.add(templates_path)
14
+ end
15
+
16
+ after do
17
+ ::EacTemplates::Searcher.default.included_paths.delete(templates_path)
18
+ end
19
+
20
+ describe '#template' do
21
+ it { expect(instance.template).to be_a(::EacTemplates::File) }
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ ::EacRubyUtils::Rspec.default_setup.describe_rubocop
@@ -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__))
@@ -15,8 +15,12 @@ Gem::Specification.new do |s|
15
15
  s.files = Dir['{lib,template}/**/*']
16
16
  s.test_files = Dir['{spec}/**/*', '.rubocop.yml', '.rspec']
17
17
 
18
+ s.add_dependency 'aranha-parsers', '~> 0.8', '>= 0.8.5'
19
+ s.add_dependency 'avm', '~> 0.3', '>= 0.3.2'
18
20
  s.add_dependency 'eac_ruby_utils', '~> 0.70'
19
21
  s.add_dependency 'eac_templates', '~> 0.1', '>= 0.1.1'
22
+ s.add_dependency 'taglib-ruby', '~> 1.1'
23
+ s.add_dependency 'ultimate_lyrics', '~> 0.1'
20
24
 
21
25
  s.add_development_dependency 'aranha-parsers', '~> 0.8'
22
26
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.3'
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_templates/patches'
5
+ require 'ehbrs_ruby_utils/patches'
@@ -3,7 +3,7 @@
3
3
  require 'avm/files/info'
4
4
  require 'eac_ruby_utils/core_ext'
5
5
 
6
- module Ehbrs
6
+ module EhbrsRubyUtils
7
7
  module Fs
8
8
  class CompressedPackage < ::Avm::Files::Info
9
9
  MIME_TYPES = {
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'ehbrs_ruby_utils/fs/selected/build_file'
5
+
6
+ module EhbrsRubyUtils
7
+ module Fs
8
+ class Selected
9
+ class Build
10
+ DEFAULT_TARGET_BASENAME_PROC = ::Proc.new { |path| path.basename.to_path }
11
+
12
+ attr_reader :selected, :target_dir, :target_basename_proc
13
+
14
+ def initialize(selected, target_dir, &target_basename_proc)
15
+ @selected = selected
16
+ @target_dir = target_dir.to_pathname
17
+ @target_basename_proc = target_basename_proc.presence || DEFAULT_TARGET_BASENAME_PROC
18
+ end
19
+
20
+ def perform
21
+ clear_target_dir
22
+ link_selected_found
23
+ end
24
+
25
+ private
26
+
27
+ def clear_target_dir
28
+ target_dir.children.each do |c|
29
+ c.unlink if c.symlink? && c.directory?
30
+ end
31
+ end
32
+
33
+ def link_selected_found
34
+ selected.found.each do |found|
35
+ ::EhbrsRubyUtils::Fs::Selected::BuildFile.new(self, found).perform
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EhbrsRubyUtils
6
+ module Fs
7
+ class Selected
8
+ class BuildFile
9
+ common_constructor :build, :path do
10
+ self.path = path.to_pathname
11
+ end
12
+
13
+ def perform
14
+ target_path.make_symlink(path)
15
+ end
16
+
17
+ def target_path
18
+ build.target_dir.join(target_basename)
19
+ end
20
+
21
+ def target_basename
22
+ build.target_basename_proc.call(path)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end