facets 1.8.49 → 1.8.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/PROJECT +4 -1
- data/Rakefile +25 -48
- data/VERSION +1 -1
- data/doc/AUTHORS +1 -0
- data/doc/CHANGES +6 -0
- data/lib/facets/core/kernel/tap.rb +33 -3
- data/lib/facets/more/command.rb +507 -271
- metadata +2 -548
- data/test/lib/facets/core/array/test_at_rand.rb +0 -34
- data/test/lib/facets/core/array/test_delete_unless.rb +0 -28
- data/test/lib/facets/core/array/test_delete_values.rb +0 -28
- data/test/lib/facets/core/array/test_delete_values_at.rb +0 -31
- data/test/lib/facets/core/array/test_first.rb +0 -46
- data/test/lib/facets/core/array/test_head.rb +0 -42
- data/test/lib/facets/core/array/test_last_index.rb +0 -26
- data/test/lib/facets/core/array/test_merge.rb +0 -35
- data/test/lib/facets/core/array/test_mid.rb +0 -33
- data/test/lib/facets/core/array/test_middle.rb +0 -29
- data/test/lib/facets/core/array/test_op_div.rb +0 -27
- data/test/lib/facets/core/array/test_op_fetch.rb +0 -35
- data/test/lib/facets/core/array/test_pad.rb +0 -48
- data/test/lib/facets/core/array/test_pick.rb +0 -40
- data/test/lib/facets/core/array/test_pos.rb +0 -28
- data/test/lib/facets/core/array/test_pot.rb +0 -28
- data/test/lib/facets/core/array/test_pull.rb +0 -28
- data/test/lib/facets/core/array/test_rand_index.rb +0 -29
- data/test/lib/facets/core/array/test_rand_subset.rb +0 -29
- data/test/lib/facets/core/array/test_range.rb +0 -32
- data/test/lib/facets/core/array/test_rotate.rb +0 -36
- data/test/lib/facets/core/array/test_select.rb +0 -28
- data/test/lib/facets/core/array/test_shuffle.rb +0 -35
- data/test/lib/facets/core/array/test_thru.rb +0 -27
- data/test/lib/facets/core/array/test_to_b.rb +0 -27
- data/test/lib/facets/core/array/test_to_h.rb +0 -33
- data/test/lib/facets/core/array/test_to_hash.rb +0 -27
- data/test/lib/facets/core/binding/self/test_of_caller.rb +0 -35
- data/test/lib/facets/core/binding/test___LINE__.rb +0 -43
- data/test/lib/facets/core/binding/test_call_stack.rb +0 -34
- data/test/lib/facets/core/binding/test_called.rb +0 -30
- data/test/lib/facets/core/binding/test_caller.rb +0 -35
- data/test/lib/facets/core/binding/test_defined.rb +0 -34
- data/test/lib/facets/core/binding/test_eval.rb +0 -34
- data/test/lib/facets/core/binding/test_local_variables.rb +0 -34
- data/test/lib/facets/core/binding/test_method_name.rb +0 -34
- data/test/lib/facets/core/binding/test_op_fetch.rb +0 -34
- data/test/lib/facets/core/binding/test_op_store.rb +0 -35
- data/test/lib/facets/core/binding/test_self.rb +0 -34
- data/test/lib/facets/core/class/test_cattr.rb +0 -63
- data/test/lib/facets/core/class/test_descendents.rb +0 -30
- data/test/lib/facets/core/class/test_method_name.rb +0 -26
- data/test/lib/facets/core/class/test_remove_descendents.rb +0 -32
- data/test/lib/facets/core/class/test_unix_path.rb +0 -26
- data/test/lib/facets/core/comparable/test_at_least.rb +0 -34
- data/test/lib/facets/core/comparable/test_clip.rb +0 -44
- data/test/lib/facets/core/comparable/test_cmp.rb +0 -28
- data/test/lib/facets/core/continuation/self/test_create.rb +0 -26
- data/test/lib/facets/core/date/test_days_in_month.rb +0 -30
- data/test/lib/facets/core/date/test_days_of_month.rb +0 -30
- data/test/lib/facets/core/date/test_stamp.rb +0 -38
- data/test/lib/facets/core/date/test_to_date.rb +0 -30
- data/test/lib/facets/core/date/test_to_s.rb +0 -30
- data/test/lib/facets/core/date/test_to_time.rb +0 -30
- data/test/lib/facets/core/dir/self/test_ancestor.rb +0 -26
- data/test/lib/facets/core/dir/self/test_ascend.rb +0 -41
- data/test/lib/facets/core/enumerable/self/test_combinations.rb +0 -46
- data/test/lib/facets/core/enumerable/test_cart.rb +0 -49
- data/test/lib/facets/core/enumerable/test_collect_with_index.rb +0 -27
- data/test/lib/facets/core/enumerable/test_commonality.rb +0 -31
- data/test/lib/facets/core/enumerable/test_compact_collect.rb +0 -27
- data/test/lib/facets/core/enumerable/test_count.rb +0 -38
- data/test/lib/facets/core/enumerable/test_each_by.rb +0 -71
- data/test/lib/facets/core/enumerable/test_each_combination.rb +0 -29
- data/test/lib/facets/core/enumerable/test_each_pair.rb +0 -29
- data/test/lib/facets/core/enumerable/test_each_slice.rb +0 -57
- data/test/lib/facets/core/enumerable/test_each_unique_pair.rb +0 -29
- data/test/lib/facets/core/enumerable/test_eachn.rb +0 -34
- data/test/lib/facets/core/enumerable/test_elementwise.rb +0 -40
- data/test/lib/facets/core/enumerable/test_entropy.rb +0 -26
- data/test/lib/facets/core/enumerable/test_every.rb +0 -35
- data/test/lib/facets/core/enumerable/test_ew.rb +0 -31
- data/test/lib/facets/core/enumerable/test_filter_collect.rb +0 -31
- data/test/lib/facets/core/enumerable/test_find_collisions.rb +0 -30
- data/test/lib/facets/core/enumerable/test_frequency.rb +0 -27
- data/test/lib/facets/core/enumerable/test_graph.rb +0 -30
- data/test/lib/facets/core/enumerable/test_ideal_entropy.rb +0 -27
- data/test/lib/facets/core/enumerable/test_none.rb +0 -33
- data/test/lib/facets/core/enumerable/test_occur.rb +0 -30
- data/test/lib/facets/core/enumerable/test_one.rb +0 -35
- data/test/lib/facets/core/enumerable/test_op_pow.rb +0 -27
- data/test/lib/facets/core/enumerable/test_op_tilde_self.rb +0 -40
- data/test/lib/facets/core/enumerable/test_partition_by.rb +0 -31
- data/test/lib/facets/core/enumerable/test_permutation.rb +0 -29
- data/test/lib/facets/core/enumerable/test_probability.rb +0 -27
- data/test/lib/facets/core/enumerable/test_to_h.rb +0 -27
- data/test/lib/facets/core/enumerable/test_uniq_by.rb +0 -28
- data/test/lib/facets/core/file/self/test_create.rb +0 -44
- data/test/lib/facets/core/file/self/test_open_as_string.rb +0 -50
- data/test/lib/facets/core/file/self/test_read_list.rb +0 -40
- data/test/lib/facets/core/file/self/test_sanitize.rb +0 -46
- data/test/lib/facets/core/file/self/test_split_all.rb +0 -27
- data/test/lib/facets/core/float/test_round_at.rb +0 -46
- data/test/lib/facets/core/float/test_round_to.rb +0 -46
- data/test/lib/facets/core/hash/self/test_zipnew.rb +0 -28
- data/test/lib/facets/core/hash/test_alias.rb +0 -31
- data/test/lib/facets/core/hash/test_assert_has_keys.rb +0 -27
- data/test/lib/facets/core/hash/test_assert_has_only_keys.rb +0 -27
- data/test/lib/facets/core/hash/test_at.rb +0 -28
- data/test/lib/facets/core/hash/test_collate.rb +0 -35
- data/test/lib/facets/core/hash/test_each_with_index.rb +0 -29
- data/test/lib/facets/core/hash/test_each_with_key.rb +0 -29
- data/test/lib/facets/core/hash/test_graph.rb +0 -28
- data/test/lib/facets/core/hash/test_has_keys.rb +0 -27
- data/test/lib/facets/core/hash/test_has_only_keys.rb +0 -27
- data/test/lib/facets/core/hash/test_inverse.rb +0 -30
- data/test/lib/facets/core/hash/test_normalize_keys.rb +0 -34
- data/test/lib/facets/core/hash/test_op_fetch.rb +0 -111
- data/test/lib/facets/core/hash/test_op_lshift.rb +0 -29
- data/test/lib/facets/core/hash/test_rand_key.rb +0 -27
- data/test/lib/facets/core/hash/test_rand_pair.rb +0 -27
- data/test/lib/facets/core/hash/test_rand_value.rb +0 -27
- data/test/lib/facets/core/hash/test_rekey.rb +0 -52
- data/test/lib/facets/core/hash/test_replace_each.rb +0 -29
- data/test/lib/facets/core/hash/test_shuffle.rb +0 -32
- data/test/lib/facets/core/hash/test_slice.rb +0 -27
- data/test/lib/facets/core/hash/test_stringify_keys.rb +0 -34
- data/test/lib/facets/core/hash/test_swap.rb +0 -27
- data/test/lib/facets/core/hash/test_swapkey.rb +0 -29
- data/test/lib/facets/core/hash/test_symbolize_keys.rb +0 -34
- data/test/lib/facets/core/hash/test_to_h.rb +0 -27
- data/test/lib/facets/core/hash/test_to_ostruct.rb +0 -30
- data/test/lib/facets/core/hash/test_to_ostruct_recurse.rb +0 -44
- data/test/lib/facets/core/hash/test_traverse.rb +0 -37
- data/test/lib/facets/core/hash/test_update_each.rb +0 -29
- data/test/lib/facets/core/hash/test_update_keys.rb +0 -28
- data/test/lib/facets/core/hash/test_update_values.rb +0 -28
- data/test/lib/facets/core/hash/test_weave.rb +0 -29
- data/test/lib/facets/core/integer/test_factorial.rb +0 -30
- data/test/lib/facets/core/integer/test_multiple.rb +0 -43
- data/test/lib/facets/core/integer/test_of.rb +0 -28
- data/test/lib/facets/core/integer/test_ordinal.rb +0 -29
- data/test/lib/facets/core/integer/test_times_collect.rb +0 -28
- data/test/lib/facets/core/kernel/test___class__.rb +0 -26
- data/test/lib/facets/core/kernel/test_as.rb +0 -42
- data/test/lib/facets/core/kernel/test_assign_from.rb +0 -31
- data/test/lib/facets/core/kernel/test_assign_with.rb +0 -31
- data/test/lib/facets/core/kernel/test_bool.rb +0 -41
- data/test/lib/facets/core/kernel/test_bug.rb +0 -26
- data/test/lib/facets/core/kernel/test_call_stack.rb +0 -26
- data/test/lib/facets/core/kernel/test_called.rb +0 -26
- data/test/lib/facets/core/kernel/test_callee.rb +0 -26
- data/test/lib/facets/core/kernel/test_constant.rb +0 -33
- data/test/lib/facets/core/kernel/test_copy.rb +0 -40
- data/test/lib/facets/core/kernel/test_deep_copy.rb +0 -40
- data/test/lib/facets/core/kernel/test_demo.rb +0 -28
- data/test/lib/facets/core/kernel/test_fn.rb +0 -26
- data/test/lib/facets/core/kernel/test_get_by_id.rb +0 -28
- data/test/lib/facets/core/kernel/test_here.rb +0 -26
- data/test/lib/facets/core/kernel/test_in.rb +0 -27
- data/test/lib/facets/core/kernel/test_instance_class.rb +0 -27
- data/test/lib/facets/core/kernel/test_instance_exec.rb +0 -58
- data/test/lib/facets/core/kernel/test_maybe.rb +0 -26
- data/test/lib/facets/core/kernel/test_meta_class.rb +0 -27
- data/test/lib/facets/core/kernel/test_metaclass.rb +0 -27
- data/test/lib/facets/core/kernel/test_method.rb +0 -32
- data/test/lib/facets/core/kernel/test_methods.rb +0 -50
- data/test/lib/facets/core/kernel/test_new.rb +0 -30
- data/test/lib/facets/core/kernel/test_object_class.rb +0 -26
- data/test/lib/facets/core/kernel/test_object_hexid.rb +0 -27
- data/test/lib/facets/core/kernel/test_qua_class.rb +0 -27
- data/test/lib/facets/core/kernel/test_require_all.rb +0 -26
- data/test/lib/facets/core/kernel/test_require_esc.rb +0 -27
- data/test/lib/facets/core/kernel/test_resc.rb +0 -27
- data/test/lib/facets/core/kernel/test_send_as.rb +0 -26
- data/test/lib/facets/core/kernel/test_set_from.rb +0 -33
- data/test/lib/facets/core/kernel/test_set_with.rb +0 -42
- data/test/lib/facets/core/kernel/test_silently.rb +0 -28
- data/test/lib/facets/core/kernel/test_singleton.rb +0 -40
- data/test/lib/facets/core/kernel/test_singleton_class.rb +0 -27
- data/test/lib/facets/core/kernel/test_super_at.rb +0 -30
- data/test/lib/facets/core/kernel/test_supermethod.rb +0 -33
- data/test/lib/facets/core/kernel/test_this.rb +0 -26
- data/test/lib/facets/core/kernel/test_to_b.rb +0 -28
- data/test/lib/facets/core/kernel/test_to_bool.rb +0 -28
- data/test/lib/facets/core/kernel/test_to_data.rb +0 -61
- data/test/lib/facets/core/kernel/test_uri.rb +0 -30
- data/test/lib/facets/core/kernel/test_val.rb +0 -43
- data/test/lib/facets/core/kernel/test_with.rb +0 -30
- data/test/lib/facets/core/kernel/test_with_accessor.rb +0 -51
- data/test/lib/facets/core/matchdata/test_match.rb +0 -29
- data/test/lib/facets/core/matchdata/test_matchtree.rb +0 -37
- data/test/lib/facets/core/module/self/test_op_add.rb +0 -50
- data/test/lib/facets/core/module/test_abstract.rb +0 -36
- data/test/lib/facets/core/module/test_alias_method_chain.rb +0 -46
- data/test/lib/facets/core/module/test_alias_module_function.rb +0 -34
- data/test/lib/facets/core/module/test_ancestor.rb +0 -26
- data/test/lib/facets/core/module/test_attr_tester.rb +0 -39
- data/test/lib/facets/core/module/test_basename.rb +0 -26
- data/test/lib/facets/core/module/test_by_name.rb +0 -29
- data/test/lib/facets/core/module/test_class_extension.rb +0 -70
- data/test/lib/facets/core/module/test_clone_using.rb +0 -55
- data/test/lib/facets/core/module/test_dirname.rb +0 -26
- data/test/lib/facets/core/module/test_equate_on.rb +0 -37
- data/test/lib/facets/core/module/test_include_as.rb +0 -45
- data/test/lib/facets/core/module/test_initializer.rb +0 -32
- data/test/lib/facets/core/module/test_instance_methods.rb +0 -59
- data/test/lib/facets/core/module/test_integrate.rb +0 -35
- data/test/lib/facets/core/module/test_memoize.rb +0 -50
- data/test/lib/facets/core/module/test_modspace.rb +0 -27
- data/test/lib/facets/core/module/test_namespace.rb +0 -66
- data/test/lib/facets/core/module/test_nesting.rb +0 -36
- data/test/lib/facets/core/module/test_new.rb +0 -34
- data/test/lib/facets/core/module/test_nodef.rb +0 -30
- data/test/lib/facets/core/module/test_on_included.rb +0 -36
- data/test/lib/facets/core/module/test_redef.rb +0 -30
- data/test/lib/facets/core/module/test_redefine_method.rb +0 -30
- data/test/lib/facets/core/module/test_redirect.rb +0 -30
- data/test/lib/facets/core/module/test_redirect_method.rb +0 -30
- data/test/lib/facets/core/module/test_remove.rb +0 -30
- data/test/lib/facets/core/module/test_rename.rb +0 -31
- data/test/lib/facets/core/module/test_rename_method.rb +0 -31
- data/test/lib/facets/core/module/test_revisal.rb +0 -35
- data/test/lib/facets/core/module/test_shadow_method.rb +0 -30
- data/test/lib/facets/core/module/test_sort_on.rb +0 -42
- data/test/lib/facets/core/module/test_this.rb +0 -31
- data/test/lib/facets/core/module/test_wrap.rb +0 -30
- data/test/lib/facets/core/module/test_wrap_method.rb +0 -30
- data/test/lib/facets/core/nilclass/test_blank.rb +0 -26
- data/test/lib/facets/core/nilclass/test_empty.rb +0 -26
- data/test/lib/facets/core/nilclass/test_include.rb +0 -26
- data/test/lib/facets/core/nilclass/test_op_fetch.rb +0 -28
- data/test/lib/facets/core/nilclass/test_size.rb +0 -30
- data/test/lib/facets/core/nilclass/test_to_h.rb +0 -26
- data/test/lib/facets/core/numeric/test_approx.rb +0 -29
- data/test/lib/facets/core/numeric/test_ceil_multiple.rb +0 -31
- data/test/lib/facets/core/numeric/test_distance.rb +0 -28
- data/test/lib/facets/core/numeric/test_succ.rb +0 -40
- data/test/lib/facets/core/numeric/test_to_b.rb +0 -27
- data/test/lib/facets/core/ostruct/test___update__.rb +0 -45
- data/test/lib/facets/core/ostruct/test_instance_delegate.rb +0 -36
- data/test/lib/facets/core/ostruct/test_op_fetch.rb +0 -33
- data/test/lib/facets/core/proc/test_compose.rb +0 -29
- data/test/lib/facets/core/proc/test_op_mul.rb +0 -34
- data/test/lib/facets/core/proc/test_to_method.rb +0 -44
- data/test/lib/facets/core/range/test_to_r.rb +0 -27
- data/test/lib/facets/core/range/test_to_range.rb +0 -27
- data/test/lib/facets/core/range/test_umbrella.rb +0 -34
- data/test/lib/facets/core/range/test_within.rb +0 -29
- data/test/lib/facets/core/regexp/test_arity.rb +0 -33
- data/test/lib/facets/core/regexp/test_to_re.rb +0 -27
- data/test/lib/facets/core/regexp/test_to_regexp.rb +0 -27
- data/test/lib/facets/core/string/self/test_interpolate.rb +0 -27
- data/test/lib/facets/core/string/self/test_patterns.rb +0 -28
- data/test/lib/facets/core/string/self/test_rand_letter.rb +0 -26
- data/test/lib/facets/core/string/test_align_center.rb +0 -34
- data/test/lib/facets/core/string/test_at_rand.rb +0 -35
- data/test/lib/facets/core/string/test_basename.rb +0 -41
- data/test/lib/facets/core/string/test_blank.rb +0 -27
- data/test/lib/facets/core/string/test_bracket.rb +0 -49
- data/test/lib/facets/core/string/test_bytes.rb +0 -25
- data/test/lib/facets/core/string/test_camelcase.rb +0 -39
- data/test/lib/facets/core/string/test_camelize.rb +0 -26
- data/test/lib/facets/core/string/test_capitalize_all.rb +0 -26
- data/test/lib/facets/core/string/test_capitalized.rb +0 -26
- data/test/lib/facets/core/string/test_chars.rb +0 -27
- data/test/lib/facets/core/string/test_cleave.rb +0 -43
- data/test/lib/facets/core/string/test_cmp.rb +0 -30
- data/test/lib/facets/core/string/test_demodulize.rb +0 -38
- data/test/lib/facets/core/string/test_divide.rb +0 -29
- data/test/lib/facets/core/string/test_downcase.rb +0 -26
- data/test/lib/facets/core/string/test_dresner.rb +0 -32
- data/test/lib/facets/core/string/test_each_char.rb +0 -29
- data/test/lib/facets/core/string/test_each_word.rb +0 -29
- data/test/lib/facets/core/string/test_first.rb +0 -43
- data/test/lib/facets/core/string/test_fold.rb +0 -34
- data/test/lib/facets/core/string/test_humanize.rb +0 -26
- data/test/lib/facets/core/string/test_indent.rb +0 -40
- data/test/lib/facets/core/string/test_index_all.rb +0 -26
- data/test/lib/facets/core/string/test_last.rb +0 -46
- data/test/lib/facets/core/string/test_line_wrap.rb +0 -27
- data/test/lib/facets/core/string/test_lines.rb +0 -26
- data/test/lib/facets/core/string/test_lowercase.rb +0 -26
- data/test/lib/facets/core/string/test_margin.rb +0 -117
- data/test/lib/facets/core/string/test_methodize.rb +0 -27
- data/test/lib/facets/core/string/test_modulize.rb +0 -29
- data/test/lib/facets/core/string/test_mscan.rb +0 -30
- data/test/lib/facets/core/string/test_natcmp.rb +0 -30
- data/test/lib/facets/core/string/test_nchar.rb +0 -29
- data/test/lib/facets/core/string/test_pathize.rb +0 -29
- data/test/lib/facets/core/string/test_pop.rb +0 -47
- data/test/lib/facets/core/string/test_pot.rb +0 -39
- data/test/lib/facets/core/string/test_push.rb +0 -40
- data/test/lib/facets/core/string/test_quote.rb +0 -49
- data/test/lib/facets/core/string/test_rand_byte.rb +0 -35
- data/test/lib/facets/core/string/test_rand_index.rb +0 -26
- data/test/lib/facets/core/string/test_range.rb +0 -27
- data/test/lib/facets/core/string/test_range_all.rb +0 -27
- data/test/lib/facets/core/string/test_range_of_line.rb +0 -28
- data/test/lib/facets/core/string/test_regesc.rb +0 -28
- data/test/lib/facets/core/string/test_shatter.rb +0 -29
- data/test/lib/facets/core/string/test_shift.rb +0 -40
- data/test/lib/facets/core/string/test_shuffle.rb +0 -27
- data/test/lib/facets/core/string/test_similarity.rb +0 -26
- data/test/lib/facets/core/string/test_singular.rb +0 -86
- data/test/lib/facets/core/string/test_soundex.rb +0 -41
- data/test/lib/facets/core/string/test_succ.rb +0 -29
- data/test/lib/facets/core/string/test_to_a.rb +0 -27
- data/test/lib/facets/core/string/test_to_b.rb +0 -41
- data/test/lib/facets/core/string/test_to_const.rb +0 -28
- data/test/lib/facets/core/string/test_to_date.rb +0 -30
- data/test/lib/facets/core/string/test_to_proc.rb +0 -33
- data/test/lib/facets/core/string/test_to_re.rb +0 -28
- data/test/lib/facets/core/string/test_to_time.rb +0 -30
- data/test/lib/facets/core/string/test_unix_crypt.rb +0 -30
- data/test/lib/facets/core/string/test_unpack.rb +0 -34
- data/test/lib/facets/core/string/test_unshift.rb +0 -39
- data/test/lib/facets/core/string/test_upcase.rb +0 -30
- data/test/lib/facets/core/string/test_whitespace.rb +0 -27
- data/test/lib/facets/core/string/test_word_filter.rb +0 -34
- data/test/lib/facets/core/string/test_word_wrap.rb +0 -51
- data/test/lib/facets/core/string/test_words.rb +0 -37
- data/test/lib/facets/core/symbol/test_camelcase.rb +0 -26
- data/test/lib/facets/core/symbol/test_camelize.rb +0 -27
- data/test/lib/facets/core/symbol/test_capitalize.rb +0 -26
- data/test/lib/facets/core/symbol/test_capitalized.rb +0 -27
- data/test/lib/facets/core/symbol/test_downcase.rb +0 -27
- data/test/lib/facets/core/symbol/test_not.rb +0 -29
- data/test/lib/facets/core/symbol/test_pad.rb +0 -27
- data/test/lib/facets/core/symbol/test_succ.rb +0 -28
- data/test/lib/facets/core/symbol/test_to_const.rb +0 -28
- data/test/lib/facets/core/symbol/test_to_proc.rb +0 -33
- data/test/lib/facets/core/symbol/test_to_str.rb +0 -28
- data/test/lib/facets/core/symbol/test_underscore.rb +0 -26
- data/test/lib/facets/core/symbol/test_upcase.rb +0 -27
- data/test/lib/facets/core/time/test_change.rb +0 -33
- data/test/lib/facets/core/time/test_elapse.rb +0 -27
- data/test/lib/facets/core/time/test_stamp.rb +0 -39
- data/test/lib/facets/core/time/test_to_date.rb +0 -31
- data/test/lib/facets/core/time/test_to_s.rb +0 -31
- data/test/lib/facets/core/time/test_to_time.rb +0 -31
- data/test/lib/facets/more/test_ann.rb +0 -112
- data/test/lib/facets/more/test_ann_attr.rb +0 -39
- data/test/lib/facets/more/test_ansicode.rb +0 -36
- data/test/lib/facets/more/test_arguments.rb +0 -83
- data/test/lib/facets/more/test_association.rb +0 -51
- data/test/lib/facets/more/test_autoarray.rb +0 -32
- data/test/lib/facets/more/test_basicobject.rb +0 -67
- data/test/lib/facets/more/test_bbcode.rb +0 -34
- data/test/lib/facets/more/test_binaryreader.rb +0 -64
- data/test/lib/facets/more/test_bitmask.rb +0 -47
- data/test/lib/facets/more/test_buildingblock.rb +0 -48
- data/test/lib/facets/more/test_bytes.rb +0 -84
- data/test/lib/facets/more/test_classmethods.rb +0 -69
- data/test/lib/facets/more/test_command.rb +0 -69
- data/test/lib/facets/more/test_coroutine.rb +0 -60
- data/test/lib/facets/more/test_crypt.rb +0 -46
- data/test/lib/facets/more/test_cut.rb +0 -198
- data/test/lib/facets/more/test_dependency.rb +0 -82
- data/test/lib/facets/more/test_dictionary.rb +0 -107
- data/test/lib/facets/more/test_elementor.rb +0 -52
- data/test/lib/facets/more/test_enumerablepass.rb +0 -86
- data/test/lib/facets/more/test_floatstring.rb +0 -36
- data/test/lib/facets/more/test_functor.rb +0 -39
- data/test/lib/facets/more/test_htmlbuilder.rb +0 -38
- data/test/lib/facets/more/test_htmlfilter.rb +0 -86
- data/test/lib/facets/more/test_infinity.rb +0 -50
- data/test/lib/facets/more/test_inheritor.rb +0 -155
- data/test/lib/facets/more/test_instance_intercept.rb +0 -50
- data/test/lib/facets/more/test_interval.rb +0 -119
- data/test/lib/facets/more/test_json.rb +0 -232
- data/test/lib/facets/more/test_linkedlist.rb +0 -53
- data/test/lib/facets/more/test_lisp.rb +0 -47
- data/test/lib/facets/more/test_lisp_format.rb +0 -37
- data/test/lib/facets/more/test_lrucache.rb +0 -25
- data/test/lib/facets/more/test_mathconstants.rb +0 -18
- data/test/lib/facets/more/test_methodfilter.rb +0 -45
- data/test/lib/facets/more/test_methodprobe.rb +0 -53
- data/test/lib/facets/more/test_multipliers.rb +0 -114
- data/test/lib/facets/more/test_multiton.rb +0 -199
- data/test/lib/facets/more/test_nackclass.rb +0 -45
- data/test/lib/facets/more/test_nilcomparable.rb +0 -47
- data/test/lib/facets/more/test_opencascade.rb +0 -75
- data/test/lib/facets/more/test_openobject.rb +0 -126
- data/test/lib/facets/more/test_overload.rb +0 -54
- data/test/lib/facets/more/test_paramix.rb +0 -100
- data/test/lib/facets/more/test_pqueue.rb +0 -39
- data/test/lib/facets/more/test_preinitialize.rb +0 -49
- data/test/lib/facets/more/test_promoteself.rb +0 -45
- data/test/lib/facets/more/test_recorder.rb +0 -44
- data/test/lib/facets/more/test_snapshot.rb +0 -34
- data/test/lib/facets/more/test_statichash.rb +0 -31
- data/test/lib/facets/more/test_syncarray.rb +0 -28
- data/test/lib/facets/more/test_synchash.rb +0 -28
- data/test/lib/facets/more/test_tagiterator.rb +0 -93
- data/test/lib/facets/more/test_timer.rb +0 -66
- data/test/lib/facets/more/test_times.rb +0 -103
- data/test/lib/facets/more/test_tuple.rb +0 -64
- data/test/lib/facets/more/test_typecast.rb +0 -68
- data/test/lib/facets/more/test_uninheritable.rb +0 -42
- data/test/lib/facets/more/test_units.rb +0 -111
- data/test/lib/facets/more/test_xmlbuilder.rb +0 -54
- data/test/lib/facets/more/test_xmlhelper.rb +0 -40
- data/test/lib/facets/more/test_xoxo.rb +0 -288
- data/test/lib/facets/more/test_yamlstruct.rb +0 -37
- data/test/lib/facets/yore/enumerable/test_cross.rb +0 -44
- data/test/lib/facets/yore/kernel/test_require_facet.rb +0 -27
- data/test/lib/facets/yore/module/test_namespace.rb +0 -33
- data/test/lib/facets/yore/test_annattr.rb +0 -39
- data/test/lib/facets/yore/test_annotation.rb +0 -318
- data/work/README +0 -42
- data/work/TODO +0 -73
- data/work/bin/minitar +0 -3
- data/work/bin/minitar.rb +0 -814
- data/work/core/array/at_rand.rb +0 -95
- data/work/core/array/each_slice.rb +0 -23
- data/work/core/array/pick_values.rb +0 -32
- data/work/core/array/rand_indexes.rb +0 -33
- data/work/core/binding/class.rb +0 -11
- data/work/core/binding/delegate-binding.rb +0 -19
- data/work/core/binding/delegate.rb +0 -15
- data/work/core/binding/proc.rb +0 -6
- data/work/core/class/to_module.rb +0 -3
- data/work/core/enumerable/op_fetch.rb +0 -30
- data/work/core/fileutils/cptouch.rb +0 -20
- data/work/core/fileutils/nl_convert.rb +0 -133
- data/work/core/io/expect.rb +0 -127
- data/work/core/join_with.rb +0 -13
- data/work/core/kernel/call_line.rb +0 -15
- data/work/core/kernel/does.rb +0 -7
- data/work/core/kernel/message.rb +0 -6
- data/work/core/kernel/query.rb +0 -15
- data/work/core/kernel/taint.rb +0 -10
- data/work/core/logger/clean_logger.rb +0 -10
- data/work/core/module/attr-old.rb +0 -308
- data/work/core/module/attr.rb +0 -98
- data/work/core/module/attr_xxx.rb +0 -22
- data/work/core/module/by_regexp.rb +0 -21
- data/work/core/module/cast.rb +0 -64
- data/work/core/module/class_attribute_accessors.rb +0 -57
- data/work/core/module/inherit.rb +0 -99
- data/work/core/module/inherit0.rb +0 -59
- data/work/core/module/let.rb +0 -51
- data/work/core/module/meta_attr.rb +0 -60
- data/work/core/module/module_attribute_accessors.rb +0 -57
- data/work/core/module/permissions.rb +0 -32
- data/work/core/module/preserved.rb +0 -108
- data/work/core/module/sattr_accessor.rb +0 -1
- data/work/core/module/sattr_reader.rb +0 -1
- data/work/core/module/sattr_setter.rb +0 -1
- data/work/core/module/sattr_tester.rb +0 -1
- data/work/core/module/sattr_writer.rb +0 -1
- data/work/core/module/tc_attr.rb +0 -107
- data/work/core/module/to_module.rb +0 -37
- data/work/core/module/version.rb +0 -23
- data/work/core/string/frequency.rb +0 -40
- data/work/core/string/op_add.rb +0 -24
- data/work/core/string/op_div.rb +0 -15
- data/work/core/string/pred.rb +0 -217
- data/work/core/string/probability.rb +0 -35
- data/work/core/string/succ_distance.rb +0 -112
- data/work/core/string/to_arr.rb +0 -57
- data/work/core/string/to_ary.rb +0 -12
- data/work/core/string/word_wrap.rb +0 -62
- data/work/hash_open.rb +0 -23
- data/work/misc/calibre/ProjectInfo.annotation +0 -46
- data/work/misc/calibre/ProjectInfo.ansicode +0 -33
- data/work/misc/calibre/ProjectInfo.association +0 -34
- data/work/misc/calibre/ProjectInfo.basicobject +0 -36
- data/work/misc/calibre/ProjectInfo.bbcode +0 -34
- data/work/misc/calibre/ProjectInfo.binaryreader +0 -35
- data/work/misc/calibre/ProjectInfo.bitmask +0 -33
- data/work/misc/calibre/ProjectInfo.classinherit +0 -36
- data/work/misc/calibre/ProjectInfo.classmethods +0 -36
- data/work/misc/calibre/ProjectInfo.cloneable +0 -33
- data/work/misc/calibre/ProjectInfo.consoleapp +0 -35
- data/work/misc/calibre/ProjectInfo.coroutine +0 -37
- data/work/misc/calibre/ProjectInfo.crypt +0 -33
- data/work/misc/calibre/ProjectInfo.dictionary +0 -40
- data/work/misc/calibre/ProjectInfo.downloader +0 -39
- data/work/misc/calibre/ProjectInfo.enumerablepass +0 -35
- data/work/misc/calibre/ProjectInfo.expirable +0 -37
- data/work/misc/calibre/ProjectInfo.floatstring +0 -35
- data/work/misc/calibre/ProjectInfo.functor +0 -40
- data/work/misc/calibre/ProjectInfo.heap +0 -33
- data/work/misc/calibre/ProjectInfo.inheritor +0 -36
- data/work/misc/calibre/ProjectInfo.interval +0 -36
- data/work/misc/calibre/ProjectInfo.lisp +0 -38
- data/work/misc/calibre/ProjectInfo.lrucache +0 -34
- data/work/misc/calibre/ProjectInfo.mathconstants +0 -41
- data/work/misc/calibre/ProjectInfo.methodprobe +0 -38
- data/work/misc/calibre/ProjectInfo.mock +0 -34
- data/work/misc/calibre/ProjectInfo.multiton +0 -36
- data/work/misc/calibre/ProjectInfo.nackclass +0 -33
- data/work/misc/calibre/ProjectInfo.nilcomparable +0 -35
- data/work/misc/calibre/ProjectInfo.nullclass +0 -35
- data/work/misc/calibre/ProjectInfo.one +0 -37
- data/work/misc/calibre/ProjectInfo.openobject +0 -39
- data/work/misc/calibre/ProjectInfo.paramix +0 -38
- data/work/misc/calibre/ProjectInfo.pool +0 -33
- data/work/misc/calibre/ProjectInfo.progressbar +0 -37
- data/work/misc/calibre/ProjectInfo.reference +0 -36
- data/work/misc/calibre/ProjectInfo.semaphore +0 -36
- data/work/misc/calibre/ProjectInfo.stateparser +0 -39
- data/work/misc/calibre/ProjectInfo.statichash +0 -33
- data/work/misc/calibre/ProjectInfo.system +0 -34
- data/work/misc/calibre/ProjectInfo.tagiterator +0 -36
- data/work/misc/calibre/ProjectInfo.timer +0 -35
- data/work/misc/calibre/ProjectInfo.tracepoint +0 -37
- data/work/misc/calibre/ProjectInfo.tuple +0 -36
- data/work/misc/calibre/ProjectInfo.uniheritable +0 -34
- data/work/misc/calibre/ProjectInfo.units +0 -34
- data/work/misc/calibre/ProjectInfo.yamlstruct +0 -34
- data/work/more/annotation-rw.rb +0 -217
- data/work/more/aobject.rb +0 -132
- data/work/more/autohash.rb +0 -67
- data/work/more/cache.rb +0 -189
- data/work/more/class_inheritable_attributes.rb +0 -120
- data/work/more/commandrunner.rb +0 -101
- data/work/more/daemon.rb +0 -70
- data/work/more/debugger.rb +0 -167
- data/work/more/detach.rb +0 -423
- data/work/more/enumtype.rb +0 -115
- data/work/more/ioreactor.rb +0 -671
- data/work/more/logger_sing.rb +0 -207
- data/work/more/must.rb +0 -37
- data/work/more/old-tkxml.rb +0 -189
- data/work/more/pairhash.rb +0 -55
- data/work/more/password.rb +0 -80
- data/work/more/print_exception.rb +0 -35
- data/work/more/rand.rb +0 -412
- data/work/more/range.rb +0 -383
- data/work/more/sanitize.rb +0 -48
- data/work/more/superstruct.rb +0 -735
- data/work/more/tag.rb +0 -31
- data/work/more/timer.rb +0 -164
- data/work/op_rshift.rb +0 -87
- data/work/openobject-temp.rb +0 -45
- data/work/pore/autorequire.rb +0 -83
- data/work/pore/basefactory.rb +0 -40
- data/work/pore/hash/each.rb +0 -76
- data/work/pore/merge3.rb +0 -765
- data/work/pore/superann.rb +0 -134
- data/work/pore/sys.rb +0 -186
- data/work/pore/utils.rb +0 -518
- data/work/yore/HashAquisition.rb +0 -36
- data/work/yore/Rakefile.old +0 -181
- data/work/yore/Reapfile +0 -63
- data/work/yore/annotation.rb +0 -489
- data/work/yore/annotation2.rb +0 -466
- data/work/yore/commandutils.rb +0 -379
- data/work/yore/openobject.rb +0 -298
- data/work/yore/reap.rb +0 -184
- data/work/yore/reap.yml +0 -47
- data/work/yore/taskable-old.rb +0 -519
- data/work/yore/taskable.rb +0 -482
data/work/yore/commandutils.rb
DELETED
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
# = command.rb
|
|
2
|
-
#
|
|
3
|
-
# == Copyright (c) 2005 Thomas Sawyer
|
|
4
|
-
#
|
|
5
|
-
# Ruby License
|
|
6
|
-
#
|
|
7
|
-
# This module is free software. You may use, modify, and/or
|
|
8
|
-
# redistribute this software under the same terms as Ruby.
|
|
9
|
-
#
|
|
10
|
-
# This program is distributed in the hope that it will be
|
|
11
|
-
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
12
|
-
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
13
|
-
# PURPOSE.
|
|
14
|
-
#
|
|
15
|
-
# == Author(s)
|
|
16
|
-
#
|
|
17
|
-
# * Thomas Sawyer
|
|
18
|
-
#
|
|
19
|
-
# == Developer Notes
|
|
20
|
-
#
|
|
21
|
-
# TODO Add documentation features. (NOT SO SURE NOW!)
|
|
22
|
-
#
|
|
23
|
-
# TODO Move to console/command.rb, but I'm not sure yet if
|
|
24
|
-
# adding subdirectories to more/ is a good idea.
|
|
25
|
-
#
|
|
26
|
-
|
|
27
|
-
# Author:: Thomas Sawyer
|
|
28
|
-
# Copyright:: Copyright (c) 2005 Thomas Sawyer
|
|
29
|
-
# License:: Ruby License
|
|
30
|
-
|
|
31
|
-
require 'facets/core/array/index'
|
|
32
|
-
require 'shellwords'
|
|
33
|
-
|
|
34
|
-
module Console
|
|
35
|
-
|
|
36
|
-
# = Console CommandUtils
|
|
37
|
-
|
|
38
|
-
module CommandUtils
|
|
39
|
-
|
|
40
|
-
module_function
|
|
41
|
-
|
|
42
|
-
# Basic command parser.
|
|
43
|
-
#
|
|
44
|
-
# Partitions the command line into flags and arguments.
|
|
45
|
-
# Flags are converted to a associative array and then the
|
|
46
|
-
# two parts are returned.
|
|
47
|
-
#
|
|
48
|
-
# line = "--trace stamp --file=VERSION"
|
|
49
|
-
#
|
|
50
|
-
# argv,keys = *parse_command(line)
|
|
51
|
-
#
|
|
52
|
-
# argv #=> ["stamp"]
|
|
53
|
-
# keys #=> [["trace",true], ["file","VERSION"]]
|
|
54
|
-
#
|
|
55
|
-
|
|
56
|
-
def parse_command( line=nil, arity={} )
|
|
57
|
-
argv = parse_line(line)
|
|
58
|
-
argv = multi_flag(argv)
|
|
59
|
-
|
|
60
|
-
argv = parse_flags( argv, arity )
|
|
61
|
-
|
|
62
|
-
keys, args = argv.partition{ |a| Array === a }
|
|
63
|
-
|
|
64
|
-
keys = format_flags(keys)
|
|
65
|
-
|
|
66
|
-
return args, keys
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
# Subcommand.
|
|
71
|
-
#
|
|
72
|
-
# Subcommand parsing assumes that the first non-flag
|
|
73
|
-
# entry is a subcommand, followed by subcommand flags.
|
|
74
|
-
#
|
|
75
|
-
|
|
76
|
-
def parse_subcommand( line=nil, arity={} )
|
|
77
|
-
argv = parse_line(line)
|
|
78
|
-
argv = multi_flag(argv)
|
|
79
|
-
|
|
80
|
-
argv, glbl = parse_front_flags( argv, arity )
|
|
81
|
-
|
|
82
|
-
cmd = argv.shift
|
|
83
|
-
|
|
84
|
-
args, keys = parse_command(argv, arity)
|
|
85
|
-
|
|
86
|
-
return cmd, args, keys, glbl
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
# Multi-command.
|
|
91
|
-
#
|
|
92
|
-
# Parses a chain of commands from a single command line.
|
|
93
|
-
# This assumes commands take no free standing arguments,
|
|
94
|
-
# and rather only utilize option flags.
|
|
95
|
-
#
|
|
96
|
-
# line = "--trace rubyforge --groupid=2014 publish --copy='**/*'
|
|
97
|
-
#
|
|
98
|
-
# This method does not support flag arity since each command in
|
|
99
|
-
# the chain could have it's own arity settings. So '=' must be
|
|
100
|
-
# used to set a flag parameter.
|
|
101
|
-
|
|
102
|
-
def parse_multicommand( line=nil )
|
|
103
|
-
argv = parse_line(line)
|
|
104
|
-
argv = multi_flag(argv)
|
|
105
|
-
|
|
106
|
-
cmds = []
|
|
107
|
-
argv.unshift(nil)
|
|
108
|
-
until argv.empty?
|
|
109
|
-
cmd = argv.shift
|
|
110
|
-
i = argv.index{ |e| e !~ /^-/ }
|
|
111
|
-
opts = argv[0...i] # options
|
|
112
|
-
keys = format_flags(parse_flags(opts))
|
|
113
|
-
cmds << [cmd, keys]
|
|
114
|
-
argv = argv[i..-1] # chain command
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
return cmds
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
# Parse flags takes the command line and
|
|
121
|
-
# transforms it such that flags (eg. -x and --x)
|
|
122
|
-
# are elemetnal associative arrays.
|
|
123
|
-
#
|
|
124
|
-
# line = "--foo hello --try=this"
|
|
125
|
-
#
|
|
126
|
-
# parse_flags(line) #=> [ [foo,true], hello, ["try","this"] ]
|
|
127
|
-
#
|
|
128
|
-
|
|
129
|
-
def parse_flags( line, arity={} )
|
|
130
|
-
argv = parse_line(line)
|
|
131
|
-
argv = multi_flag(argv)
|
|
132
|
-
|
|
133
|
-
i = 0
|
|
134
|
-
while i < argv.size
|
|
135
|
-
arg = argv[i]
|
|
136
|
-
case arg
|
|
137
|
-
when /^-/
|
|
138
|
-
arg = arg.sub(/^-{1,2}/,'')
|
|
139
|
-
if arg.index('=')
|
|
140
|
-
key, val = arg.split('=')
|
|
141
|
-
argv[i] = [key, val||true]
|
|
142
|
-
elsif arity.key?(arg)
|
|
143
|
-
cnt = arity[arg]
|
|
144
|
-
key = arg
|
|
145
|
-
val = argv[i+1,cnt]
|
|
146
|
-
argv[i,cnt+1] = [[key, *val]]
|
|
147
|
-
i += cnt
|
|
148
|
-
else
|
|
149
|
-
key = arg
|
|
150
|
-
argv[i] = [key,true]
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
i += 1
|
|
154
|
-
end
|
|
155
|
-
return argv
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
# Parse off the front flags of a command line.
|
|
159
|
-
#
|
|
160
|
-
# line = "--trace stamp --file VERSION"
|
|
161
|
-
#
|
|
162
|
-
# argv,keys = *parse_front_flags(line)
|
|
163
|
-
#
|
|
164
|
-
# argv #=> ["stamp", "--file", "VERSION"]
|
|
165
|
-
# keys #=> [["trace", true]]
|
|
166
|
-
#
|
|
167
|
-
# Provided an arity hash if any flags take free standing
|
|
168
|
-
# parameters.
|
|
169
|
-
#
|
|
170
|
-
# line = "--level 4 stamp --file VERSION"
|
|
171
|
-
#
|
|
172
|
-
# argv,keys = *parse_front_flags(line, :trace => 1)
|
|
173
|
-
#
|
|
174
|
-
# argv #=> ["stamp", "--file", "VERSION"]
|
|
175
|
-
# keys #=> [["level", 4]]
|
|
176
|
-
#
|
|
177
|
-
|
|
178
|
-
def parse_front_flags( line=nil, arity={} )
|
|
179
|
-
argv = parse_line(line)
|
|
180
|
-
argv = multi_flag(argv)
|
|
181
|
-
|
|
182
|
-
keys = []
|
|
183
|
-
while argv.first =~ /^-/
|
|
184
|
-
key = argv.shift
|
|
185
|
-
key.sub!(/^-{1,2}/,'')
|
|
186
|
-
if name.index('=')
|
|
187
|
-
key, val = key.split('=')
|
|
188
|
-
elsif a = arity[name]
|
|
189
|
-
val = argv.slice!(0,a)
|
|
190
|
-
else
|
|
191
|
-
val = true
|
|
192
|
-
end
|
|
193
|
-
keys << [key, val]
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
keys = format_flags(keys)
|
|
197
|
-
|
|
198
|
-
return argv, keys
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
# Parse out flags across the entire command line.
|
|
202
|
-
# Flags parsed are the front flags and any specified in the
|
|
203
|
-
# the +flags+ parameter. The +flags+ parameters can be either
|
|
204
|
-
# a list of flag names or a name => arity hash.
|
|
205
|
-
#
|
|
206
|
-
# Returns the remaining split line and the global flags.
|
|
207
|
-
|
|
208
|
-
def parse_global_flags( line=nil, flags={} )
|
|
209
|
-
argv = parse_line(line)
|
|
210
|
-
argv = multi_flag(argv)
|
|
211
|
-
|
|
212
|
-
keys = []
|
|
213
|
-
flags.each do |name, arity|
|
|
214
|
-
while i = argv.index{ |e| e =~ /^-{1,2}#{name}/ }
|
|
215
|
-
arg = argv[i]
|
|
216
|
-
if arg.index('=')
|
|
217
|
-
key, val = arg.split('=')
|
|
218
|
-
keys << [name,val]
|
|
219
|
-
elsif arity
|
|
220
|
-
val = argv.slice!(i+1,arity)
|
|
221
|
-
keys << [name,val]
|
|
222
|
-
else
|
|
223
|
-
keys << [name,true]
|
|
224
|
-
end
|
|
225
|
-
argv.delete(i)
|
|
226
|
-
end
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
i = argv.index{ |e| e !~ /^-/ }
|
|
230
|
-
glbl = argv[0...i] # main options
|
|
231
|
-
argv = argv[i..-1] # rest of line
|
|
232
|
-
|
|
233
|
-
glbl.each do |key|
|
|
234
|
-
name = key.sub(/^-{1,2}/,'')
|
|
235
|
-
keys.unshift [name, true]
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
keys = format_flags(keys)
|
|
239
|
-
|
|
240
|
-
return argv, keys
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
# First pass parser to split the command line into an
|
|
244
|
-
# array using Shellwords, if not already so divided.
|
|
245
|
-
|
|
246
|
-
def parse_line(line=nil)
|
|
247
|
-
return ARGV unless line
|
|
248
|
-
if String === line
|
|
249
|
-
Shellwords.shellwords(line)
|
|
250
|
-
else
|
|
251
|
-
line
|
|
252
|
-
end
|
|
253
|
-
end
|
|
254
|
-
|
|
255
|
-
# Split single letter option groupings into separate options.
|
|
256
|
-
# ie. -xyz => -x -y -z
|
|
257
|
-
|
|
258
|
-
def multi_flag(argv)
|
|
259
|
-
argv = argv.collect { |arg|
|
|
260
|
-
if md = /^-(\w{2,})/.match( arg )
|
|
261
|
-
md[1].split(//).collect { |c| "-#{c}" }
|
|
262
|
-
else
|
|
263
|
-
arg.dup
|
|
264
|
-
end
|
|
265
|
-
}.flatten
|
|
266
|
-
end
|
|
267
|
-
|
|
268
|
-
# Format flag options. This converts the associative array of flags into
|
|
269
|
-
# hash. This prevents repate option flags. If you need repeat options flags
|
|
270
|
-
# you can deacitvate this formatting by using the submodule RepeatFlag.
|
|
271
|
-
|
|
272
|
-
def format_flags(assoc_array)
|
|
273
|
-
Hash[*assoc_array.flatten]
|
|
274
|
-
end
|
|
275
|
-
|
|
276
|
-
#
|
|
277
|
-
|
|
278
|
-
module NoMultiFlag
|
|
279
|
-
include CommandUtils
|
|
280
|
-
module_function *CommandUtils.private_instance_methods(false)
|
|
281
|
-
|
|
282
|
-
module_function
|
|
283
|
-
def multi_flag(argv)
|
|
284
|
-
argv.dup
|
|
285
|
-
end
|
|
286
|
-
end
|
|
287
|
-
|
|
288
|
-
#
|
|
289
|
-
|
|
290
|
-
module RepeatFlag
|
|
291
|
-
include CommandUtils
|
|
292
|
-
module_function *CommandUtils.private_instance_methods(false)
|
|
293
|
-
|
|
294
|
-
module_function
|
|
295
|
-
def format_flags(assoc_array)
|
|
296
|
-
assoc_array.dup
|
|
297
|
-
end
|
|
298
|
-
end
|
|
299
|
-
|
|
300
|
-
#
|
|
301
|
-
|
|
302
|
-
module RepeatAndNoMultiFlag
|
|
303
|
-
include CommandUtils
|
|
304
|
-
module_function *CommandUtils.private_instance_methods(false)
|
|
305
|
-
include NoMultiFlag
|
|
306
|
-
module_function :multi_flag
|
|
307
|
-
include RepeatFlag
|
|
308
|
-
module_function :format_flags
|
|
309
|
-
end
|
|
310
|
-
|
|
311
|
-
end
|
|
312
|
-
end
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
# _____ _
|
|
316
|
-
# |_ _|__ ___| |_
|
|
317
|
-
# | |/ _ \/ __| __|
|
|
318
|
-
# | | __/\__ \ |_
|
|
319
|
-
# |_|\___||___/\__|
|
|
320
|
-
#
|
|
321
|
-
|
|
322
|
-
=begin test
|
|
323
|
-
|
|
324
|
-
require 'test/unit'
|
|
325
|
-
|
|
326
|
-
class TCCommand < Test::Unit::TestCase
|
|
327
|
-
|
|
328
|
-
include Console
|
|
329
|
-
|
|
330
|
-
def test_01
|
|
331
|
-
line = "-x baz --foo=9 bar"
|
|
332
|
-
args, keys = CommandUtils::RepeatFlag.parse_command(line)
|
|
333
|
-
assert_equal(['baz','bar'],args)
|
|
334
|
-
assert_equal([['x',true],['foo','9']],keys)
|
|
335
|
-
end
|
|
336
|
-
|
|
337
|
-
def test_02
|
|
338
|
-
line = "-x baz --foo=8 bar"
|
|
339
|
-
args, keys = CommandUtils.parse_command(line)
|
|
340
|
-
assert_equal(['baz','bar'],args)
|
|
341
|
-
assert_equal({'foo'=>'8','x'=>true},keys)
|
|
342
|
-
end
|
|
343
|
-
|
|
344
|
-
def test_03
|
|
345
|
-
line = "-x baz --foo=7 bar"
|
|
346
|
-
cmd, args, keys, glbl = CommandUtils.parse_subcommand(line)
|
|
347
|
-
assert_equal('baz',cmd)
|
|
348
|
-
assert_equal(['bar'],args)
|
|
349
|
-
assert_equal({'foo'=>'7'},keys)
|
|
350
|
-
assert_equal({'x'=>true},glbl)
|
|
351
|
-
end
|
|
352
|
-
|
|
353
|
-
def test_04
|
|
354
|
-
line = "-x baz --foo=6 bar --zoo='xx'"
|
|
355
|
-
cmds = CommandUtils.parse_multicommand(line)
|
|
356
|
-
|
|
357
|
-
cmd, keys = *cmds[0]
|
|
358
|
-
assert_equal(nil,cmd)
|
|
359
|
-
assert_equal({'x'=>true},keys)
|
|
360
|
-
|
|
361
|
-
cmd, keys = *cmds[1]
|
|
362
|
-
assert_equal('baz',cmd)
|
|
363
|
-
assert_equal({'foo'=>'6'},keys)
|
|
364
|
-
|
|
365
|
-
cmd, keys = *cmds[2]
|
|
366
|
-
assert_equal('bar',cmd)
|
|
367
|
-
assert_equal({'zoo'=>'xx'},keys)
|
|
368
|
-
end
|
|
369
|
-
|
|
370
|
-
def test_05
|
|
371
|
-
line = "-x baz --foo 5 bar"
|
|
372
|
-
args, keys = CommandUtils.parse_command(line, 'foo'=>1)
|
|
373
|
-
assert_equal(['baz','bar'],args)
|
|
374
|
-
assert_equal({'x'=>true,'foo'=>'5'},keys)
|
|
375
|
-
end
|
|
376
|
-
|
|
377
|
-
end
|
|
378
|
-
|
|
379
|
-
=end
|
data/work/yore/openobject.rb
DELETED
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
# = openobject.rb
|
|
2
|
-
#
|
|
3
|
-
# == Copyright (c) 2005 Thomas Sawyer, George Moschovitis
|
|
4
|
-
#
|
|
5
|
-
# Ruby License
|
|
6
|
-
#
|
|
7
|
-
# This module is free software. You may use, modify, and/or redistribute this
|
|
8
|
-
# software under the same terms as Ruby.
|
|
9
|
-
#
|
|
10
|
-
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
11
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
12
|
-
# FOR A PARTICULAR PURPOSE.
|
|
13
|
-
#
|
|
14
|
-
# == Authors and Contributors
|
|
15
|
-
#
|
|
16
|
-
# * Thomas Sawyer
|
|
17
|
-
# * George Moschovitis
|
|
18
|
-
|
|
19
|
-
# Author:: Thomas Sawyer, George Moschovitis
|
|
20
|
-
# Copyright:: Copyright (c) 2005 Thomas Sawyer, George Moschovitis
|
|
21
|
-
# License:: Ruby License
|
|
22
|
-
|
|
23
|
-
require 'facets/core/kernel/as'
|
|
24
|
-
require 'facets/core/kernel/object_class'
|
|
25
|
-
require 'facets/core/hash/keys_to_sym'
|
|
26
|
-
require 'facets/core/hash/to_proc'
|
|
27
|
-
#require 'facets/more/nullclass'
|
|
28
|
-
|
|
29
|
-
# = OpenObject
|
|
30
|
-
#
|
|
31
|
-
# OpenObject is similar to OpenStruct, but differs in a couple ways.
|
|
32
|
-
#
|
|
33
|
-
# OpenObject privatizes a few Kernel methods so there are fewer
|
|
34
|
-
# reserved Kernel methods in the object's namespace, reducing
|
|
35
|
-
# potential for name clashes.
|
|
36
|
-
#
|
|
37
|
-
# Also it does not create any methods for the added entries and instead
|
|
38
|
-
# uses a hash ONLY. OpenStruct OTOH creates methods, but is actaully
|
|
39
|
-
# inconsitant in their use --try #dup on an OpenStruct and
|
|
40
|
-
# all the methods disappear. Morevoer, I beleive this feature was
|
|
41
|
-
# added to OpenStruct for speed, but I have not been able to find
|
|
42
|
-
# this advantage in benchmark tests.
|
|
43
|
-
#
|
|
44
|
-
#--
|
|
45
|
-
# Third, when an entry is not found 'null' is returned rather then 'nil'.
|
|
46
|
-
# This allows for run-on entries withuot error. Eg.
|
|
47
|
-
#
|
|
48
|
-
# OpenObject.new.a.b.c #=> null
|
|
49
|
-
#++
|
|
50
|
-
|
|
51
|
-
class OpenObject
|
|
52
|
-
|
|
53
|
-
# Privatize a few Kernel methods that are most likely to clash,
|
|
54
|
-
# but arn't essential here.
|
|
55
|
-
|
|
56
|
-
private :class, :clone, :display, :type, :method, :to_a, :to_s
|
|
57
|
-
|
|
58
|
-
def initialize( init=nil )
|
|
59
|
-
case init
|
|
60
|
-
when Array
|
|
61
|
-
@table = Hash[*init].keys_to_sym
|
|
62
|
-
when Hash
|
|
63
|
-
@table = init.keys_to_sym
|
|
64
|
-
when NilClass
|
|
65
|
-
@table = {}
|
|
66
|
-
when OpenObject
|
|
67
|
-
@table = init.send(:table).dup
|
|
68
|
-
else
|
|
69
|
-
@table = init.to_h.keys_to_sym
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def to_openobject ; self ; end
|
|
74
|
-
|
|
75
|
-
def to_a ; @table.values ; end
|
|
76
|
-
def to_h ; @table.dup ; end
|
|
77
|
-
def to_hash ; @table.dup ; end
|
|
78
|
-
|
|
79
|
-
# OpenObejct can be converted to an assignment Proc.
|
|
80
|
-
#
|
|
81
|
-
# o = OpenObject.new( :a=>1 )
|
|
82
|
-
# p = o.to_proc
|
|
83
|
-
# x = OpenObject.new
|
|
84
|
-
# p[x]
|
|
85
|
-
# x.a #=> 1
|
|
86
|
-
#
|
|
87
|
-
|
|
88
|
-
def to_proc
|
|
89
|
-
@table.to_proc
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
# How to duplicate.
|
|
93
|
-
|
|
94
|
-
def initialize_copy( orig )
|
|
95
|
-
super
|
|
96
|
-
@table = @table.dup
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
def inspect
|
|
100
|
-
s = "<#{object_class}"
|
|
101
|
-
s << " " << @table.collect{|k,v| "#{k}=#{v.inspect}"}.join(' ') unless @table.empty?
|
|
102
|
-
s << ">"
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def marshal_dump
|
|
106
|
-
@table
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def marshal_load( tbl )
|
|
110
|
-
@table = tbl
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
# Compare this object and +other+ for equality.
|
|
114
|
-
|
|
115
|
-
def ==(other)
|
|
116
|
-
return false unless other.kind_of?( object_class )
|
|
117
|
-
return @table == other.send(:table) # TODO funcall in future?
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
def method_missing( sym, *args )
|
|
121
|
-
type = sym.to_s[-1,1]
|
|
122
|
-
name = sym.to_s.gsub(/[=!?]$/, '').to_sym
|
|
123
|
-
|
|
124
|
-
if type == '='
|
|
125
|
-
self[name] = args[0]
|
|
126
|
-
elsif type == '!' and args.size > 0
|
|
127
|
-
self[name] = args[0]
|
|
128
|
-
self
|
|
129
|
-
else
|
|
130
|
-
if @table.key?(name)
|
|
131
|
-
self[name]
|
|
132
|
-
#elsif @parent
|
|
133
|
-
# @parent.__send__(name)
|
|
134
|
-
else
|
|
135
|
-
nil
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
def [](name)
|
|
141
|
-
name = name.to_sym
|
|
142
|
-
#if @table.key?(name)
|
|
143
|
-
@table[name]
|
|
144
|
-
#else
|
|
145
|
-
# Kernel.null
|
|
146
|
-
#end
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
def []=(name,val)
|
|
150
|
-
@table[name.to_sym] = val
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
# For compatibility with other types of hash-like objects.
|
|
154
|
-
# Also make OpenObject usable via Enumerator.
|
|
155
|
-
|
|
156
|
-
def each(&yld)
|
|
157
|
-
@table.each( &yld )
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
private
|
|
161
|
-
|
|
162
|
-
# Access to internal table.
|
|
163
|
-
|
|
164
|
-
def table ; @table ; end
|
|
165
|
-
|
|
166
|
-
#--
|
|
167
|
-
# TODO Parent feature? Or better only for OpenCascade?
|
|
168
|
-
#++
|
|
169
|
-
#def __parent__ ; @parent ; end
|
|
170
|
-
#def __parent__=(x) ; @parent = x ; end
|
|
171
|
-
|
|
172
|
-
def fetch(k) ; @table[k.to_sym] ; end
|
|
173
|
-
#def __fetch__(k) ; @table.key?(k.to_sym) ? @table[k.to_sym] : null ; end
|
|
174
|
-
|
|
175
|
-
def store(k) ; @table[k.to_sym]=v ; end
|
|
176
|
-
|
|
177
|
-
def key?(k) ; @table.key?(k.to_sym) ; end
|
|
178
|
-
|
|
179
|
-
def keys ; @table.keys ; end
|
|
180
|
-
|
|
181
|
-
def update( other )
|
|
182
|
-
other = Hash[*other] if other.is_a?(Array)
|
|
183
|
-
other.each{ |k, v| @table[k.to_sym] = v }
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
def merge( other )
|
|
187
|
-
o = dup
|
|
188
|
-
o.send(:update, other)
|
|
189
|
-
o
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
# Core Extensions
|
|
193
|
-
|
|
194
|
-
class ::Hash
|
|
195
|
-
# Convert a Hash into an OpenObject.
|
|
196
|
-
|
|
197
|
-
def to_openobject
|
|
198
|
-
OpenObject.new( self )
|
|
199
|
-
end
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
class ::Proc
|
|
203
|
-
# Translates a Proc into an OpenObject. By droping an OpenObject into
|
|
204
|
-
# the Proc, the resulting assignments incured as the procedure is
|
|
205
|
-
# evaluated produce the OpenObject. This technique is simlar to that
|
|
206
|
-
# of MethodProbe.
|
|
207
|
-
#
|
|
208
|
-
# p = lambda { |x|
|
|
209
|
-
# x.word = "Hello"
|
|
210
|
-
# }
|
|
211
|
-
# o = p.to_openobject
|
|
212
|
-
# o.word #=> "Hello"
|
|
213
|
-
#
|
|
214
|
-
# NOTE The Proc must have an arity of one --no more and no less.
|
|
215
|
-
|
|
216
|
-
def to_openobject
|
|
217
|
-
raise ArgumentError, 'bad arity for converting Proc to openobject' if arity != 1
|
|
218
|
-
o = OpenObject.new
|
|
219
|
-
self.call( o )
|
|
220
|
-
o
|
|
221
|
-
end
|
|
222
|
-
end
|
|
223
|
-
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
# _____ _
|
|
228
|
-
# |_ _|__ ___| |_
|
|
229
|
-
# | |/ _ \/ __| __|
|
|
230
|
-
# | | __/\__ \ |_
|
|
231
|
-
# |_|\___||___/\__|
|
|
232
|
-
#
|
|
233
|
-
|
|
234
|
-
=begin testing
|
|
235
|
-
|
|
236
|
-
require 'test/unit'
|
|
237
|
-
|
|
238
|
-
class TC01 < Test::Unit::TestCase
|
|
239
|
-
|
|
240
|
-
def test_01_001
|
|
241
|
-
f0 = OpenObject.new
|
|
242
|
-
f0[:a] = 1
|
|
243
|
-
assert_equal( [1], f0.to_a )
|
|
244
|
-
assert_equal( {:a=>1}, f0.to_h )
|
|
245
|
-
end
|
|
246
|
-
|
|
247
|
-
def test_01_002
|
|
248
|
-
f0 = OpenObject.new( {:a=>1} )
|
|
249
|
-
f0[:b] = 2
|
|
250
|
-
assert_equal( {:a=>1,:b=>2}, f0.to_h )
|
|
251
|
-
end
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
class TC02 < Test::Unit::TestCase
|
|
255
|
-
|
|
256
|
-
def test_02_001
|
|
257
|
-
f0 = OpenObject.new( :f0=>"f0" )
|
|
258
|
-
h0 = { :h0=>"h0" }
|
|
259
|
-
assert_equal( OpenObject.new( :f0=>"f0", :h0=>"h0" ), f0.send(:merge,h0) )
|
|
260
|
-
assert_equal( {:f0=>"f0", :h0=>"h0"}, h0.merge( f0 ) )
|
|
261
|
-
end
|
|
262
|
-
|
|
263
|
-
def test_02_002
|
|
264
|
-
f1 = OpenObject.new( :f1=>"f1" )
|
|
265
|
-
h1 = { :h1=>"h1" }
|
|
266
|
-
f1.send(:update,h1)
|
|
267
|
-
h1.update( f1 )
|
|
268
|
-
assert_equal( OpenObject.new( :f1=>"f1", :h1=>"h1" ), f1 )
|
|
269
|
-
assert_equal( {:f1=>"f1", :h1=>"h1"}, h1 )
|
|
270
|
-
end
|
|
271
|
-
|
|
272
|
-
end
|
|
273
|
-
|
|
274
|
-
class TC03 < Test::Unit::TestCase
|
|
275
|
-
|
|
276
|
-
def test_03_001
|
|
277
|
-
fo = OpenObject.new
|
|
278
|
-
99.times{ |i| fo.__send__( "n#{i}=", 1 ) }
|
|
279
|
-
99.times{ |i|
|
|
280
|
-
assert_equal( 1, fo.__send__( "n#{i}" ) )
|
|
281
|
-
}
|
|
282
|
-
end
|
|
283
|
-
|
|
284
|
-
end
|
|
285
|
-
|
|
286
|
-
class TC04 < Test::Unit::TestCase
|
|
287
|
-
|
|
288
|
-
def test_04_001
|
|
289
|
-
p = lambda { |x|
|
|
290
|
-
x.word = "Hello"
|
|
291
|
-
}
|
|
292
|
-
o = p.to_openobject
|
|
293
|
-
assert_equal( "Hello", o.word )
|
|
294
|
-
end
|
|
295
|
-
|
|
296
|
-
end
|
|
297
|
-
|
|
298
|
-
=end
|