facets 1.8.49 → 1.8.51
Sign up to get free protection for your applications and to get access to all the features.
- 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/PROJECT
CHANGED
@@ -29,7 +29,7 @@ scm: darcs
|
|
29
29
|
changelog : doc/CHANGES
|
30
30
|
stamp : VERSION
|
31
31
|
|
32
|
-
|
32
|
+
distribute: [ -work, -test/lib ]
|
33
33
|
|
34
34
|
package: [ gem, tgz ]
|
35
35
|
|
@@ -37,6 +37,9 @@ notes:
|
|
37
37
|
labels: [ TODO, FIXME, CREDIT ]
|
38
38
|
|
39
39
|
rdoc:
|
40
|
+
output : doc/rdoc/core
|
41
|
+
title : Facets/CORE
|
42
|
+
files : [ '[A-Z]*', 'lib/facets/core/**/*' ]
|
40
43
|
template : jamis
|
41
44
|
options : ['--all', '--inline-source']
|
42
45
|
|
data/Rakefile
CHANGED
@@ -4,12 +4,6 @@
|
|
4
4
|
|
5
5
|
require 'autorake'
|
6
6
|
|
7
|
-
#
|
8
|
-
# Redirect, extact tests and run tests
|
9
|
-
#
|
10
|
-
|
11
|
-
#task :prepare => [ :redirect, :extest, :test ]
|
12
|
-
|
13
7
|
#
|
14
8
|
# Generate facet/ redirection files
|
15
9
|
#
|
@@ -42,25 +36,7 @@ task :redirect do
|
|
42
36
|
puts "Created #{count} redirection files in #{REDIR}/ folder."
|
43
37
|
end
|
44
38
|
|
45
|
-
#
|
46
|
-
# Extract tests
|
47
|
-
#
|
48
|
-
|
49
|
-
#desc "ectract units tests"
|
50
|
-
#task :extest do
|
51
|
-
# project.extract(:files=>'lib/facets/**/*.rb')
|
52
|
-
#end
|
53
|
-
|
54
|
-
#
|
55
|
-
# Run tests
|
56
|
-
#
|
57
|
-
|
58
|
-
#desc "run tests"
|
59
|
-
#task :test do
|
60
|
-
# project.test
|
61
|
-
#end
|
62
39
|
|
63
|
-
=begin
|
64
40
|
#
|
65
41
|
# Generate API documentation
|
66
42
|
#
|
@@ -68,31 +44,32 @@ end
|
|
68
44
|
# where teh deafult it 'all'.
|
69
45
|
#
|
70
46
|
|
71
|
-
desc "rdoc all libs"
|
72
|
-
task :
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
- '
|
81
|
-
|
82
|
-
|
83
|
-
|
47
|
+
#desc "rdoc all libs"
|
48
|
+
#task :rdocs => [:rdoc_core, :rdoc_more] do
|
49
|
+
#end
|
50
|
+
|
51
|
+
#desc "rdoc for core lib"
|
52
|
+
#task :rdocs_core do
|
53
|
+
# project.rdoc(YAML.load(<<-END))
|
54
|
+
# title: Facets/CORE
|
55
|
+
# include:
|
56
|
+
# - 'lib/facets/core/**/*'
|
57
|
+
# - '[A-Z]*'
|
58
|
+
# output: doc/rdoc/core
|
59
|
+
# END
|
60
|
+
#end
|
61
|
+
|
62
|
+
#desc "rdocs for more lib"
|
63
|
+
#task :rdocs_more do
|
64
|
+
# project.rdoc(YAML.load(<<-END))
|
65
|
+
# title: Facets/MORE
|
66
|
+
# include:
|
67
|
+
# - 'lib/facets/more/**/*'
|
68
|
+
# - '[A-Z]*'
|
69
|
+
# output: doc/rdoc/more
|
70
|
+
# END
|
71
|
+
#end
|
84
72
|
|
85
|
-
desc "rdoc more lib"
|
86
|
-
task :rdoc_more do
|
87
|
-
project.rdoc(YAML.load(<<-END))
|
88
|
-
title: Facets/MORE
|
89
|
-
include:
|
90
|
-
- 'lib/facets/more/**/*'
|
91
|
-
- '[A-Z]*'
|
92
|
-
output: doc/rdoc/more
|
93
|
-
END
|
94
|
-
end
|
95
|
-
=end
|
96
73
|
|
97
74
|
#
|
98
75
|
# List core methods
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.8.
|
1
|
+
1.8.51 stable (2007-02-19)
|
data/doc/AUTHORS
CHANGED
data/doc/CHANGES
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
Mon Feb 19 12:40:55 EST 2007 Trans <transfire@gmail.com>
|
2
|
+
* significant improvements to command.rb thanks to Tyler Rick
|
3
|
+
|
4
|
+
Fri Feb 16 04:10:35 EST 2007 Trans <transfire@gmail.com>
|
5
|
+
* added tests to elementwise and tap
|
6
|
+
|
1
7
|
Fri Feb 16 01:10:15 EST 2007 Trans <transfire@gmail.com>
|
2
8
|
* fixed test for elementwise and op_tilde_self
|
3
9
|
|
@@ -1,12 +1,42 @@
|
|
1
1
|
|
2
2
|
module Kernel
|
3
3
|
|
4
|
-
#
|
4
|
+
# Yield self and return self.
|
5
|
+
|
6
|
+
def tap &b
|
7
|
+
if b.arity == 1
|
8
|
+
yield self
|
9
|
+
else
|
10
|
+
instance_eval(&b)
|
11
|
+
end
|
5
12
|
|
6
|
-
def tap
|
7
|
-
yield self
|
8
13
|
return self
|
9
14
|
end
|
10
15
|
|
11
16
|
end
|
12
17
|
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
=begin test
|
22
|
+
|
23
|
+
require 'test/unit'
|
24
|
+
|
25
|
+
class TestTap < Test::Unit::TestCase
|
26
|
+
|
27
|
+
def test_tap
|
28
|
+
x = "foo"
|
29
|
+
r = ("foobar".tap{ gsub! /bar/, '' })
|
30
|
+
assert_equal(x, r)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_tap_array
|
34
|
+
x = [1,2,3]
|
35
|
+
x.tap{ |a|
|
36
|
+
assert_equal(x, a)
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
=end
|
42
|
+
|
data/lib/facets/more/command.rb
CHANGED
@@ -14,7 +14,8 @@
|
|
14
14
|
#
|
15
15
|
# == Author(s)
|
16
16
|
#
|
17
|
-
#
|
17
|
+
# CREDIT Thomas Sawyer
|
18
|
+
# CREDIT Tyler Rick
|
18
19
|
#
|
19
20
|
# == Developer Notes
|
20
21
|
#
|
@@ -24,12 +25,11 @@
|
|
24
25
|
# adding subdirectories to more/ is a good idea.
|
25
26
|
#
|
26
27
|
|
27
|
-
# Author:: Thomas Sawyer
|
28
|
-
# Copyright:: Copyright (c) 2005
|
28
|
+
# Author:: Thomas Sawyer, Tyler Rick
|
29
|
+
# Copyright:: Copyright (c) 2005-2007
|
29
30
|
# License:: Ruby License
|
30
31
|
|
31
32
|
require 'shellwords'
|
32
|
-
#require 'facets/core/string/modulize'
|
33
33
|
|
34
34
|
# = Console
|
35
35
|
#
|
@@ -38,8 +38,6 @@ require 'shellwords'
|
|
38
38
|
|
39
39
|
module Console ; end
|
40
40
|
|
41
|
-
# Initialize common globals to avoid warnings.
|
42
|
-
|
43
41
|
# = Console Command
|
44
42
|
#
|
45
43
|
# Console::Command provides a clean and easy way
|
@@ -163,7 +161,28 @@ module Console ; end
|
|
163
161
|
# You can use #option_missing to catch any options that are not explicility
|
164
162
|
# defined.
|
165
163
|
#
|
166
|
-
#
|
164
|
+
# The method signature should look like:
|
165
|
+
#
|
166
|
+
# option_missing(option_name, args)
|
167
|
+
#
|
168
|
+
# Example:
|
169
|
+
# def option_missing(option_name, args)
|
170
|
+
# p args if $debug
|
171
|
+
# case option_name
|
172
|
+
# when 'p'
|
173
|
+
# @a = args[0].to_i
|
174
|
+
# @b = args[1].to_i
|
175
|
+
# 2
|
176
|
+
# else
|
177
|
+
# raise InvalidOptionError(option_name, args)
|
178
|
+
# end
|
179
|
+
# end
|
180
|
+
#
|
181
|
+
# Its return value should be the effective "arity" of that options -- that is,
|
182
|
+
# how many arguments it consumed ("-p a b", for example, would consume 2 args:
|
183
|
+
# "a" and "b"). An arity of 1 is assumed if nil or false is returned.
|
184
|
+
#
|
185
|
+
# Be aware that when using subcommand modules, the same option_missing
|
167
186
|
# method will catch missing options for global options and subcommand
|
168
187
|
# options too unless an option_missing method is also defined in the
|
169
188
|
# subcommand module.
|
@@ -202,122 +221,129 @@ module Console ; end
|
|
202
221
|
|
203
222
|
class Console::Command
|
204
223
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
224
|
+
class << self
|
225
|
+
# Starts the command execution.
|
226
|
+
|
227
|
+
def execute( *args )
|
228
|
+
new(global_options).execute( *args )
|
229
|
+
end
|
230
|
+
|
231
|
+
# Alias for #execute.
|
232
|
+
|
233
|
+
alias_method :start, :execute
|
234
|
+
|
235
|
+
# Change the option mode.
|
236
|
+
|
237
|
+
def global_option( *names )
|
238
|
+
names.each{ |name| global_options << name.to_sym }
|
239
|
+
end
|
240
|
+
|
241
|
+
def global_options
|
242
|
+
@global_options ||= []
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
# Do not let this pass through to
|
247
|
+
# any included module.
|
248
|
+
|
249
|
+
def initialize(global_options)
|
250
|
+
@global_options = global_options
|
251
|
+
end
|
252
|
+
|
253
|
+
# Execute the command.
|
254
|
+
|
255
|
+
def execute( line=nil )
|
256
|
+
case line
|
257
|
+
when String
|
258
|
+
arguments = Shellwords.shellwords(line)
|
259
|
+
when Array
|
260
|
+
arguments = line
|
261
|
+
else
|
262
|
+
arguments = ARGV
|
263
|
+
end
|
264
|
+
|
265
|
+
# duplicate arguments to work on them in-place.
|
266
|
+
|
267
|
+
argv = arguments.dup
|
268
|
+
|
269
|
+
# Split single letter option groupings into separate options.
|
270
|
+
# ie. -xyz => -x -y -z
|
271
|
+
|
272
|
+
argv = argv.collect { |arg|
|
273
|
+
if md = /^-(\w{2,})/.match( arg )
|
274
|
+
md[1].split(//).collect { |c| "-#{c}" }
|
275
|
+
else
|
276
|
+
arg
|
277
|
+
end
|
278
|
+
}.flatten
|
279
|
+
|
280
|
+
# process global options
|
281
|
+
global_options.each do |name|
|
282
|
+
o = name.to_s.sub('__','--').sub('_','-')
|
283
|
+
m = method(name)
|
284
|
+
c = m.arity
|
285
|
+
while i = argv.index(o)
|
286
|
+
args = argv.slice!(i,c+1)
|
287
|
+
args.shift
|
288
|
+
m.call(*args)
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
# Does this command take subcommands?
|
293
|
+
subcommand = !respond_to?(:main)
|
294
|
+
|
295
|
+
# process primary options
|
296
|
+
argv = execute_options( argv, subcommand )
|
297
|
+
|
298
|
+
# If this command doesn't take subcommands, then the remaining arguments are arguments for main().
|
299
|
+
return send(:main, *argv) unless subcommand
|
300
|
+
|
301
|
+
# What to do if there is nothing else?
|
302
|
+
if argv.empty?
|
303
|
+
if respond_to?(:default)
|
304
|
+
return __send__(:default)
|
305
|
+
else
|
306
|
+
$stderr << "Nothing to do."
|
307
|
+
return
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
# Remaining arguments are subcommand and suboptions.
|
312
|
+
|
313
|
+
subcmd = argv.shift.gsub('-','_')
|
314
|
+
#puts "subcmd = #{subcmd}"
|
315
|
+
|
316
|
+
# Extend subcommand option module
|
317
|
+
subconst = subcmd.gsub(/\W/,'_').capitalize
|
318
|
+
#puts self.class.name
|
319
|
+
if self.class.const_defined?(subconst)
|
320
|
+
puts "Extending self (#{self.class}) with subcommand module #{subconst}" if $debug
|
321
|
+
submod = self.class.const_get(subconst)
|
322
|
+
self.extend submod
|
323
|
+
end
|
324
|
+
|
325
|
+
# process subcommand options
|
326
|
+
#puts "Treating the rest of the args as subcommand options:"
|
327
|
+
#p argv
|
328
|
+
argv = execute_options( argv )
|
329
|
+
|
330
|
+
# This is a little tricky. The method has to be defined by a subclass.
|
331
|
+
if self.respond_to?( subcmd ) and not Console::Command.public_instance_methods.include?( subcmd.to_s )
|
332
|
+
puts "Calling #{subcmd}(#{argv.inspect})" if $debug
|
333
|
+
__send__(subcmd, *argv)
|
334
|
+
else
|
335
|
+
#begin
|
336
|
+
puts "Calling method_missing with #{subcmd}, #{argv.inspect}" if $debug
|
337
|
+
method_missing(subcmd, *argv)
|
338
|
+
#rescue NoMethodError => e
|
339
|
+
#if self.private_methods.include?( "no_command_error" )
|
340
|
+
# no_command_error( *args )
|
341
|
+
#else
|
342
|
+
# $stderr << "Non-applicable command -- #{argv.join(' ')}\n"
|
343
|
+
# exit -1
|
344
|
+
#end
|
345
|
+
#end
|
346
|
+
end
|
321
347
|
|
322
348
|
# rescue => err
|
323
349
|
# if $DEBUG
|
@@ -328,120 +354,138 @@ class Console::Command
|
|
328
354
|
# msg << " (#{err.class})" if $VERBOSE
|
329
355
|
# $stderr << msg
|
330
356
|
# end
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
357
|
+
end
|
358
|
+
|
359
|
+
private
|
360
|
+
|
361
|
+
#
|
362
|
+
|
363
|
+
def global_options
|
364
|
+
@global_options
|
365
|
+
end
|
366
|
+
|
367
|
+
#
|
368
|
+
|
369
|
+
def execute_options( argv, subcmd=false )
|
370
|
+
puts "in execute_options:" if $debug
|
371
|
+
argv = argv.dup
|
372
|
+
args_to_return = []
|
373
|
+
until argv.empty?
|
374
|
+
arg = argv.first
|
375
|
+
if arg[0,1] == '-'
|
376
|
+
puts "'#{arg}' -- is an option" if $debug
|
377
|
+
|
378
|
+
name = arg.gsub('-','_')
|
379
|
+
puts " responds_to(#{name})?" if $debug
|
380
|
+
if respond_to?(name)
|
381
|
+
m = method(name)
|
382
|
+
arity = m.arity
|
383
|
+
#puts "{argv before slice: #{argv.inspect}" if $debug
|
384
|
+
args_for_current_option = argv.slice!(0, arity+1)
|
385
|
+
#puts "}argv after slice: #{argv.inspect}" if $debug
|
386
|
+
#puts "{args_for_current_option before shift: #{args_for_current_option.inspect}" if $debug
|
387
|
+
args_for_current_option.shift
|
388
|
+
#puts "}args_for_current_option after shift: #{args_for_current_option.inspect}" if $debug
|
389
|
+
#puts " arity=#{m.arity}" if $debug
|
390
|
+
#puts " calling #{name} with #{args_for_current_option.inspect}" if $debug
|
391
|
+
m.call(*args_for_current_option)
|
392
|
+
elsif respond_to?(:option_missing)
|
393
|
+
puts " option_missing(#{argv.inspect})" if $debug
|
394
|
+
arity = option_missing(arg.gsub(/^[-]+/,''), argv[1..-1]) || 1
|
395
|
+
puts " arity == #{arity}" if $debug
|
396
|
+
argv.slice!(0, arity)
|
397
|
+
argv.shift # Get rid of the *name* of the option
|
398
|
+
else
|
399
|
+
$stderr << "Unknown option '#{arg}'.\n"
|
400
|
+
exit -1
|
401
|
+
end
|
402
|
+
else
|
403
|
+
puts "'#{arg}' -- not an option. Adding to args_to_return..." if $debug
|
404
|
+
if subcmd
|
405
|
+
args_to_return = argv
|
406
|
+
#puts "subcommand. args_to_return=#{args_to_return.inspect}" if $debug
|
407
|
+
break
|
408
|
+
else
|
409
|
+
args_to_return << argv.shift
|
410
|
+
puts "args_to_return=#{args_to_return.inspect}" if $debug
|
411
|
+
end
|
412
|
+
end
|
413
|
+
end
|
414
|
+
puts "Returning #{args_to_return.inspect}" if $debug
|
415
|
+
return args_to_return
|
416
|
+
end
|
417
|
+
|
418
|
+
public
|
375
419
|
|
376
420
|
=begin
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
421
|
+
# We include a module here so you can define your own help
|
422
|
+
# command and call #super to utilize this one.
|
423
|
+
|
424
|
+
module Help
|
425
|
+
|
426
|
+
def help
|
427
|
+
opts = help_options
|
428
|
+
s = ""
|
429
|
+
s << "#{File.basename($0)}\n\n"
|
430
|
+
unless opts.empty?
|
431
|
+
s << "OPTIONS\n"
|
432
|
+
s << help_options
|
433
|
+
s << "\n"
|
434
|
+
end
|
435
|
+
s << "COMMANDS\n"
|
436
|
+
s << help_commands
|
437
|
+
puts s
|
438
|
+
end
|
439
|
+
|
440
|
+
private
|
441
|
+
|
442
|
+
def help_commands
|
443
|
+
help = self.class.help
|
444
|
+
bufs = help.keys.collect{ |a| a.to_s.size }.max + 3
|
445
|
+
lines = []
|
446
|
+
help.each { |cmd, str|
|
447
|
+
cmd = cmd.to_s
|
448
|
+
if cmd !~ /^_/
|
449
|
+
lines << " " + cmd + (" " * (bufs - cmd.size)) + str
|
450
|
+
end
|
451
|
+
}
|
452
|
+
lines.join("\n")
|
453
|
+
end
|
454
|
+
|
455
|
+
def help_options
|
456
|
+
help = self.class.help
|
457
|
+
bufs = help.keys.collect{ |a| a.to_s.size }.max + 3
|
458
|
+
lines = []
|
459
|
+
help.each { |cmd, str|
|
460
|
+
cmd = cmd.to_s
|
461
|
+
if cmd =~ /^_/
|
462
|
+
lines << " " + cmd.gsub(/_/,'-') + (" " * (bufs - cmd.size)) + str
|
463
|
+
end
|
464
|
+
}
|
465
|
+
lines.join("\n")
|
466
|
+
end
|
467
|
+
|
468
|
+
module ClassMethods
|
469
|
+
|
470
|
+
def help( str=nil )
|
471
|
+
return (@help ||= {}) unless str
|
472
|
+
@current_help = str
|
473
|
+
end
|
474
|
+
|
475
|
+
def method_added( meth )
|
476
|
+
if @current_help
|
477
|
+
@help ||= {}
|
478
|
+
@help[meth] = @current_help
|
479
|
+
@current_help = nil
|
480
|
+
end
|
481
|
+
end
|
482
|
+
|
483
|
+
end
|
484
|
+
|
485
|
+
end
|
486
|
+
|
487
|
+
include Help
|
488
|
+
extend Help::ClassMethods
|
445
489
|
=end
|
446
490
|
|
447
491
|
end
|
@@ -457,57 +501,249 @@ end
|
|
457
501
|
|
458
502
|
=begin test
|
459
503
|
|
460
|
-
|
504
|
+
require 'test/unit'
|
505
|
+
require 'stringio'
|
506
|
+
|
507
|
+
class TestCommand < Test::Unit::TestCase
|
508
|
+
def setup
|
509
|
+
$output = nil
|
510
|
+
$stderr = StringIO.new
|
511
|
+
end
|
512
|
+
|
513
|
+
#
|
514
|
+
|
515
|
+
class SimpleCommand < Console::Command
|
516
|
+
def __here ; @here = true ; end
|
517
|
+
|
518
|
+
def main(*args)
|
519
|
+
$output = [@here] | args
|
520
|
+
end
|
521
|
+
end
|
522
|
+
|
523
|
+
def test_SimpleCommand
|
524
|
+
SimpleCommand.execute( '--here file1 file2' )
|
525
|
+
assert_equal( [true, 'file1', 'file2'], $output )
|
526
|
+
end
|
527
|
+
|
528
|
+
#
|
529
|
+
|
530
|
+
class CommandWithMethodMissingSubcommand < Console::Command
|
531
|
+
def __here ; @here = true ; end
|
532
|
+
|
533
|
+
def method_missing(subcommand, *args)
|
534
|
+
$output = [@here, subcommand] | args
|
535
|
+
end
|
536
|
+
end
|
537
|
+
|
538
|
+
def test_CommandWithMethodMissingSubcommand
|
539
|
+
CommandWithMethodMissingSubcommand.execute( '--here go file1' )
|
540
|
+
assert_equal( [true, 'go', 'file1'], $output )
|
541
|
+
end
|
542
|
+
|
543
|
+
#
|
461
544
|
|
462
|
-
|
545
|
+
class CommandWithSimpleSubcommand < Console::Command
|
546
|
+
def __here ; @here = true ; end
|
463
547
|
|
464
|
-
|
548
|
+
# subcommand
|
465
549
|
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
550
|
+
module Go
|
551
|
+
def _p(n)
|
552
|
+
@p = n.to_i
|
553
|
+
end
|
554
|
+
end
|
470
555
|
|
471
|
-
|
556
|
+
def go ; $output = [@here, @p] ; end
|
557
|
+
end
|
472
558
|
|
473
|
-
|
474
|
-
|
559
|
+
def test_CommandWithSimpleSubcommand
|
560
|
+
CommandWithSimpleSubcommand.execute( '--here go -p 1' )
|
561
|
+
assert_equal( [true, 1], $output )
|
562
|
+
end
|
475
563
|
|
476
|
-
|
477
|
-
def _p(n)
|
478
|
-
@p = n.to_i
|
479
|
-
end
|
480
|
-
end
|
481
|
-
end
|
564
|
+
#
|
482
565
|
|
483
|
-
|
566
|
+
# Global options can be anywhere, right? Even after subcommands? Let's find out.
|
567
|
+
class CommandWithGlobalOptionsAfterSubcommand < Console::Command
|
568
|
+
def _x ; @x = true ; end
|
569
|
+
global_option :_x
|
484
570
|
|
485
|
-
|
486
|
-
assert_equal( [true, true, 'HERE', 1], $output )
|
487
|
-
end
|
571
|
+
def go ; $output = [@x, @p] ; end
|
488
572
|
|
489
|
-
|
573
|
+
module Go
|
574
|
+
def _p(n)
|
575
|
+
@p = n.to_i
|
576
|
+
end
|
577
|
+
end
|
578
|
+
end
|
490
579
|
|
491
|
-
|
492
|
-
|
580
|
+
def test_CommandWithGlobalOptionsAfterSubcommand
|
581
|
+
CommandWithGlobalOptionsAfterSubcommand.execute( 'go -x -p 1' )
|
582
|
+
assert_equal( [true, 1], $output )
|
493
583
|
|
494
|
-
|
584
|
+
CommandWithGlobalOptionsAfterSubcommand.execute( 'go -p 1 -x' )
|
585
|
+
assert_equal( [true, 1], $output )
|
586
|
+
end
|
495
587
|
|
496
|
-
|
497
|
-
def _p(n)
|
498
|
-
@p = n.to_i
|
499
|
-
end
|
500
|
-
end
|
588
|
+
#
|
501
589
|
|
502
|
-
|
503
|
-
|
590
|
+
class GivingUnrecognizedOptions < Console::Command
|
591
|
+
def _x ; @x = true ; end
|
592
|
+
def go ; $output = [@x, @p] ; end
|
593
|
+
end
|
504
594
|
|
505
|
-
|
595
|
+
def test_GivingUnrecognizedOptions
|
596
|
+
assert_raise(SystemExit) do
|
597
|
+
GivingUnrecognizedOptions.execute( '--an-option-that-wont-be-recognized -x go' )
|
598
|
+
end
|
599
|
+
assert_equal "Unknown option '--an-option-that-wont-be-recognized'.\n", $stderr.string
|
600
|
+
assert_equal( nil, $output )
|
601
|
+
end
|
602
|
+
#
|
506
603
|
|
507
|
-
|
508
|
-
|
509
|
-
|
604
|
+
class PassingMultipleSingleCharOptionsAsOneOption < Console::Command
|
605
|
+
def _x ; @x = true ; end
|
606
|
+
def _y ; @y = true ; end
|
607
|
+
def _z(n) ; @z = n ; end
|
608
|
+
|
609
|
+
global_option :_x
|
610
|
+
|
611
|
+
def go ; $output = [@x, @y, @z, @p] ; end
|
510
612
|
|
511
|
-
|
613
|
+
module Go
|
614
|
+
def _p(n)
|
615
|
+
@p = n.to_i
|
616
|
+
end
|
617
|
+
end
|
618
|
+
end
|
619
|
+
|
620
|
+
def test_PassingMultipleSingleCharOptionsAsOneOption
|
621
|
+
PassingMultipleSingleCharOptionsAsOneOption.execute( '-xy -z HERE go -p 1' )
|
622
|
+
assert_equal( [true, true, 'HERE', 1], $output )
|
623
|
+
end
|
624
|
+
|
625
|
+
#
|
626
|
+
|
627
|
+
class CommandWithOptionUsingEquals < Console::Command
|
628
|
+
module Go
|
629
|
+
def __mode(mode) ; @mode = mode ; end
|
630
|
+
end
|
631
|
+
def go ; $output = [@mode] ; end
|
632
|
+
end
|
633
|
+
|
634
|
+
def test_CommandWithOptionUsingEquals
|
635
|
+
CommandWithOptionUsingEquals.execute( 'go --mode smart' )
|
636
|
+
assert_equal( ['smart'], $output )
|
637
|
+
|
638
|
+
# I would expect this to work too, but currently it doesn't.
|
639
|
+
#assert_nothing_raised { CommandWithOptionUsingEquals.execute( 'go --mode=smart' ) }
|
640
|
+
#assert_equal( ['smart'], $output )
|
641
|
+
end
|
642
|
+
|
643
|
+
#
|
644
|
+
|
645
|
+
class CommandWithSubcommandThatTakesArgs < Console::Command
|
646
|
+
def go(arg1, *args) ; $output = [arg1] | args ; end
|
647
|
+
end
|
648
|
+
|
649
|
+
def test_CommandWithSubcommandThatTakesArgs
|
650
|
+
CommandWithSubcommandThatTakesArgs.execute( 'go file1 file2 file3' )
|
651
|
+
assert_equal( ['file1', 'file2', 'file3'], $output )
|
652
|
+
end
|
653
|
+
|
654
|
+
#
|
655
|
+
|
656
|
+
class CommandWith2OptionalArgs < Console::Command
|
657
|
+
def __here ; @here = true ; end
|
658
|
+
|
659
|
+
module Go
|
660
|
+
def _p(n)
|
661
|
+
@p = n.to_i
|
662
|
+
end
|
663
|
+
end
|
664
|
+
|
665
|
+
def go(required1 = nil, optional2 = nil) ; $output = [@here, @p, required1, optional2 ] ; end
|
666
|
+
end
|
667
|
+
|
668
|
+
def test_CommandWith2OptionalArgs
|
669
|
+
CommandWith2OptionalArgs.execute( '--here go -p 1 to' )
|
670
|
+
assert_equal( [true, 1, 'to', nil], $output )
|
671
|
+
end
|
672
|
+
|
673
|
+
#
|
674
|
+
|
675
|
+
class CommandWithVariableArgs < Console::Command
|
676
|
+
def __here ; @here = true ; end
|
677
|
+
|
678
|
+
module Go
|
679
|
+
def _p(n)
|
680
|
+
@p = n.to_i
|
681
|
+
end
|
682
|
+
end
|
683
|
+
|
684
|
+
def go(*args) ; $output = [@here, @p] | args ; end
|
685
|
+
end
|
686
|
+
|
687
|
+
def test_CommandWithVariableArgs
|
688
|
+
CommandWithVariableArgs.execute( '--here go -p 1 to bed' )
|
689
|
+
assert_equal( [true, 1, 'to', 'bed'], $output )
|
690
|
+
end
|
691
|
+
|
692
|
+
#
|
693
|
+
|
694
|
+
class CommandWithOptionMissing < Console::Command
|
695
|
+
def __here ; @here = true ; end
|
696
|
+
|
697
|
+
module Go
|
698
|
+
def option_missing(option_name, args)
|
699
|
+
p args if $debug
|
700
|
+
case option_name
|
701
|
+
when 'p'
|
702
|
+
@p = args[0].to_i
|
703
|
+
1
|
704
|
+
else
|
705
|
+
raise InvalidOptionError(option_name, args)
|
706
|
+
end
|
707
|
+
end
|
708
|
+
end
|
709
|
+
|
710
|
+
def go(*args) ; $output = [@here, @p] | args ; end
|
711
|
+
end
|
712
|
+
|
713
|
+
def test_CommandWithOptionMissing
|
714
|
+
CommandWithOptionMissing.execute( '--here go -p 1 to bed right now' )
|
715
|
+
assert_equal( [true, 1, 'to', 'bed', 'right', 'now'], $output )
|
716
|
+
end
|
717
|
+
|
718
|
+
#
|
719
|
+
|
720
|
+
class CommandWithOptionMissingArityOf2 < Console::Command
|
721
|
+
def __here ; @here = true ; end
|
722
|
+
|
723
|
+
module Go
|
724
|
+
def option_missing(option_name, args)
|
725
|
+
p args if $debug
|
726
|
+
case option_name
|
727
|
+
when 'p'
|
728
|
+
@p1 = args[0].to_i
|
729
|
+
@p2 = args[1].to_i
|
730
|
+
2
|
731
|
+
when 'q'
|
732
|
+
@q = args[0].to_i
|
733
|
+
nil # Test default arity
|
734
|
+
else
|
735
|
+
raise InvalidOptionError(option_name, args)
|
736
|
+
end
|
737
|
+
end
|
738
|
+
end
|
739
|
+
|
740
|
+
def go(*args) ; $output = [@here, @p1, @p2, @q] | args ; end
|
741
|
+
end
|
742
|
+
|
743
|
+
def test_CommandWithOptionMissingArityOf2
|
744
|
+
CommandWithOptionMissingArityOf2.execute( '--here go -p 1 2 -q 3 to bed right now' )
|
745
|
+
assert_equal( [true, 1, 2, 3, 'to', 'bed', 'right', 'now'], $output )
|
746
|
+
end
|
747
|
+
end
|
512
748
|
|
513
749
|
=end
|