eac_tools 0.2.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +42 -30
- data/lib/eac_tools/version.rb +1 -1
- data/sub/avm/lib/avm/sources/base/configuration.rb +14 -6
- data/sub/avm/lib/avm/sources/base/testing.rb +50 -7
- data/sub/avm/lib/avm/sources/tests/builder.rb +8 -1
- data/sub/avm/lib/avm/sources/tests/single.rb +28 -9
- data/sub/avm/lib/avm/version.rb +1 -1
- data/sub/avm-eac_generic_base0/Gemfile +3 -0
- data/sub/avm-eac_generic_base0/avm-eac_generic_base0.gemspec +3 -3
- data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/base.rb +0 -6
- data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/version.rb +1 -1
- data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/Gemfile +0 -0
- data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/avm-eac_rails_base0.gemspec +0 -0
- data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/lib/avm/eac_rails_base0/apache_host.rb +0 -0
- data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/lib/avm/eac_rails_base0/apache_path.rb +0 -0
- data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/lib/avm/eac_rails_base0/deploy.rb +0 -0
- data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/lib/avm/eac_rails_base0/instance.rb +0 -0
- data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/lib/avm/eac_rails_base0/runners/base.rb +0 -0
- data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/lib/avm/eac_rails_base0/runners.rb +0 -0
- data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/lib/avm/eac_rails_base0/sources/base.rb +14 -1
- data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/lib/avm/eac_rails_base0/version.rb +1 -1
- data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/lib/avm/eac_rails_base0.rb +0 -0
- 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
- 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
- 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
- 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
- data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/spec/rubocop_spec.rb +0 -0
- data/sub/{avm-tools/sub/avm-eac_rails_base0 → avm-eac_rails_base0}/spec/spec_helper.rb +0 -0
- 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
- 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
- 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
- data/sub/avm-eac_rails_base1/Gemfile +3 -0
- data/sub/avm-eac_rails_base1/avm-eac_rails_base1.gemspec +2 -2
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/sources/base.rb +16 -0
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/version.rb +1 -1
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
- data/sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/deploy/config/install.sh.template +4 -0
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base.rb +15 -7
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/version.rb +1 -1
- data/sub/avm-tools/Gemfile.lock +24 -28
- data/sub/avm-tools/lib/avm/tools/version.rb +1 -1
- data/sub/eac_ruby_utils/Gemfile +16 -0
- data/sub/eac_ruby_utils/MIT-LICENCE +16 -0
- data/sub/eac_ruby_utils/README.rdoc +3 -0
- data/sub/eac_ruby_utils/eac_ruby_utils.gemspec +24 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/abstract_methods.rb +68 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/arguments_consumer.rb +81 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/bit.rb +46 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/bit_array.rb +81 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/blank_not_blank.rb +19 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/boolean.rb +31 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/by_reference.rb +23 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/byte.rb +105 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/byte_array.rb +36 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_concern/class_setup.rb +52 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +41 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +20 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_initialize.rb +29 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/instance_initialize.rb +53 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/super_args.rb +54 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +89 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/compact.rb +22 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/compare_by.rb +28 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/context.rb +33 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb +21 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/core_ext.rb +7 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/custom_format.rb +53 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/enum.rb +102 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/base_env.rb +28 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command/concat.rb +33 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command/envvars.rb +24 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +33 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +172 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/executable.rb +81 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/file.rb +22 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/local_env.rb +17 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/process.rb +27 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/spawn.rb +32 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/dasho_options.rb +53 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/identity_file.rb +25 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/quiet.rb +24 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/terminal.rb +34 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env.rb +75 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs.rb +23 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/fs/clearable_directory.rb +57 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/fs/extname.rb +30 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/directory.rb +16 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp/file.rb +34 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/fs/temp.rb +52 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/fs.rb +9 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/gems_registry/gem.rb +79 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/gems_registry.rb +35 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/immutable/array_accessor.rb +32 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/immutable/base_accessor.rb +23 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/immutable/boolean_accessor.rb +16 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/immutable/class_methods.rb +20 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/immutable/common_accessor.rb +30 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/immutable/hash_accessor.rb +46 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/immutable/instance_methods.rb +21 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/immutable.rb +15 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +29 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/class_methods.rb +14 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/instance_methods.rb +30 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/integer_list.rb +23 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +111 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/lists.rb +59 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/string_list.rb +19 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/symbol_list.rb +19 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb +49 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable.rb +17 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb +48 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales/from_all_gems.rb +4 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales/from_gem.rb +47 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales/module_i18n_translate.rb +74 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/locales.rb +9 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/method_class.rb +35 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/options_consumer.rb +62 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patch.rb +11 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/class/abstract.rb +9 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/class/common_constructor.rb +9 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/class/self_included_modules.rb +7 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/class/settings_provider.rb +10 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/class.rb +4 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerable/boolean_combinations.rb +45 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerable.rb +4 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator/current.rb +9 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator/stopped.rb +14 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator.rb +4 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/hash/options_consumer.rb +10 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/hash/sym_keys_hash.rb +10 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/hash/to_struct.rb +10 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/hash.rb +5 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel/nyi.rb +10 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel.rb +4 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/abstract_methods.rb +10 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/common_concern.rb +9 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/compare_by.rb +9 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/context.rb +11 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/i18n_translate.rb +9 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/immutable.rb +10 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/listable.rb +10 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/method_class.rb +9 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/patch.rb +9 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/require_sub.rb +9 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/simple_cache.rb +10 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/speaker.rb +9 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module.rb +4 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/asserts.rb +25 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/call_if_proc.rb +11 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/compact.rb +20 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb +23 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/i18n_translate.rb +13 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_nil.rb +17 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_present.rb +19 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_respond.rb +22 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_pathname.rb +15 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb +15 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object.rb +5 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_noext.rb +10 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_sub.rb +9 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/if_exist.rb +10 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/mkpath_s.rb +12 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/parent_n.rb +11 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/readlink_r.rb +11 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/reqdir_glob.rb +13 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname.rb +4 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/regexp/if_match.rb +16 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/regexp/to_parser.rb +10 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/regexp.rb +4 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/string/delimited.rb +16 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/string/inflector.rb +11 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/string.rb +4 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/time/required_zone.rb +11 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/time.rb +4 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches.rb +4 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/recursive_builder.rb +51 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/regexp_parser.rb +34 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/require_sub.rb +134 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/default_setup.rb +20 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup/conditionals.rb +17 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup.rb +12 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup_manager.rb +49 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/stub_speaker.rb +39 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec.rb +9 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/ruby/command.rb +32 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/ruby/on_clean_environment.rb +38 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/ruby.rb +9 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/settings_provider/setting_value.rb +69 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/settings_provider.rb +46 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/simple_cache.rb +77 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/speaker/receiver.rb +64 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/speaker/sender.rb +32 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/speaker.rb +16 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/string_delimited.rb +70 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +63 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +5 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +105 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils.rb +6 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/abstract_methods_spec.rb +28 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/arguments_consumer_spec.rb +17 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/bit_array_spec.rb +22 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/blank_not_blank_spec.rb +16 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/byte_spec.rb +54 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +65 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +125 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/compact_spec.rb +20 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/compare_by_spec.rb +38 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/custom_format_spec.rb +60 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/enum_spec.rb +43 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/envs/executable_spec.rb +37 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/envs/ssh_env_spec.rb +25 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/extname_spec.rb +18 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp/directory_spec.rb +12 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp_spec.rb +52 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb +16 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/listable_spec.rb +275 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/local_time_zone_spec.rb +17 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/method_class_spec.rb +46 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb +80 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/class/abstract_spec.rb +25 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/class/self_included_modules_spec.rb +30 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerable/boolean_combinations_spec.rb +39 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/current_spec.rb +26 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb +32 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/hash/options_consumer_spec.rb +17 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/hash/sym_keys_hash_spec.rb +13 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/compare_by_spec.rb +36 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/listable_spec.rb +15 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/method_class_spec.rb +20 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/simple_cache_spec.rb +15 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/speaker_spec.rb +13 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/call_if_proc_spec.rb +11 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/compact_spec.rb +20 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/if_present_spec.rb +13 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/template_spec_files/path/my_stub_with_template +1 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/pathname/basename_noext_spec.rb +26 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/pathname/basename_sub_spec.rb +17 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/pathname/parent_n_spec.rb +33 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/string/delimited_spec.rb +34 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/recursive_builder_spec.rb +65 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub_spec/stubbed_module_a.rb +6 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub_spec/stubbed_not_module.rb +6 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub_spec.rb +19 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/ruby_spec.rb +22 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/settings_provider_spec.rb +57 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/simple_cache_spec.rb +129 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +57 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/yaml_spec.rb +75 -0
- data/sub/eac_ruby_utils/spec/locales/pt-BR.yml +58 -0
- data/sub/eac_ruby_utils/spec/rubocop_check_spec.rb +3 -0
- data/sub/eac_ruby_utils/spec/spec_helper.rb +15 -0
- metadata +255 -52
- data/sub/avm/lib/avm/sources/tester.rb +0 -24
- data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/tester.rb +0 -56
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/tester.rb +0 -36
data/sub/avm-tools/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
avm-tools (0.121.
|
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.
|
126
|
-
eac_cli (~> 0.
|
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.
|
135
|
-
avm (~> 0.
|
136
|
-
eac_ruby_utils (~> 0.
|
137
|
-
avm-
|
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.
|
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.
|
149
|
-
avm (~> 0.
|
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.
|
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.
|
162
|
-
parslet (~>
|
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.
|
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.
|
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.
|
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.
|
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.
|
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 (
|
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!
|
@@ -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,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
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/bit'
|
4
|
+
require 'eac_ruby_utils/bit_array'
|
5
|
+
require 'eac_ruby_utils/patches/module/compare_by'
|
6
|
+
|
7
|
+
module EacRubyUtils
|
8
|
+
class Byte
|
9
|
+
ASSEMBLY_HEXADECIMAL_PREFIX = '$'
|
10
|
+
BIT_COUNT = 8
|
11
|
+
BIT_INDEX_RANGE = (0..7).freeze
|
12
|
+
VALUE_RANGE = (0..255).freeze
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def assert(obj)
|
16
|
+
return obj if obj.is_a?(self)
|
17
|
+
|
18
|
+
new(obj.to_i)
|
19
|
+
end
|
20
|
+
|
21
|
+
def from_bit_array(bit_array, big_endian = false)
|
22
|
+
bit_array = ::EacRubyUtils::BitArray.assert(bit_array)
|
23
|
+
raise ::ArgumentError, "Wrong bit array size: #{bit_array.size}" if
|
24
|
+
bit_array.size != BIT_COUNT
|
25
|
+
|
26
|
+
bit_array = bit_array.reverse if big_endian
|
27
|
+
bit_array.each_with_index.inject(new(0)) do |a, e|
|
28
|
+
a.bit_set(e[1], e[0])
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def valid_bit_index?(value)
|
33
|
+
value.is_a?(::Integer) && BIT_INDEX_RANGE.include?(value)
|
34
|
+
end
|
35
|
+
|
36
|
+
def validate_bit_index(value)
|
37
|
+
return value if valid_bit_index?(value)
|
38
|
+
|
39
|
+
raise(::ArgumentError, "Invalid bit index: #{value} (Range: #{BIT_INDEX_RANGE})")
|
40
|
+
end
|
41
|
+
|
42
|
+
def valid_value?(value)
|
43
|
+
value.is_a?(::Integer) && VALUE_RANGE.include?(value)
|
44
|
+
end
|
45
|
+
|
46
|
+
def validate_value(value)
|
47
|
+
return value if valid_value?(value)
|
48
|
+
|
49
|
+
raise(::ArgumentError, "Invalid byte value: #{value} (Range: #{VALUE_RANGE})")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
attr_reader :value
|
54
|
+
compare_by :value
|
55
|
+
|
56
|
+
def initialize(value)
|
57
|
+
self.value = value
|
58
|
+
end
|
59
|
+
|
60
|
+
# @param bit_index [Integer]
|
61
|
+
# @return [EacRubyUtils::Bit]
|
62
|
+
def [](bit_index)
|
63
|
+
bit_get(bit_index)
|
64
|
+
end
|
65
|
+
|
66
|
+
# @param bit_index [Integer]
|
67
|
+
# @return [EacRubyUtils::Bit]
|
68
|
+
def bit_get(bit_index)
|
69
|
+
self.class.validate_bit_index(bit_index)
|
70
|
+
|
71
|
+
::EacRubyUtils::Bit.new((value & (1 << bit_index)) >> bit_index)
|
72
|
+
end
|
73
|
+
|
74
|
+
def bit_set(bit_index, bit_value)
|
75
|
+
self.class.validate_bit_index(bit_index)
|
76
|
+
bit = ::EacRubyUtils::Bit.assert(bit_value)
|
77
|
+
mask = (1 << bit_index)
|
78
|
+
self.class.new(bit.zero? ? value & ~mask : value | mask)
|
79
|
+
end
|
80
|
+
|
81
|
+
# @return [EacRubyUtils::BitArray]
|
82
|
+
def to_bit_array(range = BIT_INDEX_RANGE)
|
83
|
+
::EacRubyUtils::BitArray.new(range.map { |bit_index| self[bit_index] })
|
84
|
+
end
|
85
|
+
|
86
|
+
# @return [Integer]
|
87
|
+
def to_i
|
88
|
+
value
|
89
|
+
end
|
90
|
+
|
91
|
+
# @return [String]
|
92
|
+
def to_asm_hex
|
93
|
+
ASSEMBLY_HEXADECIMAL_PREFIX + to_hex
|
94
|
+
end
|
95
|
+
|
96
|
+
# @return [String]
|
97
|
+
def to_hex
|
98
|
+
value.to_s(16).upcase.rjust(2, '0')
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
|
103
|
+
attr_writer :value
|
104
|
+
end
|
105
|
+
end
|