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
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/options_consumer'
|
4
|
+
|
5
|
+
RSpec.describe ::EacRubyUtils::OptionsConsumer do
|
6
|
+
context 'with instance created with some data' do
|
7
|
+
subject(:instance) { described_class.new(a: 'a_value', b: 'b_value', c: 'c_value') }
|
8
|
+
|
9
|
+
let(:consumed_a) { instance.consume(:a) }
|
10
|
+
let(:consumed_b) { instance.consume(:b) }
|
11
|
+
let(:consumed_c) { instance.consume(:c) }
|
12
|
+
|
13
|
+
it 'left data should be Hash' do
|
14
|
+
expect(instance.left_data).to be_a(::Hash)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'left data should be not empty' do
|
18
|
+
expect { instance.validate }.to raise_error(::StandardError)
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when no data is consumed' do
|
22
|
+
it do
|
23
|
+
expect(instance.left_data).to eq({ a: 'a_value', b: 'b_value', c: 'c_value' }
|
24
|
+
.with_indifferent_access)
|
25
|
+
end
|
26
|
+
|
27
|
+
it { expect(consumed_a).to eq('a_value') }
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when A value is consumed' do
|
31
|
+
before { consumed_a }
|
32
|
+
|
33
|
+
it do
|
34
|
+
expect(instance.left_data).to eq({ b: 'b_value', c: 'c_value' }.with_indifferent_access)
|
35
|
+
end
|
36
|
+
|
37
|
+
it { expect(instance.consume(:c)).to eq('c_value') }
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when A and C values are consumed' do
|
41
|
+
before do
|
42
|
+
consumed_a
|
43
|
+
consumed_c
|
44
|
+
end
|
45
|
+
|
46
|
+
it { expect(instance.left_data).to eq({ b: 'b_value' }.with_indifferent_access) }
|
47
|
+
|
48
|
+
it { expect(consumed_b).to eq('b_value') }
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'when all values are consumed' do
|
52
|
+
before do
|
53
|
+
consumed_a
|
54
|
+
consumed_b
|
55
|
+
consumed_c
|
56
|
+
end
|
57
|
+
|
58
|
+
it { expect(instance.left_data).to eq({}.with_indifferent_access) }
|
59
|
+
|
60
|
+
it do
|
61
|
+
expect { instance.validate }.not_to raise_error
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'raises if validate has left data' do
|
66
|
+
expect(instance.left_data.empty?).to eq(false)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '#consume_all' do
|
71
|
+
subject(:instance) { described_class.new(a: 'a_value', b: 'b_value', c: 'c_value') }
|
72
|
+
|
73
|
+
let(:all_consumed) { instance.consume_all(:a, :b, :c, :d) }
|
74
|
+
|
75
|
+
it { expect(all_consumed[0]).to eq('a_value') }
|
76
|
+
it { expect(all_consumed[1]).to eq('b_value') }
|
77
|
+
it { expect(all_consumed[2]).to eq('c_value') }
|
78
|
+
it { expect(all_consumed[3]).to eq(nil) }
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/class/abstract'
|
4
|
+
|
5
|
+
RSpec.describe ::Class do
|
6
|
+
let(:abstract_class) do
|
7
|
+
described_class.new do
|
8
|
+
enable_abstract_methods
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:concrect_class) do
|
13
|
+
described_class.new(abstract_class)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#abstract' do
|
17
|
+
it do
|
18
|
+
expect(abstract_class).to be_abstract
|
19
|
+
end
|
20
|
+
|
21
|
+
it do
|
22
|
+
expect(concrect_class).not_to be_abstract
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/class/self_included_modules'
|
4
|
+
|
5
|
+
RSpec.describe ::Class do
|
6
|
+
let(:includeable_module) do
|
7
|
+
::Module.new
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:parent_class) do
|
11
|
+
module_to_include = includeable_module
|
12
|
+
described_class.new do
|
13
|
+
include module_to_include
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:child_class) do
|
18
|
+
described_class.new(parent_class)
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#self_included_modules' do
|
22
|
+
it do
|
23
|
+
expect(parent_class.self_included_modules).to include(includeable_module)
|
24
|
+
end
|
25
|
+
|
26
|
+
it do
|
27
|
+
expect(child_class.self_included_modules).not_to include(includeable_module)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerable/boolean_combinations_spec.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/enumerable/boolean_combinations'
|
4
|
+
|
5
|
+
RSpec.describe ::Enumerable do
|
6
|
+
let(:empty_instance) { [].to_enum }
|
7
|
+
let(:a_instance) { [:a].to_enum }
|
8
|
+
let(:ab_instance) { %i[a b].to_enum }
|
9
|
+
|
10
|
+
describe '#bool_hash_combs' do
|
11
|
+
it do
|
12
|
+
expect(empty_instance.bool_hash_combs).to eq([])
|
13
|
+
end
|
14
|
+
|
15
|
+
it do
|
16
|
+
expect(a_instance.bool_hash_combs).to eq([{ a: false }, { a: true }])
|
17
|
+
end
|
18
|
+
|
19
|
+
it do
|
20
|
+
expect(ab_instance.bool_hash_combs)
|
21
|
+
.to eq([{ a: false, b: false }, { a: false, b: true }, { a: true, b: false },
|
22
|
+
{ a: true, b: true }])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#bool_array_combs' do
|
27
|
+
it do
|
28
|
+
expect(empty_instance.bool_array_combs).to eq([])
|
29
|
+
end
|
30
|
+
|
31
|
+
it do
|
32
|
+
expect(a_instance.bool_array_combs).to eq([[], [:a]])
|
33
|
+
end
|
34
|
+
|
35
|
+
it do
|
36
|
+
expect(ab_instance.bool_array_combs).to eq([[], [:a], [:b], %i[a b]])
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/enumerator/current'
|
4
|
+
|
5
|
+
RSpec.describe ::Enumerator do
|
6
|
+
let(:list) { %w[a b] }
|
7
|
+
let(:instance) { list.each }
|
8
|
+
|
9
|
+
it { expect(instance).to be_a(described_class) }
|
10
|
+
it { expect(instance.current).to eq('a') }
|
11
|
+
|
12
|
+
context 'with first next' do
|
13
|
+
before { instance.next }
|
14
|
+
|
15
|
+
it { expect(instance.current).to eq('b') }
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with last next' do
|
19
|
+
before do
|
20
|
+
instance.next
|
21
|
+
instance.next
|
22
|
+
end
|
23
|
+
|
24
|
+
it { expect(instance.current).to eq(nil) }
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/enumerator/stopped'
|
4
|
+
|
5
|
+
RSpec.describe ::Enumerator do
|
6
|
+
let(:list) { %w[a b] }
|
7
|
+
let(:instance) { list.each }
|
8
|
+
|
9
|
+
it { expect(instance).to be_a(described_class) }
|
10
|
+
it { expect(instance.peek).to eq('a') }
|
11
|
+
it { expect(instance).to be_ongoing }
|
12
|
+
it { expect(instance).not_to be_stopped }
|
13
|
+
|
14
|
+
context 'with first next' do
|
15
|
+
before { instance.next }
|
16
|
+
|
17
|
+
it { expect(instance.peek).to eq('b') }
|
18
|
+
it { expect(instance).to be_ongoing }
|
19
|
+
it { expect(instance).not_to be_stopped }
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'with last next' do
|
23
|
+
before do
|
24
|
+
instance.next
|
25
|
+
instance.next
|
26
|
+
end
|
27
|
+
|
28
|
+
it { expect { instance.peek }.to raise_error(::StopIteration) }
|
29
|
+
it { expect(instance).not_to be_ongoing }
|
30
|
+
it { expect(instance).to be_stopped }
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/hash/options_consumer'
|
4
|
+
|
5
|
+
RSpec.describe ::Hash do
|
6
|
+
let(:a_hash) { { a: 'a_value', b: 'b_value', c: 'c_value' } }
|
7
|
+
let(:instance) { a_hash.to_options_consumer }
|
8
|
+
|
9
|
+
it 'returns a OptionsConsumer' do
|
10
|
+
expect(instance).to be_a(::EacRubyUtils::OptionsConsumer)
|
11
|
+
end
|
12
|
+
|
13
|
+
it do
|
14
|
+
expect(instance.left_data).to eq({ a: 'a_value', b: 'b_value', c: 'c_value' }
|
15
|
+
.with_indifferent_access)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/hash/sym_keys_hash'
|
4
|
+
|
5
|
+
RSpec.describe ::Hash do
|
6
|
+
let(:a_hash) { { 'a' => 'a_value', 1 => '1_value', s: 's_value' } }
|
7
|
+
|
8
|
+
describe '#to_sym_keys_hash' do
|
9
|
+
it 'converts all keys to symbols' do
|
10
|
+
expect(a_hash.to_sym_keys_hash).to eq(a: 'a_value', '1': '1_value', s: 's_value')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/module/compare_by'
|
4
|
+
|
5
|
+
RSpec.describe ::Module do
|
6
|
+
let(:klass) do
|
7
|
+
::Class.new do
|
8
|
+
compare_by :field1, :field2
|
9
|
+
attr_reader :field1, :field2
|
10
|
+
def initialize(field1, field2)
|
11
|
+
@field1 = field1
|
12
|
+
@field2 = field2
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
let(:o1) { klass.new(1, 2) }
|
17
|
+
let(:o2) { klass.new(2, 1) }
|
18
|
+
let(:o3) { klass.new(1, 1) }
|
19
|
+
|
20
|
+
describe '#comparable' do
|
21
|
+
it { expect(o1).to be < o2 }
|
22
|
+
it { expect(o1).to be > o3 }
|
23
|
+
it { expect(o2).to be > o3 }
|
24
|
+
it { expect([o1, o2, o3].sort).to eq([o3, o1, o2]) }
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#equality' do
|
28
|
+
it { expect(o1).not_to eq(o2) }
|
29
|
+
it { expect(o1).not_to eq(o3) }
|
30
|
+
it { expect(o2).not_to eq(o3) }
|
31
|
+
|
32
|
+
it { expect(o1).to eq(klass.new(1, 2)) }
|
33
|
+
it { expect(o2).to eq(klass.new(2, 1)) }
|
34
|
+
it { expect(o3).to eq(klass.new(1, 1)) }
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/module/listable'
|
4
|
+
|
5
|
+
RSpec.describe ::Module do
|
6
|
+
let(:stub_class) do
|
7
|
+
::Class.new do
|
8
|
+
enable_listable
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#enable_listable' do
|
13
|
+
it { expect(stub_class.included_modules).to include(::EacRubyUtils::Listable) }
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/method_class'
|
4
|
+
require 'eac_ruby_utils/patches/module/method_class'
|
5
|
+
|
6
|
+
RSpec.describe ::Class do
|
7
|
+
let(:stub_method_class) do
|
8
|
+
described_class.new do
|
9
|
+
def self.name
|
10
|
+
'StubMethodClass'
|
11
|
+
end
|
12
|
+
|
13
|
+
enable_method_class
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#enable_simple_cache' do
|
18
|
+
it { expect(stub_method_class.included_modules).to include(::EacRubyUtils::MethodClass) }
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/module/simple_cache'
|
4
|
+
|
5
|
+
RSpec.describe ::Module do
|
6
|
+
let(:stub_class) do
|
7
|
+
::Class.new do
|
8
|
+
enable_simple_cache
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#enable_simple_cache' do
|
13
|
+
it { expect(stub_class.included_modules).to include(::EacRubyUtils::SimpleCache) }
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/module/speaker'
|
4
|
+
|
5
|
+
RSpec.describe ::Module do
|
6
|
+
class StubClass # rubocop:disable RSpec/LeakyConstantDeclaration
|
7
|
+
enable_speaker
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#enable_speaker' do
|
11
|
+
it { expect(StubClass.included_modules).to include(::EacRubyUtils::Speaker::Sender) }
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/object/call_if_proc'
|
4
|
+
|
5
|
+
RSpec.describe ::Object do
|
6
|
+
describe '#call_if_proc' do
|
7
|
+
it { expect(nil.call_if_proc).to eq(nil) }
|
8
|
+
it { expect('a string'.call_if_proc).to eq('a string') }
|
9
|
+
it { expect(-> { 'a returned value' }.call_if_proc).to eq('a returned value') }
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/object/compact'
|
4
|
+
|
5
|
+
::RSpec.describe ::Object do
|
6
|
+
let(:instance) { ::OpenStruct.new(a_attr: 'a_value', b_attr: 'b_value') }
|
7
|
+
let(:attributes) { %w[a_attr b_attr] }
|
8
|
+
|
9
|
+
describe '#compact' do
|
10
|
+
it do
|
11
|
+
expect(instance.compact_to_a(*attributes)).to eq(%w[a_value b_value])
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#to_h' do
|
16
|
+
it do
|
17
|
+
expect(instance.compact_to_h(*attributes)).to eq(a_attr: 'a_value', b_attr: 'b_value')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/object/if_present'
|
4
|
+
|
5
|
+
RSpec.describe ::Object do
|
6
|
+
describe '#if_present' do
|
7
|
+
it { expect(nil.if_present).to eq(nil) }
|
8
|
+
it { expect(nil.if_present('default')) .to eq('default') }
|
9
|
+
it { expect(nil.if_present('default') { |_v| 'calculated' }).to eq('default') }
|
10
|
+
it { expect('present'.if_present('default')).to eq('present') }
|
11
|
+
it { expect('present'.if_present { |v| v + '_calculated' }) .to eq('present_calculated') }
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/pathname/basename_noext'
|
4
|
+
|
5
|
+
RSpec.describe ::Pathname do
|
6
|
+
describe '#basename_noext' do
|
7
|
+
{
|
8
|
+
'After.Life.S01E01.WEBRip.x264-ION10.mp4' =>
|
9
|
+
%w[After.Life.S01E01.WEBRip.x264-ION10 After.Life.S01E01.WEBRip.x264-ION10.mp4
|
10
|
+
After.Life.S01E01.WEBRip.x264-ION10 After.Life.S01E01.WEBRip.x264-ION10],
|
11
|
+
's01e01.en.srt' => %w[s01e01 s01e01.en.srt s01e01.en s01e01 s01e01],
|
12
|
+
's01e01.srt' => %w[s01e01 s01e01.srt s01e01 s01e01 s01e01],
|
13
|
+
'/path/to/file.tar.gz' => %w[file file.tar.gz file.tar file file]
|
14
|
+
}.each do |source, expected_values|
|
15
|
+
expected_values.each_with_index do |expected_value, index|
|
16
|
+
limit = index - 1
|
17
|
+
context "when source is \"#{source}\" and limit is \"#{limit}\"" do
|
18
|
+
let(:instance) { described_class.new(source) }
|
19
|
+
let(:expected_path) { described_class.new(expected_value) }
|
20
|
+
|
21
|
+
it { expect(instance.basename_noext(limit)).to eq(expected_path) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/pathname/basename_sub'
|
4
|
+
|
5
|
+
RSpec.describe ::Pathname do
|
6
|
+
it do
|
7
|
+
expect(described_class.new('/absolute/path/to/file').basename_sub { |_b| 'other_file' }).to eq(
|
8
|
+
described_class.new('/absolute/path/to/other_file')
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
it do
|
13
|
+
expect(described_class.new('file').basename_sub { |b| b.to_s + '_appended' }).to eq(
|
14
|
+
described_class.new('file_appended')
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/pathname/parent_n'
|
4
|
+
|
5
|
+
RSpec.describe ::Pathname do
|
6
|
+
[
|
7
|
+
['/absolute/path/to/file', 0, '/absolute/path/to/file'],
|
8
|
+
['/absolute/path/to/file', 1, '/absolute/path/to'],
|
9
|
+
['/absolute/path/to/file', 2, '/absolute/path'],
|
10
|
+
['/absolute/path/to/file', 3, '/absolute'],
|
11
|
+
['/absolute/path/to/file', 4, '/'],
|
12
|
+
['/absolute/path/to/file', 5, '/'],
|
13
|
+
['relative/path/to/file', 0, 'relative/path/to/file'],
|
14
|
+
['relative/path/to/file', 1, 'relative/path/to'],
|
15
|
+
['relative/path/to/file', 2, 'relative/path'],
|
16
|
+
['relative/path/to/file', 3, 'relative'],
|
17
|
+
['relative/path/to/file', 4, '.'],
|
18
|
+
['relative/path/to/file', 5, '..'],
|
19
|
+
['relative/path/to/file', 6, '../..']
|
20
|
+
].each do |test_data|
|
21
|
+
input_path = test_data[0]
|
22
|
+
context "when path is \"#{input_path}\"" do
|
23
|
+
let(:n) { test_data[1] }
|
24
|
+
let(:expected_path) { test_data[2] }
|
25
|
+
|
26
|
+
it do
|
27
|
+
expect(described_class.new(input_path).parent_n(n)).to(
|
28
|
+
eq(described_class.new(expected_path))
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/string/delimited'
|
4
|
+
|
5
|
+
::RSpec.describe ::String do
|
6
|
+
let(:instance) { 'A text with <b>content between</b> tags.' }
|
7
|
+
|
8
|
+
{
|
9
|
+
['<b>', '</b>'] => {
|
10
|
+
'inner' => 'content between',
|
11
|
+
'without_inner' => 'A text with <b></b> tags.',
|
12
|
+
'outer' => '<b>content between</b>',
|
13
|
+
'without_outer' => 'A text with tags.'
|
14
|
+
},
|
15
|
+
['<b>', '</br>'] => {
|
16
|
+
'inner' => '',
|
17
|
+
'without_inner' => 'A text with <b>content between</b> tags.',
|
18
|
+
'outer' => '',
|
19
|
+
'without_outer' => 'A text with <b>content between</b> tags.'
|
20
|
+
}
|
21
|
+
}.each do |delimiters, expected_values|
|
22
|
+
context "when delimiters are #{delimiters}" do
|
23
|
+
let(:bdel) { delimiters[0] }
|
24
|
+
let(:edel) { delimiters[1] }
|
25
|
+
|
26
|
+
expected_values.each do |method_suffix, expected_value|
|
27
|
+
method_name = "delimited_#{method_suffix}"
|
28
|
+
it "#{method_name} should return \"#{expected_value}\"" do
|
29
|
+
expect(instance.send(method_name, bdel, edel)).to eq(expected_value)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/recursive_builder'
|
4
|
+
|
5
|
+
RSpec.describe ::EacRubyUtils::RecursiveBuilder do
|
6
|
+
let(:item_class) do
|
7
|
+
::Class.new do
|
8
|
+
class << self
|
9
|
+
def create(label, dependencies_keys)
|
10
|
+
item = new(label, dependencies_keys)
|
11
|
+
registry[item.label] = item
|
12
|
+
item
|
13
|
+
end
|
14
|
+
|
15
|
+
def registry
|
16
|
+
@registry ||= {}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_reader :label, :dependencies_keys
|
21
|
+
|
22
|
+
def initialize(label, dependencies_keys)
|
23
|
+
@label = label
|
24
|
+
@dependencies_keys = dependencies_keys.freeze
|
25
|
+
end
|
26
|
+
|
27
|
+
def dependencies
|
28
|
+
dependencies_keys.map { |key| self.class.registry.fetch(key) }
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_s
|
32
|
+
label
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
items = [
|
38
|
+
[:a, %w[c], %w[a c]],
|
39
|
+
[:b, %w[a], %w[b a c]],
|
40
|
+
[:c, [], %w[c]],
|
41
|
+
[:d, %w[a b c e], %w[d a b c e]],
|
42
|
+
[:e, %w[c b], %w[e c b a]]
|
43
|
+
]
|
44
|
+
|
45
|
+
items.each do |item|
|
46
|
+
let(item[0]) { item_class.create(item[0].to_s, item[1]) }
|
47
|
+
before { send(item[0]) }
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#result' do
|
51
|
+
items.each do |item|
|
52
|
+
context "when root is \"#{item[0]}\"" do
|
53
|
+
let(:root) { send(item[0]) }
|
54
|
+
let(:dependencies) { item[2].map { |d| send(d) } }
|
55
|
+
let(:builder) do
|
56
|
+
described_class.new(root, &:dependencies)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "is #{item[2]}" do
|
60
|
+
expect(builder.result).to eq(dependencies)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/require_sub'
|
4
|
+
|
5
|
+
class RequireSubStubClass
|
6
|
+
end
|
7
|
+
|
8
|
+
RSpec.describe ::EacRubyUtils::RequireSub do
|
9
|
+
let(:instance) { described_class.new(__FILE__, base: RequireSubStubClass, include_modules: true) }
|
10
|
+
|
11
|
+
before do
|
12
|
+
instance.apply
|
13
|
+
end
|
14
|
+
|
15
|
+
it do
|
16
|
+
expect(RequireSubStubClass.included_modules)
|
17
|
+
.to include(RequireSubStubClass::StubbedModuleA)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/ruby'
|
4
|
+
|
5
|
+
RSpec.describe ::EacRubyUtils::Ruby do
|
6
|
+
describe '#on_clean_environment' do
|
7
|
+
let(:envvar_name) { 'BUNDLE_NOT_EXISTENT_ENV_VAR' }
|
8
|
+
let(:envvar_value) { 'any value' }
|
9
|
+
|
10
|
+
before do
|
11
|
+
ENV[envvar_name] = envvar_value
|
12
|
+
end
|
13
|
+
|
14
|
+
it do # rubocop:disable RSpec/MultipleExpectations
|
15
|
+
expect(ENV[envvar_name]).to eq(envvar_value)
|
16
|
+
described_class.on_clean_environment do
|
17
|
+
expect(ENV[envvar_name]).to eq(nil)
|
18
|
+
end
|
19
|
+
expect(ENV[envvar_name]).to eq(envvar_value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|