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.
- 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 +19 -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/Gemfile +3 -0
- data/sub/avm-eac_redmine_base0/avm-eac_redmine_base0.gemspec +6 -6
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/base.rb +8 -0
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base.rb +18 -8
- 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 +257 -48
- 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,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
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/settings_provider'
|
4
|
+
|
5
|
+
RSpec.describe ::EacRubyUtils::SettingsProvider do
|
6
|
+
let(:stub_class) do
|
7
|
+
the_described_class = described_class
|
8
|
+
r = ::Class.new do
|
9
|
+
include the_described_class
|
10
|
+
|
11
|
+
def key_a
|
12
|
+
'method_a'
|
13
|
+
end
|
14
|
+
|
15
|
+
def key_b
|
16
|
+
'method_b'
|
17
|
+
end
|
18
|
+
|
19
|
+
def settings
|
20
|
+
{ 'key_b' => 'setting_b', key_c: 'setting_c' }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
r.const_set(:KEY_A, 'constant_a')
|
24
|
+
r.const_set(:KEY_D, 'constant_d')
|
25
|
+
r
|
26
|
+
end
|
27
|
+
|
28
|
+
let(:stub) { stub_class.new }
|
29
|
+
|
30
|
+
describe '#setting_value' do
|
31
|
+
{
|
32
|
+
['key_a'] => 'method_a',
|
33
|
+
[:key_b] => 'setting_b',
|
34
|
+
['key_b', { order: %w[constant method settings_object] }] => 'method_b',
|
35
|
+
['key_c'] => 'setting_c',
|
36
|
+
['key_d'] => 'constant_d'
|
37
|
+
}.each do |args, expected_value|
|
38
|
+
it { expect(stub.setting_value(*args)).to eq(expected_value) }
|
39
|
+
end
|
40
|
+
|
41
|
+
it do
|
42
|
+
expect { stub.setting_value('key_e') }.to raise_error(::StandardError)
|
43
|
+
end
|
44
|
+
|
45
|
+
it do
|
46
|
+
expect(stub.setting_value('key_e', required: false)).to eq(nil)
|
47
|
+
end
|
48
|
+
|
49
|
+
it do
|
50
|
+
expect(stub.setting_value('key_e', default: nil)).to eq(nil)
|
51
|
+
end
|
52
|
+
|
53
|
+
it do
|
54
|
+
expect(stub.setting_value('key_e', default: 'default_e')).to eq('default_e')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/simple_cache'
|
4
|
+
|
5
|
+
class CacheableObject
|
6
|
+
include ::EacRubyUtils::SimpleCache
|
7
|
+
|
8
|
+
def my_method_uncached
|
9
|
+
@counter ||= 0
|
10
|
+
@counter += 1
|
11
|
+
end
|
12
|
+
|
13
|
+
def method_with_question_uncached?
|
14
|
+
'question'
|
15
|
+
end
|
16
|
+
|
17
|
+
def method_with_exclamation_uncached!
|
18
|
+
'exclamation'
|
19
|
+
end
|
20
|
+
|
21
|
+
def method_with_args_uncached(arg1)
|
22
|
+
@counter2 ||= 0
|
23
|
+
@counter2 += 1
|
24
|
+
"#{arg1}/#{@counter2}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def method_with_reset_uncached
|
28
|
+
reset_cache
|
29
|
+
'result'
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def private_method_uncached
|
35
|
+
@counter3 ||= 0
|
36
|
+
@counter3 += 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
RSpec.describe ::EacRubyUtils::SimpleCache do
|
41
|
+
let(:instance) { CacheableObject.new }
|
42
|
+
|
43
|
+
describe 'cached value' do
|
44
|
+
it 'uncached method return value should update at each call' do
|
45
|
+
expect(instance.my_method_uncached).not_to eq(instance.my_method_uncached)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'cached method should return same values at each call' do
|
49
|
+
expect(instance.my_method).to eq(instance.my_method)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'is able to call private uncached as cached' do
|
53
|
+
expect(instance.private_method).to eq(instance.private_method)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'return value even if reset cache' do
|
57
|
+
expect(instance.method_with_reset).to eq('result')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'cache value with args' do
|
62
|
+
it do
|
63
|
+
expect(instance.method_with_args_uncached('123'))
|
64
|
+
.not_to eq(instance.method_with_args_uncached('123'))
|
65
|
+
end
|
66
|
+
|
67
|
+
it do
|
68
|
+
expect(instance.method_with_args_uncached('456'))
|
69
|
+
.not_to eq(instance.method_with_args_uncached('456'))
|
70
|
+
end
|
71
|
+
|
72
|
+
it do
|
73
|
+
expect(instance.method_with_args('123')).to eq(instance.method_with_args('123'))
|
74
|
+
end
|
75
|
+
|
76
|
+
it do
|
77
|
+
expect(instance.method_with_args('456')).to eq(instance.method_with_args('456'))
|
78
|
+
end
|
79
|
+
|
80
|
+
it do
|
81
|
+
expect(instance.method_with_args('456')).not_to eq(instance.method_with_args('123'))
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe 'method with marks' do
|
86
|
+
it 'found uncached method with exclamation mark' do
|
87
|
+
expect(instance.method_with_exclamation!).to eq('exclamation')
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'found uncached method with question mark' do
|
91
|
+
expect(instance.method_with_question?).to eq('question')
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '#respond_to?' do
|
96
|
+
it 'responds to cached method without args' do
|
97
|
+
expect(instance.respond_to?(:my_method)).to be(true)
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'responds to cached method with args' do
|
101
|
+
expect(instance.respond_to?(:method_with_args)).to be(true)
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'responds to cached method of uncached private method' do
|
105
|
+
expect(instance.respond_to?(:private_method)).to be(true)
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'not respond to not existent method' do
|
109
|
+
expect(instance.respond_to?(:not_exist)).to be(false)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe '#reset_cache' do
|
114
|
+
let(:instance) { CacheableObject.new }
|
115
|
+
let(:cached_value) { instance.my_method }
|
116
|
+
|
117
|
+
it 'cached method return should return cached value' do
|
118
|
+
expect(instance.my_method).to eq(cached_value)
|
119
|
+
end
|
120
|
+
|
121
|
+
context 'when reset_cache method is called' do
|
122
|
+
it 'cached method return should return new cached value' do
|
123
|
+
cached_value
|
124
|
+
instance.reset_cache
|
125
|
+
expect(instance.my_method).not_to eq(cached_value)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/struct'
|
4
|
+
|
5
|
+
RSpec.describe ::EacRubyUtils::Struct do
|
6
|
+
let(:instance) { described_class.new('a' => 1, b: '') }
|
7
|
+
let(:other) { described_class.new('a' => 'm1', c: 'm2') }
|
8
|
+
|
9
|
+
describe '#[]' do
|
10
|
+
it { expect(instance[:a]).to eq(1) }
|
11
|
+
it { expect(instance['a']).to eq(1) }
|
12
|
+
it { expect(instance[:a?]).to eq(true) }
|
13
|
+
it { expect(instance['a?']).to eq(true) }
|
14
|
+
it { expect(instance[:b]).to eq('') }
|
15
|
+
it { expect(instance['b']).to eq('') }
|
16
|
+
it { expect(instance[:b?]).to eq(false) }
|
17
|
+
it { expect(instance['b?']).to eq(false) }
|
18
|
+
it { expect(instance[:c]).to eq(nil) }
|
19
|
+
it { expect(instance['c']).to eq(nil) }
|
20
|
+
it { expect(instance[:c?]).to eq(false) }
|
21
|
+
it { expect(instance['c?']).to eq(false) }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#fetch' do
|
25
|
+
it { expect(instance.fetch(:a)).to eq(1) }
|
26
|
+
it { expect(instance.fetch('a')).to eq(1) }
|
27
|
+
it { expect(instance.fetch(:a?)).to eq(true) }
|
28
|
+
it { expect(instance.fetch('a?')).to eq(true) }
|
29
|
+
it { expect(instance.fetch(:b)).to eq('') }
|
30
|
+
it { expect(instance.fetch('b')).to eq('') }
|
31
|
+
it { expect(instance.fetch(:b?)).to eq(false) }
|
32
|
+
it { expect(instance.fetch('b?')).to eq(false) }
|
33
|
+
it { expect { instance.fetch(:c) }.to raise_error(::KeyError) }
|
34
|
+
it { expect { instance.fetch('c') }.to raise_error(::KeyError) }
|
35
|
+
it { expect { instance.fetch(:c?) }.to raise_error(::KeyError) }
|
36
|
+
it { expect { instance.fetch('c?') }.to raise_error(::KeyError) }
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#merge' do
|
40
|
+
let(:merged) { instance.merge(other) }
|
41
|
+
|
42
|
+
it { expect(merged.to_h).to eq(a: 'm1', b: '', c: 'm2') }
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#property_method' do
|
46
|
+
it { expect(instance.a).to eq(1) }
|
47
|
+
it { expect(instance.a?).to eq(true) }
|
48
|
+
it { expect(instance.b).to eq('') }
|
49
|
+
it { expect(instance.b?).to eq(false) }
|
50
|
+
it { expect { instance.c }.to raise_error(::NoMethodError) }
|
51
|
+
it { expect { instance.c? }.to raise_error(::NoMethodError) }
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#to_h' do
|
55
|
+
it { expect(instance.to_h).to eq(a: 1, b: '') }
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/hash_with_indifferent_access'
|
4
|
+
require 'eac_ruby_utils/yaml'
|
5
|
+
|
6
|
+
RSpec.describe ::EacRubyUtils::Yaml do
|
7
|
+
let(:unpermitted_class) do
|
8
|
+
Class.new do
|
9
|
+
def initialize(value)
|
10
|
+
@value = value
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_s
|
14
|
+
@value.to_s
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:arrayliable_class) do
|
20
|
+
Class.new do
|
21
|
+
def initialize(value)
|
22
|
+
@value = value
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_a
|
26
|
+
[@value]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
let(:source) do
|
32
|
+
{
|
33
|
+
a: 'a', b: :b, c: false, d: true, e: nil,
|
34
|
+
f: [
|
35
|
+
'f',
|
36
|
+
{
|
37
|
+
g: 'g',
|
38
|
+
h: ::ActiveSupport::HashWithIndifferentAccess.new(
|
39
|
+
'i' => ['i', unpermitted_class.new('j')],
|
40
|
+
k: arrayliable_class.new('k')
|
41
|
+
)
|
42
|
+
}
|
43
|
+
]
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
let(:target) do
|
48
|
+
{
|
49
|
+
a: 'a', b: :b, c: false, d: true, e: nil,
|
50
|
+
f: ['f', { g: 'g', h: { i: %w[i j], k: ['k'] } }]
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#dump' do
|
55
|
+
it { expect(described_class.load(described_class.dump(source))).to eq(target) }
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#sanitize' do
|
59
|
+
it { expect(described_class.sanitize(target)).to eq(target) }
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#yaml' do
|
63
|
+
{
|
64
|
+
['text'] => false,
|
65
|
+
'text' => false,
|
66
|
+
"--- Text\n\n" => true,
|
67
|
+
"---\n" + ":index: 0\n" + ":codec_name: h264\n" + ":codec_type: video\n" => true,
|
68
|
+
'--- - \n bla bla bla' => false
|
69
|
+
}.each do |source, result|
|
70
|
+
it "return #{result} to source \"#{source}\"" do
|
71
|
+
expect(described_class.yaml?(source)).to eq(result)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|