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
@@ -25,18 +25,21 @@ end
|
|
25
25
|
|
26
26
|
require 'test/unit'
|
27
27
|
|
28
|
-
#
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
# mock behavior for file access
|
29
|
+
|
30
|
+
class File
|
31
|
+
def self.mock_read( content )
|
32
|
+
@content = content
|
33
|
+
end
|
34
|
+
def self.read( fpath )
|
35
|
+
@content
|
36
|
+
end
|
33
37
|
end
|
34
|
-
raise unless $TESTDIR
|
35
38
|
|
36
39
|
class TC_READ_LIST < Test::Unit::TestCase
|
37
40
|
|
38
41
|
def test_read_list
|
39
|
-
f = File.
|
42
|
+
f = File.mock_read("A\nB\nC")
|
40
43
|
s = File.read_list( f )
|
41
44
|
r = ['A','B','C']
|
42
45
|
assert_equal( r, s )
|
@@ -45,3 +48,4 @@ end
|
|
45
48
|
end
|
46
49
|
|
47
50
|
=end
|
51
|
+
|
@@ -71,17 +71,12 @@ end
|
|
71
71
|
# | | __/\__ \ |_
|
72
72
|
# |_|\___||___/\__|
|
73
73
|
#
|
74
|
-
=begin test
|
75
74
|
|
76
|
-
|
75
|
+
# TODO This test needs a Mock File.
|
77
76
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
f = (paths.slice(0..i)+['test']).join('/')
|
82
|
-
$TESTDIR = File.join(f,'FIXTURE') if File.directory?(f)
|
83
|
-
end
|
84
|
-
raise unless $TESTDIR
|
77
|
+
=begin #no test yet
|
78
|
+
|
79
|
+
require 'test/unit'
|
85
80
|
|
86
81
|
class TC_FileUtils_WC < Test::Unit::TestCase
|
87
82
|
|
@@ -67,19 +67,14 @@ end
|
|
67
67
|
# | | __/\__ \ |_
|
68
68
|
# |_|\___||___/\__|
|
69
69
|
#
|
70
|
-
|
70
|
+
|
71
|
+
# TODO This test needs a mock File.
|
72
|
+
|
73
|
+
=begin #no test yet
|
71
74
|
|
72
75
|
require 'test/unit'
|
73
76
|
require 'rbconfig'
|
74
77
|
|
75
|
-
# FIND TEST DIRECTORY
|
76
|
-
paths = File.expand_path(File.dirname(__FILE__)).split('/')
|
77
|
-
paths.size.downto(1) do |i|
|
78
|
-
f = (paths.slice(0..i)+['test']).join('/')
|
79
|
-
$TESTDIR = File.join(f,'FIXTURE') if File.directory?(f)
|
80
|
-
end
|
81
|
-
raise unless $TESTDIR
|
82
|
-
|
83
78
|
class TC_FileUtils_Which < Test::Unit::TestCase
|
84
79
|
include Config
|
85
80
|
|
data/lib/facets/core/kernel.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'facets/core/kernel/__DIR__'
|
2
2
|
require 'facets/core/kernel/__class__'
|
3
|
+
require 'facets/core/kernel/__self__'
|
3
4
|
require 'facets/core/kernel/adhoc'
|
4
5
|
require 'facets/core/kernel/as'
|
5
6
|
require 'facets/core/kernel/assign_from'
|
@@ -23,7 +24,6 @@ require 'facets/core/kernel/generate_method_name'
|
|
23
24
|
require 'facets/core/kernel/get_by_id'
|
24
25
|
require 'facets/core/kernel/here'
|
25
26
|
require 'facets/core/kernel/in'
|
26
|
-
require 'facets/core/kernel/instance'
|
27
27
|
require 'facets/core/kernel/instance_assign'
|
28
28
|
require 'facets/core/kernel/instvar'
|
29
29
|
require 'facets/core/kernel/is'
|
@@ -32,6 +32,7 @@ require 'facets/core/kernel/me'
|
|
32
32
|
require 'facets/core/kernel/metaclass'
|
33
33
|
require 'facets/core/kernel/method'
|
34
34
|
require 'facets/core/kernel/method_name'
|
35
|
+
require 'facets/core/kernel/methodname'
|
35
36
|
require 'facets/core/kernel/methods'
|
36
37
|
require 'facets/core/kernel/nack'
|
37
38
|
require 'facets/core/kernel/new'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
require 'facets/more/functor.rb'
|
3
|
+
|
4
|
+
module Kernel #class Object
|
5
|
+
|
6
|
+
# Returns a Functor that allows one to call any
|
7
|
+
# Kernel or Object method bound to self, making it
|
8
|
+
# possible to bypass overrides of Kernel and Object
|
9
|
+
# methods.
|
10
|
+
#
|
11
|
+
# class A
|
12
|
+
# def object_id ; "OBTUSE" ; end
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# c = C.new
|
16
|
+
# c.object_id #=> "OBTUSE"
|
17
|
+
# c.__self__.object_id #=> 6664875832
|
18
|
+
#
|
19
|
+
#--
|
20
|
+
# Might this be better named as 'object' or '__object__'?
|
21
|
+
# Should this method actually be private?
|
22
|
+
#++
|
23
|
+
|
24
|
+
def __self__
|
25
|
+
@__self__ ||= Functor.new do |meth, *args| # &blk|
|
26
|
+
Object.instance_method(meth).bind(self).call(*args) # ,&blk)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
#alias_method :self, :__self__
|
31
|
+
|
32
|
+
end
|
@@ -26,8 +26,7 @@ class Object
|
|
26
26
|
#
|
27
27
|
def assign_from(obj, *fields)
|
28
28
|
force = false
|
29
|
-
case fields.last
|
30
|
-
when true, false, nil
|
29
|
+
case fields.last when true, false, nil
|
31
30
|
force = fields.pop
|
32
31
|
end
|
33
32
|
|
@@ -49,7 +48,8 @@ class Object
|
|
49
48
|
instance_variable_set( var, obj.instance_variable_get(var) )
|
50
49
|
end
|
51
50
|
end
|
52
|
-
|
51
|
+
|
52
|
+
return self
|
53
53
|
end
|
54
54
|
|
55
55
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
module Kernel
|
2
3
|
|
3
4
|
private
|
@@ -5,9 +6,9 @@ module Kernel
|
|
5
6
|
# Retreive the current running method name.
|
6
7
|
#
|
7
8
|
# There is a lot of debate on what to call this.
|
8
|
-
# #
|
9
|
+
# #me returns a symbol, not a string.
|
9
10
|
#
|
10
|
-
# def tester;
|
11
|
+
# def tester; me; end
|
11
12
|
# tester #=> :tester
|
12
13
|
#
|
13
14
|
def me
|
@@ -1,49 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
private
|
5
|
-
|
6
|
-
# Retreive the current running method.
|
7
|
-
# There is a lot of debate on what to call this.
|
8
|
-
# #method_name differs from #called only by the fact
|
9
|
-
# that it returns a string, rather then a symbol.
|
10
|
-
#
|
11
|
-
# def tester; method_name; end
|
12
|
-
# tester #=> "tester"
|
13
|
-
#
|
14
|
-
def methodname
|
15
|
-
name = /\`([^\']+)\'/.match(caller(1).first)[1]
|
16
|
-
return name
|
17
|
-
end
|
18
|
-
|
19
|
-
# depricate?
|
20
|
-
alias_method :method_name, :methodname
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
# _____ _
|
27
|
-
# |_ _|__ ___| |_
|
28
|
-
# | |/ _ \/ __| __|
|
29
|
-
# | | __/\__ \ |_
|
30
|
-
# |_|\___||___/\__|
|
31
|
-
#
|
32
|
-
=begin test
|
33
|
-
|
34
|
-
require 'test/unit'
|
35
|
-
|
36
|
-
class TCKernel < Test::Unit::TestCase
|
37
|
-
|
38
|
-
def test_method_name
|
39
|
-
# For some reason this was returning a string
|
40
|
-
# even when aliased to #called. Why?
|
41
|
-
# Well, I couldn't seem to fix it, so I just
|
42
|
-
# accepted it as fact and made +method_name+
|
43
|
-
# purposefully work that way.
|
44
|
-
assert_equal( "test_method_name", method_name )
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
=end
|
1
|
+
# stub
|
2
|
+
require 'facets/core/kernel/methodname.rb'
|
@@ -0,0 +1,49 @@
|
|
1
|
+
|
2
|
+
module Kernel
|
3
|
+
|
4
|
+
private
|
5
|
+
|
6
|
+
# Retreive the current running method.
|
7
|
+
# There is a lot of debate on what to call this.
|
8
|
+
# #method_name differs from #called only by the fact
|
9
|
+
# that it returns a string, rather then a symbol.
|
10
|
+
#
|
11
|
+
# def tester; method_name; end
|
12
|
+
# tester #=> "tester"
|
13
|
+
#
|
14
|
+
def methodname
|
15
|
+
name = /\`([^\']+)\'/.match(caller(1).first)[1]
|
16
|
+
return name
|
17
|
+
end
|
18
|
+
|
19
|
+
# depricate?
|
20
|
+
alias_method :method_name, :methodname
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
# _____ _
|
27
|
+
# |_ _|__ ___| |_
|
28
|
+
# | |/ _ \/ __| __|
|
29
|
+
# | | __/\__ \ |_
|
30
|
+
# |_|\___||___/\__|
|
31
|
+
#
|
32
|
+
=begin test
|
33
|
+
|
34
|
+
require 'test/unit'
|
35
|
+
|
36
|
+
class TCKernel < Test::Unit::TestCase
|
37
|
+
|
38
|
+
def test_method_name
|
39
|
+
# For some reason this was returning a string
|
40
|
+
# even when aliased to #called. Why?
|
41
|
+
# Well, I couldn't seem to fix it, so I just
|
42
|
+
# accepted it as fact and made +method_name+
|
43
|
+
# purposefully work that way.
|
44
|
+
assert_equal( "test_method_name", method_name )
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
=end
|
data/lib/facets/core/module.rb
CHANGED
@@ -2,14 +2,12 @@ require 'facets/core/module/abstract'
|
|
2
2
|
require 'facets/core/module/alias_module_function'
|
3
3
|
require 'facets/core/module/ancestor'
|
4
4
|
require 'facets/core/module/attr'
|
5
|
+
require 'facets/core/module/attr_query'
|
5
6
|
require 'facets/core/module/attr_setter'
|
6
7
|
require 'facets/core/module/attr_tester'
|
8
|
+
require 'facets/core/module/attr_validator'
|
7
9
|
require 'facets/core/module/basename'
|
8
10
|
require 'facets/core/module/by_name'
|
9
|
-
require 'facets/core/module/cattr'
|
10
|
-
require 'facets/core/module/cattr_accessor'
|
11
|
-
require 'facets/core/module/cattr_reader'
|
12
|
-
require 'facets/core/module/cattr_writer'
|
13
11
|
require 'facets/core/module/clone_removing'
|
14
12
|
require 'facets/core/module/clone_renaming'
|
15
13
|
require 'facets/core/module/clone_using'
|
@@ -17,10 +15,16 @@ require 'facets/core/module/dirname'
|
|
17
15
|
require 'facets/core/module/equate_on'
|
18
16
|
require 'facets/core/module/generate_instance_method_name'
|
19
17
|
require 'facets/core/module/include_as'
|
18
|
+
require 'facets/core/module/inherit'
|
20
19
|
require 'facets/core/module/initializer'
|
21
20
|
require 'facets/core/module/instance_methods'
|
22
21
|
require 'facets/core/module/integrate'
|
23
22
|
require 'facets/core/module/is'
|
23
|
+
require 'facets/core/module/let'
|
24
|
+
require 'facets/core/module/mattr'
|
25
|
+
require 'facets/core/module/mattr_accessor'
|
26
|
+
require 'facets/core/module/mattr_reader'
|
27
|
+
require 'facets/core/module/mattr_writer'
|
24
28
|
require 'facets/core/module/memoize'
|
25
29
|
require 'facets/core/module/modspace'
|
26
30
|
require 'facets/core/module/namespace'
|
@@ -36,6 +40,7 @@ require 'facets/core/module/rename_method'
|
|
36
40
|
require 'facets/core/module/revisal'
|
37
41
|
require 'facets/core/module/shadow_all'
|
38
42
|
require 'facets/core/module/shadow_method'
|
43
|
+
require 'facets/core/module/singleton_to_module'
|
39
44
|
require 'facets/core/module/sort_on'
|
40
45
|
require 'facets/core/module/undef'
|
41
46
|
require 'facets/core/module/wrap'
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'facet/kernel/nack'
|
2
|
+
|
3
|
+
class Module
|
4
|
+
|
5
|
+
# Create an tester attribute. This creates two methods for
|
6
|
+
# each given variable name. One is used to test
|
7
|
+
# the attribute and the other is used to set or toggle it.
|
8
|
+
#
|
9
|
+
# attr_switch :a
|
10
|
+
#
|
11
|
+
# is equivalent to
|
12
|
+
#
|
13
|
+
# def a?
|
14
|
+
# @a ? true : @a
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# def a!(switch=nack)
|
18
|
+
# if switch == nack
|
19
|
+
# @a = ! @a
|
20
|
+
# else
|
21
|
+
# @a = @a ? switch : @a
|
22
|
+
# self
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
def attr_tester(*args)
|
27
|
+
make = {}
|
28
|
+
args.each { |a|
|
29
|
+
make["#{a}?".to_sym] = %{ def #{a}?; @#{a} ? true : @#{a}; end }
|
30
|
+
make["#{a}!".to_sym] = %{
|
31
|
+
def #{a}!(switch=nack)
|
32
|
+
if switch==nack
|
33
|
+
@#{a} = !@#{a}
|
34
|
+
else
|
35
|
+
@#{a} = @#{a} ? switch : @#{a}
|
36
|
+
self
|
37
|
+
end
|
38
|
+
end
|
39
|
+
}
|
40
|
+
}
|
41
|
+
module_eval make.values.join("\n")
|
42
|
+
|
43
|
+
return make.keys
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
# _____ _
|
51
|
+
# |_ _|__ ___| |_
|
52
|
+
# | |/ _ \/ __| __|
|
53
|
+
# | | __/\__ \ |_
|
54
|
+
# |_|\___||___/\__|
|
55
|
+
#
|
56
|
+
# TODO
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
class Module
|
3
|
+
|
4
|
+
# Like attr_writer, but the writer method validates the
|
5
|
+
# setting against the given block.
|
6
|
+
|
7
|
+
def attr_validator(*symbols, &validator)
|
8
|
+
symbols.each do |symbol|
|
9
|
+
define_method "#{symbol}=" do |val|
|
10
|
+
unless validator.call(val)
|
11
|
+
raise ArgumentError, "Invalid value provided for #{symbol}"
|
12
|
+
end
|
13
|
+
instance_variable_set("@#{symbol}", val)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'facets/core/module/singleton_to_module'
|
4
|
+
|
5
|
+
class Module
|
6
|
+
|
7
|
+
def inherit( mod )
|
8
|
+
smod = mod.singleton_to_module
|
9
|
+
#smethods -= ['included'] if Class === self
|
10
|
+
extend smod
|
11
|
+
include mod
|
12
|
+
nil
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
# _____ _
|
20
|
+
# |_ _|__ ___| |_
|
21
|
+
# | |/ _ \/ __| __|
|
22
|
+
# | | __/\__ \ |_
|
23
|
+
# |_|\___||___/\__|
|
24
|
+
#
|
25
|
+
|
26
|
+
=begin test
|
27
|
+
|
28
|
+
require 'test/unit'
|
29
|
+
|
30
|
+
class TCinherit < Test::Unit::TestCase
|
31
|
+
|
32
|
+
module Foo
|
33
|
+
def self.x ; 10 ; end
|
34
|
+
def y ; 20 ; end
|
35
|
+
end
|
36
|
+
|
37
|
+
module Bar
|
38
|
+
inherit Foo
|
39
|
+
end
|
40
|
+
|
41
|
+
class X
|
42
|
+
inherit Bar
|
43
|
+
end
|
44
|
+
|
45
|
+
# test
|
46
|
+
|
47
|
+
def test_001
|
48
|
+
assert_equal( 10, X.x )
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_002
|
52
|
+
x = X.new
|
53
|
+
assert_equal( 20, x.y )
|
54
|
+
end
|
55
|
+
|
56
|
+
# These won't work; this solution in non-dynamic.
|
57
|
+
|
58
|
+
#def test_004
|
59
|
+
# def Foo.g ; 30 ; end
|
60
|
+
# assert_equal( 30, Bar.g )
|
61
|
+
#end
|
62
|
+
|
63
|
+
#def test_005
|
64
|
+
# #def Foo.g ; 30 ; end
|
65
|
+
# assert_equal( 30, X.g )
|
66
|
+
#end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
=end
|