eac_tools 0.97.1 → 0.97.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (346) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +30 -25
  3. data/lib/eac_tools/version.rb +1 -1
  4. data/sub/eac_config/eac_config.gemspec +20 -0
  5. data/sub/eac_config/lib/eac_config/entries.rb +35 -0
  6. data/sub/eac_config/lib/eac_config/entry/not_found_error.rb +13 -0
  7. data/sub/eac_config/lib/eac_config/entry.rb +64 -0
  8. data/sub/eac_config/lib/eac_config/entry_path.rb +89 -0
  9. data/sub/eac_config/lib/eac_config/envvars_node/entry.rb +54 -0
  10. data/sub/eac_config/lib/eac_config/envvars_node.rb +35 -0
  11. data/sub/eac_config/lib/eac_config/load_nodes_search.rb +39 -0
  12. data/sub/eac_config/lib/eac_config/load_path.rb +28 -0
  13. data/sub/eac_config/lib/eac_config/node.rb +81 -0
  14. data/sub/eac_config/lib/eac_config/node_entry.rb +28 -0
  15. data/sub/eac_config/lib/eac_config/node_uri/instanciate_single.rb +29 -0
  16. data/sub/eac_config/lib/eac_config/node_uri.rb +45 -0
  17. data/sub/eac_config/lib/eac_config/old_configs/base.rb +43 -0
  18. data/sub/eac_config/lib/eac_config/old_configs/file.rb +47 -0
  19. data/sub/eac_config/lib/eac_config/old_configs.rb +75 -0
  20. data/sub/eac_config/lib/eac_config/paths_hash/entry_key_error.rb +8 -0
  21. data/sub/eac_config/lib/eac_config/paths_hash/node.rb +67 -0
  22. data/sub/eac_config/lib/eac_config/paths_hash/path_search.rb +39 -0
  23. data/sub/eac_config/lib/eac_config/paths_hash.rb +63 -0
  24. data/sub/eac_config/lib/eac_config/prefixed_path_node/entry.rb +25 -0
  25. data/sub/eac_config/lib/eac_config/prefixed_path_node.rb +19 -0
  26. data/sub/eac_config/lib/eac_config/rspec/setup.rb +65 -0
  27. data/sub/{avm-eac_rails_base1/lib/avm/eac_rails_base1.rb → eac_config/lib/eac_config/rspec.rb} +2 -2
  28. data/sub/eac_config/lib/eac_config/version.rb +5 -0
  29. data/sub/eac_config/lib/eac_config/yaml_file_node/entry.rb +36 -0
  30. data/sub/eac_config/lib/eac_config/yaml_file_node/self_entries.rb +72 -0
  31. data/sub/eac_config/lib/eac_config/yaml_file_node.rb +54 -0
  32. data/sub/eac_config/lib/eac_config.rb +7 -0
  33. data/sub/eac_config/spec/lib/eac_config/entry_path_spec.rb +30 -0
  34. data/sub/eac_config/spec/lib/eac_config/envvars_node/entry_spec.rb +14 -0
  35. data/sub/eac_config/spec/lib/eac_config/envvars_node_spec.rb +51 -0
  36. data/sub/eac_config/spec/lib/eac_config/old_configs_spec.rb +46 -0
  37. data/sub/eac_config/spec/lib/eac_config/paths_hash_spec.rb +63 -0
  38. data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec.rb +88 -0
  39. data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1.yaml +10 -0
  40. data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_1.yaml +4 -0
  41. data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2/storage1_2_1.yaml +4 -0
  42. data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2.yaml +10 -0
  43. data/sub/eac_ruby_utils/Gemfile +8 -0
  44. data/sub/eac_ruby_utils/MIT-LICENCE +16 -0
  45. data/sub/eac_ruby_utils/README.rdoc +3 -0
  46. data/sub/eac_ruby_utils/eac_ruby_utils.gemspec +26 -0
  47. data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_abstract.rb +100 -0
  48. data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_immutable/array_accessor.rb +25 -0
  49. data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_immutable/base_accessor.rb +57 -0
  50. data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_immutable/boolean_accessor.rb +16 -0
  51. data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_immutable/class_methods.rb +20 -0
  52. data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_immutable/common_accessor.rb +30 -0
  53. data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_immutable/enumerable_accessor.rb +52 -0
  54. data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_immutable/hash_accessor.rb +57 -0
  55. data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_immutable/instance_methods.rb +21 -0
  56. data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_immutable/set_accessor.rb +25 -0
  57. data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_immutable.rb +15 -0
  58. data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_instance_method.rb +34 -0
  59. data/sub/eac_ruby_utils/lib/eac_ruby_utils/arguments_consumer.rb +80 -0
  60. data/sub/eac_ruby_utils/lib/eac_ruby_utils/bit.rb +47 -0
  61. data/sub/eac_ruby_utils/lib/eac_ruby_utils/bit_array.rb +81 -0
  62. data/sub/eac_ruby_utils/lib/eac_ruby_utils/blank_not_blank.rb +19 -0
  63. data/sub/eac_ruby_utils/lib/eac_ruby_utils/boolean.rb +31 -0
  64. data/sub/eac_ruby_utils/lib/eac_ruby_utils/by_reference.rb +23 -0
  65. data/sub/eac_ruby_utils/lib/eac_ruby_utils/byte.rb +106 -0
  66. data/sub/eac_ruby_utils/lib/eac_ruby_utils/byte_array.rb +36 -0
  67. data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_concern/class_setup.rb +52 -0
  68. data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +41 -0
  69. data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +20 -0
  70. data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_accessors.rb +36 -0
  71. data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_initialize.rb +39 -0
  72. data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/instance_initialize.rb +64 -0
  73. data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/super_args.rb +55 -0
  74. data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +93 -0
  75. data/sub/eac_ruby_utils/lib/eac_ruby_utils/compact.rb +32 -0
  76. data/sub/eac_ruby_utils/lib/eac_ruby_utils/compare_by.rb +28 -0
  77. data/sub/eac_ruby_utils/lib/eac_ruby_utils/context.rb +33 -0
  78. data/sub/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb +21 -0
  79. data/sub/eac_ruby_utils/lib/eac_ruby_utils/core_ext.rb +7 -0
  80. data/sub/eac_ruby_utils/lib/eac_ruby_utils/custom_format.rb +53 -0
  81. data/sub/eac_ruby_utils/lib/eac_ruby_utils/enum.rb +102 -0
  82. data/sub/eac_ruby_utils/lib/eac_ruby_utils/enumerables_methods.rb +42 -0
  83. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/base_command/append_command_options.rb +38 -0
  84. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/base_command/concat.rb +41 -0
  85. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/base_command/debugging.rb +19 -0
  86. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/base_command/execution.rb +52 -0
  87. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/base_command/extra_options.rb +28 -0
  88. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/base_command.rb +45 -0
  89. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/base_env.rb +28 -0
  90. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command/envvars.rb +27 -0
  91. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +23 -0
  92. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +67 -0
  93. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/composite_command.rb +45 -0
  94. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/executable.rb +93 -0
  95. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/execution_error.rb +8 -0
  96. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/execution_result.rb +45 -0
  97. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/file.rb +22 -0
  98. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/local_env.rb +17 -0
  99. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/process.rb +27 -0
  100. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/spawn.rb +32 -0
  101. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/dasho_options.rb +53 -0
  102. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/identity_file.rb +25 -0
  103. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/quiet.rb +24 -0
  104. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/terminal.rb +34 -0
  105. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env.rb +74 -0
  106. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs.rb +23 -0
  107. data/sub/eac_ruby_utils/lib/eac_ruby_utils/fs/clearable_directory.rb +57 -0
  108. data/sub/eac_ruby_utils/lib/eac_ruby_utils/fs/extname.rb +30 -0
  109. data/sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/directory.rb +16 -0
  110. data/sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb +34 -0
  111. data/sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp.rb +52 -0
  112. data/sub/eac_ruby_utils/lib/eac_ruby_utils/fs.rb +9 -0
  113. data/sub/eac_ruby_utils/lib/eac_ruby_utils/gems_registry/gem.rb +80 -0
  114. data/sub/eac_ruby_utils/lib/eac_ruby_utils/gems_registry.rb +34 -0
  115. data/sub/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +29 -0
  116. data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/class_methods.rb +14 -0
  117. data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/instance_methods.rb +30 -0
  118. data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/integer_list.rb +23 -0
  119. data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/item.rb +48 -0
  120. data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +129 -0
  121. data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/lists.rb +51 -0
  122. data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/string_list.rb +19 -0
  123. data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/symbol_list.rb +19 -0
  124. data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable.rb +17 -0
  125. data/sub/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb +48 -0
  126. data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales/from_all_gems.rb +4 -0
  127. data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales/from_gem.rb +47 -0
  128. data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales/module_i18n_translate.rb +74 -0
  129. data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales.rb +9 -0
  130. data/sub/eac_ruby_utils/lib/eac_ruby_utils/method_class.rb +30 -0
  131. data/sub/eac_ruby_utils/lib/eac_ruby_utils/module_ancestors_variable/base.rb +34 -0
  132. data/sub/eac_ruby_utils/lib/eac_ruby_utils/module_ancestors_variable/hash.rb +20 -0
  133. data/sub/eac_ruby_utils/lib/eac_ruby_utils/module_ancestors_variable/set.rb +19 -0
  134. data/sub/eac_ruby_utils/lib/eac_ruby_utils/module_ancestors_variable.rb +9 -0
  135. data/sub/eac_ruby_utils/lib/eac_ruby_utils/options_consumer.rb +62 -0
  136. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patch.rb +11 -0
  137. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/addressable/uri/query_value.rb +37 -0
  138. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/addressable/uri.rb +4 -0
  139. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/addressable.rb +4 -0
  140. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/class/abstract.rb +9 -0
  141. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/class/common_constructor.rb +9 -0
  142. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/class/method_class.rb +9 -0
  143. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/class/self_included_modules.rb +7 -0
  144. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/class/settings_provider.rb +10 -0
  145. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/class/static_method_class.rb +9 -0
  146. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/class.rb +4 -0
  147. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerable/boolean_combinations.rb +45 -0
  148. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerable.rb +4 -0
  149. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator/current.rb +9 -0
  150. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator/stopped.rb +14 -0
  151. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator.rb +4 -0
  152. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/hash/if_key.rb +12 -0
  153. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/hash/options_consumer.rb +10 -0
  154. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/hash/sym_keys_hash.rb +10 -0
  155. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/hash/to_struct.rb +10 -0
  156. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/hash.rb +5 -0
  157. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel/ibr.rb +10 -0
  158. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel/nyi.rb +10 -0
  159. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel.rb +4 -0
  160. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/abstract_methods.rb +10 -0
  161. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/acts_as_abstract.rb +14 -0
  162. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/acts_as_immutable.rb +10 -0
  163. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/acts_as_instance_method.rb +10 -0
  164. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/common_concern.rb +9 -0
  165. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/compare_by.rb +9 -0
  166. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/context.rb +11 -0
  167. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/i18n_translate.rb +9 -0
  168. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/immutable.rb +11 -0
  169. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/listable.rb +10 -0
  170. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/module_parent.rb +5 -0
  171. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/patch.rb +9 -0
  172. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/require_sub.rb +9 -0
  173. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/simple_cache.rb +10 -0
  174. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/speaker.rb +9 -0
  175. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module.rb +4 -0
  176. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/asserts.rb +25 -0
  177. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/call_if_proc.rb +11 -0
  178. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/compact.rb +20 -0
  179. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb +55 -0
  180. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/i18n_translate.rb +13 -0
  181. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_nil.rb +17 -0
  182. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_present.rb +19 -0
  183. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_respond.rb +22 -0
  184. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/recursive_build.rb +12 -0
  185. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_bool.rb +12 -0
  186. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_pathname.rb +15 -0
  187. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_sym_by_eac.rb +11 -0
  188. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb +15 -0
  189. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object.rb +5 -0
  190. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/assert_parent.rb +12 -0
  191. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_noext.rb +10 -0
  192. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_sub.rb +13 -0
  193. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb +16 -0
  194. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/if_exist.rb +10 -0
  195. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/mkpath_s.rb +12 -0
  196. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/parent_n.rb +11 -0
  197. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/readlink_r.rb +11 -0
  198. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/reqdir_glob.rb +13 -0
  199. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname.rb +4 -0
  200. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/regexp/if_match.rb +16 -0
  201. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/regexp/to_parser.rb +10 -0
  202. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/regexp.rb +4 -0
  203. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/string/delimited.rb +16 -0
  204. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/string/inflector.rb +11 -0
  205. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/string.rb +4 -0
  206. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/time/required_zone.rb +11 -0
  207. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/time.rb +4 -0
  208. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches.rb +4 -0
  209. data/sub/eac_ruby_utils/lib/eac_ruby_utils/recursive_builder.rb +51 -0
  210. data/sub/eac_ruby_utils/lib/eac_ruby_utils/regexp_parser.rb +39 -0
  211. data/sub/eac_ruby_utils/lib/eac_ruby_utils/require_sub/base.rb +80 -0
  212. data/sub/eac_ruby_utils/lib/eac_ruby_utils/require_sub/sub_file.rb +59 -0
  213. data/sub/eac_ruby_utils/lib/eac_ruby_utils/require_sub.rb +11 -0
  214. data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/default_setup.rb +20 -0
  215. data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup/conditionals.rb +17 -0
  216. data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup/setup_manager.rb +17 -0
  217. data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup.rb +27 -0
  218. data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup_manager.rb +49 -0
  219. data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/stub_speaker.rb +39 -0
  220. data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec.rb +9 -0
  221. data/sub/eac_ruby_utils/lib/eac_ruby_utils/ruby/command.rb +32 -0
  222. data/sub/eac_ruby_utils/lib/eac_ruby_utils/ruby/on_clean_environment.rb +71 -0
  223. data/sub/eac_ruby_utils/lib/eac_ruby_utils/ruby/on_replace_objects/replace_instance_method.rb +36 -0
  224. data/sub/eac_ruby_utils/lib/eac_ruby_utils/ruby/on_replace_objects.rb +52 -0
  225. data/sub/eac_ruby_utils/lib/eac_ruby_utils/ruby.rb +9 -0
  226. data/sub/eac_ruby_utils/lib/eac_ruby_utils/settings_provider/setting_value.rb +79 -0
  227. data/sub/eac_ruby_utils/lib/eac_ruby_utils/settings_provider.rb +50 -0
  228. data/sub/eac_ruby_utils/lib/eac_ruby_utils/simple_cache.rb +77 -0
  229. data/sub/eac_ruby_utils/lib/eac_ruby_utils/speaker/receiver.rb +64 -0
  230. data/sub/eac_ruby_utils/lib/eac_ruby_utils/speaker/sender.rb +37 -0
  231. data/sub/eac_ruby_utils/lib/eac_ruby_utils/speaker.rb +16 -0
  232. data/sub/eac_ruby_utils/lib/eac_ruby_utils/static_method_class.rb +12 -0
  233. data/sub/eac_ruby_utils/lib/eac_ruby_utils/string_delimited.rb +70 -0
  234. data/sub/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +63 -0
  235. data/sub/eac_ruby_utils/lib/eac_ruby_utils/unimplemented_method_error.rb +6 -0
  236. data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +5 -0
  237. data/sub/eac_ruby_utils/lib/eac_ruby_utils/wildcards.rb +26 -0
  238. data/sub/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +107 -0
  239. data/sub/eac_ruby_utils/lib/eac_ruby_utils.rb +6 -0
  240. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/acts_as_abstract_spec.rb +94 -0
  241. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/acts_as_immutable/array_accessor_spec.rb +43 -0
  242. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/acts_as_immutable/common_accessor_spec.rb +57 -0
  243. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/acts_as_immutable/hash_accessor_spec.rb +42 -0
  244. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/acts_as_immutable/set_accessor_spec.rb +43 -0
  245. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/arguments_consumer_spec.rb +17 -0
  246. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/bit_array_spec.rb +22 -0
  247. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/blank_not_blank_spec.rb +16 -0
  248. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/byte_spec.rb +54 -0
  249. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +65 -0
  250. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +151 -0
  251. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/compact_spec.rb +21 -0
  252. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/compare_by_spec.rb +39 -0
  253. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/custom_format_spec.rb +60 -0
  254. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/enum_spec.rb +44 -0
  255. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/enumerables_methods_spec.rb +50 -0
  256. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/envs/command/base_example.rb +97 -0
  257. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/envs/command/local_env_spec.rb +11 -0
  258. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/envs/command/ssh_env_spec.rb +17 -0
  259. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/envs/executable_spec.rb +37 -0
  260. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/envs/ssh_env_spec.rb +25 -0
  261. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/extname_spec.rb +18 -0
  262. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp/directory_spec.rb +12 -0
  263. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp_spec.rb +52 -0
  264. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb +16 -0
  265. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/listable_spec.rb +225 -0
  266. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/local_time_zone_spec.rb +17 -0
  267. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/method_class_spec.rb +46 -0
  268. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/module_ancestors_variable/hash_spec.rb +57 -0
  269. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/module_ancestors_variable/set_spec.rb +57 -0
  270. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb +80 -0
  271. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/addressable/uri/query_value_spec.rb +25 -0
  272. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/class/abstract_spec.rb +25 -0
  273. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/class/acts_as_abstract_spec.rb +14 -0
  274. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/class/method_class_spec.rb +20 -0
  275. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/class/self_included_modules_spec.rb +30 -0
  276. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/class/static_method_class_spec.rb +20 -0
  277. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerable/boolean_combinations_spec.rb +39 -0
  278. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/current_spec.rb +26 -0
  279. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb +32 -0
  280. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/hash/if_key_spec.rb +23 -0
  281. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/hash/options_consumer_spec.rb +17 -0
  282. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/hash/sym_keys_hash_spec.rb +13 -0
  283. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/compare_by_spec.rb +37 -0
  284. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/listable_spec.rb +15 -0
  285. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/simple_cache_spec.rb +15 -0
  286. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/speaker_spec.rb +15 -0
  287. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/call_if_proc_spec.rb +11 -0
  288. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/compact_spec.rb +20 -0
  289. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/if_present_spec.rb +13 -0
  290. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/recursive_build_spec.rb +62 -0
  291. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/template_spec_files/path/my_stub_with_template +1 -0
  292. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/pathname/assert_parent_spec.rb +21 -0
  293. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/pathname/basename_noext_spec.rb +26 -0
  294. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/pathname/basename_sub_spec.rb +17 -0
  295. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/pathname/child_of_spec.rb +26 -0
  296. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/pathname/parent_n_spec.rb +33 -0
  297. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/string/delimited_spec.rb +34 -0
  298. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/recursive_builder_spec.rb +65 -0
  299. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub/base_spec/stubbed_module_a.rb +6 -0
  300. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub/base_spec/stubbed_not_module.rb +6 -0
  301. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub/base_spec.rb +19 -0
  302. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/rspec/setup/setup_manager_spec.rb +17 -0
  303. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/ruby/on_clean_environment_spec.rb +31 -0
  304. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/ruby/on_replace_objects_spec.rb +65 -0
  305. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/settings_provider_spec.rb +64 -0
  306. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/simple_cache_spec.rb +129 -0
  307. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/static_method_class_spec.rb +44 -0
  308. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +57 -0
  309. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/wildcards_spec.rb +27 -0
  310. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/yaml_spec.rb +76 -0
  311. data/sub/eac_ruby_utils/spec/locales/pt-BR.yml +58 -0
  312. data/sub/eac_ruby_utils/spec/rubocop_check_spec.rb +3 -0
  313. data/sub/eac_ruby_utils/spec/spec_helper.rb +15 -0
  314. metadata +317 -37
  315. data/sub/avm-eac_rails_base1/avm-eac_rails_base1.gemspec +0 -22
  316. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/apache_base.rb +0 -16
  317. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/apache_host.rb +0 -18
  318. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/apache_path.rb +0 -21
  319. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/base.rb +0 -50
  320. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/deploy.rb +0 -23
  321. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/processes/daemon.rb +0 -39
  322. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/processes/tasks_scheduler.rb +0 -27
  323. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/processes.rb +0 -13
  324. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/runners/bundle.rb +0 -28
  325. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/runners/code_runner.rb +0 -28
  326. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/runners/log.rb +0 -45
  327. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/runners/logs/clear.rb +0 -27
  328. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/runners/logs.rb +0 -19
  329. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/runners/rails_server.rb +0 -34
  330. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/runners/tasks_scheduler/systemd_unit.rb +0 -48
  331. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/runners/tasks_scheduler.rb +0 -19
  332. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/runners.rb +0 -13
  333. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/systemd_unit/service.rb +0 -72
  334. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/systemd_unit/tasks_scheduler_command.rb +0 -31
  335. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/systemd_unit.rb +0 -59
  336. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances.rb +0 -11
  337. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner_with/bundle.rb +0 -27
  338. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner_with/rails_environment.rb +0 -47
  339. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/sources/base.rb +0 -43
  340. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/version.rb +0 -7
  341. data/sub/avm-eac_rails_base1/template/avm/eac_rails_base1/instances/apache_path/extra_content.conf +0 -5
  342. data/sub/avm-eac_rails_base1/template/avm/eac_rails_base1/instances/systemd_unit/tasks_scheduler.service +0 -12
  343. data/sub/avm-eac_rails_base1/template/avm/eac_rails_base1/instances/systemd_unit/tasks_scheduler_command.sh +0 -6
  344. /data/sub/{avm-eac_rails_base1 → eac_config}/Gemfile +0 -0
  345. /data/sub/{avm-eac_rails_base1 → eac_config}/spec/rubocop_spec.rb +0 -0
  346. /data/sub/{avm-eac_rails_base1 → eac_config}/spec/spec_helper.rb +0 -0
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/concern'
4
+ require 'eac_ruby_utils/common_concern/class_setup'
5
+ require 'eac_ruby_utils/simple_cache'
6
+ require 'eac_ruby_utils/patches/object/if_present'
7
+
8
+ module EacRubyUtils
9
+ class CommonConcern
10
+ class ModuleSetup
11
+ include ::EacRubyUtils::SimpleCache
12
+ attr_reader :a_module, :common_concern
13
+
14
+ def initialize(common_concern, a_module)
15
+ @common_concern = common_concern
16
+ @a_module = a_module
17
+ end
18
+
19
+ def run
20
+ a_module.extend(::ActiveSupport::Concern)
21
+ include_or_prepend(:included, :include)
22
+ include_or_prepend(:prepended, :prepend)
23
+ end
24
+
25
+ private
26
+
27
+ def include_or_prepend(module_method, class_setup_method)
28
+ setup = self
29
+ a_module.send(module_method, *a_module_method_args(module_method)) do
30
+ ::EacRubyUtils::CommonConcern::ClassSetup.new(setup, self, class_setup_method).run
31
+ end
32
+ end
33
+
34
+ def a_module_method_args(module_method)
35
+ method_arity = a_module.method(module_method).arity
36
+ method_arity = -method_arity - 1 if method_arity.negative?
37
+ method_arity.times.map { |_n| a_module }
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/common_concern/module_setup'
4
+
5
+ module EacRubyUtils
6
+ class CommonConcern
7
+ CLASS_METHODS_MODULE_NAME = 'ClassMethods'
8
+ INSTANCE_METHODS_MODULE_NAME = 'InstanceMethods'
9
+
10
+ attr_reader :after_callback
11
+
12
+ def initialize(&after_callback)
13
+ @after_callback = after_callback
14
+ end
15
+
16
+ def setup(a_module)
17
+ ::EacRubyUtils::CommonConcern::ModuleSetup.new(self, a_module).run
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/common_constructor/instance_initialize'
4
+ require 'eac_ruby_utils/common_constructor/super_args'
5
+
6
+ module EacRubyUtils
7
+ class CommonConstructor
8
+ class ClassAccessors
9
+ attr_reader :common_constructor, :klass
10
+
11
+ def initialize(common_constructor, klass)
12
+ @common_constructor = common_constructor
13
+ @klass = klass
14
+ end
15
+
16
+ def args
17
+ common_constructor.all_args
18
+ end
19
+
20
+ def perform
21
+ setup_class_attr_readers
22
+ setup_class_attr_writers
23
+ end
24
+
25
+ def setup_class_attr_readers
26
+ klass.send(:attr_reader, *args)
27
+ klass.send(:public, *args) if args.any?
28
+ end
29
+
30
+ def setup_class_attr_writers
31
+ klass.send(:attr_writer, *args)
32
+ klass.send(:private, *args.map { |a| "#{a}=" }) if args.any?
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/common_constructor/instance_initialize'
4
+ require 'eac_ruby_utils/common_constructor/super_args'
5
+
6
+ module EacRubyUtils
7
+ class CommonConstructor
8
+ class ClassInitialize
9
+ attr_reader :common_constructor, :klass
10
+
11
+ def initialize(common_constructor, klass)
12
+ @common_constructor = common_constructor
13
+ @klass = klass
14
+ end
15
+
16
+ def define_initialize_callbacks
17
+ klass.include(::ActiveSupport::Callbacks)
18
+ klass.define_callbacks :initialize
19
+ end
20
+
21
+ def define_initialize_method
22
+ class_initialize = self
23
+ klass.send(:define_method, :initialize) do |*args, &block|
24
+ ::EacRubyUtils::CommonConstructor::InstanceInitialize.new(
25
+ class_initialize.common_constructor, args, self, block
26
+ ).perform
27
+ super(*::EacRubyUtils::CommonConstructor::SuperArgs.new(
28
+ class_initialize, args, self
29
+ ).result)
30
+ end
31
+ end
32
+
33
+ def perform
34
+ define_initialize_callbacks
35
+ define_initialize_method
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ class CommonConstructor
5
+ class InstanceInitialize
6
+ attr_reader :common_constructor, :args, :object, :block
7
+
8
+ def initialize(common_constructor, args, object, block)
9
+ @common_constructor = common_constructor
10
+ @args = args
11
+ @object = object
12
+ @block = block
13
+ end
14
+
15
+ def perform
16
+ validate_args_count
17
+ object.run_callbacks :initialize do
18
+ object_attributes_set
19
+ object_block_set
20
+ object_after_callback
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def arg_value(arg_name)
27
+ arg_index = common_constructor.args.index(arg_name)
28
+ if arg_index < args.count
29
+ args[arg_index]
30
+ else
31
+ common_constructor.default_values[arg_index - common_constructor.args_count_min]
32
+ end
33
+ end
34
+
35
+ def object_after_callback
36
+ return unless common_constructor.after_set_block
37
+
38
+ object.instance_eval(&common_constructor.after_set_block)
39
+ end
40
+
41
+ def object_attribute_set(attr_name, attr_value)
42
+ object.send("#{attr_name}=", attr_value)
43
+ end
44
+
45
+ def object_attributes_set
46
+ common_constructor.args.each do |arg_name|
47
+ object_attribute_set(arg_name, arg_value(arg_name))
48
+ end
49
+ end
50
+
51
+ def object_block_set
52
+ block_arg = common_constructor.block_arg
53
+ object_attribute_set(block_arg, block) if block_arg
54
+ end
55
+
56
+ def validate_args_count
57
+ return if common_constructor.args_count.include?(args.count)
58
+
59
+ raise ArgumentError, "#{object.class}.initialize: wrong number of arguments " \
60
+ "(given #{args.count}, expected #{common_constructor.args_count})"
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/module/delegation'
4
+
5
+ module EacRubyUtils
6
+ class CommonConstructor
7
+ class SuperArgs
8
+ attr_reader :class_initialize, :args, :object
9
+
10
+ delegate :common_constructor, to: :class_initialize
11
+
12
+ def initialize(class_initialize, args, object)
13
+ @class_initialize = class_initialize
14
+ @args = args
15
+ @object = object
16
+ end
17
+
18
+ def auto_result
19
+ r = []
20
+ sub_args.each do |name, value|
21
+ i = super_arg_index(name)
22
+ r[i] = value if i
23
+ end
24
+ r
25
+ end
26
+
27
+ def result
28
+ result_from_options || auto_result
29
+ end
30
+
31
+ def result_from_options
32
+ return unless common_constructor.super_args
33
+
34
+ object.instance_exec(&common_constructor.super_args)
35
+ end
36
+
37
+ def sub_args
38
+ common_constructor.args.each_with_index.to_h do |name, index|
39
+ [name, args[index]]
40
+ end
41
+ end
42
+
43
+ def super_arg_index(name)
44
+ super_method.parameters.each_with_index do |arg, index|
45
+ return index if arg[1] == name
46
+ end
47
+ nil
48
+ end
49
+
50
+ def super_method
51
+ class_initialize.klass.superclass&.instance_method(:initialize)
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/callbacks'
4
+ require 'eac_ruby_utils/arguments_consumer'
5
+ require 'eac_ruby_utils/common_constructor/class_accessors'
6
+ require 'eac_ruby_utils/common_constructor/class_initialize'
7
+
8
+ module EacRubyUtils
9
+ class CommonConstructor
10
+ attr_reader :all_args, :options, :after_set_block
11
+
12
+ class << self
13
+ def parse_args_options(args)
14
+ result = ::Struct.new(:args, :options).new([], {})
15
+ options_reached = false
16
+ args.each do |arg|
17
+ raise "Options reached and there is more arguments (Arguments: #{args})" if
18
+ options_reached
19
+
20
+ options_reached = parse_arg_options_process_arg(result, arg)
21
+ end
22
+ result
23
+ end
24
+
25
+ private
26
+
27
+ def parse_arg_options_process_arg(result, arg)
28
+ if arg.is_a?(::Hash)
29
+ result.options = arg
30
+ true
31
+ else
32
+ result.args << arg
33
+ false
34
+ end
35
+ end
36
+ end
37
+
38
+ def initialize(*args, &after_set_block)
39
+ args_processed = self.class.parse_args_options(args)
40
+ @all_args = args_processed.args
41
+ @options = args_processed.options
42
+ @after_set_block = after_set_block
43
+ end
44
+
45
+ def args
46
+ block_arg? ? all_args[0..-2] : all_args
47
+ end
48
+
49
+ def args_count
50
+ (args_count_min..args_count_max)
51
+ end
52
+
53
+ def args_count_min
54
+ args.count - default_values.count
55
+ end
56
+
57
+ def args_count_max
58
+ args.count
59
+ end
60
+
61
+ def block_arg
62
+ block_arg? ? all_args.last : nil
63
+ end
64
+
65
+ def block_arg?
66
+ options[:block_arg] || false
67
+ end
68
+
69
+ def default_values
70
+ options[:default] || []
71
+ end
72
+
73
+ def setup_class(klass)
74
+ setup_class_accessors(klass)
75
+
76
+ setup_class_initialize(klass)
77
+
78
+ klass
79
+ end
80
+
81
+ def setup_class_accessors(klass)
82
+ ::EacRubyUtils::CommonConstructor::ClassAccessors.new(self, klass).perform
83
+ end
84
+
85
+ def setup_class_initialize(klass)
86
+ ::EacRubyUtils::CommonConstructor::ClassInitialize.new(self, klass).perform
87
+ end
88
+
89
+ def super_args
90
+ options[:super_args]
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ class Compact
5
+ ATTRIBUTE_SEPARATOR = '.'
6
+
7
+ attr_reader :object, :attributes
8
+
9
+ def initialize(object, attributes)
10
+ @object = object
11
+ @attributes = attributes
12
+ end
13
+
14
+ # @param attr_path [String, Symbol] A path separated by +ATTRIBUTE_SEPARATOR+.
15
+ # @return [Object]
16
+ def attribute_value(attr_path)
17
+ attr_path.to_s.split(ATTRIBUTE_SEPARATOR).inject(object) do |a, e|
18
+ a.send(e)
19
+ end
20
+ end
21
+
22
+ # @return [Array]
23
+ def to_a
24
+ attributes.map { |attr| attribute_value(attr) }
25
+ end
26
+
27
+ # @return [Hash]
28
+ def to_h
29
+ attributes.to_h { |attr| [attr.to_sym, attribute_value(attr)] }
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/common_concern/module_setup'
4
+
5
+ module EacRubyUtils
6
+ class CompareBy
7
+ attr_reader :fields
8
+
9
+ def initialize(fields)
10
+ @fields = fields
11
+ end
12
+
13
+ def apply(klass)
14
+ pself = self
15
+ klass.include(::Comparable)
16
+ %i[<=> eql?].each do |cmp_method|
17
+ klass.define_method(cmp_method) do |other|
18
+ pself.object_values(self).send(cmp_method, pself.object_values(other))
19
+ end
20
+ end
21
+ klass.define_method(:hash) { pself.object_values(self).hash }
22
+ end
23
+
24
+ def object_values(object)
25
+ fields.map { |field| object.send(field) }
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ class Context
5
+ delegate :any?, to: :stack
6
+
7
+ def current
8
+ optional_current || raise('No elements in context')
9
+ end
10
+
11
+ def optional_current
12
+ stack.last
13
+ end
14
+
15
+ delegate :pop, to: :stack
16
+ delegate :push, to: :stack
17
+
18
+ def on(obj)
19
+ push(obj)
20
+ begin
21
+ yield
22
+ ensure
23
+ pop
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def stack
30
+ @stack ||= []
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/context'
4
+
5
+ module EacRubyUtils
6
+ module Contextualizable
7
+ common_concern
8
+
9
+ module ClassMethods
10
+ def context
11
+ @context ||= ::EacRubyUtils::Context.new
12
+ end
13
+ end
14
+
15
+ module InstanceMethods
16
+ def context
17
+ self.class.context
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/locales/from_all_gems'
4
+ require 'eac_ruby_utils/patches'
5
+ require 'active_support/dependencies/autoload'
6
+ require 'active_support/core_ext'
7
+ require 'active_support/json'
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ # A formatter like [String.sprintf].
5
+ class CustomFormat
6
+ TYPE_PATTERN = /[a-zA-Z]/.freeze
7
+ SEQUENCE_PATTERN = /(?<!%)%(#{TYPE_PATTERN})/.freeze
8
+
9
+ attr_reader :mapping
10
+
11
+ def initialize(mapping)
12
+ @mapping = mapping.transform_keys(&:to_sym).freeze
13
+ end
14
+
15
+ def format(string)
16
+ ::EacRubyUtils::CustomFormat::String.new(self, string)
17
+ end
18
+
19
+ class String
20
+ attr_reader :format, :string
21
+
22
+ def initialize(format, string)
23
+ @format = format
24
+ @string = string
25
+ end
26
+
27
+ def mapping
28
+ @mapping ||= format.mapping.select do |k, _v|
29
+ sequences.include?(k)
30
+ end
31
+ end
32
+
33
+ def sequences
34
+ @sequences ||= string.scan(SEQUENCE_PATTERN).map(&:first).uniq.map(&:to_sym)
35
+ end
36
+
37
+ def source_object_value(object, method)
38
+ return object.send(method) if object.respond_to?(method)
39
+ return object[method] if object.respond_to?('[]')
40
+
41
+ raise ::ArgumentError, "Methods \"#{method}\" or \"[]\" not found for #{object}"
42
+ end
43
+
44
+ def with(source_object)
45
+ r = string
46
+ mapping.each do |key, method|
47
+ r = r.gsub(/%#{::Regexp.quote(key)}/, source_object_value(source_object, method).to_s)
48
+ end
49
+ r.gsub('%%', '%')
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/inflector'
4
+
5
+ module EacRubyUtils
6
+ # Similar to Java's enum type (https://docs.oracle.com/javase/tutorial/java/javaOO/enum.html).
7
+ class Enum
8
+ class << self
9
+ def enum(key, *args, &block)
10
+ value = Value.new(self, key, args, &block)
11
+ raise ::ArgumentError, "#{self} already has a value with key=#{value.key}" if
12
+ value_set.include?(value)
13
+
14
+ value_set << value.apply
15
+
16
+ self
17
+ end
18
+
19
+ def values
20
+ value_set.map(&:value)
21
+ end
22
+
23
+ private
24
+
25
+ def value_set
26
+ @value_set ||= []
27
+ end
28
+ end
29
+
30
+ attr_reader :key
31
+
32
+ protected
33
+
34
+ def initialize(key)
35
+ @key = key
36
+ end
37
+
38
+ class Value
39
+ include ::Comparable
40
+
41
+ attr_reader :klass, :key, :args, :block
42
+
43
+ def initialize(klass, key, args, &block)
44
+ @klass = klass
45
+ @key = ::EacRubyUtils::Inflector.variableize(key.to_s).to_sym
46
+ @args = args
47
+ @block = block
48
+ end
49
+
50
+ def <=>(other)
51
+ key <=> other.key
52
+ end
53
+
54
+ def apply
55
+ define_constant
56
+ define_class_method
57
+
58
+ self
59
+ end
60
+
61
+ # @return [String]
62
+ def class_method_name
63
+ key.to_s
64
+ end
65
+
66
+ # @return [String]
67
+ def constant_name
68
+ class_method_name.upcase
69
+ end
70
+
71
+ def value
72
+ @value ||= uncached_value
73
+ end
74
+
75
+ private
76
+
77
+ def define_class_method
78
+ the_value = self
79
+ klass.define_singleton_method(class_method_name) { the_value.value }
80
+ end
81
+
82
+ def define_constant
83
+ klass.const_set(constant_name, value)
84
+ end
85
+
86
+ def uncached_value
87
+ klass.new(key, *value_args)
88
+ end
89
+
90
+ def value_args
91
+ r = if block
92
+ block.call
93
+ elsif args.count == 1 && args.first.is_a?(::Enumerable)
94
+ args.first
95
+ else
96
+ args
97
+ end
98
+ r.is_a?(::Enumerable) ? r : [r]
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patches/object/debug'
4
+
5
+ module EacRubyUtils
6
+ module EnumerablesMethods
7
+ class << self
8
+ WRITE_METHOD_PATTERNS = [/\A[a-z].*[\!\=]\z/i] +
9
+ %i[\[\]= <<].map { |m| /\A#{::Regexp.quote(m)}\z/ } +
10
+ %i[add clear delete divide keep reset shift subtract]
11
+ .map { |m| /\A#{::Regexp.quote(m)}.*\z/ }
12
+
13
+ # @param klass [Klass]
14
+ # @return [Enumerable<Symbol>]
15
+ def self_methods_names(klass)
16
+ (klass.public_instance_methods - klass.superclass.public_instance_methods).sort
17
+ end
18
+
19
+ # @param method_name [Symbol]
20
+ # @return [Boolean]
21
+ def write_method?(method_name)
22
+ WRITE_METHOD_PATTERNS.any? { |pattern| pattern.match?(method_name.to_s) }
23
+ end
24
+ end
25
+
26
+ ARRAY_METHODS = self_methods_names(::Array)
27
+ ARRAY_WRITE_METHODS = ARRAY_METHODS.select { |m| write_method?(m) }
28
+ ARRAY_READ_METHODS = ARRAY_METHODS - ARRAY_WRITE_METHODS
29
+
30
+ ENUMERABLE_METHODS = ::Enumerable.public_instance_methods.sort
31
+ ENUMERABLE_WRITE_METHODS = ENUMERABLE_METHODS.select { |m| write_method?(m) }
32
+ ENUMERABLE_READ_METHODS = ENUMERABLE_METHODS - ENUMERABLE_WRITE_METHODS
33
+
34
+ HASH_METHODS = self_methods_names(::Hash)
35
+ HASH_WRITE_METHODS = HASH_METHODS.select { |m| write_method?(m) }
36
+ HASH_READ_METHODS = HASH_METHODS - HASH_WRITE_METHODS
37
+
38
+ SET_METHODS = self_methods_names(::Set)
39
+ SET_WRITE_METHODS = SET_METHODS.select { |m| write_method?(m) } + [:merge]
40
+ SET_READ_METHODS = SET_METHODS - SET_WRITE_METHODS
41
+ end
42
+ end