facets 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ProjectInfo +32 -25
- data/data/facets/index.yml +30 -6
- data/data/facets/units/binary/base.yaml +12 -0
- data/data/facets/units/binary/extra.yaml +8 -0
- data/data/facets/units/cex.yaml +7 -0
- data/data/facets/units/currency/base.yaml +268 -0
- data/data/facets/units/default.yaml +22 -0
- data/data/facets/units/dump_yaml.rb +309 -0
- data/data/facets/units/si/base.yaml +36 -0
- data/data/facets/units/si/derived.yaml +133 -0
- data/data/facets/units/si/extra.yaml +107 -0
- data/data/facets/units/standard.yaml +5 -0
- data/data/facets/units/uk.yaml +16 -0
- data/data/facets/units/uk/base.yaml +107 -0
- data/data/facets/units/us.yaml +16 -0
- data/data/facets/units/us/base.yaml +112 -0
- data/data/facets/units/xmethods/cached.yaml +83 -0
- data/data/facets/units/xmethods/mapping.yaml +85 -0
- data/lib/facet/array/join_sentence.rb +1 -0
- data/lib/facet/class/cattr.rb +1 -0
- data/lib/facet/class/cattr_accessor.rb +1 -0
- data/lib/facet/class/cattr_reader.rb +1 -0
- data/lib/facet/class/cattr_writer.rb +1 -0
- data/lib/facet/elementor.rb +1 -0
- data/lib/facet/enumerable/accumulate.rb +1 -0
- data/lib/facet/enumerable/collect_if.rb +1 -0
- data/lib/facet/enumerable/map_if.rb +1 -0
- data/lib/facet/file/self/append.rb +1 -0
- data/lib/facet/file/self/read_binary.rb +1 -0
- data/lib/facet/file/self/write.rb +1 -0
- data/lib/facet/json.rb +1 -0
- data/lib/facet/kernel/__self__.rb +1 -0
- data/lib/facet/kernel/methodname.rb +1 -0
- data/lib/facet/module/attr_query.rb +1 -0
- data/lib/facet/module/attr_validator.rb +1 -0
- data/lib/facet/module/inherit.rb +1 -0
- data/lib/facet/module/let.rb +1 -0
- data/lib/facet/module/mattr.rb +1 -0
- data/lib/facet/module/mattr_accessor.rb +1 -0
- data/lib/facet/module/mattr_reader.rb +1 -0
- data/lib/facet/module/mattr_writer.rb +1 -0
- data/lib/facet/module/singleton_to_module.rb +1 -0
- data/lib/facet/nilclass/op_cmp.rb +1 -0
- data/lib/facet/nilclass/succ.rb +1 -0
- data/lib/facet/recorder.rb +1 -0
- data/lib/facet/xoxo.rb +1 -0
- data/lib/facets/core/array.rb +1 -0
- data/lib/facets/core/array/join_sentence.rb +12 -0
- data/lib/facets/core/class.rb +4 -0
- data/lib/facets/core/{module → class}/cattr.rb +7 -9
- data/lib/facets/core/class/cattr_accessor.rb +2 -0
- data/lib/facets/core/class/cattr_reader.rb +3 -0
- data/lib/facets/core/class/cattr_writer.rb +2 -0
- data/lib/facets/core/dir/self/ls_r.rb +4 -9
- data/lib/facets/core/enumerable.rb +3 -0
- data/lib/facets/core/enumerable/accumulate.rb +25 -0
- data/lib/facets/core/enumerable/collect_if.rb +15 -0
- data/lib/facets/core/enumerable/ew.rb +1 -5
- data/lib/facets/core/enumerable/map_if.rb +3 -0
- data/lib/facets/core/file.rb +3 -0
- data/lib/facets/core/file/self/append.rb +8 -0
- data/lib/facets/core/file/self/create.rb +14 -8
- data/lib/facets/core/file/self/open_as_string.rb +31 -13
- data/lib/facets/core/file/self/read_binary.rb +8 -0
- data/lib/facets/core/file/self/read_list.rb +11 -7
- data/lib/facets/core/file/self/write.rb +8 -0
- data/lib/facets/core/fileutils/wc.rb +4 -9
- data/lib/facets/core/fileutils/which.rb +4 -9
- data/lib/facets/core/kernel.rb +2 -1
- data/lib/facets/core/kernel/__self__.rb +32 -0
- data/lib/facets/core/kernel/as.rb +1 -1
- data/lib/facets/core/kernel/assign_from.rb +3 -3
- data/lib/facets/core/kernel/assign_with.rb +2 -0
- data/lib/facets/core/kernel/me.rb +3 -2
- data/lib/facets/core/kernel/method_name.rb +2 -49
- data/lib/facets/core/kernel/methodname.rb +49 -0
- data/lib/facets/core/module.rb +9 -4
- data/lib/facets/core/module/attr_query.rb +56 -0
- data/lib/facets/core/module/attr_validator.rb +18 -0
- data/lib/facets/core/module/inherit.rb +70 -0
- data/lib/facets/core/module/integrate.rb +1 -1
- data/lib/facets/core/module/let.rb +55 -0
- data/lib/facets/core/module/mattr.rb +180 -0
- data/lib/facets/core/module/{cattr_accessor.rb → mattr_accessor.rb} +0 -0
- data/lib/facets/core/module/{cattr_reader.rb → mattr_reader.rb} +0 -0
- data/lib/facets/core/module/{cattr_writer.rb → mattr_writer.rb} +0 -0
- data/lib/facets/core/module/on_included.rb +3 -1
- data/lib/facets/core/module/singleton_to_module.rb +23 -0
- data/lib/facets/core/nilclass.rb +2 -0
- data/lib/facets/core/string/methodize.rb +4 -3
- data/lib/facets/core/string/modulize.rb +3 -3
- data/lib/facets/more/ansicode.rb +1 -1
- data/lib/facets/more/aspects.rb +1 -1
- data/lib/facets/more/basicobject.rb +67 -22
- data/lib/facets/more/classinherit.rb +2 -2
- data/lib/facets/more/cloneable.rb +1 -1
- data/lib/facets/more/consoleapp.rb +31 -20
- data/lib/facets/more/dictionary.rb +1 -1
- data/lib/facets/more/filelist.rb +2 -10
- data/lib/facets/more/functor.rb +6 -6
- data/lib/facets/more/json.rb +891 -0
- data/lib/facets/more/methodprobe.rb +1 -1
- data/lib/facets/more/multiton.rb +16 -8
- data/lib/facets/more/nilcomparable.rb +31 -49
- data/lib/facets/more/openobject.rb +50 -10
- data/lib/facets/more/recorder.rb +125 -0
- data/lib/facets/more/rtals.rb +199 -4
- data/lib/facets/more/typecast.rb +12 -12
- data/lib/facets/more/units.rb +20 -14
- data/lib/facets/more/xoxo.rb +519 -0
- data/setup.rb +283 -271
- data/test/lib/facets/core/array/test_at_rand.rb +1 -1
- data/test/lib/facets/core/array/test_delete_unless.rb +1 -1
- data/test/lib/facets/core/array/test_delete_values.rb +1 -1
- data/test/lib/facets/core/array/test_delete_values_at.rb +1 -1
- data/test/lib/facets/core/array/test_first.rb +1 -1
- data/test/lib/facets/core/array/test_head.rb +1 -1
- data/test/lib/facets/core/array/test_last_index.rb +1 -1
- data/test/lib/facets/core/array/test_merge.rb +1 -1
- data/test/lib/facets/core/array/test_mid.rb +1 -1
- data/test/lib/facets/core/array/test_middle.rb +1 -1
- data/test/lib/facets/core/array/test_op_fetch.rb +1 -1
- data/test/lib/facets/core/array/test_op_store.rb +1 -1
- data/test/lib/facets/core/array/test_pick.rb +1 -1
- data/test/lib/facets/core/array/test_pos.rb +1 -1
- data/test/lib/facets/core/array/test_pull.rb +1 -1
- data/test/lib/facets/core/array/test_rand_index.rb +1 -1
- data/test/lib/facets/core/array/test_rand_subset.rb +1 -1
- data/test/lib/facets/core/array/test_range.rb +1 -1
- data/test/lib/facets/core/array/test_rotate.rb +1 -1
- data/test/lib/facets/core/array/test_select.rb +1 -1
- data/test/lib/facets/core/array/test_shuffle.rb +1 -1
- data/test/lib/facets/core/array/test_slap.rb +1 -1
- data/test/lib/facets/core/array/test_thru.rb +1 -1
- data/test/lib/facets/core/array/test_to_b.rb +1 -1
- data/test/lib/facets/core/array/test_to_h.rb +1 -1
- data/test/lib/facets/core/array/test_to_hash.rb +1 -1
- data/test/lib/facets/core/binding/self/test_of_caller.rb +1 -1
- data/test/lib/facets/core/binding/test___LINE__.rb +1 -1
- data/test/lib/facets/core/binding/test_call_stack.rb +1 -1
- data/test/lib/facets/core/binding/test_called.rb +1 -1
- data/test/lib/facets/core/binding/test_caller.rb +1 -1
- data/test/lib/facets/core/binding/test_defined.rb +1 -1
- data/test/lib/facets/core/binding/test_eval.rb +1 -1
- data/test/lib/facets/core/binding/test_local_variables.rb +1 -1
- data/test/lib/facets/core/binding/test_method_name.rb +1 -1
- data/test/lib/facets/core/binding/test_op_fetch.rb +1 -1
- data/test/lib/facets/core/binding/test_op_store.rb +1 -1
- data/test/lib/facets/core/binding/test_self.rb +1 -1
- data/test/lib/facets/core/{module/test_cattr_accessor.rb → class/test_cattr.rb} +11 -3
- data/test/lib/facets/core/class/test_descendents.rb +1 -1
- data/test/lib/facets/core/class/test_method_name.rb +1 -1
- data/test/lib/facets/core/class/test_remove_descendents.rb +1 -1
- data/test/lib/facets/core/class/test_unix_path.rb +1 -1
- data/test/lib/facets/core/comparable/test_at_least.rb +1 -1
- data/test/lib/facets/core/comparable/test_clip.rb +1 -1
- data/test/lib/facets/core/comparable/test_cmp.rb +1 -1
- data/test/lib/facets/core/continuation/self/test_create.rb +1 -1
- data/test/lib/facets/core/date/test_days_in_month.rb +1 -1
- data/test/lib/facets/core/date/test_days_of_month.rb +1 -1
- data/test/lib/facets/core/date/test_stamp.rb +1 -1
- data/test/lib/facets/core/date/test_to_date.rb +1 -1
- data/test/lib/facets/core/date/test_to_s.rb +1 -1
- data/test/lib/facets/core/date/test_to_time.rb +1 -1
- data/test/lib/facets/core/dir/self/test_ancestor.rb +1 -1
- data/test/lib/facets/core/dir/self/test_ascend.rb +1 -1
- data/test/lib/facets/core/enumerable/self/test_combinations.rb +1 -1
- data/test/lib/facets/core/enumerable/self/test_cross.rb +1 -1
- data/test/lib/facets/core/enumerable/test_collect_with_index.rb +1 -1
- data/test/lib/facets/core/enumerable/test_commonality.rb +1 -1
- data/test/lib/facets/core/enumerable/test_compact_collect.rb +1 -1
- data/test/lib/facets/core/enumerable/test_cross.rb +1 -1
- data/test/lib/facets/core/enumerable/test_each_combination.rb +1 -1
- data/test/lib/facets/core/enumerable/test_each_pair.rb +1 -1
- data/test/lib/facets/core/enumerable/test_each_slice.rb +1 -1
- data/test/lib/facets/core/enumerable/test_each_unique_pair.rb +1 -1
- data/test/lib/facets/core/enumerable/test_entropy.rb +1 -1
- data/test/lib/facets/core/enumerable/test_every.rb +1 -1
- data/test/lib/facets/core/enumerable/test_ew.rb +1 -1
- data/test/lib/facets/core/enumerable/test_filter_collect.rb +1 -1
- data/test/lib/facets/core/enumerable/test_find_collisions.rb +1 -1
- data/test/lib/facets/core/enumerable/test_frequency.rb +1 -1
- data/test/lib/facets/core/enumerable/test_graph.rb +1 -1
- data/test/lib/facets/core/enumerable/test_ideal_entropy.rb +1 -1
- data/test/lib/facets/core/enumerable/test_none.rb +1 -1
- data/test/lib/facets/core/enumerable/test_occur.rb +1 -1
- data/test/lib/facets/core/enumerable/test_one.rb +1 -1
- data/test/lib/facets/core/enumerable/test_op_pow.rb +1 -1
- data/test/lib/facets/core/enumerable/test_partition_by.rb +1 -1
- data/test/lib/facets/core/enumerable/test_permute.rb +1 -1
- data/test/lib/facets/core/enumerable/test_probability.rb +1 -1
- data/test/lib/facets/core/enumerable/test_to_h.rb +1 -1
- data/test/lib/facets/core/enumerable/test_uniq_by.rb +1 -1
- data/test/lib/facets/core/file/self/test_create.rb +14 -9
- data/test/lib/facets/core/file/self/test_open_as_string.rb +21 -11
- data/test/lib/facets/core/file/self/test_read_list.rb +11 -8
- data/test/lib/facets/core/file/self/test_sanitize.rb +1 -1
- data/test/lib/facets/core/file/self/test_split_all.rb +1 -1
- data/test/lib/facets/core/float/test_round_at.rb +1 -1
- data/test/lib/facets/core/float/test_round_to.rb +1 -1
- data/test/lib/facets/core/hash/self/test_zipnew.rb +1 -1
- data/test/lib/facets/core/hash/test_alias.rb +1 -1
- data/test/lib/facets/core/hash/test_assert_has_keys.rb +1 -1
- data/test/lib/facets/core/hash/test_assert_has_only_keys.rb +1 -1
- data/test/lib/facets/core/hash/test_at.rb +1 -1
- data/test/lib/facets/core/hash/test_collate.rb +1 -1
- data/test/lib/facets/core/hash/test_each.rb +1 -1
- data/test/lib/facets/core/hash/test_each_with_index.rb +1 -1
- data/test/lib/facets/core/hash/test_each_with_key.rb +1 -1
- data/test/lib/facets/core/hash/test_graph.rb +1 -1
- data/test/lib/facets/core/hash/test_has_keys.rb +1 -1
- data/test/lib/facets/core/hash/test_has_only_keys.rb +1 -1
- data/test/lib/facets/core/hash/test_inverse.rb +1 -1
- data/test/lib/facets/core/hash/test_keys_to_s.rb +1 -1
- data/test/lib/facets/core/hash/test_keys_to_sym.rb +1 -1
- data/test/lib/facets/core/hash/test_op_fetch.rb +1 -1
- data/test/lib/facets/core/hash/test_op_lshift.rb +1 -1
- data/test/lib/facets/core/hash/test_rand_key.rb +1 -1
- data/test/lib/facets/core/hash/test_rand_pair.rb +1 -1
- data/test/lib/facets/core/hash/test_rand_value.rb +1 -1
- data/test/lib/facets/core/hash/test_replace_each.rb +1 -1
- data/test/lib/facets/core/hash/test_shuffle.rb +1 -1
- data/test/lib/facets/core/hash/test_slice.rb +1 -1
- data/test/lib/facets/core/hash/test_swap.rb +1 -1
- data/test/lib/facets/core/hash/test_swapkey.rb +1 -1
- data/test/lib/facets/core/hash/test_to_h.rb +1 -1
- data/test/lib/facets/core/hash/test_to_ostruct.rb +1 -1
- data/test/lib/facets/core/hash/test_to_ostruct_recurse.rb +1 -1
- data/test/lib/facets/core/hash/test_traverse.rb +1 -1
- data/test/lib/facets/core/hash/test_update_each.rb +1 -1
- data/test/lib/facets/core/hash/test_update_keys.rb +1 -1
- data/test/lib/facets/core/hash/test_update_values.rb +1 -1
- data/test/lib/facets/core/hash/test_weave.rb +1 -1
- data/test/lib/facets/core/integer/test_factorial.rb +1 -1
- data/test/lib/facets/core/integer/test_multiple.rb +1 -1
- data/test/lib/facets/core/integer/test_ordinal.rb +1 -1
- data/test/lib/facets/core/integer/test_times_collect.rb +1 -1
- data/test/lib/facets/core/kernel/test___class__.rb +1 -1
- data/test/lib/facets/core/kernel/test_as.rb +1 -1
- data/test/lib/facets/core/kernel/test_assign_from.rb +1 -1
- data/test/lib/facets/core/kernel/test_assign_with.rb +1 -1
- data/test/lib/facets/core/kernel/test_bool.rb +1 -1
- data/test/lib/facets/core/kernel/test_bug.rb +1 -1
- data/test/lib/facets/core/kernel/test_call_stack.rb +1 -1
- data/test/lib/facets/core/kernel/test_called.rb +1 -1
- data/test/lib/facets/core/kernel/test_constant.rb +1 -1
- data/test/lib/facets/core/kernel/test_copy.rb +1 -1
- data/test/lib/facets/core/kernel/test_deep_copy.rb +1 -1
- data/test/lib/facets/core/kernel/test_demo.rb +1 -1
- data/test/lib/facets/core/kernel/test_fn.rb +1 -1
- data/test/lib/facets/core/kernel/test_generate_method_name.rb +1 -1
- data/test/lib/facets/core/kernel/test_get_by_id.rb +1 -1
- data/test/lib/facets/core/kernel/test_here.rb +1 -1
- data/test/lib/facets/core/kernel/test_in.rb +1 -1
- data/test/lib/facets/core/kernel/test_maybe.rb +1 -1
- data/test/lib/facets/core/kernel/test_metaclass.rb +1 -1
- data/test/lib/facets/core/kernel/test_method.rb +1 -1
- data/test/lib/facets/core/kernel/{test_method_name.rb → test_methodname.rb} +3 -3
- data/test/lib/facets/core/kernel/test_methods.rb +1 -1
- data/test/lib/facets/core/kernel/test_new.rb +1 -1
- data/test/lib/facets/core/kernel/test_object_class.rb +1 -1
- data/test/lib/facets/core/kernel/test_object_hexid.rb +1 -1
- data/test/lib/facets/core/kernel/test_require_all.rb +1 -1
- data/test/lib/facets/core/kernel/test_require_esc.rb +1 -1
- data/test/lib/facets/core/kernel/test_require_facet.rb +1 -1
- data/test/lib/facets/core/kernel/test_resc.rb +1 -1
- data/test/lib/facets/core/kernel/test_returning.rb +1 -1
- data/test/lib/facets/core/kernel/test_send_as.rb +1 -1
- data/test/lib/facets/core/kernel/test_set_from.rb +1 -1
- data/test/lib/facets/core/kernel/test_set_with.rb +1 -1
- data/test/lib/facets/core/kernel/test_silently.rb +1 -1
- data/test/lib/facets/core/kernel/test_singleton.rb +1 -1
- data/test/lib/facets/core/kernel/test_superior.rb +1 -1
- data/test/lib/facets/core/kernel/test_supermethod.rb +1 -1
- data/test/lib/facets/core/kernel/test_this.rb +1 -1
- data/test/lib/facets/core/kernel/test_to_b.rb +1 -1
- data/test/lib/facets/core/kernel/test_to_bool.rb +1 -1
- data/test/lib/facets/core/kernel/test_uri.rb +1 -1
- data/test/lib/facets/core/kernel/test_val.rb +1 -1
- data/test/lib/facets/core/kernel/test_with_accessor.rb +1 -1
- data/test/lib/facets/core/matchdata/test_match.rb +1 -1
- data/test/lib/facets/core/matchdata/test_matchtree.rb +1 -1
- data/test/lib/facets/core/module/test_abstract.rb +1 -1
- data/test/lib/facets/core/module/test_alias_module_function.rb +1 -1
- data/test/lib/facets/core/module/test_ancestor.rb +1 -1
- data/test/lib/facets/core/module/test_basename.rb +1 -1
- data/test/lib/facets/core/module/test_by_name.rb +1 -1
- data/test/lib/facets/core/module/test_clone_using.rb +1 -1
- data/test/lib/facets/core/module/test_dirname.rb +1 -1
- data/test/lib/facets/core/module/test_equate_on.rb +1 -1
- data/test/lib/facets/core/module/test_generate_instance_method_name.rb +1 -1
- data/test/lib/facets/core/module/test_include_as.rb +1 -1
- data/test/lib/facets/core/module/test_inherit.rb +58 -0
- data/test/lib/facets/core/module/test_initializer.rb +1 -1
- data/test/lib/facets/core/module/test_instance_methods.rb +1 -1
- data/test/lib/facets/core/module/test_integrate.rb +1 -1
- data/test/lib/facets/core/module/test_let.rb +31 -0
- data/test/lib/facets/core/module/test_mattr.rb +71 -0
- data/test/lib/facets/core/module/test_memoize.rb +1 -1
- data/test/lib/facets/core/module/test_modspace.rb +1 -1
- data/test/lib/facets/core/module/test_namespace.rb +1 -1
- data/test/lib/facets/core/module/test_nesting.rb +1 -1
- data/test/lib/facets/core/module/test_on_included.rb +36 -0
- data/test/lib/facets/core/module/test_redef.rb +1 -1
- data/test/lib/facets/core/module/test_redefine_method.rb +1 -1
- data/test/lib/facets/core/module/test_redirect.rb +1 -1
- data/test/lib/facets/core/module/test_redirect_method.rb +1 -1
- data/test/lib/facets/core/module/test_remove.rb +1 -1
- data/test/lib/facets/core/module/test_rename.rb +1 -1
- data/test/lib/facets/core/module/test_rename_method.rb +1 -1
- data/test/lib/facets/core/module/test_revisal.rb +1 -1
- data/test/lib/facets/core/module/test_shadow_method.rb +1 -1
- data/test/lib/facets/core/module/test_sort_on.rb +1 -1
- data/test/lib/facets/core/module/test_undef.rb +1 -1
- data/test/lib/facets/core/module/test_wrap.rb +1 -1
- data/test/lib/facets/core/module/test_wrap_method.rb +1 -1
- data/test/lib/facets/core/nilclass/{test_to_f.rb → test_blank.rb} +5 -5
- data/test/lib/facets/core/nilclass/test_empty.rb +1 -1
- data/test/lib/facets/core/nilclass/test_include.rb +1 -1
- data/test/lib/facets/core/nilclass/test_op_fetch.rb +1 -1
- data/test/lib/facets/core/nilclass/test_size.rb +1 -1
- data/test/lib/facets/core/nilclass/test_to_h.rb +1 -1
- data/test/lib/facets/core/{float → numeric}/test_approx.rb +4 -3
- data/test/lib/facets/core/numeric/test_ceil_multiple.rb +1 -1
- data/test/lib/facets/core/numeric/test_succ.rb +1 -1
- data/test/lib/facets/core/numeric/test_to_b.rb +1 -1
- data/test/lib/facets/core/ostruct/test___merge__.rb +1 -1
- data/test/lib/facets/core/ostruct/test___update__.rb +1 -1
- data/test/lib/facets/core/ostruct/test_op_fetch.rb +1 -1
- data/test/lib/facets/core/ostruct/test_op_store.rb +1 -1
- data/test/lib/facets/core/proc/test_compose.rb +1 -1
- data/test/lib/facets/core/proc/test_to_method.rb +1 -1
- data/test/lib/facets/core/range/test_to_r.rb +1 -1
- data/test/lib/facets/core/range/test_to_range.rb +1 -1
- data/test/lib/facets/core/range/test_umbrella.rb +1 -1
- data/test/lib/facets/core/range/test_within.rb +1 -1
- data/test/lib/facets/core/regexp/test_arity.rb +1 -1
- data/test/lib/facets/core/regexp/test_to_re.rb +1 -1
- data/test/lib/facets/core/regexp/test_to_regexp.rb +1 -1
- data/test/lib/facets/core/string/self/test_interpolate.rb +1 -1
- data/test/lib/facets/core/string/self/test_patterns.rb +1 -1
- data/test/lib/facets/core/string/self/test_rand_letter.rb +1 -1
- data/test/lib/facets/core/string/test_align_center.rb +1 -1
- data/test/lib/facets/core/string/test_at_rand.rb +1 -1
- data/test/lib/facets/core/string/test_basename.rb +1 -1
- data/test/lib/facets/core/string/test_blank.rb +1 -1
- data/test/lib/facets/core/string/test_bracket.rb +1 -1
- data/test/lib/facets/core/string/test_camelcase.rb +1 -1
- data/test/lib/facets/core/string/test_camelize.rb +1 -1
- data/test/lib/facets/core/string/test_capitalized.rb +1 -1
- data/test/lib/facets/core/string/test_chars.rb +1 -1
- data/test/lib/facets/core/string/test_cmp.rb +1 -1
- data/test/lib/facets/core/string/test_demodulize.rb +1 -1
- data/test/lib/facets/core/string/test_downcase.rb +1 -1
- data/test/lib/facets/core/string/test_dresner.rb +1 -1
- data/test/lib/facets/core/string/test_each_char.rb +1 -1
- data/test/lib/facets/core/string/test_each_word.rb +1 -1
- data/test/lib/facets/core/string/test_first.rb +1 -1
- data/test/lib/facets/core/string/test_fold.rb +1 -1
- data/test/lib/facets/core/string/test_frequency.rb +1 -1
- data/test/lib/facets/core/string/test_humanize.rb +1 -1
- data/test/lib/facets/core/string/test_indent.rb +1 -1
- data/test/lib/facets/core/string/test_index_all.rb +1 -1
- data/test/lib/facets/core/string/test_last.rb +1 -1
- data/test/lib/facets/core/string/test_line_wrap.rb +1 -1
- data/test/lib/facets/core/string/test_lines.rb +1 -1
- data/test/lib/facets/core/string/test_lowercase.rb +1 -1
- data/test/lib/facets/core/string/test_margin.rb +1 -1
- data/test/lib/facets/core/string/test_methodize.rb +1 -1
- data/test/lib/facets/core/string/test_modulize.rb +1 -1
- data/test/lib/facets/core/string/test_mscan.rb +1 -1
- data/test/lib/facets/core/string/test_natcmp.rb +1 -1
- data/test/lib/facets/core/string/test_nchar.rb +1 -1
- data/test/lib/facets/core/string/test_pathize.rb +1 -1
- data/test/lib/facets/core/string/test_pop.rb +1 -1
- data/test/lib/facets/core/string/test_probability.rb +1 -1
- data/test/lib/facets/core/string/test_push.rb +1 -1
- data/test/lib/facets/core/string/test_quote.rb +1 -1
- data/test/lib/facets/core/string/test_rand_byte.rb +1 -1
- data/test/lib/facets/core/string/test_rand_index.rb +1 -1
- data/test/lib/facets/core/string/test_range.rb +1 -1
- data/test/lib/facets/core/string/test_range_all.rb +1 -1
- data/test/lib/facets/core/string/test_range_of_line.rb +1 -1
- data/test/lib/facets/core/string/test_regesc.rb +1 -1
- data/test/lib/facets/core/string/test_shatter.rb +1 -1
- data/test/lib/facets/core/string/test_shift.rb +1 -1
- data/test/lib/facets/core/string/test_shuffle.rb +1 -1
- data/test/lib/facets/core/string/test_similarity.rb +1 -1
- data/test/lib/facets/core/string/test_singular.rb +1 -1
- data/test/lib/facets/core/string/test_slap.rb +1 -1
- data/test/lib/facets/core/string/test_soundex.rb +1 -1
- data/test/lib/facets/core/string/test_succ.rb +1 -1
- data/test/lib/facets/core/string/test_to_a.rb +1 -1
- data/test/lib/facets/core/string/test_to_arr.rb +1 -1
- data/test/lib/facets/core/string/test_to_b.rb +1 -1
- data/test/lib/facets/core/string/test_to_const.rb +1 -1
- data/test/lib/facets/core/string/test_to_date.rb +1 -1
- data/test/lib/facets/core/string/test_to_proc.rb +1 -1
- data/test/lib/facets/core/string/test_to_re.rb +1 -1
- data/test/lib/facets/core/string/test_to_time.rb +1 -1
- data/test/lib/facets/core/string/test_unix_crypt.rb +1 -1
- data/test/lib/facets/core/string/test_unpack.rb +1 -1
- data/test/lib/facets/core/string/test_unshift.rb +1 -1
- data/test/lib/facets/core/string/test_upcase.rb +1 -1
- data/test/lib/facets/core/string/test_whitespace.rb +1 -1
- data/test/lib/facets/core/string/test_word_filter.rb +1 -1
- data/test/lib/facets/core/string/test_word_wrap.rb +1 -1
- data/test/lib/facets/core/string/test_words.rb +1 -1
- data/test/lib/facets/core/symbol/test_camelcase.rb +1 -1
- data/test/lib/facets/core/symbol/test_camelize.rb +1 -1
- data/test/lib/facets/core/symbol/test_capitalize.rb +1 -1
- data/test/lib/facets/core/symbol/test_capitalized.rb +1 -1
- data/test/lib/facets/core/symbol/test_downcase.rb +1 -1
- data/test/lib/facets/core/symbol/test_not.rb +1 -1
- data/test/lib/facets/core/symbol/test_pad.rb +1 -1
- data/test/lib/facets/core/symbol/test_succ.rb +1 -1
- data/test/lib/facets/core/symbol/test_to_const.rb +1 -1
- data/test/lib/facets/core/symbol/test_to_proc.rb +1 -1
- data/test/lib/facets/core/symbol/test_to_str.rb +1 -1
- data/test/lib/facets/core/symbol/test_underscore.rb +1 -1
- data/test/lib/facets/core/symbol/test_upcase.rb +1 -1
- data/test/lib/facets/core/time/test_change.rb +1 -1
- data/test/lib/facets/core/time/test_elapse.rb +1 -1
- data/test/lib/facets/core/time/test_stamp.rb +1 -1
- data/test/lib/facets/core/time/test_to_date.rb +1 -1
- data/test/lib/facets/core/time/test_to_s.rb +1 -1
- data/test/lib/facets/core/time/test_to_time.rb +1 -1
- data/test/lib/facets/more/test_annotation.rb +1 -1
- data/test/lib/facets/more/test_ansicode.rb +1 -1
- data/test/lib/facets/more/test_association.rb +1 -1
- data/test/lib/facets/more/test_basicobject.rb +58 -0
- data/test/lib/facets/more/test_bbcode.rb +1 -1
- data/test/lib/facets/more/test_bitmask.rb +1 -1
- data/test/lib/facets/more/test_bytes.rb +1 -1
- data/test/lib/facets/more/test_classinherit.rb +1 -1
- data/test/lib/facets/more/test_classmethods.rb +1 -1
- data/test/lib/facets/more/test_coroutine.rb +1 -1
- data/test/lib/facets/more/test_crypt.rb +1 -1
- data/test/lib/facets/more/test_dictionary.rb +1 -1
- data/test/lib/facets/more/test_elementor.rb +48 -0
- data/test/lib/facets/more/test_enumerablepass.rb +1 -1
- data/test/lib/facets/more/test_floatstring.rb +1 -1
- data/test/lib/facets/more/test_functor.rb +1 -1
- data/test/lib/facets/more/test_inheritor.rb +1 -1
- data/test/lib/facets/more/test_interval.rb +1 -1
- data/test/lib/facets/more/test_json.rb +232 -0
- data/test/lib/facets/more/test_lisp.rb +1 -1
- data/test/lib/facets/more/test_lisp_format.rb +1 -1
- data/test/lib/facets/more/test_lrucache.rb +1 -1
- data/test/lib/facets/more/test_mathconstants.rb +1 -1
- data/test/lib/facets/more/test_methodprobe.rb +1 -1
- data/test/lib/facets/more/test_multipliers.rb +1 -1
- data/test/lib/facets/more/test_multiton.rb +1 -1
- data/test/lib/facets/more/test_nackclass.rb +1 -1
- data/test/lib/facets/more/test_nilcomparable.rb +6 -2
- data/test/lib/facets/more/test_openobject.rb +1 -1
- data/test/lib/facets/more/test_overload.rb +1 -1
- data/test/lib/facets/more/test_paramix.rb +1 -1
- data/test/lib/facets/more/test_preinitialize.rb +1 -1
- data/test/lib/facets/more/test_promoteself.rb +1 -1
- data/test/lib/facets/more/test_recorder.rb +44 -0
- data/test/lib/facets/more/test_snapshot.rb +1 -1
- data/test/lib/facets/more/test_statichash.rb +1 -1
- data/test/lib/facets/more/test_syncarray.rb +1 -1
- data/test/lib/facets/more/test_synchash.rb +1 -1
- data/test/lib/facets/more/test_tagiterator.rb +1 -1
- data/test/lib/facets/more/test_timer.rb +1 -1
- data/test/lib/facets/more/test_times.rb +1 -1
- data/test/lib/facets/more/test_tuple.rb +1 -1
- data/test/lib/facets/more/test_typecast.rb +2 -2
- data/test/lib/facets/more/test_uninheritable.rb +1 -1
- data/test/lib/facets/more/test_units.rb +16 -10
- data/test/lib/facets/more/test_xoxo.rb +288 -0
- data/test/lib/facets/more/test_yamlstruct.rb +1 -1
- metadata +92 -25
- data/lib/facet/kernel/instance.rb +0 -1
- data/lib/facet/module/cattr.rb +0 -1
- data/lib/facet/module/cattr_accessor.rb +0 -1
- data/lib/facet/module/cattr_reader.rb +0 -1
- data/lib/facet/module/cattr_writer.rb +0 -1
- data/lib/facets/core/kernel/instance.rb +0 -29
- data/test/FIXTURE/create_file +0 -1
- data/test/FIXTURE/open_as_string_file +0 -1
- data/test/FIXTURE/read_list_file +0 -6
- data/test/lib/facets/core/dir/self/test_ls_r.rb +0 -52
- data/test/lib/facets/core/fileutils/test_wc.rb +0 -68
- data/test/lib/facets/core/fileutils/test_which.rb +0 -61
- data/test/testdir.rb +0 -8
@@ -0,0 +1,55 @@
|
|
1
|
+
|
2
|
+
require 'facets/more/functor'
|
3
|
+
|
4
|
+
# class X
|
5
|
+
#
|
6
|
+
# let.x = 10
|
7
|
+
# let.x = "Hello"
|
8
|
+
#
|
9
|
+
# end
|
10
|
+
|
11
|
+
class Module
|
12
|
+
|
13
|
+
def let
|
14
|
+
klass = self
|
15
|
+
Functor.new do |op, *args|
|
16
|
+
case op.to_s[-1,1]
|
17
|
+
when '='
|
18
|
+
op = op.to_s.chomp('=')
|
19
|
+
define_method( op ) do
|
20
|
+
r = instance_variable_set( "@#{op}", args[0] )
|
21
|
+
klass.class.class_eval %{
|
22
|
+
def #{op}; @#{op}; end
|
23
|
+
}
|
24
|
+
r
|
25
|
+
end
|
26
|
+
else
|
27
|
+
klass.class_eval %{
|
28
|
+
def #{op}; @#{op}; end
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
=begin test
|
38
|
+
|
39
|
+
require 'test/unit'
|
40
|
+
|
41
|
+
class TCthis < Test::Unit::TestCase
|
42
|
+
|
43
|
+
class Foo
|
44
|
+
let.bar = 10
|
45
|
+
end
|
46
|
+
|
47
|
+
def test01
|
48
|
+
x = Foo.new
|
49
|
+
assert_equal( 10, x.bar )
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
=end
|
55
|
+
|
@@ -0,0 +1,180 @@
|
|
1
|
+
|
2
|
+
class Module
|
3
|
+
|
4
|
+
# Creates a class instance variable attribute that can
|
5
|
+
# be accessed both on an instance and class level.
|
6
|
+
|
7
|
+
def mattr( *syms )
|
8
|
+
writer = false
|
9
|
+
syms.reject! do |s|
|
10
|
+
case s
|
11
|
+
when TrueClass
|
12
|
+
writer = true
|
13
|
+
when FalseClass, NilClass
|
14
|
+
true
|
15
|
+
else
|
16
|
+
false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
if writer
|
20
|
+
mattr_accessor( *syms )
|
21
|
+
else
|
22
|
+
mattr_reader( *syms )
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Creates a class instance variable attr_reader
|
27
|
+
# accessable both on an instance and class level.
|
28
|
+
#
|
29
|
+
# class MyClass
|
30
|
+
# mattr_reader :a
|
31
|
+
# def self.set ; @a = 10 ; end
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# MyClass.set
|
35
|
+
# MyClass.a #=> 10
|
36
|
+
# mc = MyClass
|
37
|
+
# mc.a #=> 10
|
38
|
+
#
|
39
|
+
def mattr_reader( *syms )
|
40
|
+
hsyms = ( syms.last.is_a?(Hash) ? syms.pop : {} )
|
41
|
+
hsyms.update( Hash[*(syms.zip([nil]*syms.size).flatten)] )
|
42
|
+
hsyms.each_pair do |sym, val|
|
43
|
+
class_eval <<-EOS
|
44
|
+
if ! defined? @#{sym}
|
45
|
+
@#{sym} = val
|
46
|
+
end
|
47
|
+
def self.#{sym}
|
48
|
+
@#{sym}
|
49
|
+
end
|
50
|
+
def #{sym}
|
51
|
+
self.class.#{sym}
|
52
|
+
end
|
53
|
+
EOS
|
54
|
+
end
|
55
|
+
return hsyms.keys
|
56
|
+
end
|
57
|
+
|
58
|
+
# Creates a class instance variable attr_writer
|
59
|
+
# accessable both on an instance and class level.
|
60
|
+
#
|
61
|
+
# class MyClass
|
62
|
+
# mattr_writer :a
|
63
|
+
# def self.show ; @a ; end
|
64
|
+
# end
|
65
|
+
#
|
66
|
+
# MyClass.a = 10
|
67
|
+
# MyClass.show #=> 10
|
68
|
+
# m = MyClass.new
|
69
|
+
# m.a = 29
|
70
|
+
# MyClass.show #=> 29
|
71
|
+
#
|
72
|
+
def mattr_writer(*syms)
|
73
|
+
hsyms = ( syms.last.is_a?(Hash) ? syms.pop : {} )
|
74
|
+
hsyms.update( Hash[*(syms.zip([nil]*syms.size).flatten)] )
|
75
|
+
hsyms.each_pair do |sym, val|
|
76
|
+
class_eval <<-EOS
|
77
|
+
if ! defined? @#{sym}
|
78
|
+
@#{sym} = val
|
79
|
+
end
|
80
|
+
def self.#{sym}=(obj)
|
81
|
+
@#{sym} = obj
|
82
|
+
end
|
83
|
+
def #{sym}=(obj)
|
84
|
+
self.class.#{sym}=(obj)
|
85
|
+
end
|
86
|
+
EOS
|
87
|
+
end
|
88
|
+
return hsyms.keys
|
89
|
+
end
|
90
|
+
|
91
|
+
# Creates a class instance variable attr_accessor
|
92
|
+
# accessable both on an instance and class level.
|
93
|
+
#
|
94
|
+
# class MyClass
|
95
|
+
# mattr_accessor :a
|
96
|
+
# end
|
97
|
+
#
|
98
|
+
# MyClass.a = 10
|
99
|
+
# MyClass.a #=> 10
|
100
|
+
# mc = MyClass.new
|
101
|
+
# mc.a #=> 10
|
102
|
+
# mc.a = 20
|
103
|
+
# mc.a #=> 20
|
104
|
+
# MyClass.a #=> 20
|
105
|
+
#
|
106
|
+
def mattr_accessor(*syms)
|
107
|
+
m = []
|
108
|
+
m.concat( mattr_reader(*syms) )
|
109
|
+
m.concat( mattr_writer(*syms) )
|
110
|
+
m
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
# _____ _
|
118
|
+
# |_ _|__ ___| |_
|
119
|
+
# | |/ _ \/ __| __|
|
120
|
+
# | | __/\__ \ |_
|
121
|
+
# |_|\___||___/\__|
|
122
|
+
#
|
123
|
+
=begin test
|
124
|
+
|
125
|
+
require 'test/unit'
|
126
|
+
|
127
|
+
class TCModule < Test::Unit::TestCase
|
128
|
+
|
129
|
+
class M
|
130
|
+
def self.setup
|
131
|
+
@a = 10
|
132
|
+
end
|
133
|
+
# for testing writer
|
134
|
+
def b
|
135
|
+
self.class.instance_eval { @b }
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def setup
|
140
|
+
M.setup
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_mattr
|
144
|
+
assert_nothing_raised {
|
145
|
+
M.class_eval { mattr :a }
|
146
|
+
}
|
147
|
+
t = M.new
|
148
|
+
assert_equal( 10, M.a )
|
149
|
+
assert_equal( 10, t.a )
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_mattr_reader
|
153
|
+
assert_nothing_raised {
|
154
|
+
M.class_eval { mattr_reader :a }
|
155
|
+
}
|
156
|
+
t = M.new
|
157
|
+
assert_equal( 10, t.a )
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_mattr_writer
|
161
|
+
assert_nothing_raised {
|
162
|
+
M.class_eval { mattr_writer :b }
|
163
|
+
}
|
164
|
+
t = M.new
|
165
|
+
t.b = 5
|
166
|
+
assert_equal( 5, t.b )
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_mattr_accessor
|
170
|
+
assert_nothing_raised {
|
171
|
+
M.class_eval { mattr_accessor :c }
|
172
|
+
}
|
173
|
+
t = M.new
|
174
|
+
t.c = 50
|
175
|
+
assert_equal( 50, t.c )
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
=end
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
class Module
|
3
|
+
|
4
|
+
# Creates a new module by copying the methods of the class.
|
5
|
+
|
6
|
+
#--
|
7
|
+
# This is unfortuate. Class#to_module would be mcuh better,
|
8
|
+
# but doesn't look easily possible. Sigh.
|
9
|
+
#++
|
10
|
+
|
11
|
+
def singleton_to_module #( include_ancestors=false )
|
12
|
+
new_module = Module.new
|
13
|
+
klass = self
|
14
|
+
meths = singleton_methods(true) #-= ['included']
|
15
|
+
meths.each do |m|
|
16
|
+
new_module.class_eval do
|
17
|
+
define_method(m, &(klass.method(m)))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
new_module
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/lib/facets/core/nilclass.rb
CHANGED
@@ -2,6 +2,8 @@ require 'facets/core/nilclass/blank'
|
|
2
2
|
require 'facets/core/nilclass/empty'
|
3
3
|
require 'facets/core/nilclass/include'
|
4
4
|
require 'facets/core/nilclass/length'
|
5
|
+
require 'facets/core/nilclass/op_cmp'
|
5
6
|
require 'facets/core/nilclass/op_fetch'
|
6
7
|
require 'facets/core/nilclass/size'
|
8
|
+
require 'facets/core/nilclass/succ'
|
7
9
|
require 'facets/core/nilclass/to_h'
|
@@ -4,16 +4,17 @@ class String
|
|
4
4
|
# Converts a string into a valid ruby method name
|
5
5
|
# This method is geared toward code reflection.
|
6
6
|
#
|
7
|
-
# See : String#modulize, String#pathize
|
8
7
|
#
|
9
8
|
# "MyModule::MyClass".methodize #=> "my_module__my_class"
|
10
9
|
#
|
11
|
-
#
|
10
|
+
# See also String#modulize, String#pathize
|
11
|
+
#
|
12
|
+
# == TODO
|
12
13
|
#
|
13
14
|
# * Make sure that all scenarios return a valid ruby class name
|
14
15
|
# * Make sure it is revertible
|
15
16
|
#
|
16
|
-
|
17
|
+
|
17
18
|
def methodize
|
18
19
|
to_s.gsub(/([A-Z])/, '_\1').downcase.gsub(/^_/,'').gsub(/(::|\/)_?/, '__')
|
19
20
|
end
|
@@ -4,11 +4,11 @@ class String
|
|
4
4
|
# Converts a string into a valid ruby class or module name
|
5
5
|
# This method is geared toward code reflection.
|
6
6
|
#
|
7
|
-
# See : String#methodize, String#pathize
|
8
|
-
#
|
9
7
|
# "my_module__my_path".modulize #=> "MyModule::MyPath"
|
10
8
|
#
|
11
|
-
#
|
9
|
+
# See also String#methodize, String#pathize
|
10
|
+
#
|
11
|
+
# TODO
|
12
12
|
#
|
13
13
|
# * Make sure that all scenarios return a valid ruby class name
|
14
14
|
# * Make sure it is revertible
|
data/lib/facets/more/ansicode.rb
CHANGED
data/lib/facets/more/aspects.rb
CHANGED
@@ -16,17 +16,20 @@
|
|
16
16
|
# ==========================================================================
|
17
17
|
# Revision History
|
18
18
|
# ==========================================================================
|
19
|
+
# 2006.04.03
|
20
|
+
# * added #instance method.
|
21
|
+
#
|
19
22
|
# 2005.10.26
|
20
23
|
# * preserved a few addtional methods --everyhting ending in ?, dup and
|
21
24
|
# object_id.
|
22
25
|
# * changed name from BlankSlate to BasicObject
|
23
26
|
#
|
24
27
|
# 2005.04.28 trans
|
25
|
-
# * ported
|
28
|
+
# * ported from BlankSlate and added __class__
|
26
29
|
# ==========================================================================
|
27
30
|
#
|
28
|
-
# TODO
|
29
|
-
# were excluded.
|
31
|
+
# TODO Might be nice it there were a factory method to alter which methods
|
32
|
+
# were excluded. But probably too dangerous.
|
30
33
|
#
|
31
34
|
#++
|
32
35
|
|
@@ -48,10 +51,22 @@ require 'facets/core/kernel/__class__'
|
|
48
51
|
#
|
49
52
|
# By default these are the reserved methods:
|
50
53
|
#
|
51
|
-
# __id__ __class__ __send__ dup eql? equal? frozen? inspect instance_eval
|
54
|
+
# __id__ __class__ __self__ __send__ dup eql? equal? frozen? inspect instance_eval
|
52
55
|
# instance_of? instance_variable_get instance_variable_set instance_variables
|
53
56
|
# is_a? kind_of? nil? null object_id respond_to? tainted?
|
54
57
|
#
|
58
|
+
# The special method #__self__ allows access to the underlying object via a
|
59
|
+
# specialized Functor-style class called, BasicObject::Self. This binds the
|
60
|
+
# actual self to the subsequently called methods of Object instancea methods.
|
61
|
+
# So even though a method may no longer be defined for BasicObject it can still
|
62
|
+
# be called via this interface.
|
63
|
+
#
|
64
|
+
# class A < BasicObject
|
65
|
+
# end
|
66
|
+
#
|
67
|
+
# a.__self__.class #=> A
|
68
|
+
# a.class #=> NoMethodError
|
69
|
+
#
|
55
70
|
|
56
71
|
class BasicObject
|
57
72
|
|
@@ -67,6 +82,16 @@ class BasicObject
|
|
67
82
|
|
68
83
|
instance_methods.each { |m| hide(m) }
|
69
84
|
|
85
|
+
class Self < self
|
86
|
+
define_method( :method_missing ) do |meth, *args| # &blk|
|
87
|
+
Object.instance_method(meth).bind(self).call(*args) # ,&blk)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def __self__
|
92
|
+
@__self__ ||= Self.new
|
93
|
+
end
|
94
|
+
|
70
95
|
end
|
71
96
|
|
72
97
|
# Since Ruby is very dynamic, methods added to the ancestors of
|
@@ -76,26 +101,26 @@ end
|
|
76
101
|
|
77
102
|
module Kernel
|
78
103
|
class << self
|
79
|
-
|
80
|
-
#def method_added(name)
|
81
|
-
# return if name == :blank_slate_method_added
|
82
|
-
# blank_slate_method_added(name)
|
83
|
-
madded = instance_method(:method_added)
|
104
|
+
madded = method(:method_added)
|
84
105
|
define_method(:method_added) do |name|
|
85
|
-
|
106
|
+
#return if name == :kernel_method_added
|
107
|
+
r = madded.call(name)
|
86
108
|
return if self != Kernel
|
87
109
|
BasicObject.hide(name)
|
110
|
+
r
|
88
111
|
end
|
89
112
|
end
|
90
113
|
end
|
91
114
|
|
92
115
|
class Object
|
93
116
|
class << self
|
94
|
-
madded =
|
117
|
+
madded = method(:method_added)
|
95
118
|
define_method(:method_added) do |name|
|
96
|
-
|
119
|
+
#return if name == :object_method_added
|
120
|
+
r = madded.call(name)
|
97
121
|
return if self != Object
|
98
122
|
BasicObject.hide(name)
|
123
|
+
r
|
99
124
|
end
|
100
125
|
end
|
101
126
|
end
|
@@ -108,26 +133,46 @@ end
|
|
108
133
|
# |_|\___||___/\__|
|
109
134
|
#
|
110
135
|
|
111
|
-
|
112
|
-
|
113
|
-
=begin #test
|
136
|
+
=begin test
|
114
137
|
|
115
138
|
require 'test/unit'
|
116
139
|
|
117
|
-
class
|
140
|
+
class TCBasicObject < Test::Unit::TestCase
|
141
|
+
|
142
|
+
class A < BasicObject
|
143
|
+
end
|
118
144
|
|
119
|
-
|
120
|
-
|
145
|
+
def setup
|
146
|
+
@a = A.new
|
121
147
|
end
|
122
148
|
|
123
149
|
def test_001
|
124
|
-
|
150
|
+
assert(
|
151
|
+
@a.__class__.instance_methods.all? do |m|
|
152
|
+
m =~ BasicObject::EXCLUDE or m == 'instance'
|
153
|
+
end
|
154
|
+
)
|
125
155
|
end
|
126
156
|
|
127
157
|
def test_002
|
128
|
-
Kernel.
|
129
|
-
|
130
|
-
|
158
|
+
Kernel.module_eval { def xxx ; end }
|
159
|
+
assert( ! @a.__class__.method_defined?( :xxx ) )
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_003
|
163
|
+
Object.class_eval { def yyy ; end }
|
164
|
+
assert( ! @a.__class__.method_defined?( :yyy ) )
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_004
|
168
|
+
Object.class_eval { def yyy ; end }
|
169
|
+
assert( ! @a.__self__.methods.include?( 'yyy' ) )
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_005
|
173
|
+
assert( @a.__self__.methods.include?( '__id__' ) )
|
174
|
+
assert( @a.__self__.methods.include?( '__send__' ) )
|
175
|
+
assert( @a.__self__.methods.include?( '__class__' ) )
|
131
176
|
end
|
132
177
|
|
133
178
|
end
|