eac_tools 0.97.1 → 0.97.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +30 -25
- data/lib/eac_tools/version.rb +1 -1
- data/sub/eac_config/eac_config.gemspec +20 -0
- data/sub/eac_config/lib/eac_config/entries.rb +35 -0
- data/sub/eac_config/lib/eac_config/entry/not_found_error.rb +13 -0
- data/sub/eac_config/lib/eac_config/entry.rb +64 -0
- data/sub/eac_config/lib/eac_config/entry_path.rb +89 -0
- data/sub/eac_config/lib/eac_config/envvars_node/entry.rb +54 -0
- data/sub/eac_config/lib/eac_config/envvars_node.rb +35 -0
- data/sub/eac_config/lib/eac_config/load_nodes_search.rb +39 -0
- data/sub/eac_config/lib/eac_config/load_path.rb +28 -0
- data/sub/eac_config/lib/eac_config/node.rb +81 -0
- data/sub/eac_config/lib/eac_config/node_entry.rb +28 -0
- data/sub/eac_config/lib/eac_config/node_uri/instanciate_single.rb +29 -0
- data/sub/eac_config/lib/eac_config/node_uri.rb +45 -0
- data/sub/eac_config/lib/eac_config/old_configs/base.rb +43 -0
- data/sub/eac_config/lib/eac_config/old_configs/file.rb +47 -0
- data/sub/eac_config/lib/eac_config/old_configs.rb +75 -0
- data/sub/eac_config/lib/eac_config/paths_hash/entry_key_error.rb +8 -0
- data/sub/eac_config/lib/eac_config/paths_hash/node.rb +67 -0
- data/sub/eac_config/lib/eac_config/paths_hash/path_search.rb +39 -0
- data/sub/eac_config/lib/eac_config/paths_hash.rb +63 -0
- data/sub/eac_config/lib/eac_config/prefixed_path_node/entry.rb +25 -0
- data/sub/eac_config/lib/eac_config/prefixed_path_node.rb +19 -0
- data/sub/eac_config/lib/eac_config/rspec/setup.rb +65 -0
- data/sub/{avm-eac_rails_base1/lib/avm/eac_rails_base1.rb → eac_config/lib/eac_config/rspec.rb} +2 -2
- data/sub/eac_config/lib/eac_config/version.rb +5 -0
- data/sub/eac_config/lib/eac_config/yaml_file_node/entry.rb +36 -0
- data/sub/eac_config/lib/eac_config/yaml_file_node/self_entries.rb +72 -0
- data/sub/eac_config/lib/eac_config/yaml_file_node.rb +54 -0
- data/sub/eac_config/lib/eac_config.rb +7 -0
- data/sub/eac_config/spec/lib/eac_config/entry_path_spec.rb +30 -0
- data/sub/eac_config/spec/lib/eac_config/envvars_node/entry_spec.rb +14 -0
- data/sub/eac_config/spec/lib/eac_config/envvars_node_spec.rb +51 -0
- data/sub/eac_config/spec/lib/eac_config/old_configs_spec.rb +46 -0
- data/sub/eac_config/spec/lib/eac_config/paths_hash_spec.rb +63 -0
- data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec.rb +88 -0
- data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1.yaml +10 -0
- data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_1.yaml +4 -0
- data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2/storage1_2_1.yaml +4 -0
- data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2.yaml +10 -0
- data/sub/eac_ruby_utils/Gemfile +8 -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 +26 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_abstract.rb +100 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_immutable/array_accessor.rb +25 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_immutable/base_accessor.rb +57 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_immutable/boolean_accessor.rb +16 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_immutable/class_methods.rb +20 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_immutable/common_accessor.rb +30 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_immutable/enumerable_accessor.rb +52 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_immutable/hash_accessor.rb +57 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_immutable/instance_methods.rb +21 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_immutable/set_accessor.rb +25 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_immutable.rb +15 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/acts_as_instance_method.rb +34 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/arguments_consumer.rb +80 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/bit.rb +47 -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 +106 -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_accessors.rb +36 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_initialize.rb +39 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/instance_initialize.rb +64 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/super_args.rb +55 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +93 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/compact.rb +32 -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/enumerables_methods.rb +42 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/base_command/append_command_options.rb +38 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/base_command/concat.rb +41 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/base_command/debugging.rb +19 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/base_command/execution.rb +52 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/base_command/extra_options.rb +28 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/base_command.rb +45 -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/envvars.rb +27 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +23 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +67 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/composite_command.rb +45 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/executable.rb +93 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/execution_error.rb +8 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/execution_result.rb +45 -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 +74 -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 +80 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/gems_registry.rb +34 -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/item.rb +48 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +129 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/listable/lists.rb +51 -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.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 +30 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/module_ancestors_variable/base.rb +34 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/module_ancestors_variable/hash.rb +20 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/module_ancestors_variable/set.rb +19 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/module_ancestors_variable.rb +9 -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/addressable/uri/query_value.rb +37 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/addressable/uri.rb +4 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/addressable.rb +4 -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/method_class.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/static_method_class.rb +9 -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/if_key.rb +12 -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/ibr.rb +10 -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/acts_as_abstract.rb +14 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/acts_as_immutable.rb +10 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/module/acts_as_instance_method.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 +11 -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/module_parent.rb +5 -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 +55 -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/recursive_build.rb +12 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_bool.rb +12 -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_sym_by_eac.rb +11 -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/assert_parent.rb +12 -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 +13 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb +16 -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 +39 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/require_sub/base.rb +80 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/require_sub/sub_file.rb +59 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/require_sub.rb +11 -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/setup_manager.rb +17 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup.rb +27 -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 +71 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/ruby/on_replace_objects/replace_instance_method.rb +36 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/ruby/on_replace_objects.rb +52 -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 +79 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/settings_provider.rb +50 -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 +37 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/speaker.rb +16 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/static_method_class.rb +12 -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/unimplemented_method_error.rb +6 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +5 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/wildcards.rb +26 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +107 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils.rb +6 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/acts_as_abstract_spec.rb +94 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/acts_as_immutable/array_accessor_spec.rb +43 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/acts_as_immutable/common_accessor_spec.rb +57 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/acts_as_immutable/hash_accessor_spec.rb +42 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/acts_as_immutable/set_accessor_spec.rb +43 -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 +151 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/compact_spec.rb +21 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/compare_by_spec.rb +39 -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 +44 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/enumerables_methods_spec.rb +50 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/envs/command/base_example.rb +97 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/envs/command/local_env_spec.rb +11 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/envs/command/ssh_env_spec.rb +17 -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 +225 -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/module_ancestors_variable/hash_spec.rb +57 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/module_ancestors_variable/set_spec.rb +57 -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/addressable/uri/query_value_spec.rb +25 -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/acts_as_abstract_spec.rb +14 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/class/method_class_spec.rb +20 -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/class/static_method_class_spec.rb +20 -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/if_key_spec.rb +23 -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 +37 -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/simple_cache_spec.rb +15 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/module/speaker_spec.rb +15 -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/recursive_build_spec.rb +62 -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/assert_parent_spec.rb +21 -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/child_of_spec.rb +26 -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/base_spec/stubbed_module_a.rb +6 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub/base_spec/stubbed_not_module.rb +6 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub/base_spec.rb +19 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/rspec/setup/setup_manager_spec.rb +17 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/ruby/on_clean_environment_spec.rb +31 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/ruby/on_replace_objects_spec.rb +65 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/settings_provider_spec.rb +64 -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/static_method_class_spec.rb +44 -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/wildcards_spec.rb +27 -0
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/yaml_spec.rb +76 -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 +317 -37
- data/sub/avm-eac_rails_base1/avm-eac_rails_base1.gemspec +0 -22
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/apache_base.rb +0 -16
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/apache_host.rb +0 -18
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/apache_path.rb +0 -21
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/base.rb +0 -50
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/deploy.rb +0 -23
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/processes/daemon.rb +0 -39
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/processes/tasks_scheduler.rb +0 -27
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/processes.rb +0 -13
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/runners/bundle.rb +0 -28
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/runners/code_runner.rb +0 -28
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/runners/log.rb +0 -45
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/runners/logs/clear.rb +0 -27
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/runners/logs.rb +0 -19
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/runners/rails_server.rb +0 -34
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/runners/tasks_scheduler/systemd_unit.rb +0 -48
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/runners/tasks_scheduler.rb +0 -19
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/runners.rb +0 -13
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/systemd_unit/service.rb +0 -72
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/systemd_unit/tasks_scheduler_command.rb +0 -31
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/systemd_unit.rb +0 -59
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances.rb +0 -11
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner_with/bundle.rb +0 -27
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner_with/rails_environment.rb +0 -47
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/sources/base.rb +0 -43
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/version.rb +0 -7
- data/sub/avm-eac_rails_base1/template/avm/eac_rails_base1/instances/apache_path/extra_content.conf +0 -5
- data/sub/avm-eac_rails_base1/template/avm/eac_rails_base1/instances/systemd_unit/tasks_scheduler.service +0 -12
- data/sub/avm-eac_rails_base1/template/avm/eac_rails_base1/instances/systemd_unit/tasks_scheduler_command.sh +0 -6
- /data/sub/{avm-eac_rails_base1 → eac_config}/Gemfile +0 -0
- /data/sub/{avm-eac_rails_base1 → eac_config}/spec/rubocop_spec.rb +0 -0
- /data/sub/{avm-eac_rails_base1 → eac_config}/spec/spec_helper.rb +0 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/concern'
|
4
|
+
require 'eac_ruby_utils/common_concern/class_setup'
|
5
|
+
require 'eac_ruby_utils/simple_cache'
|
6
|
+
require 'eac_ruby_utils/patches/object/if_present'
|
7
|
+
|
8
|
+
module EacRubyUtils
|
9
|
+
class CommonConcern
|
10
|
+
class ModuleSetup
|
11
|
+
include ::EacRubyUtils::SimpleCache
|
12
|
+
attr_reader :a_module, :common_concern
|
13
|
+
|
14
|
+
def initialize(common_concern, a_module)
|
15
|
+
@common_concern = common_concern
|
16
|
+
@a_module = a_module
|
17
|
+
end
|
18
|
+
|
19
|
+
def run
|
20
|
+
a_module.extend(::ActiveSupport::Concern)
|
21
|
+
include_or_prepend(:included, :include)
|
22
|
+
include_or_prepend(:prepended, :prepend)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def include_or_prepend(module_method, class_setup_method)
|
28
|
+
setup = self
|
29
|
+
a_module.send(module_method, *a_module_method_args(module_method)) do
|
30
|
+
::EacRubyUtils::CommonConcern::ClassSetup.new(setup, self, class_setup_method).run
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def a_module_method_args(module_method)
|
35
|
+
method_arity = a_module.method(module_method).arity
|
36
|
+
method_arity = -method_arity - 1 if method_arity.negative?
|
37
|
+
method_arity.times.map { |_n| a_module }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/common_concern/module_setup'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
class CommonConcern
|
7
|
+
CLASS_METHODS_MODULE_NAME = 'ClassMethods'
|
8
|
+
INSTANCE_METHODS_MODULE_NAME = 'InstanceMethods'
|
9
|
+
|
10
|
+
attr_reader :after_callback
|
11
|
+
|
12
|
+
def initialize(&after_callback)
|
13
|
+
@after_callback = after_callback
|
14
|
+
end
|
15
|
+
|
16
|
+
def setup(a_module)
|
17
|
+
::EacRubyUtils::CommonConcern::ModuleSetup.new(self, a_module).run
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/common_constructor/instance_initialize'
|
4
|
+
require 'eac_ruby_utils/common_constructor/super_args'
|
5
|
+
|
6
|
+
module EacRubyUtils
|
7
|
+
class CommonConstructor
|
8
|
+
class ClassAccessors
|
9
|
+
attr_reader :common_constructor, :klass
|
10
|
+
|
11
|
+
def initialize(common_constructor, klass)
|
12
|
+
@common_constructor = common_constructor
|
13
|
+
@klass = klass
|
14
|
+
end
|
15
|
+
|
16
|
+
def args
|
17
|
+
common_constructor.all_args
|
18
|
+
end
|
19
|
+
|
20
|
+
def perform
|
21
|
+
setup_class_attr_readers
|
22
|
+
setup_class_attr_writers
|
23
|
+
end
|
24
|
+
|
25
|
+
def setup_class_attr_readers
|
26
|
+
klass.send(:attr_reader, *args)
|
27
|
+
klass.send(:public, *args) if args.any?
|
28
|
+
end
|
29
|
+
|
30
|
+
def setup_class_attr_writers
|
31
|
+
klass.send(:attr_writer, *args)
|
32
|
+
klass.send(:private, *args.map { |a| "#{a}=" }) if args.any?
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/common_constructor/instance_initialize'
|
4
|
+
require 'eac_ruby_utils/common_constructor/super_args'
|
5
|
+
|
6
|
+
module EacRubyUtils
|
7
|
+
class CommonConstructor
|
8
|
+
class ClassInitialize
|
9
|
+
attr_reader :common_constructor, :klass
|
10
|
+
|
11
|
+
def initialize(common_constructor, klass)
|
12
|
+
@common_constructor = common_constructor
|
13
|
+
@klass = klass
|
14
|
+
end
|
15
|
+
|
16
|
+
def define_initialize_callbacks
|
17
|
+
klass.include(::ActiveSupport::Callbacks)
|
18
|
+
klass.define_callbacks :initialize
|
19
|
+
end
|
20
|
+
|
21
|
+
def define_initialize_method
|
22
|
+
class_initialize = self
|
23
|
+
klass.send(:define_method, :initialize) do |*args, &block|
|
24
|
+
::EacRubyUtils::CommonConstructor::InstanceInitialize.new(
|
25
|
+
class_initialize.common_constructor, args, self, block
|
26
|
+
).perform
|
27
|
+
super(*::EacRubyUtils::CommonConstructor::SuperArgs.new(
|
28
|
+
class_initialize, args, self
|
29
|
+
).result)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def perform
|
34
|
+
define_initialize_callbacks
|
35
|
+
define_initialize_method
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacRubyUtils
|
4
|
+
class CommonConstructor
|
5
|
+
class InstanceInitialize
|
6
|
+
attr_reader :common_constructor, :args, :object, :block
|
7
|
+
|
8
|
+
def initialize(common_constructor, args, object, block)
|
9
|
+
@common_constructor = common_constructor
|
10
|
+
@args = args
|
11
|
+
@object = object
|
12
|
+
@block = block
|
13
|
+
end
|
14
|
+
|
15
|
+
def perform
|
16
|
+
validate_args_count
|
17
|
+
object.run_callbacks :initialize do
|
18
|
+
object_attributes_set
|
19
|
+
object_block_set
|
20
|
+
object_after_callback
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def arg_value(arg_name)
|
27
|
+
arg_index = common_constructor.args.index(arg_name)
|
28
|
+
if arg_index < args.count
|
29
|
+
args[arg_index]
|
30
|
+
else
|
31
|
+
common_constructor.default_values[arg_index - common_constructor.args_count_min]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def object_after_callback
|
36
|
+
return unless common_constructor.after_set_block
|
37
|
+
|
38
|
+
object.instance_eval(&common_constructor.after_set_block)
|
39
|
+
end
|
40
|
+
|
41
|
+
def object_attribute_set(attr_name, attr_value)
|
42
|
+
object.send("#{attr_name}=", attr_value)
|
43
|
+
end
|
44
|
+
|
45
|
+
def object_attributes_set
|
46
|
+
common_constructor.args.each do |arg_name|
|
47
|
+
object_attribute_set(arg_name, arg_value(arg_name))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def object_block_set
|
52
|
+
block_arg = common_constructor.block_arg
|
53
|
+
object_attribute_set(block_arg, block) if block_arg
|
54
|
+
end
|
55
|
+
|
56
|
+
def validate_args_count
|
57
|
+
return if common_constructor.args_count.include?(args.count)
|
58
|
+
|
59
|
+
raise ArgumentError, "#{object.class}.initialize: wrong number of arguments " \
|
60
|
+
"(given #{args.count}, expected #{common_constructor.args_count})"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/module/delegation'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
class CommonConstructor
|
7
|
+
class SuperArgs
|
8
|
+
attr_reader :class_initialize, :args, :object
|
9
|
+
|
10
|
+
delegate :common_constructor, to: :class_initialize
|
11
|
+
|
12
|
+
def initialize(class_initialize, args, object)
|
13
|
+
@class_initialize = class_initialize
|
14
|
+
@args = args
|
15
|
+
@object = object
|
16
|
+
end
|
17
|
+
|
18
|
+
def auto_result
|
19
|
+
r = []
|
20
|
+
sub_args.each do |name, value|
|
21
|
+
i = super_arg_index(name)
|
22
|
+
r[i] = value if i
|
23
|
+
end
|
24
|
+
r
|
25
|
+
end
|
26
|
+
|
27
|
+
def result
|
28
|
+
result_from_options || auto_result
|
29
|
+
end
|
30
|
+
|
31
|
+
def result_from_options
|
32
|
+
return unless common_constructor.super_args
|
33
|
+
|
34
|
+
object.instance_exec(&common_constructor.super_args)
|
35
|
+
end
|
36
|
+
|
37
|
+
def sub_args
|
38
|
+
common_constructor.args.each_with_index.to_h do |name, index|
|
39
|
+
[name, args[index]]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def super_arg_index(name)
|
44
|
+
super_method.parameters.each_with_index do |arg, index|
|
45
|
+
return index if arg[1] == name
|
46
|
+
end
|
47
|
+
nil
|
48
|
+
end
|
49
|
+
|
50
|
+
def super_method
|
51
|
+
class_initialize.klass.superclass&.instance_method(:initialize)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/callbacks'
|
4
|
+
require 'eac_ruby_utils/arguments_consumer'
|
5
|
+
require 'eac_ruby_utils/common_constructor/class_accessors'
|
6
|
+
require 'eac_ruby_utils/common_constructor/class_initialize'
|
7
|
+
|
8
|
+
module EacRubyUtils
|
9
|
+
class CommonConstructor
|
10
|
+
attr_reader :all_args, :options, :after_set_block
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def parse_args_options(args)
|
14
|
+
result = ::Struct.new(:args, :options).new([], {})
|
15
|
+
options_reached = false
|
16
|
+
args.each do |arg|
|
17
|
+
raise "Options reached and there is more arguments (Arguments: #{args})" if
|
18
|
+
options_reached
|
19
|
+
|
20
|
+
options_reached = parse_arg_options_process_arg(result, arg)
|
21
|
+
end
|
22
|
+
result
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def parse_arg_options_process_arg(result, arg)
|
28
|
+
if arg.is_a?(::Hash)
|
29
|
+
result.options = arg
|
30
|
+
true
|
31
|
+
else
|
32
|
+
result.args << arg
|
33
|
+
false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def initialize(*args, &after_set_block)
|
39
|
+
args_processed = self.class.parse_args_options(args)
|
40
|
+
@all_args = args_processed.args
|
41
|
+
@options = args_processed.options
|
42
|
+
@after_set_block = after_set_block
|
43
|
+
end
|
44
|
+
|
45
|
+
def args
|
46
|
+
block_arg? ? all_args[0..-2] : all_args
|
47
|
+
end
|
48
|
+
|
49
|
+
def args_count
|
50
|
+
(args_count_min..args_count_max)
|
51
|
+
end
|
52
|
+
|
53
|
+
def args_count_min
|
54
|
+
args.count - default_values.count
|
55
|
+
end
|
56
|
+
|
57
|
+
def args_count_max
|
58
|
+
args.count
|
59
|
+
end
|
60
|
+
|
61
|
+
def block_arg
|
62
|
+
block_arg? ? all_args.last : nil
|
63
|
+
end
|
64
|
+
|
65
|
+
def block_arg?
|
66
|
+
options[:block_arg] || false
|
67
|
+
end
|
68
|
+
|
69
|
+
def default_values
|
70
|
+
options[:default] || []
|
71
|
+
end
|
72
|
+
|
73
|
+
def setup_class(klass)
|
74
|
+
setup_class_accessors(klass)
|
75
|
+
|
76
|
+
setup_class_initialize(klass)
|
77
|
+
|
78
|
+
klass
|
79
|
+
end
|
80
|
+
|
81
|
+
def setup_class_accessors(klass)
|
82
|
+
::EacRubyUtils::CommonConstructor::ClassAccessors.new(self, klass).perform
|
83
|
+
end
|
84
|
+
|
85
|
+
def setup_class_initialize(klass)
|
86
|
+
::EacRubyUtils::CommonConstructor::ClassInitialize.new(self, klass).perform
|
87
|
+
end
|
88
|
+
|
89
|
+
def super_args
|
90
|
+
options[:super_args]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacRubyUtils
|
4
|
+
class Compact
|
5
|
+
ATTRIBUTE_SEPARATOR = '.'
|
6
|
+
|
7
|
+
attr_reader :object, :attributes
|
8
|
+
|
9
|
+
def initialize(object, attributes)
|
10
|
+
@object = object
|
11
|
+
@attributes = attributes
|
12
|
+
end
|
13
|
+
|
14
|
+
# @param attr_path [String, Symbol] A path separated by +ATTRIBUTE_SEPARATOR+.
|
15
|
+
# @return [Object]
|
16
|
+
def attribute_value(attr_path)
|
17
|
+
attr_path.to_s.split(ATTRIBUTE_SEPARATOR).inject(object) do |a, e|
|
18
|
+
a.send(e)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Array]
|
23
|
+
def to_a
|
24
|
+
attributes.map { |attr| attribute_value(attr) }
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Hash]
|
28
|
+
def to_h
|
29
|
+
attributes.to_h { |attr| [attr.to_sym, attribute_value(attr)] }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/common_concern/module_setup'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
class CompareBy
|
7
|
+
attr_reader :fields
|
8
|
+
|
9
|
+
def initialize(fields)
|
10
|
+
@fields = fields
|
11
|
+
end
|
12
|
+
|
13
|
+
def apply(klass)
|
14
|
+
pself = self
|
15
|
+
klass.include(::Comparable)
|
16
|
+
%i[<=> eql?].each do |cmp_method|
|
17
|
+
klass.define_method(cmp_method) do |other|
|
18
|
+
pself.object_values(self).send(cmp_method, pself.object_values(other))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
klass.define_method(:hash) { pself.object_values(self).hash }
|
22
|
+
end
|
23
|
+
|
24
|
+
def object_values(object)
|
25
|
+
fields.map { |field| object.send(field) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacRubyUtils
|
4
|
+
class Context
|
5
|
+
delegate :any?, to: :stack
|
6
|
+
|
7
|
+
def current
|
8
|
+
optional_current || raise('No elements in context')
|
9
|
+
end
|
10
|
+
|
11
|
+
def optional_current
|
12
|
+
stack.last
|
13
|
+
end
|
14
|
+
|
15
|
+
delegate :pop, to: :stack
|
16
|
+
delegate :push, to: :stack
|
17
|
+
|
18
|
+
def on(obj)
|
19
|
+
push(obj)
|
20
|
+
begin
|
21
|
+
yield
|
22
|
+
ensure
|
23
|
+
pop
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def stack
|
30
|
+
@stack ||= []
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/context'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
module Contextualizable
|
7
|
+
common_concern
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def context
|
11
|
+
@context ||= ::EacRubyUtils::Context.new
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module InstanceMethods
|
16
|
+
def context
|
17
|
+
self.class.context
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacRubyUtils
|
4
|
+
# A formatter like [String.sprintf].
|
5
|
+
class CustomFormat
|
6
|
+
TYPE_PATTERN = /[a-zA-Z]/.freeze
|
7
|
+
SEQUENCE_PATTERN = /(?<!%)%(#{TYPE_PATTERN})/.freeze
|
8
|
+
|
9
|
+
attr_reader :mapping
|
10
|
+
|
11
|
+
def initialize(mapping)
|
12
|
+
@mapping = mapping.transform_keys(&:to_sym).freeze
|
13
|
+
end
|
14
|
+
|
15
|
+
def format(string)
|
16
|
+
::EacRubyUtils::CustomFormat::String.new(self, string)
|
17
|
+
end
|
18
|
+
|
19
|
+
class String
|
20
|
+
attr_reader :format, :string
|
21
|
+
|
22
|
+
def initialize(format, string)
|
23
|
+
@format = format
|
24
|
+
@string = string
|
25
|
+
end
|
26
|
+
|
27
|
+
def mapping
|
28
|
+
@mapping ||= format.mapping.select do |k, _v|
|
29
|
+
sequences.include?(k)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def sequences
|
34
|
+
@sequences ||= string.scan(SEQUENCE_PATTERN).map(&:first).uniq.map(&:to_sym)
|
35
|
+
end
|
36
|
+
|
37
|
+
def source_object_value(object, method)
|
38
|
+
return object.send(method) if object.respond_to?(method)
|
39
|
+
return object[method] if object.respond_to?('[]')
|
40
|
+
|
41
|
+
raise ::ArgumentError, "Methods \"#{method}\" or \"[]\" not found for #{object}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def with(source_object)
|
45
|
+
r = string
|
46
|
+
mapping.each do |key, method|
|
47
|
+
r = r.gsub(/%#{::Regexp.quote(key)}/, source_object_value(source_object, method).to_s)
|
48
|
+
end
|
49
|
+
r.gsub('%%', '%')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/inflector'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
# Similar to Java's enum type (https://docs.oracle.com/javase/tutorial/java/javaOO/enum.html).
|
7
|
+
class Enum
|
8
|
+
class << self
|
9
|
+
def enum(key, *args, &block)
|
10
|
+
value = Value.new(self, key, args, &block)
|
11
|
+
raise ::ArgumentError, "#{self} already has a value with key=#{value.key}" if
|
12
|
+
value_set.include?(value)
|
13
|
+
|
14
|
+
value_set << value.apply
|
15
|
+
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def values
|
20
|
+
value_set.map(&:value)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def value_set
|
26
|
+
@value_set ||= []
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
attr_reader :key
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
def initialize(key)
|
35
|
+
@key = key
|
36
|
+
end
|
37
|
+
|
38
|
+
class Value
|
39
|
+
include ::Comparable
|
40
|
+
|
41
|
+
attr_reader :klass, :key, :args, :block
|
42
|
+
|
43
|
+
def initialize(klass, key, args, &block)
|
44
|
+
@klass = klass
|
45
|
+
@key = ::EacRubyUtils::Inflector.variableize(key.to_s).to_sym
|
46
|
+
@args = args
|
47
|
+
@block = block
|
48
|
+
end
|
49
|
+
|
50
|
+
def <=>(other)
|
51
|
+
key <=> other.key
|
52
|
+
end
|
53
|
+
|
54
|
+
def apply
|
55
|
+
define_constant
|
56
|
+
define_class_method
|
57
|
+
|
58
|
+
self
|
59
|
+
end
|
60
|
+
|
61
|
+
# @return [String]
|
62
|
+
def class_method_name
|
63
|
+
key.to_s
|
64
|
+
end
|
65
|
+
|
66
|
+
# @return [String]
|
67
|
+
def constant_name
|
68
|
+
class_method_name.upcase
|
69
|
+
end
|
70
|
+
|
71
|
+
def value
|
72
|
+
@value ||= uncached_value
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def define_class_method
|
78
|
+
the_value = self
|
79
|
+
klass.define_singleton_method(class_method_name) { the_value.value }
|
80
|
+
end
|
81
|
+
|
82
|
+
def define_constant
|
83
|
+
klass.const_set(constant_name, value)
|
84
|
+
end
|
85
|
+
|
86
|
+
def uncached_value
|
87
|
+
klass.new(key, *value_args)
|
88
|
+
end
|
89
|
+
|
90
|
+
def value_args
|
91
|
+
r = if block
|
92
|
+
block.call
|
93
|
+
elsif args.count == 1 && args.first.is_a?(::Enumerable)
|
94
|
+
args.first
|
95
|
+
else
|
96
|
+
args
|
97
|
+
end
|
98
|
+
r.is_a?(::Enumerable) ? r : [r]
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/object/debug'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
module EnumerablesMethods
|
7
|
+
class << self
|
8
|
+
WRITE_METHOD_PATTERNS = [/\A[a-z].*[\!\=]\z/i] +
|
9
|
+
%i[\[\]= <<].map { |m| /\A#{::Regexp.quote(m)}\z/ } +
|
10
|
+
%i[add clear delete divide keep reset shift subtract]
|
11
|
+
.map { |m| /\A#{::Regexp.quote(m)}.*\z/ }
|
12
|
+
|
13
|
+
# @param klass [Klass]
|
14
|
+
# @return [Enumerable<Symbol>]
|
15
|
+
def self_methods_names(klass)
|
16
|
+
(klass.public_instance_methods - klass.superclass.public_instance_methods).sort
|
17
|
+
end
|
18
|
+
|
19
|
+
# @param method_name [Symbol]
|
20
|
+
# @return [Boolean]
|
21
|
+
def write_method?(method_name)
|
22
|
+
WRITE_METHOD_PATTERNS.any? { |pattern| pattern.match?(method_name.to_s) }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
ARRAY_METHODS = self_methods_names(::Array)
|
27
|
+
ARRAY_WRITE_METHODS = ARRAY_METHODS.select { |m| write_method?(m) }
|
28
|
+
ARRAY_READ_METHODS = ARRAY_METHODS - ARRAY_WRITE_METHODS
|
29
|
+
|
30
|
+
ENUMERABLE_METHODS = ::Enumerable.public_instance_methods.sort
|
31
|
+
ENUMERABLE_WRITE_METHODS = ENUMERABLE_METHODS.select { |m| write_method?(m) }
|
32
|
+
ENUMERABLE_READ_METHODS = ENUMERABLE_METHODS - ENUMERABLE_WRITE_METHODS
|
33
|
+
|
34
|
+
HASH_METHODS = self_methods_names(::Hash)
|
35
|
+
HASH_WRITE_METHODS = HASH_METHODS.select { |m| write_method?(m) }
|
36
|
+
HASH_READ_METHODS = HASH_METHODS - HASH_WRITE_METHODS
|
37
|
+
|
38
|
+
SET_METHODS = self_methods_names(::Set)
|
39
|
+
SET_WRITE_METHODS = SET_METHODS.select { |m| write_method?(m) } + [:merge]
|
40
|
+
SET_READ_METHODS = SET_METHODS - SET_WRITE_METHODS
|
41
|
+
end
|
42
|
+
end
|