eac_tools 0.3.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (258) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +42 -30
  3. data/lib/eac_tools/version.rb +1 -1
  4. data/sub/avm/lib/avm/sources/base/configuration.rb +14 -6
  5. data/sub/avm/lib/avm/sources/base/testing.rb +50 -7
  6. data/sub/avm/lib/avm/sources/tests/builder.rb +19 -1
  7. data/sub/avm/lib/avm/sources/tests/single.rb +28 -9
  8. data/sub/avm/lib/avm/version.rb +1 -1
  9. data/sub/avm-eac_generic_base0/Gemfile +3 -0
  10. data/sub/avm-eac_generic_base0/avm-eac_generic_base0.gemspec +3 -3
  11. data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/base.rb +0 -6
  12. data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/version.rb +1 -1
  13. data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/Gemfile +0 -0
  14. data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/avm-eac_rails_base0.gemspec +0 -0
  15. data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/lib/avm/eac_rails_base0/apache_host.rb +0 -0
  16. data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/lib/avm/eac_rails_base0/apache_path.rb +0 -0
  17. data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/lib/avm/eac_rails_base0/deploy.rb +0 -0
  18. data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/lib/avm/eac_rails_base0/instance.rb +0 -0
  19. data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/lib/avm/eac_rails_base0/runners/base.rb +0 -0
  20. data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/lib/avm/eac_rails_base0/runners.rb +0 -0
  21. data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/lib/avm/eac_rails_base0/sources/base.rb +14 -1
  22. data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/lib/avm/eac_rails_base0/version.rb +1 -1
  23. data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/lib/avm/eac_rails_base0.rb +0 -0
  24. data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/spec/lib/avm/eac_rails_base0/apache_host_spec.rb +0 -0
  25. data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/spec/lib/avm/eac_rails_base0/apache_host_spec_files/apache_host_spec_no_ssl_content.conf +0 -0
  26. data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/spec/lib/avm/eac_rails_base0/apache_path_spec.rb +0 -0
  27. data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/spec/lib/avm/eac_rails_base0/apache_path_spec_files/stub-app_0_apache_path.conf +0 -0
  28. data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/spec/rubocop_spec.rb +0 -0
  29. data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/spec/spec_helper.rb +0 -0
  30. data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/template/avm/eac_rails_base0/apache_path/extra_content.conf +0 -0
  31. data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/template/avm/eac_rails_base0/deploy/config/database.yml.template +0 -0
  32. data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/template/avm/eac_rails_base0/deploy/config/envvars.d/email.yml.template +0 -0
  33. data/sub/avm-eac_rails_base1/Gemfile +3 -0
  34. data/sub/avm-eac_rails_base1/avm-eac_rails_base1.gemspec +2 -2
  35. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/sources/base.rb +16 -0
  36. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/version.rb +1 -1
  37. data/sub/avm-eac_redmine_base0/Gemfile +3 -0
  38. data/sub/avm-eac_redmine_base0/avm-eac_redmine_base0.gemspec +6 -6
  39. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/base.rb +8 -0
  40. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
  41. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base.rb +18 -8
  42. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/version.rb +1 -1
  43. data/sub/avm-tools/Gemfile.lock +24 -28
  44. data/sub/avm-tools/lib/avm/tools/version.rb +1 -1
  45. data/sub/eac_ruby_utils/Gemfile +16 -0
  46. data/sub/eac_ruby_utils/MIT-LICENCE +16 -0
  47. data/sub/eac_ruby_utils/README.rdoc +3 -0
  48. data/sub/eac_ruby_utils/eac_ruby_utils.gemspec +24 -0
  49. data/sub/eac_ruby_utils/lib/eac_ruby_utils/abstract_methods.rb +68 -0
  50. data/sub/eac_ruby_utils/lib/eac_ruby_utils/arguments_consumer.rb +81 -0
  51. data/sub/eac_ruby_utils/lib/eac_ruby_utils/bit.rb +46 -0
  52. data/sub/eac_ruby_utils/lib/eac_ruby_utils/bit_array.rb +81 -0
  53. data/sub/eac_ruby_utils/lib/eac_ruby_utils/blank_not_blank.rb +19 -0
  54. data/sub/eac_ruby_utils/lib/eac_ruby_utils/boolean.rb +31 -0
  55. data/sub/eac_ruby_utils/lib/eac_ruby_utils/by_reference.rb +23 -0
  56. data/sub/eac_ruby_utils/lib/eac_ruby_utils/byte.rb +105 -0
  57. data/sub/eac_ruby_utils/lib/eac_ruby_utils/byte_array.rb +36 -0
  58. data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_concern/class_setup.rb +52 -0
  59. data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +41 -0
  60. data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +20 -0
  61. data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_initialize.rb +29 -0
  62. data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/instance_initialize.rb +53 -0
  63. data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/super_args.rb +54 -0
  64. data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +89 -0
  65. data/sub/eac_ruby_utils/lib/eac_ruby_utils/compact.rb +22 -0
  66. data/sub/eac_ruby_utils/lib/eac_ruby_utils/compare_by.rb +28 -0
  67. data/sub/eac_ruby_utils/lib/eac_ruby_utils/context.rb +33 -0
  68. data/sub/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb +21 -0
  69. data/sub/eac_ruby_utils/lib/eac_ruby_utils/core_ext.rb +7 -0
  70. data/sub/eac_ruby_utils/lib/eac_ruby_utils/custom_format.rb +53 -0
  71. data/sub/eac_ruby_utils/lib/eac_ruby_utils/enum.rb +102 -0
  72. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/base_env.rb +28 -0
  73. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command/concat.rb +33 -0
  74. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command/envvars.rb +24 -0
  75. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +33 -0
  76. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +172 -0
  77. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/executable.rb +81 -0
  78. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/file.rb +22 -0
  79. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/local_env.rb +17 -0
  80. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/process.rb +27 -0
  81. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/spawn.rb +32 -0
  82. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/dasho_options.rb +53 -0
  83. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/identity_file.rb +25 -0
  84. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/quiet.rb +24 -0
  85. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/terminal.rb +34 -0
  86. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env.rb +75 -0
  87. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs.rb +23 -0
  88. data/sub/eac_ruby_utils/lib/eac_ruby_utils/fs/clearable_directory.rb +57 -0
  89. data/sub/eac_ruby_utils/lib/eac_ruby_utils/fs/extname.rb +30 -0
  90. data/sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/directory.rb +16 -0
  91. data/sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb +34 -0
  92. data/sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp.rb +52 -0
  93. data/sub/eac_ruby_utils/lib/eac_ruby_utils/fs.rb +9 -0
  94. data/sub/eac_ruby_utils/lib/eac_ruby_utils/gems_registry/gem.rb +79 -0
  95. data/sub/eac_ruby_utils/lib/eac_ruby_utils/gems_registry.rb +35 -0
  96. data/sub/eac_ruby_utils/lib/eac_ruby_utils/immutable/array_accessor.rb +32 -0
  97. data/sub/eac_ruby_utils/lib/eac_ruby_utils/immutable/base_accessor.rb +23 -0
  98. data/sub/eac_ruby_utils/lib/eac_ruby_utils/immutable/boolean_accessor.rb +16 -0
  99. data/sub/eac_ruby_utils/lib/eac_ruby_utils/immutable/class_methods.rb +20 -0
  100. data/sub/eac_ruby_utils/lib/eac_ruby_utils/immutable/common_accessor.rb +30 -0
  101. data/sub/eac_ruby_utils/lib/eac_ruby_utils/immutable/hash_accessor.rb +46 -0
  102. data/sub/eac_ruby_utils/lib/eac_ruby_utils/immutable/instance_methods.rb +21 -0
  103. data/sub/eac_ruby_utils/lib/eac_ruby_utils/immutable.rb +15 -0
  104. data/sub/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +29 -0
  105. data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/class_methods.rb +14 -0
  106. data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/instance_methods.rb +30 -0
  107. data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/integer_list.rb +23 -0
  108. data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +111 -0
  109. data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/lists.rb +59 -0
  110. data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/string_list.rb +19 -0
  111. data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/symbol_list.rb +19 -0
  112. data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb +49 -0
  113. data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable.rb +17 -0
  114. data/sub/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb +48 -0
  115. data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales/from_all_gems.rb +4 -0
  116. data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales/from_gem.rb +47 -0
  117. data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales/module_i18n_translate.rb +74 -0
  118. data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales.rb +9 -0
  119. data/sub/eac_ruby_utils/lib/eac_ruby_utils/method_class.rb +35 -0
  120. data/sub/eac_ruby_utils/lib/eac_ruby_utils/options_consumer.rb +62 -0
  121. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patch.rb +11 -0
  122. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/class/abstract.rb +9 -0
  123. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/class/common_constructor.rb +9 -0
  124. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/class/self_included_modules.rb +7 -0
  125. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/class/settings_provider.rb +10 -0
  126. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/class.rb +4 -0
  127. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerable/boolean_combinations.rb +45 -0
  128. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerable.rb +4 -0
  129. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator/current.rb +9 -0
  130. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator/stopped.rb +14 -0
  131. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator.rb +4 -0
  132. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/hash/options_consumer.rb +10 -0
  133. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/hash/sym_keys_hash.rb +10 -0
  134. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/hash/to_struct.rb +10 -0
  135. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/hash.rb +5 -0
  136. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel/nyi.rb +10 -0
  137. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel.rb +4 -0
  138. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/abstract_methods.rb +10 -0
  139. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/common_concern.rb +9 -0
  140. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/compare_by.rb +9 -0
  141. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/context.rb +11 -0
  142. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/i18n_translate.rb +9 -0
  143. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/immutable.rb +10 -0
  144. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/listable.rb +10 -0
  145. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/method_class.rb +9 -0
  146. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/patch.rb +9 -0
  147. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/require_sub.rb +9 -0
  148. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/simple_cache.rb +10 -0
  149. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/speaker.rb +9 -0
  150. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module.rb +4 -0
  151. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/asserts.rb +25 -0
  152. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/call_if_proc.rb +11 -0
  153. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/compact.rb +20 -0
  154. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb +23 -0
  155. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/i18n_translate.rb +13 -0
  156. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_nil.rb +17 -0
  157. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_present.rb +19 -0
  158. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_respond.rb +22 -0
  159. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_pathname.rb +15 -0
  160. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb +15 -0
  161. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object.rb +5 -0
  162. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_noext.rb +10 -0
  163. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_sub.rb +9 -0
  164. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/if_exist.rb +10 -0
  165. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/mkpath_s.rb +12 -0
  166. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/parent_n.rb +11 -0
  167. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/readlink_r.rb +11 -0
  168. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/reqdir_glob.rb +13 -0
  169. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname.rb +4 -0
  170. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/regexp/if_match.rb +16 -0
  171. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/regexp/to_parser.rb +10 -0
  172. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/regexp.rb +4 -0
  173. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/string/delimited.rb +16 -0
  174. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/string/inflector.rb +11 -0
  175. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/string.rb +4 -0
  176. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/time/required_zone.rb +11 -0
  177. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/time.rb +4 -0
  178. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches.rb +4 -0
  179. data/sub/eac_ruby_utils/lib/eac_ruby_utils/recursive_builder.rb +51 -0
  180. data/sub/eac_ruby_utils/lib/eac_ruby_utils/regexp_parser.rb +34 -0
  181. data/sub/eac_ruby_utils/lib/eac_ruby_utils/require_sub.rb +134 -0
  182. data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/default_setup.rb +20 -0
  183. data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup/conditionals.rb +17 -0
  184. data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup.rb +12 -0
  185. data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup_manager.rb +49 -0
  186. data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/stub_speaker.rb +39 -0
  187. data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec.rb +9 -0
  188. data/sub/eac_ruby_utils/lib/eac_ruby_utils/ruby/command.rb +32 -0
  189. data/sub/eac_ruby_utils/lib/eac_ruby_utils/ruby/on_clean_environment.rb +38 -0
  190. data/sub/eac_ruby_utils/lib/eac_ruby_utils/ruby.rb +9 -0
  191. data/sub/eac_ruby_utils/lib/eac_ruby_utils/settings_provider/setting_value.rb +69 -0
  192. data/sub/eac_ruby_utils/lib/eac_ruby_utils/settings_provider.rb +46 -0
  193. data/sub/eac_ruby_utils/lib/eac_ruby_utils/simple_cache.rb +77 -0
  194. data/sub/eac_ruby_utils/lib/eac_ruby_utils/speaker/receiver.rb +64 -0
  195. data/sub/eac_ruby_utils/lib/eac_ruby_utils/speaker/sender.rb +32 -0
  196. data/sub/eac_ruby_utils/lib/eac_ruby_utils/speaker.rb +16 -0
  197. data/sub/eac_ruby_utils/lib/eac_ruby_utils/string_delimited.rb +70 -0
  198. data/sub/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +63 -0
  199. data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +5 -0
  200. data/sub/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +105 -0
  201. data/sub/eac_ruby_utils/lib/eac_ruby_utils.rb +6 -0
  202. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/abstract_methods_spec.rb +28 -0
  203. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/arguments_consumer_spec.rb +17 -0
  204. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/bit_array_spec.rb +22 -0
  205. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/blank_not_blank_spec.rb +16 -0
  206. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/byte_spec.rb +54 -0
  207. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +65 -0
  208. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +125 -0
  209. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/compact_spec.rb +20 -0
  210. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/compare_by_spec.rb +38 -0
  211. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/custom_format_spec.rb +60 -0
  212. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/enum_spec.rb +43 -0
  213. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/envs/executable_spec.rb +37 -0
  214. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/envs/ssh_env_spec.rb +25 -0
  215. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/extname_spec.rb +18 -0
  216. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp/directory_spec.rb +12 -0
  217. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp_spec.rb +52 -0
  218. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb +16 -0
  219. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/listable_spec.rb +275 -0
  220. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/local_time_zone_spec.rb +17 -0
  221. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/method_class_spec.rb +46 -0
  222. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb +80 -0
  223. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/class/abstract_spec.rb +25 -0
  224. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/class/self_included_modules_spec.rb +30 -0
  225. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerable/boolean_combinations_spec.rb +39 -0
  226. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/current_spec.rb +26 -0
  227. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb +32 -0
  228. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/hash/options_consumer_spec.rb +17 -0
  229. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/hash/sym_keys_hash_spec.rb +13 -0
  230. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/compare_by_spec.rb +36 -0
  231. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/listable_spec.rb +15 -0
  232. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/method_class_spec.rb +20 -0
  233. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/simple_cache_spec.rb +15 -0
  234. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/speaker_spec.rb +13 -0
  235. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/call_if_proc_spec.rb +11 -0
  236. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/compact_spec.rb +20 -0
  237. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/if_present_spec.rb +13 -0
  238. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/template_spec_files/path/my_stub_with_template +1 -0
  239. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/pathname/basename_noext_spec.rb +26 -0
  240. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/pathname/basename_sub_spec.rb +17 -0
  241. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/pathname/parent_n_spec.rb +33 -0
  242. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/string/delimited_spec.rb +34 -0
  243. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/recursive_builder_spec.rb +65 -0
  244. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub_spec/stubbed_module_a.rb +6 -0
  245. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub_spec/stubbed_not_module.rb +6 -0
  246. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub_spec.rb +19 -0
  247. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/ruby_spec.rb +22 -0
  248. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/settings_provider_spec.rb +57 -0
  249. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/simple_cache_spec.rb +129 -0
  250. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +57 -0
  251. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/yaml_spec.rb +75 -0
  252. data/sub/eac_ruby_utils/spec/locales/pt-BR.yml +58 -0
  253. data/sub/eac_ruby_utils/spec/rubocop_check_spec.rb +3 -0
  254. data/sub/eac_ruby_utils/spec/spec_helper.rb +15 -0
  255. metadata +257 -48
  256. data/sub/avm/lib/avm/sources/tester.rb +0 -24
  257. data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/tester.rb +0 -56
  258. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/tester.rb +0 -36
@@ -3,7 +3,6 @@
3
3
  require 'avm/eac_generic_base0/sources/base'
4
4
  require 'avm/eac_ruby_base1/rubygems/version_file'
5
5
  require 'avm/eac_ruby_base1/sources/update'
6
- require 'avm/eac_ruby_base1/sources/tester'
7
6
  require 'avm/eac_ruby_base1/sources/runners/bundler'
8
7
  require 'avm/version_number'
9
8
  require 'eac_ruby_utils/core_ext'
@@ -12,11 +11,22 @@ module Avm
12
11
  module EacRubyBase1
13
12
  module Sources
14
13
  class Base < ::Avm::EacGenericBase0::Sources::Base
15
- require_sub __FILE__, include_modules: :prepend, require_dependency: true
14
+ RSPEC_TEST_COMMAND = 'rspec'
15
+
16
+ require_sub __FILE__, include_modules: :prepend
17
+
18
+ # @return [Hash<String, EacRubyUtils::Envs::Command>]
19
+ def default_test_commands
20
+ {
21
+ RSPEC_TEST_COMMAND => rspec_test_command
22
+ }
23
+ end
16
24
 
17
25
  # To-do: dismiss this method at Avm::EacRailsBase1::Instance and remove.
18
26
  # @return [EacRubyUtils::Envs::BaseEnv]
19
- attr_reader :env
27
+ def env
28
+ @env.presence || super
29
+ end
20
30
 
21
31
  # To-do: dismiss this method at Avm::EacRailsBase1::Instance and remove.
22
32
  # @return [Avm::EacRubyBase1::Sources::Base]
@@ -26,13 +36,13 @@ module Avm
26
36
  self
27
37
  end
28
38
 
29
- def valid?
30
- gemfile_path.exist? || gemspec_path.present?
39
+ # @return [EacRubyUtils::Envs::Command]
40
+ def rspec_test_command
41
+ bundle('exec', 'rspec', '--fail-fast').chdir_root
31
42
  end
32
43
 
33
- # @return [Avm::EacRubyBase1::Sources::Tester]
34
- def tester_class
35
- Avm::EacRubyBase1::Sources::Tester
44
+ def valid?
45
+ gemfile_path.exist? || gemspec_path.present?
36
46
  end
37
47
 
38
48
  def update
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacRubyBase1
5
- VERSION = '0.8.2'
5
+ VERSION = '0.9.1'
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avm-tools (0.121.1)
4
+ avm-tools (0.121.2)
5
5
  aranha-parsers (~> 0.4)
6
6
  avm (~> 0.22)
7
7
  avm-eac_asciidoctor_base0 (~> 0.3, >= 0.3.4)
@@ -34,13 +34,6 @@ PATH
34
34
  avm (~> 0.12, >= 0.12.1)
35
35
  eac_ruby_utils (~> 0.82)
36
36
 
37
- PATH
38
- remote: sub/avm-eac_rails_base0
39
- specs:
40
- avm-eac_rails_base0 (0.4.1)
41
- avm-eac_rails_base1 (~> 0.3)
42
- eac_ruby_utils (~> 0.80, >= 0.80.2)
43
-
44
37
  PATH
45
38
  remote: sub/avm-eac_ubuntu_base0
46
39
  specs:
@@ -103,7 +96,7 @@ PATH
103
96
  GEM
104
97
  remote: https://rubygems.org/
105
98
  specs:
106
- activesupport (6.1.6)
99
+ activesupport (6.1.6.1)
107
100
  concurrent-ruby (~> 1.0, >= 1.0.2)
108
101
  i18n (>= 1.6, < 2)
109
102
  minitest (>= 5.1)
@@ -122,8 +115,8 @@ GEM
122
115
  ofx-parser (~> 1.1.0)
123
116
  asciidoctor (2.0.17)
124
117
  ast (2.4.2)
125
- avm (0.22.0)
126
- eac_cli (~> 0.23, >= 0.23.1)
118
+ avm (0.24.0)
119
+ eac_cli (~> 0.27, >= 0.27.6)
127
120
  eac_docker (~> 0.3)
128
121
  eac_git (~> 0.6)
129
122
  eac_ruby_utils (~> 0.95)
@@ -131,24 +124,27 @@ GEM
131
124
  filesize (~> 0.2)
132
125
  htmlbeautifier (~> 1.3, >= 1.3.1)
133
126
  minitar (~> 0.9)
134
- avm-eac_generic_base0 (0.2.0)
135
- avm (~> 0.19)
136
- eac_ruby_utils (~> 0.80)
137
- avm-eac_rails_base1 (0.3.1)
127
+ avm-eac_generic_base0 (0.3.0)
128
+ avm (~> 0.24)
129
+ eac_ruby_utils (~> 0.05, >= 0.95.2)
130
+ avm-eac_rails_base0 (0.4.1)
131
+ avm-eac_rails_base1 (~> 0.3)
132
+ eac_ruby_utils (~> 0.80, >= 0.80.2)
133
+ avm-eac_rails_base1 (0.3.2)
138
134
  avm-eac_ruby_base1 (~> 0.8)
139
135
  avm-eac_webapp_base0 (~> 0.3)
140
136
  eac_ruby_utils (~> 0.95, >= 0.95.1)
141
- avm-eac_redmine_base0 (0.6.1)
137
+ avm-eac_redmine_base0 (0.8.0)
142
138
  avm-eac_rails_base1 (~> 0.3)
143
139
  avm-eac_ubuntu_base0 (~> 0.2)
144
140
  curb (~> 0.9.10)
145
141
  eac_fs (~> 0.4)
146
142
  eac_rest (~> 0.4)
147
143
  eac_ruby_utils (~> 0.68)
148
- avm-eac_ruby_base1 (0.8.1)
149
- avm (~> 0.22)
144
+ avm-eac_ruby_base1 (0.9.0)
145
+ avm (~> 0.23)
150
146
  avm-eac_generic_base0 (~> 0.2)
151
- eac_ruby_utils (~> 0.80)
147
+ eac_ruby_utils (~> 0.95, >= 0.95.1)
152
148
  avm-eac_webapp_base0 (0.3.0)
153
149
  avm (~> 0.1)
154
150
  avm-eac_generic_base0 (~> 0.1)
@@ -158,15 +154,15 @@ GEM
158
154
  clipboard (1.3.6)
159
155
  colorize (0.8.1)
160
156
  concurrent-ruby (1.1.10)
161
- content-type (0.0.1)
162
- parslet (~> 1.5)
157
+ content-type (0.0.2)
158
+ parslet (~> 2.0)
163
159
  curb (0.9.11)
164
160
  diff-lcs (1.5.0)
165
- eac_cli (0.27.5)
161
+ eac_cli (0.27.6)
166
162
  colorize (~> 0.8.1)
167
163
  eac_config (~> 0.8)
168
164
  eac_ruby_utils (~> 0.95)
169
- eac_fs (0.12.1)
165
+ eac_fs (0.12.2)
170
166
  content-type
171
167
  eac_ruby_utils (~> 0.70)
172
168
  ruby-filemagic
@@ -181,9 +177,10 @@ GEM
181
177
  rubocop (~> 0.80.1)
182
178
  rubocop-rails (~> 2.4.2)
183
179
  rubocop-rspec (~> 1.38.1)
184
- eac_ruby_utils (0.95.1)
180
+ eac_ruby_utils (0.95.2)
185
181
  activesupport (>= 4, < 7)
186
182
  addressable (~> 2.6)
183
+ bundler
187
184
  filesize
188
185
  net-ssh (~> 4.2)
189
186
  faraday (1.10.0)
@@ -219,14 +216,14 @@ GEM
219
216
  rchardet (~> 1.8)
220
217
  hpricot (0.8.6)
221
218
  htmlbeautifier (1.4.2)
222
- i18n (1.10.0)
219
+ i18n (1.12.0)
223
220
  concurrent-ruby (~> 1.0)
224
221
  jaro_winkler (1.5.4)
225
222
  minitar (0.9)
226
223
  minitest (5.16.2)
227
224
  multipart-post (2.2.3)
228
225
  net-ssh (4.2.0)
229
- nokogiri (1.13.6-x86_64-linux)
226
+ nokogiri (1.13.7-x86_64-linux)
230
227
  racc (~> 1.4)
231
228
  ofx-parser (1.1.0)
232
229
  hpricot (>= 0.6)
@@ -235,7 +232,7 @@ GEM
235
232
  parseconfig (1.1.2)
236
233
  parser (3.1.2.0)
237
234
  ast (~> 2.4.1)
238
- parslet (1.8.2)
235
+ parslet (2.0.0)
239
236
  public_suffix (4.0.7)
240
237
  racc (1.6.0)
241
238
  rack (2.2.4)
@@ -284,7 +281,6 @@ PLATFORMS
284
281
  DEPENDENCIES
285
282
  avm-eac_asciidoctor_base0!
286
283
  avm-eac_postgresql_base0!
287
- avm-eac_rails_base0!
288
284
  avm-eac_ubuntu_base0!
289
285
  avm-files!
290
286
  avm-git!
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.121.1'
5
+ VERSION = '0.121.2'
6
6
  end
7
7
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Declare your gem's dependencies in users_support.gemspec.
6
+ # Bundler will treat runtime dependencies like base dependencies, and
7
+ # development dependencies will be added by default to the :development group.
8
+ gemspec
9
+
10
+ # Declare any dependencies that are still in development here instead of in
11
+ # your gemspec. These might include edge Rails or gems from your path or
12
+ # Git. Remember to move these dependencies to your gemspec before releasing
13
+ # your gem to rubygems.org.
14
+
15
+ # To use a debugger
16
+ # gem 'byebug', group: [:development, :test]
@@ -0,0 +1,16 @@
1
+ Copyright 2018 Eduardo Henrique Bogoni <eduardobogoni@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
4
+ associated documentation files (the "Software"), to deal in the Software without restriction,
5
+ including without limitation the rights to use, copy, modify, merge, publish, distribute,
6
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
7
+ furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or substantial
10
+ portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
13
+ NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
15
+ OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ = E.A.C. Ruby Utilities
2
+
3
+ Utilities for E.A.C.'s Ruby projects.
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
+
5
+ # Maintain your gem's version:
6
+ require 'eac_ruby_utils/version'
7
+
8
+ # Describe your gem and declare its dependencies:
9
+ Gem::Specification.new do |s|
10
+ s.name = 'eac_ruby_utils'
11
+ s.version = ::EacRubyUtils::VERSION
12
+ s.authors = ['Esquilo Azul Company']
13
+ s.summary = 'Utilities for E.A.C.\'s Ruby projects.'
14
+ s.license = 'MIT'
15
+
16
+ s.files = Dir['{lib}/**/*', 'MIT-LICENSE', 'README.rdoc']
17
+
18
+ s.add_dependency 'activesupport', '>= 4', '< 7'
19
+ s.add_dependency 'addressable', '~> 2.6'
20
+ s.add_dependency 'bundler'
21
+ s.add_dependency 'filesize'
22
+ s.add_dependency 'net-ssh', '~> 4.2'
23
+ s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5.1'
24
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patches/class/self_included_modules'
4
+ require 'eac_ruby_utils/patches/module/common_concern'
5
+
6
+ module EacRubyUtils
7
+ # Support to abstract methods.
8
+ #
9
+ # Usage:
10
+ #
11
+ # require 'eac_ruby_utils/abstract_methods'
12
+ #
13
+ # class BaseClass
14
+ # include EacRubyUtils::AbstractMethods
15
+ #
16
+ # abstract_methods :mymethod
17
+ # end
18
+ #
19
+ # BaseClass.new.mymethod # raise "Abstract method: mymethod"
20
+ #
21
+ # class SubClass
22
+ # def mymethod
23
+ # "Implemented"
24
+ # end
25
+ # end
26
+ #
27
+ # SubClass.new.mymethod # return "Implemented"
28
+ module AbstractMethods
29
+ common_concern
30
+
31
+ class << self
32
+ def abstract?(a_class)
33
+ a_class.self_included_modules.include?(::EacRubyUtils::AbstractMethods)
34
+ end
35
+ end
36
+
37
+ module ClassMethods
38
+ def abstract_methods(*methods_names)
39
+ methods_names.each do |method_name|
40
+ define_method method_name do
41
+ raise_abstract_method(method_name)
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ module InstanceMethods
48
+ def respond_to_missing?(method_name, include_private = false)
49
+ super || abstract_method?(method_name)
50
+ end
51
+
52
+ def method_missing(method_name, *arguments, &block)
53
+ raise_abstract_method(method_name) if abstract_method?(method_name)
54
+
55
+ super
56
+ end
57
+
58
+ def abstract_method?(method_name)
59
+ self.class.abstract_methods.include?(method_name.to_sym)
60
+ end
61
+
62
+ def raise_abstract_method(method_name)
63
+ raise ::NoMethodError, "Abstract method \"#{method_name}\" hit in \"#{self}\"" \
64
+ " (Class: #{self.class})"
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/hash_with_indifferent_access'
4
+ require 'ostruct'
5
+
6
+ module EacRubyUtils
7
+ class ArgumentsConsumer
8
+ class << self
9
+ def parse(args, positional = [], options = {})
10
+ new(args, positional, options).data
11
+ end
12
+ end
13
+
14
+ attr_reader :positional, :default_options
15
+
16
+ def initialize(positional, default_options)
17
+ @positional = positional.dup.freeze
18
+ @default_options = default_options.dup.freeze
19
+ end
20
+
21
+ def parse(args)
22
+ Parser.new(self, args).data
23
+ end
24
+
25
+ class Parser
26
+ attr_reader :data, :arguments_consumer
27
+
28
+ def initialize(arguments_consumer, args)
29
+ @arguments_consumer = arguments_consumer
30
+ @data = ::ActiveSupport::HashWithIndifferentAccess.new
31
+ @options_found = false
32
+ arguments_consumer.positional.each { |key| data[key] = nil }
33
+ data.merge!(arguments_consumer.default_options)
34
+ args.each_with_index { |value, index| add_arg(value, index) }
35
+ data.freeze
36
+ end
37
+
38
+ private
39
+
40
+ def add_arg(value, index)
41
+ arg = ::OpenStruct.new(value: value, index: index)
42
+ if arg.value.is_a?(::Hash)
43
+ add_hash_arg(arg)
44
+ else
45
+ add_positional_arg(arg)
46
+ end
47
+ end
48
+
49
+ def add_hash_arg(arg)
50
+ check_no_more_arguments(arg)
51
+ data.merge!(arg.value)
52
+ @options_found = true
53
+ end
54
+
55
+ def add_positional_arg(arg)
56
+ check_no_more_arguments(arg)
57
+ invalid_argument arg, 'No more valid positional' if
58
+ arg.index >= arguments_consumer.positional.count
59
+ data[arguments_consumer.positional[arg.index]] = arg.value
60
+ end
61
+
62
+ def check_no_more_arguments(arg)
63
+ return unless @options_found
64
+
65
+ invalid_argument arg, 'Hash already found - no more positional allowed'
66
+ end
67
+
68
+ def invalid_argument(arg, message)
69
+ raise InvalidArgumentError.new(self, arg, message)
70
+ end
71
+ end
72
+
73
+ class InvalidArgumentError < StandardError
74
+ def initialize(args_consumer, arg, message)
75
+ @args_consumer = args_consumer
76
+ @arg = arg
77
+ super "#{message} (Arg: #{arg}, Args Consumer: #{args_consumer})"
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patches/module/compare_by'
4
+
5
+ module EacRubyUtils
6
+ class Bit
7
+ VALID_VALUES = [0, 1].freeze
8
+
9
+ class << self
10
+ def assert(obj)
11
+ return obj if obj.is_a?(self)
12
+
13
+ new(obj.to_i)
14
+ end
15
+
16
+ def valid_integer?(value)
17
+ value.is_a?(::Integer) && VALID_VALUES.include?(value)
18
+ end
19
+
20
+ def validate_integer(value)
21
+ return value if valid_integer?(value)
22
+
23
+ raise(::ArgumentError, "Invalid bit value: #{value} (Valid: #{VALID_VALUES})")
24
+ end
25
+ end
26
+
27
+ attr_reader :value
28
+ compare_by :value
29
+ delegate :to_s, :zero?, to: :value
30
+
31
+ # @param value [Integer]
32
+ def initialize(value)
33
+ @value = self.class.validate_integer(value)
34
+ end
35
+
36
+ # @return [Boolean]
37
+ def one?
38
+ !zero?
39
+ end
40
+
41
+ # @return [Integer]
42
+ def to_i
43
+ value
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/bit'
4
+ require 'eac_ruby_utils/byte'
5
+ require 'eac_ruby_utils/byte_array'
6
+ require 'eac_ruby_utils/patches/module/compare_by'
7
+
8
+ module EacRubyUtils
9
+ class BitArray
10
+ class << self
11
+ def assert(obj)
12
+ return obj if obj.is_a?(self)
13
+ return new(obj) if obj.is_a?(::Enumerable)
14
+
15
+ raise "Could not convert #{obj} to #{self}"
16
+ end
17
+ end
18
+
19
+ delegate :each, :each_with_index, :to_a, :size, :count, :length, :[], :fetch, to: :values_array
20
+ compare_by :values_array
21
+
22
+ def initialize(values = [])
23
+ values.each { |value| push(value) }
24
+ end
25
+
26
+ def <<(value)
27
+ push(value)
28
+ end
29
+
30
+ # @return [EacRubyUtils::BitArray] +self+.
31
+ def push_array(other_bit_array)
32
+ values_array.push(*other_bit_array.to_a)
33
+
34
+ self
35
+ end
36
+
37
+ # @param value [EacRubyUtils::Bit]
38
+ # @return [EacRubyUtils::Bit]
39
+ def push(value)
40
+ values_array.push(::EacRubyUtils::Bit.assert(value))
41
+ end
42
+
43
+ # @return [EacRubyUtils::BitArray]
44
+ def reverse
45
+ self.class.new(values_array.reverse)
46
+ end
47
+
48
+ # @param big_endian [Boolean]
49
+ # @return [EacRubyUtils::ByteArray]
50
+ def to_byte_array(big_endian = false)
51
+ unless count.modulo(::EacRubyUtils::Byte::BIT_COUNT).zero?
52
+ raise 'Bits returned is not multile of 8'
53
+ end
54
+
55
+ byte_bits_enumerator.each_with_object(::EacRubyUtils::ByteArray.new) do |e, a|
56
+ a << ::EacRubyUtils::Byte.from_bit_array(e, big_endian)
57
+ end
58
+ end
59
+
60
+ # @return [Array<Integer>]
61
+ def to_int_array
62
+ values_array.map(&:to_i)
63
+ end
64
+
65
+ private
66
+
67
+ def byte_bits_enumerator
68
+ ::Enumerator.new do |y|
69
+ offset = 0
70
+ while offset < values_array.count
71
+ y.yield(values_array.slice(offset, ::EacRubyUtils::Byte::BIT_COUNT))
72
+ offset += ::EacRubyUtils::Byte::BIT_COUNT
73
+ end
74
+ end
75
+ end
76
+
77
+ def values_array
78
+ @values_array ||= []
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/object/blank'
4
+ require 'singleton'
5
+
6
+ module EacRubyUtils
7
+ # A blank string which returns +false+ for +blank?+ method.
8
+ class BlankNotBlank < String
9
+ include ::Singleton
10
+
11
+ def initialize
12
+ super('')
13
+ end
14
+
15
+ def blank?
16
+ false
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ class Boolean
5
+ class << self
6
+ def parse(value)
7
+ return parse_string(value) if value.is_a?(::String)
8
+ return parse_string(value.to_s) if value.is_a?(::Symbol)
9
+ return parse_number(value) if value.is_a?(::Numeric)
10
+
11
+ value ? true : false
12
+ end
13
+
14
+ private
15
+
16
+ def parse_string(value)
17
+ ['', 'n', 'no', 'f', 'false'].include?(value.strip.downcase) ? false : true
18
+ end
19
+
20
+ def parse_number(value)
21
+ value.zero?
22
+ end
23
+ end
24
+
25
+ attr_reader :value
26
+
27
+ def initialize(value)
28
+ @value = self.class.parse(value)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ class ByReference
5
+ def initialize(&object_provider)
6
+ @object_provider = object_provider
7
+ end
8
+
9
+ def method_missing(method_name, *arguments, &block)
10
+ return object.send(method_name, *arguments, &block) if object.respond_to?(method_name)
11
+
12
+ super
13
+ end
14
+
15
+ def object
16
+ @object_provider.call
17
+ end
18
+
19
+ def respond_to_missing?(method_name, include_private = false)
20
+ object.respond_to?(method_name, include_private)
21
+ end
22
+ end
23
+ end