ehbrs-tools 0.19.0 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (220) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ehbrs/cooking_book/project.rb +8 -2
  3. data/lib/ehbrs/core_ext.rb +4 -0
  4. data/lib/ehbrs/music.rb +9 -0
  5. data/lib/ehbrs/music/album.rb +44 -0
  6. data/lib/ehbrs/observers/base.rb +1 -1
  7. data/lib/ehbrs/observers/with_persistence.rb +1 -1
  8. data/lib/ehbrs/patches.rb +4 -0
  9. data/lib/ehbrs/patches/object/template.rb +2 -2
  10. data/lib/ehbrs/runner/cooking_book/build.rb +20 -2
  11. data/lib/ehbrs/runner/fs/selected.rb +79 -0
  12. data/lib/ehbrs/runner/fs/used_space.rb +2 -3
  13. data/lib/ehbrs/runner/music.rb +16 -0
  14. data/lib/ehbrs/runner/music/selected.rb +26 -0
  15. data/lib/ehbrs/runner/videos/probe.rb +2 -2
  16. data/lib/ehbrs/runner/web_utils/videos/upload.rb +1 -1
  17. data/lib/ehbrs/tools/version.rb +1 -1
  18. data/lib/ehbrs/vg/wii/game_file.rb +10 -0
  19. data/lib/ehbrs/videos/convert_job.rb +1 -1
  20. data/lib/ehbrs/videos/series/rename/line_result.rb +1 -1
  21. data/lib/ehbrs/videos/unsupported/check_support.rb +12 -7
  22. data/lib/ehbrs/videos/unsupported/search.rb +1 -1
  23. data/lib/ehbrs/videos/unsupported/track.rb +1 -1
  24. data/vendor/aranha-parsers/aranha-parsers.gemspec +1 -1
  25. data/vendor/aranha-parsers/lib/aranha/parsers/version.rb +1 -1
  26. data/vendor/aranha-parsers/spec/lib/rubocop_check_spec.rb +1 -5
  27. data/vendor/aranha-parsers/spec/spec_helper.rb +3 -0
  28. data/vendor/aranha-selenium/lib/aranha/selenium/driver_factory/base.rb +8 -0
  29. data/vendor/aranha-selenium/lib/aranha/selenium/driver_factory/chrome.rb +10 -5
  30. data/vendor/aranha-selenium/lib/aranha/selenium/driver_factory/firefox.rb +25 -11
  31. data/vendor/aranha-selenium/lib/aranha/selenium/version.rb +1 -1
  32. data/vendor/eac_cli/eac_cli.gemspec +4 -2
  33. data/vendor/eac_cli/lib/eac_cli/config.rb +18 -0
  34. data/vendor/eac_cli/lib/eac_cli/config/entry.rb +48 -0
  35. data/vendor/{eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb → eac_cli/lib/eac_cli/config/entry/options.rb} +20 -9
  36. data/vendor/eac_cli/lib/eac_cli/config/entry/undefined.rb +26 -0
  37. data/vendor/eac_cli/lib/eac_cli/core_ext.rb +2 -0
  38. data/vendor/eac_cli/lib/eac_cli/default_runner.rb +1 -1
  39. data/vendor/eac_cli/lib/eac_cli/definition/alternative.rb +4 -7
  40. data/vendor/eac_cli/lib/eac_cli/definition/argument_option.rb +8 -0
  41. data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +26 -10
  42. data/vendor/eac_cli/lib/eac_cli/definition/base_option/initialize_args_parser.rb +47 -0
  43. data/vendor/eac_cli/lib/eac_cli/definition/boolean_option.rb +8 -0
  44. data/vendor/eac_cli/lib/eac_cli/definition/help_formatter.rb +3 -2
  45. data/vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb +18 -1
  46. data/vendor/eac_cli/lib/eac_cli/old_configs.rb +35 -0
  47. data/vendor/eac_cli/lib/eac_cli/old_configs/entry_reader.rb +80 -0
  48. data/vendor/eac_cli/lib/eac_cli/old_configs/password_entry_reader.rb +16 -0
  49. data/vendor/eac_cli/lib/eac_cli/old_configs/read_entry_options.rb +44 -0
  50. data/vendor/eac_cli/lib/eac_cli/old_configs/store_passwords_entry_reader.rb +25 -0
  51. data/vendor/eac_cli/lib/eac_cli/old_configs_bridge.rb +39 -0
  52. data/vendor/eac_cli/lib/eac_cli/parser/alternative/short_options.rb +4 -2
  53. data/vendor/eac_cli/lib/eac_cli/parser/collector.rb +3 -17
  54. data/vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb +3 -2
  55. data/vendor/eac_cli/lib/eac_cli/runner.rb +0 -50
  56. data/vendor/eac_cli/lib/eac_cli/runner/after_class_methods.rb +46 -0
  57. data/vendor/eac_cli/lib/eac_cli/runner/context.rb +2 -1
  58. data/vendor/eac_cli/lib/eac_cli/runner/instance_methods.rb +42 -0
  59. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +9 -4
  60. data/vendor/eac_cli/lib/eac_cli/runner_with/help/builder.rb +73 -0
  61. data/vendor/eac_cli/lib/eac_cli/runner_with/help/builder/alternative.rb +56 -0
  62. data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +11 -5
  63. data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands/definition_concern.rb +10 -0
  64. data/vendor/eac_cli/lib/eac_cli/runner_with_set.rb +50 -0
  65. data/vendor/eac_cli/lib/eac_cli/speaker.rb +127 -0
  66. data/vendor/eac_cli/lib/eac_cli/speaker/_constants.rb +12 -0
  67. data/vendor/eac_cli/lib/eac_cli/speaker/list.rb +61 -0
  68. data/vendor/eac_cli/lib/eac_cli/speaker/options.rb +38 -0
  69. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  70. data/vendor/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +4 -0
  71. data/vendor/{eac_ruby_utils/spec/lib/eac_ruby_utils/console/configs_spec.rb → eac_cli/spec/lib/eac_cli/old_configs_spec.rb} +2 -2
  72. data/vendor/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +1 -1
  73. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +21 -4
  74. data/vendor/{eac_ruby_utils/spec/lib/eac_ruby_utils/console → eac_cli/spec/lib/eac_cli}/speaker_spec.rb +7 -11
  75. data/vendor/eac_cli/spec/rubocop_spec.rb +1 -5
  76. data/vendor/eac_cli/spec/spec_helper.rb +3 -0
  77. data/vendor/eac_config/Gemfile +5 -0
  78. data/vendor/eac_config/eac_config.gemspec +19 -0
  79. data/vendor/eac_config/lib/eac_config.rb +7 -0
  80. data/vendor/eac_config/lib/eac_config/entry.rb +49 -0
  81. data/vendor/eac_config/lib/eac_config/entry_path.rb +41 -0
  82. data/vendor/eac_config/lib/eac_config/envvars_node.rb +25 -0
  83. data/vendor/eac_config/lib/eac_config/envvars_node/entry.rb +54 -0
  84. data/vendor/eac_config/lib/eac_config/load_nodes_search.rb +39 -0
  85. data/vendor/eac_config/lib/eac_config/load_path.rb +28 -0
  86. data/vendor/eac_config/lib/eac_config/node.rb +67 -0
  87. data/vendor/eac_config/lib/eac_config/node_entry.rb +18 -0
  88. data/vendor/eac_config/lib/eac_config/node_uri.rb +38 -0
  89. data/vendor/{eac_ruby_utils/lib/eac_ruby_utils/configs.rb → eac_config/lib/eac_config/old_configs.rb} +6 -5
  90. data/vendor/{eac_ruby_utils/lib/eac_ruby_utils/configs → eac_config/lib/eac_config/old_configs}/base.rb +5 -5
  91. data/vendor/{eac_ruby_utils/lib/eac_ruby_utils/configs → eac_config/lib/eac_config/old_configs}/file.rb +4 -4
  92. data/vendor/{eac_ruby_utils/lib/eac_ruby_utils → eac_config/lib/eac_config}/paths_hash.rb +8 -8
  93. data/vendor/{eac_ruby_utils/lib/eac_ruby_utils → eac_config/lib/eac_config}/paths_hash/entry_key_error.rb +1 -1
  94. data/vendor/{eac_ruby_utils/lib/eac_ruby_utils → eac_config/lib/eac_config}/paths_hash/node.rb +2 -2
  95. data/vendor/{eac_ruby_utils/lib/eac_ruby_utils → eac_config/lib/eac_config}/paths_hash/path_search.rb +4 -4
  96. data/vendor/eac_config/lib/eac_config/version.rb +5 -0
  97. data/vendor/eac_config/lib/eac_config/yaml_file_node.rb +48 -0
  98. data/vendor/eac_config/lib/eac_config/yaml_file_node/entry.rb +37 -0
  99. data/vendor/eac_config/spec/lib/eac_config/entry_path_spec.rb +30 -0
  100. data/vendor/eac_config/spec/lib/eac_config/envvars_node/entry_spec.rb +14 -0
  101. data/vendor/eac_config/spec/lib/eac_config/envvars_node_spec.rb +40 -0
  102. data/vendor/{eac_ruby_utils/spec/lib/eac_ruby_utils/configs_spec.rb → eac_config/spec/lib/eac_config/old_configs_spec.rb} +2 -2
  103. data/vendor/{eac_ruby_utils/spec/lib/eac_ruby_utils → eac_config/spec/lib/eac_config}/paths_hash_spec.rb +6 -6
  104. data/vendor/eac_config/spec/lib/eac_config/yaml_file_node_spec.rb +52 -0
  105. data/vendor/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1.yaml +6 -0
  106. data/vendor/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_1.yaml +2 -0
  107. data/vendor/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2.yaml +4 -0
  108. data/vendor/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2/storage1_2_1.yaml +2 -0
  109. data/vendor/eac_config/spec/rubocop_spec.rb +3 -0
  110. data/vendor/eac_config/spec/spec_helper.rb +17 -0
  111. data/vendor/eac_docker/eac_docker.gemspec +3 -2
  112. data/vendor/eac_docker/lib/eac_docker/images/templatized.rb +1 -0
  113. data/vendor/eac_docker/lib/eac_docker/version.rb +1 -1
  114. data/vendor/eac_docker/spec/lib/eac_docker/images/templatized_spec.rb +2 -1
  115. data/vendor/eac_docker/spec/rubocop_spec.rb +1 -5
  116. data/vendor/eac_docker/spec/spec_helper.rb +3 -0
  117. data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +4 -4
  118. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +23 -9
  119. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application_xdg.rb +34 -0
  120. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/core_ext.rb +4 -0
  121. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/jobs_runner.rb +31 -0
  122. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches.rb +4 -0
  123. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/class.rb +4 -0
  124. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/class/jobs_runner.rb +10 -0
  125. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/object.rb +5 -0
  126. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/object/runner_with.rb +5 -0
  127. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +22 -12
  128. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with.rb +9 -0
  129. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/confirmation.rb +43 -0
  130. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/filesystem_traverser.rb +52 -0
  131. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/input.rb +36 -0
  132. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/output.rb +58 -0
  133. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  134. data/vendor/eac_ruby_base0/spec/lib/eac_ruby_base0/runner_with/confirmation_spec.rb +42 -0
  135. data/vendor/eac_ruby_base0/spec/lib/eac_ruby_base0/runner_with/output_spec.rb +81 -0
  136. data/vendor/eac_ruby_base0/spec/rubocop_spec.rb +1 -5
  137. data/vendor/eac_ruby_base0/spec/spec_helper.rb +3 -0
  138. data/vendor/eac_ruby_utils/eac_ruby_utils.gemspec +2 -3
  139. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/context.rb +31 -0
  140. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb +12 -7
  141. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +10 -5
  142. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/filesystem_cache.rb +6 -0
  143. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/logs.rb +63 -0
  144. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +9 -1
  145. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +3 -2
  146. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb +12 -2
  147. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/class/settings_provider.rb +10 -0
  148. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel/nyi.rb +4 -2
  149. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/common_concern.rb +0 -1
  150. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/context.rb +11 -0
  151. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/speaker.rb +9 -0
  152. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_nil.rb +17 -0
  153. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/parent_n.rb +11 -0
  154. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/regexp/to_parser.rb +10 -0
  155. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string/inflector.rb +4 -2
  156. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/required_zone.rb +11 -0
  157. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/regexp_parser.rb +34 -0
  158. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/conditional.rb +1 -4
  159. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/settings_provider.rb +10 -29
  160. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/settings_provider/setting_value.rb +69 -0
  161. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/simple_cache.rb +26 -5
  162. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/speaker.rb +16 -0
  163. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/speaker/receiver.rb +57 -0
  164. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/speaker/sender.rb +32 -0
  165. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  166. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/speaker_spec.rb +13 -0
  167. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/pathname/parent_n_spec.rb +33 -0
  168. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/settings_provider_spec.rb +8 -0
  169. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/simple_cache_spec.rb +27 -0
  170. data/vendor/eac_ruby_utils/spec/rubocop_check_spec.rb +1 -5
  171. data/vendor/eac_ruby_utils/spec/spec_helper.rb +3 -0
  172. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/convert_job.rb +1 -1
  173. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/videos/files_list.rb +1 -1
  174. metadata +118 -67
  175. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +0 -55
  176. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder/alternative.rb +0 -50
  177. data/vendor/eac_cli/lib/eac_cli/docopt/runner_context_replacement.rb +0 -15
  178. data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +0 -51
  179. data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +0 -30
  180. data/vendor/eac_cli/spec/lib/eac_cli/docopt/runner_extension_spec.rb +0 -35
  181. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb +0 -53
  182. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console.rb +0 -5
  183. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb +0 -38
  184. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/entry_reader.rb +0 -81
  185. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/password_entry_reader.rb +0 -18
  186. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/store_passwords_entry_reader.rb +0 -27
  187. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner.rb +0 -45
  188. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_class_methods.rb +0 -18
  189. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_doc.rb +0 -25
  190. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_settings.rb +0 -19
  191. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb +0 -154
  192. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/speaker.rb +0 -133
  193. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/speaker/_class_methods.rb +0 -39
  194. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/speaker/_constants.rb +0 -14
  195. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/speaker/list.rb +0 -63
  196. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/speaker/node.rb +0 -26
  197. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/console_speaker.rb +0 -10
  198. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/template.rb +0 -10
  199. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/template.rb +0 -9
  200. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/default_time_zone_set.rb +0 -6
  201. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates.rb +0 -9
  202. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/directory.rb +0 -110
  203. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/file.rb +0 -50
  204. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/searcher.rb +0 -55
  205. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_not_found_error.rb +0 -7
  206. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers.rb +0 -25
  207. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/base.rb +0 -23
  208. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/entries_reader.rb +0 -25
  209. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/generic.rb +0 -25
  210. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/hash.rb +0 -29
  211. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/console/docopt_runner_spec.rb +0 -136
  212. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/console_speaker_spec.rb +0 -13
  213. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/template_spec.rb +0 -23
  214. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb +0 -35
  215. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec_files/expected_content +0 -2
  216. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec_files/source.template +0 -2
  217. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/searcher_spec.rb +0 -30
  218. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/searcher_spec_files/path1/subdir1/file1.template +0 -1
  219. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/searcher_spec_files/path1/subdir1/file2 +0 -1
  220. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/searcher_spec_files/path2/subdir1/file3.template +0 -1
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/by_reference'
4
+
5
+ module EacCli
6
+ # https://github.com/fazibear/colorize
7
+ class Speaker
8
+ STDERR = ::EacRubyUtils::ByReference.new { $stderr }
9
+ STDIN = ::EacRubyUtils::ByReference.new { $stdin }
10
+ STDOUT = ::EacRubyUtils::ByReference.new { $stdout }
11
+ end
12
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/hash_with_indifferent_access'
4
+ require 'ostruct'
5
+
6
+ module EacCli
7
+ class Speaker
8
+ class List
9
+ class << self
10
+ def build(list)
11
+ return List.new(hash_to_values(list)) if list.is_a?(::Hash)
12
+ return List.new(array_to_values(list)) if list.is_a?(::Array)
13
+
14
+ raise "Invalid list: #{list} (#{list.class})"
15
+ end
16
+
17
+ private
18
+
19
+ def hash_to_values(list)
20
+ list.map { |key, value| ::OpenStruct.new(key: key, label: key, value: value) }
21
+ end
22
+
23
+ def array_to_values(list)
24
+ list.map { |value| ::OpenStruct.new(key: value, label: value, value: value) }
25
+ end
26
+ end
27
+
28
+ attr_reader :values
29
+
30
+ def initialize(values)
31
+ @values = values.map do |v|
32
+ ::OpenStruct.new(key: to_key(v.key), label: to_label(v.label), value: v.value)
33
+ end
34
+ end
35
+
36
+ def valid_labels
37
+ values.map(&:label)
38
+ end
39
+
40
+ def valid_value?(value)
41
+ values.any? { |v| v.key == to_key(value) }
42
+ end
43
+
44
+ def to_key(value)
45
+ to_label(value).downcase
46
+ end
47
+
48
+ def to_label(value)
49
+ value.to_s.strip
50
+ end
51
+
52
+ def build_value(value)
53
+ key = to_key(value)
54
+ values.each do |v| # rubocop:disable Style/HashEachMethods
55
+ return v.value if v.key == key
56
+ end
57
+ raise "Value not found: \"#{value}\" (#{values})"
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacCli
6
+ class Speaker
7
+ module Options
8
+ common_concern do
9
+ enable_listable
10
+ lists.add_symbol :option, :out_out, :err_out, :in_in, :parent, :err_line_prefix
11
+ end
12
+
13
+ def err_out
14
+ option(OPTION_ERR_OUT, ::EacCli::Speaker::STDERR)
15
+ end
16
+
17
+ def out_out
18
+ option(OPTION_OUT_OUT, ::EacCli::Speaker::STDOUT)
19
+ end
20
+
21
+ def in_in
22
+ option(OPTION_IN_IN, ::EacCli::Speaker::STDIN)
23
+ end
24
+
25
+ def err_line_prefix
26
+ option(OPTION_ERR_LINE_PREFIX, '')
27
+ end
28
+
29
+ def parent
30
+ options[OPTION_PARENT]
31
+ end
32
+
33
+ def option(key, default)
34
+ options[key] || parent.if_present(default) { |v| v.send(__METHOD__) }
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.12.5'
4
+ VERSION = '0.22.0'
5
5
  end
@@ -7,6 +7,10 @@ RSpec.describe ::EacCli::Definition::Alternative do
7
7
 
8
8
  it { expect { instance.arg_opt '-a', '--opt2', 'A argument option' }.not_to raise_error }
9
9
  it { expect { instance.bool_opt '-b', '--opt1', 'A boolean option' }.not_to raise_error }
10
+ it { expect { instance.bool_opt '-b', '--no-description' }.not_to raise_error }
11
+ it { expect { instance.bool_opt '--opt1', 'A option without short' }.not_to raise_error }
12
+ it { expect { instance.bool_opt '-b', 'A option without long' }.not_to raise_error }
13
+ it { expect { instance.bool_opt 'A option without selectors' }.to raise_error(::StandardError) }
10
14
  it { expect { instance.options_argument(true) }.not_to raise_error }
11
15
  it { expect { instance.pos_arg :pos1 }.not_to raise_error }
12
16
  it { expect { instance.pos_arg :pos2, optional: true, repeat: true }.not_to raise_error }
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/console/configs'
3
+ require 'eac_cli/old_configs'
4
4
 
5
- RSpec.describe ::EacRubyUtils::Console::Configs do
5
+ RSpec.describe ::EacCli::OldConfigs do
6
6
  describe '#entry_key_to_envvar_name' do
7
7
  {
8
8
  'a.entry.value' => 'A_ENTRY_VALUE',
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_cli/docopt/runner_extension'
3
+ require 'eac_cli/parser/alternative'
4
4
 
5
5
  RSpec.describe ::EacCli::Parser::Alternative do
6
6
  let(:instance) { described_class.new(alternative, argv) }
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/console/docopt_runner'
4
3
  require 'eac_cli/runner'
5
4
 
6
5
  RSpec.describe ::EacCli::Runner do
@@ -12,6 +11,8 @@ RSpec.describe ::EacCli::Runner do
12
11
  runner_definition do
13
12
  arg_opt '-o', '--opt1', 'A arg option.'
14
13
  bool_opt '-p', '--opt2', 'A boolean option'
14
+ arg_opt '-q', '--opt4', 'A repeatable argument option.', repeat: true
15
+ bool_opt '-r', '--opt5', 'A repeatable boolean option', repeat: true
15
16
  pos_arg :pos1
16
17
  pos_arg :pos2, repeat: true, optional: true
17
18
  alt do
@@ -29,7 +30,7 @@ RSpec.describe ::EacCli::Runner do
29
30
  context 'when all args are supplied' do
30
31
  let(:argv) { %w[--opt1 aaa --opt2 bbb ccc ddd] }
31
32
  let(:parsed_expected) do
32
- { opt1: 'aaa', opt2: true, opt3: false, pos1: 'bbb',
33
+ { opt1: 'aaa', opt2: true, opt3: false, opt4: [], opt5: 0, pos1: 'bbb',
33
34
  pos2: %w[ccc ddd] }
34
35
  end
35
36
 
@@ -63,7 +64,10 @@ RSpec.describe ::EacCli::Runner do
63
64
 
64
65
  context 'when only required args are supplied' do
65
66
  let(:argv) { %w[bbb] }
66
- let(:parsed_expected) { { opt1: nil, opt2: false, opt3: false, pos1: 'bbb', pos2: [] } }
67
+ let(:parsed_expected) do
68
+ { opt1: nil, opt2: false, opt3: false, opt4: [], opt5: 0, pos1: 'bbb',
69
+ pos2: [] }
70
+ end
67
71
 
68
72
  it { expect(parsed_actual).to eq(parsed_expected) }
69
73
  it { expect(instance.parsed.opt1).to be_nil }
@@ -82,12 +86,25 @@ RSpec.describe ::EacCli::Runner do
82
86
 
83
87
  context 'when alternative args are supplied' do
84
88
  let(:argv) { %w[--opt3] }
85
- let(:parsed_expected) { { opt1: nil, opt2: false, opt3: true, pos1: nil, pos2: [] } }
89
+ let(:parsed_expected) do
90
+ { opt1: nil, opt2: false, opt3: true, opt4: [], opt5: 0, pos1: nil,
91
+ pos2: [] }
92
+ end
86
93
 
87
94
  it { expect(parsed_actual).to eq(parsed_expected) }
88
95
  it { expect(instance.parsed.opt3?).to eq(true) }
89
96
  end
90
97
 
98
+ context 'when repeated options are supplied' do
99
+ let(:argv) { %w[--opt5 -rrr --opt4=A -q B --opt4 C AAA] }
100
+ let(:parsed_expected) do
101
+ { opt1: nil, opt2: false, opt3: false, opt4: %w[A B C], opt5: 4, pos1: 'AAA',
102
+ pos2: [] }
103
+ end
104
+
105
+ it { expect(parsed_actual).to eq(parsed_expected) }
106
+ end
107
+
91
108
  context 'when extra args are not supplied' do
92
109
  let(:runner_class) do
93
110
  the_module = described_class
@@ -1,25 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/console/speaker'
3
+ require 'eac_cli/speaker'
4
4
 
5
- RSpec.describe ::EacRubyUtils::Console::Speaker do
6
- let(:instance) do
7
- r = ::Object.new
8
- r.extend(described_class)
9
- r
10
- end
5
+ RSpec.describe ::EacCli::Speaker do
6
+ let(:instance) { described_class.new }
11
7
 
12
- describe '#request_input' do
8
+ describe '#input' do
13
9
  it 'recover value from hash list' do
14
10
  allow(instance).to receive(:request_string).and_return('opt1')
15
11
  list = { opt1: 'value1', opt2: 'value2' }
16
- expect(instance.request_input('Question', list: list)).to eq('value1')
12
+ expect(instance.input('Question', list: list)).to eq('value1')
17
13
  end
18
14
 
19
15
  it 'recover value from array list' do
20
16
  allow(instance).to receive(:request_string).and_return('OPT1')
21
17
  list = %w[opt1 opt2]
22
- expect(instance.request_input('Question', list: list)).to eq('opt1')
18
+ expect(instance.input('Question', list: list)).to eq('opt1')
23
19
  end
24
20
 
25
21
  {
@@ -28,7 +24,7 @@ RSpec.describe ::EacRubyUtils::Console::Speaker do
28
24
  context "when bool: true and input is \"#{input}\"" do
29
25
  it "return #{expected}" do
30
26
  allow(instance).to receive(:request_string).and_return(input)
31
- expect(instance.request_input('Question', bool: true)).to eq(expected)
27
+ expect(instance.input('Question', bool: true)).to eq(expected)
32
28
  end
33
29
  end
34
30
  end
@@ -1,7 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_gem_support/spec/examples/rubocop_check'
4
-
5
- RSpec.describe ::RuboCop, slow: true do
6
- include_examples 'rubocop_check', ::File.expand_path('..', __dir__)
7
- end
3
+ ::EacRubyGemSupport::Rspec.default.describe_rubocop
@@ -97,4 +97,7 @@ RSpec.configure do |config|
97
97
  # # test failures related to randomization by passing the same `--seed` value
98
98
  # # as the one that triggered the failure.
99
99
  # Kernel.srand config.seed
100
+
101
+ require 'eac_ruby_gem_support/rspec'
102
+ ::EacRubyGemSupport::Rspec.setup(::File.expand_path('..', __dir__), config)
100
103
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
+
5
+ require 'eac_config/version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = 'eac_config'
9
+ s.version = EacConfig::VERSION
10
+ s.authors = ['Put here the authors']
11
+ s.summary = 'Put here de description.'
12
+
13
+ s.files = Dir['{lib}/**/*']
14
+
15
+ s.add_dependency 'addressable'
16
+ s.add_dependency 'eac_ruby_utils', '~> 0.64'
17
+
18
+ s.add_development_dependency 'eac_ruby_gem_support', '~> 0.2'
19
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacConfig
6
+ require_sub __FILE__
7
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_config/entry_path'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module EacConfig
7
+ class Entry
8
+ enable_simple_cache
9
+ common_constructor :root_node, :path do
10
+ self.path = ::EacConfig::EntryPath.assert(path)
11
+ end
12
+
13
+ def found?
14
+ node_entry.if_present(false, &:found?)
15
+ end
16
+
17
+ def found_node
18
+ node_entry.if_present(&:node)
19
+ end
20
+
21
+ def value
22
+ node_entry.if_present(&:value)
23
+ end
24
+
25
+ def value=(a_value)
26
+ write_node.self_entry(path).value = a_value
27
+ end
28
+
29
+ def write_node
30
+ root_node.write_node || root_node
31
+ end
32
+
33
+ private
34
+
35
+ def node_entry_uncached
36
+ node_entry_from_root || node_entry_from_load_path
37
+ end
38
+
39
+ def node_entry_from_load_path_uncached
40
+ root_node.recursive_loaded_nodes.lazy.map { |loaded_node| loaded_node.self_entry(path) }
41
+ .find(&:found?)
42
+ end
43
+
44
+ def node_entry_from_root_uncached
45
+ e = root_node.self_entry(path)
46
+ e.found? ? e : nil
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacConfig
6
+ class EntryPath
7
+ PART_SEPARATOR = '.'
8
+
9
+ class << self
10
+ def assert(source)
11
+ source.is_a?(self) ? source : new(build_parts(source))
12
+ end
13
+
14
+ def build_parts(source)
15
+ return validate_parts!(source.split(PART_SEPARATOR)) if source.is_a?(::String)
16
+ return validate_parts!(source.flat_map { |part| build_parts(part) }) if
17
+ source.is_a?(::Enumerable)
18
+
19
+ build_parts(source.to_s)
20
+ end
21
+
22
+ def validate_parts!(parts)
23
+ parts.assert_argument(::Enumerable, 'parts')
24
+ parts.each_with_index do |part, index|
25
+ raise ::ArgumentError, "Part #{index} of #{parts} is blank" if part.blank?
26
+ raise ::ArgumentError, "Part #{index} is not a string" unless part.is_a?(::String)
27
+ end
28
+ end
29
+ end
30
+
31
+ attr_reader :parts
32
+
33
+ def initialize(parts)
34
+ @parts = parts.to_a.freeze
35
+ end
36
+
37
+ def to_s
38
+ "#{self.class}[#{parts.join(PART_SEPARATOR)}]"
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'addressable'
4
+ require 'eac_config/node'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module EacConfig
8
+ # A node that read/write entries from environment variables.
9
+ class EnvvarsNode
10
+ require_sub __FILE__
11
+ include ::EacConfig::Node
12
+
13
+ URI = ::Addressable::URI.parse('self://envvars')
14
+
15
+ class << self
16
+ def from_uri(uri)
17
+ return new if uri == URI
18
+ end
19
+ end
20
+
21
+ def url
22
+ URI
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_config/entry_path'
4
+ require 'eac_config/node_entry'
5
+ require 'eac_ruby_utils/blank_not_blank'
6
+ require 'eac_ruby_utils/core_ext'
7
+ require 'eac_ruby_utils/yaml'
8
+
9
+ module EacConfig
10
+ class EnvvarsNode
11
+ class Entry < ::EacConfig::NodeEntry
12
+ class << self
13
+ def entry_path_to_envvar_name(path)
14
+ ::EacConfig::EntryPath.assert(path).parts.join('_').gsub(/[^a-z0-9_]/i, '')
15
+ .gsub(/\A_+/, '').gsub(/_+\z/, '').gsub(/_{2,}/, '_').upcase
16
+ end
17
+
18
+ def from_value(string)
19
+ return nil if string.nil?
20
+ return ::EacRubyUtils::Yaml.load(string) if string.start_with?('---')
21
+
22
+ string
23
+ end
24
+
25
+ def to_value(object)
26
+ return nil if object.nil?
27
+ return object if object.is_a?(String)
28
+
29
+ ::EacRubyUtils::Yaml.dump(object)
30
+ end
31
+ end
32
+
33
+ enable_simple_cache
34
+
35
+ def found?
36
+ ENV.key?(envvar_name)
37
+ end
38
+
39
+ def value
40
+ self.class.from_value(ENV[envvar_name])
41
+ end
42
+
43
+ def value=(a_value)
44
+ ENV[envvar_name] = self.class.to_value(a_value)
45
+ end
46
+
47
+ private
48
+
49
+ def envvar_name_uncached
50
+ self.class.entry_path_to_envvar_name(path)
51
+ end
52
+ end
53
+ end
54
+ end