facets 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +5 -2
- data/ProjectInfo +21 -12
- data/README +73 -44
- data/Rakefile +11 -11
- data/data/facets/index.yml +1 -0
- data/lib/facet/annotation.rb +1 -0
- data/lib/facet/ansicode.rb +1 -0
- data/lib/facet/array.rb +1 -34
- data/lib/facet/array/at_rand.rb +1 -52
- data/lib/facet/array/body.rb +1 -2
- data/lib/facet/array/delete_unless.rb +1 -35
- data/lib/facet/array/delete_values.rb +1 -38
- data/lib/facet/array/delete_values_at.rb +1 -57
- data/lib/facet/array/each_with_key.rb +1 -9
- data/lib/facet/array/first.rb +1 -84
- data/lib/facet/array/foot.rb +1 -2
- data/lib/facet/array/head.rb +1 -80
- data/lib/facet/array/last.rb +1 -2
- data/lib/facet/array/last_index.rb +1 -35
- data/lib/facet/array/merge.rb +1 -40
- data/lib/facet/array/mid.rb +1 -50
- data/lib/facet/array/middle.rb +1 -45
- data/lib/facet/array/op_fetch.rb +1 -40
- data/lib/facet/array/op_mod.rb +1 -16
- data/lib/facet/array/op_store.rb +1 -47
- data/lib/facet/array/pick.rb +1 -68
- data/lib/facet/array/pos.rb +1 -39
- data/lib/facet/array/pull.rb +1 -37
- data/lib/facet/array/rand_index.rb +1 -30
- data/lib/facet/array/rand_subset.rb +1 -56
- data/lib/facet/array/range.rb +1 -47
- data/lib/facet/array/rotate.rb +1 -67
- data/lib/facet/array/select.rb +1 -37
- data/lib/facet/array/shuffle.rb +1 -66
- data/lib/facet/array/slap.rb +1 -37
- data/lib/facet/array/store.rb +1 -7
- data/lib/facet/array/tail.rb +1 -2
- data/lib/facet/array/thru.rb +1 -38
- data/lib/facet/array/to_b.rb +1 -31
- data/lib/facet/array/to_h.rb +1 -57
- data/lib/facet/array/to_hash.rb +1 -46
- data/lib/facet/array/unzip.rb +1 -20
- data/lib/facet/association.rb +1 -0
- data/lib/facet/basicobject.rb +1 -0
- data/lib/facet/bbcode.rb +1 -0
- data/lib/facet/binaryreader.rb +1 -0
- data/lib/facet/binding.rb +1 -14
- data/lib/facet/binding/__DIR__.rb +1 -2
- data/lib/facet/binding/__FILE__.rb +1 -2
- data/lib/facet/binding/__LINE__.rb +1 -58
- data/lib/facet/binding/call_stack.rb +1 -42
- data/lib/facet/binding/called.rb +1 -41
- data/lib/facet/binding/caller.rb +1 -42
- data/lib/facet/binding/defined.rb +1 -41
- data/lib/facet/binding/eval.rb +1 -42
- data/lib/facet/binding/local_variables.rb +1 -45
- data/lib/facet/binding/method_name.rb +1 -48
- data/lib/facet/binding/op_fetch.rb +1 -45
- data/lib/facet/binding/op_store.rb +1 -46
- data/lib/facet/binding/self.rb +1 -41
- data/lib/facet/binding/self/of_caller.rb +1 -122
- data/lib/facet/bitmask.rb +1 -0
- data/lib/facet/blankslate.rb +1 -0
- data/lib/facet/bytes.rb +1 -0
- data/lib/facet/class.rb +1 -7
- data/lib/facet/class/by_name.rb +1 -1
- data/lib/facet/class/descendents.rb +1 -44
- data/lib/facet/class/method_name.rb +1 -33
- data/lib/facet/class/remove_descendents.rb +1 -46
- data/lib/facet/class/remove_subclasses.rb +1 -2
- data/lib/facet/class/subclasses.rb +1 -2
- data/lib/facet/class/unix_path.rb +1 -34
- data/lib/facet/classinherit.rb +1 -0
- data/lib/facet/classmethods.rb +1 -0
- data/lib/facet/cloneable.rb +1 -0
- data/lib/facet/comparable.rb +1 -5
- data/lib/facet/comparable/at_least.rb +1 -53
- data/lib/facet/comparable/at_most.rb +1 -2
- data/lib/facet/comparable/cap.rb +1 -2
- data/lib/facet/comparable/clip.rb +1 -72
- data/lib/facet/comparable/cmp.rb +1 -38
- data/lib/facet/consoleapp.rb +1 -0
- data/lib/facet/continuation.rb +1 -1
- data/lib/facet/continuation/self/create.rb +1 -71
- data/lib/facet/coroutine.rb +1 -0
- data/lib/facet/crypt.rb +1 -0
- data/lib/facet/date.rb +1 -0
- data/lib/facet/date/days_in_month.rb +1 -42
- data/lib/facet/date/days_of_month.rb +1 -34
- data/lib/facet/date/stamp.rb +1 -52
- data/lib/facet/date/to_date.rb +1 -36
- data/lib/facet/date/to_s.rb +1 -33
- data/lib/facet/date/to_time.rb +1 -36
- data/lib/facet/dictionary.rb +1 -0
- data/lib/facet/dir.rb +1 -4
- data/lib/facet/dir/self/ancestor.rb +1 -33
- data/lib/facet/dir/self/ascend.rb +1 -56
- data/lib/facet/dir/self/ls_r.rb +1 -76
- data/lib/facet/dir/self/recurse.rb +1 -2
- data/lib/facet/downloader.rb +1 -0
- data/lib/facet/enumerable.rb +1 -39
- data/lib/facet/enumerable/collect_with_counter.rb +1 -2
- data/lib/facet/enumerable/collect_with_index.rb +1 -51
- data/lib/facet/enumerable/commonality.rb +1 -63
- data/lib/facet/enumerable/compact_collect.rb +1 -50
- data/lib/facet/enumerable/compact_map.rb +1 -2
- data/lib/facet/enumerable/cross.rb +1 -44
- data/lib/facet/enumerable/each_by.rb +1 -2
- data/lib/facet/enumerable/each_combination.rb +1 -59
- data/lib/facet/enumerable/each_pair.rb +1 -50
- data/lib/facet/enumerable/each_permutation.rb +1 -2
- data/lib/facet/enumerable/each_slice.rb +1 -131
- data/lib/facet/enumerable/each_unique_pair.rb +1 -66
- data/lib/facet/enumerable/each_with_counter.rb +1 -8
- data/lib/facet/enumerable/elementwise.rb +1 -2
- data/lib/facet/enumerable/entropy.rb +1 -52
- data/lib/facet/enumerable/every.rb +1 -65
- data/lib/facet/enumerable/ew.rb +1 -64
- data/lib/facet/enumerable/filter_collect.rb +1 -58
- data/lib/facet/enumerable/filter_map.rb +1 -2
- data/lib/facet/enumerable/find_collisions.rb +1 -41
- data/lib/facet/enumerable/frequency.rb +1 -39
- data/lib/facet/enumerable/graph.rb +1 -59
- data/lib/facet/enumerable/ideal_entropy.rb +1 -49
- data/lib/facet/enumerable/map_with_counter.rb +1 -2
- data/lib/facet/enumerable/map_with_index.rb +1 -2
- data/lib/facet/enumerable/none.rb +1 -56
- data/lib/facet/enumerable/nonuniq.rb +1 -39
- data/lib/facet/enumerable/occur.rb +1 -62
- data/lib/facet/enumerable/one.rb +1 -65
- data/lib/facet/enumerable/op_pow.rb +1 -38
- data/lib/facet/enumerable/partition_by.rb +1 -55
- data/lib/facet/enumerable/permute.rb +1 -135
- data/lib/facet/enumerable/probability.rb +1 -59
- data/lib/facet/enumerable/project.rb +1 -11
- data/lib/facet/enumerable/self/combinations.rb +1 -68
- data/lib/facet/enumerable/self/cross.rb +1 -79
- data/lib/facet/enumerable/to_h.rb +1 -50
- data/lib/facet/enumerable/uniq_by.rb +1 -39
- data/lib/facet/enumerable/where.rb +1 -12
- data/lib/facet/enumerablepass.rb +1 -0
- data/lib/facet/expirable.rb +1 -0
- data/lib/facet/file.rb +1 -5
- data/lib/facet/file/self/create.rb +1 -52
- data/lib/facet/file/self/open_as_string.rb +1 -81
- data/lib/facet/file/self/read_list.rb +1 -47
- data/lib/facet/file/self/sanitize.rb +1 -50
- data/lib/facet/file/self/split_all.rb +1 -36
- data/lib/facet/filelist.rb +1 -0
- data/lib/facet/fileutils.rb +1 -0
- data/lib/facet/fileutils/head.rb +1 -2
- data/lib/facet/fileutils/safe_ln.rb +1 -38
- data/lib/facet/fileutils/slice.rb +1 -152
- data/lib/facet/fileutils/split_all.rb +1 -29
- data/lib/facet/fileutils/tail.rb +1 -2
- data/lib/facet/fileutils/wc.rb +1 -128
- data/lib/facet/fileutils/whereis.rb +1 -76
- data/lib/facet/fileutils/which.rb +1 -117
- data/lib/facet/float.rb +1 -3
- data/lib/facet/float/approx.rb +1 -42
- data/lib/facet/float/round_at.rb +1 -72
- data/lib/facet/float/round_to.rb +1 -73
- data/lib/facet/floatstring.rb +1 -0
- data/lib/facet/functor.rb +1 -41
- data/lib/facet/gem.rb +1 -3
- data/lib/facet/gem/self/active.rb +1 -9
- data/lib/facet/gem/self/gempath.rb +1 -10
- data/lib/facet/gem/self/gemspec.rb +1 -10
- data/lib/facet/hash.rb +1 -40
- data/lib/facet/hash/alias.rb +1 -54
- data/lib/facet/hash/assert_has_keys.rb +1 -38
- data/lib/facet/hash/assert_has_only_keys.rb +1 -38
- data/lib/facet/hash/at.rb +1 -26
- data/lib/facet/hash/collate.rb +1 -53
- data/lib/facet/hash/delete_unless.rb +1 -15
- data/lib/facet/hash/each.rb +1 -61
- data/lib/facet/hash/each_with_index.rb +1 -35
- data/lib/facet/hash/each_with_key.rb +1 -32
- data/lib/facet/hash/graph.rb +1 -31
- data/lib/facet/hash/has_keys.rb +1 -37
- data/lib/facet/hash/has_only_keys.rb +1 -37
- data/lib/facet/hash/inverse.rb +1 -51
- data/lib/facet/hash/join.rb +1 -19
- data/lib/facet/hash/keys_to_iv.rb +1 -60
- data/lib/facet/hash/keys_to_s.rb +1 -80
- data/lib/facet/hash/keys_to_sym.rb +1 -91
- data/lib/facet/hash/op_fetch.rb +1 -146
- data/lib/facet/hash/op_lshift.rb +1 -28
- data/lib/facet/hash/op_store.rb +1 -2
- data/lib/facet/hash/rand_key.rb +1 -47
- data/lib/facet/hash/rand_pair.rb +1 -50
- data/lib/facet/hash/rand_value.rb +1 -60
- data/lib/facet/hash/replace_each.rb +1 -33
- data/lib/facet/hash/self/zipnew.rb +1 -37
- data/lib/facet/hash/shuffle.rb +1 -53
- data/lib/facet/hash/slice.rb +1 -33
- data/lib/facet/hash/stringify_keys.rb +1 -2
- data/lib/facet/hash/swap.rb +1 -36
- data/lib/facet/hash/swapkey.rb +1 -44
- data/lib/facet/hash/symoblize_keys.rb +1 -2
- data/lib/facet/hash/to_h.rb +1 -35
- data/lib/facet/hash/to_ostruct.rb +1 -40
- data/lib/facet/hash/to_ostruct_recurse.rb +1 -45
- data/lib/facet/hash/traverse.rb +1 -63
- data/lib/facet/hash/update_each.rb +1 -43
- data/lib/facet/hash/update_keys.rb +1 -31
- data/lib/facet/hash/update_values.rb +1 -32
- data/lib/facet/hash/variablize_keys.rb +1 -2
- data/lib/facet/hash/weave.rb +1 -88
- data/lib/facet/heap.rb +1 -0
- data/lib/facet/inflect.rb +1 -70
- data/lib/facet/inheritor.rb +1 -0
- data/lib/facet/integer.rb +1 -9
- data/lib/facet/integer/even.rb +1 -2
- data/lib/facet/integer/fac.rb +1 -2
- data/lib/facet/integer/fact.rb +1 -2
- data/lib/facet/integer/factorial.rb +1 -61
- data/lib/facet/integer/multiple.rb +1 -69
- data/lib/facet/integer/odd.rb +1 -2
- data/lib/facet/integer/ordinal.rb +1 -41
- data/lib/facet/integer/times_collect.rb +1 -39
- data/lib/facet/integer/times_map.rb +1 -2
- data/lib/facet/interval.rb +1 -0
- data/lib/facet/ioredirect.rb +1 -0
- data/lib/facet/kernel.rb +1 -68
- data/lib/facet/kernel/__DIR__.rb +1 -11
- data/lib/facet/kernel/__class__.rb +1 -31
- data/lib/facet/kernel/__meta__.rb +1 -28
- data/lib/facet/kernel/adhoc.rb +1 -11
- data/lib/facet/kernel/as.rb +1 -91
- data/lib/facet/kernel/assign_from.rb +1 -82
- data/lib/facet/kernel/assign_with.rb +1 -75
- data/lib/facet/kernel/autoreload.rb +1 -124
- data/lib/facet/kernel/autoreload_files.rb +1 -2
- data/lib/facet/kernel/autoreload_glob.rb +1 -3
- data/lib/facet/kernel/bool.rb +1 -77
- data/lib/facet/kernel/bug.rb +1 -39
- data/lib/facet/kernel/call_stack.rb +1 -59
- data/lib/facet/kernel/called.rb +1 -40
- data/lib/facet/kernel/complete.rb +1 -6
- data/lib/facet/kernel/constant.rb +1 -52
- data/lib/facet/kernel/copy.rb +1 -48
- data/lib/facet/kernel/deep_copy.rb +1 -49
- data/lib/facet/kernel/demo.rb +1 -46
- data/lib/facet/kernel/eigenclass.rb +1 -17
- data/lib/facet/kernel/false.rb +1 -2
- data/lib/facet/kernel/fn.rb +1 -33
- data/lib/facet/kernel/generate_method_name.rb +1 -39
- data/lib/facet/kernel/get_by_id.rb +1 -33
- data/lib/facet/kernel/here.rb +1 -34
- data/lib/facet/kernel/in.rb +1 -35
- data/lib/facet/kernel/instance_assign.rb +1 -25
- data/lib/facet/kernel/instvar.rb +1 -13
- data/lib/facet/kernel/is.rb +1 -5
- data/lib/facet/kernel/maybe.rb +1 -41
- data/lib/facet/kernel/me.rb +1 -17
- data/lib/facet/kernel/meta.rb +1 -2
- data/lib/facet/kernel/metaclass.rb +1 -42
- data/lib/facet/kernel/method.rb +1 -76
- data/lib/facet/kernel/method_name.rb +1 -49
- data/lib/facet/kernel/methods.rb +1 -79
- data/lib/facet/kernel/nack.rb +1 -12
- data/lib/facet/kernel/new.rb +1 -40
- data/lib/facet/kernel/object_class.rb +1 -31
- data/lib/facet/kernel/object_hexid.rb +1 -35
- data/lib/facet/kernel/op_esc.rb +1 -37
- data/lib/facet/kernel/own.rb +1 -17
- data/lib/facet/kernel/p.rb +1 -12
- data/lib/facet/kernel/require_all.rb +1 -44
- data/lib/facet/kernel/require_esc.rb +1 -42
- data/lib/facet/kernel/require_facet.rb +1 -41
- data/lib/facet/kernel/require_local.rb +1 -25
- data/lib/facet/kernel/resc.rb +1 -32
- data/lib/facet/kernel/returning.rb +1 -49
- data/lib/facet/kernel/send_as.rb +1 -34
- data/lib/facet/kernel/set_from.rb +1 -69
- data/lib/facet/kernel/set_with.rb +1 -74
- data/lib/facet/kernel/silence_warnings.rb +1 -2
- data/lib/facet/kernel/silently.rb +1 -41
- data/lib/facet/kernel/singleton.rb +1 -47
- data/lib/facet/kernel/superior.rb +1 -53
- data/lib/facet/kernel/supermethod.rb +1 -44
- data/lib/facet/kernel/this.rb +1 -33
- data/lib/facet/kernel/to_b.rb +1 -41
- data/lib/facet/kernel/to_bool.rb +1 -47
- data/lib/facet/kernel/true.rb +1 -2
- data/lib/facet/kernel/unuri.rb +1 -2
- data/lib/facet/kernel/uri.rb +1 -38
- data/lib/facet/kernel/val.rb +1 -52
- data/lib/facet/kernel/warn_with_line.rb +1 -30
- data/lib/facet/kernel/with_accessor.rb +1 -94
- data/lib/facet/kernel/with_reader.rb +1 -2
- data/lib/facet/kernel/with_writer.rb +1 -2
- data/lib/facet/lisp.rb +1 -0
- data/lib/facet/lisp_format.rb +1 -0
- data/lib/facet/logger.rb +1 -0
- data/lib/facet/logger/format.rb +1 -28
- data/lib/facet/logger/format_message.rb +1 -1
- data/lib/facet/lrucache.rb +1 -0
- data/lib/facet/matchdata.rb +1 -3
- data/lib/facet/matchdata/match.rb +1 -37
- data/lib/facet/matchdata/matchset.rb +1 -2
- data/lib/facet/matchdata/matchtree.rb +1 -62
- data/lib/facet/mathconstants.rb +1 -0
- data/lib/facet/methodprobe.rb +1 -0
- data/lib/facet/mock.rb +1 -0
- data/lib/facet/module.rb +1 -40
- data/lib/facet/module/abstract.rb +1 -50
- data/lib/facet/module/alias_module_function.rb +1 -57
- data/lib/facet/module/ancestor.rb +1 -38
- data/lib/facet/module/attr.rb +1 -23
- data/lib/facet/module/attr_setter.rb +1 -48
- data/lib/facet/module/attr_tester.rb +1 -56
- data/lib/facet/module/basename.rb +1 -39
- data/lib/facet/module/by_name.rb +1 -68
- data/lib/facet/module/cattr_accessor.rb +1 -141
- data/lib/facet/module/cattr_reader.rb +1 -2
- data/lib/facet/module/cattr_writer.rb +1 -2
- data/lib/facet/module/clone_removing.rb +1 -2
- data/lib/facet/module/clone_renaming.rb +1 -2
- data/lib/facet/module/clone_using.rb +1 -87
- data/lib/facet/module/dirname.rb +1 -42
- data/lib/facet/module/equate_on.rb +1 -70
- data/lib/facet/module/generate_instance_method_name.rb +1 -47
- data/lib/facet/module/include_as.rb +1 -102
- data/lib/facet/module/initializer.rb +1 -65
- data/lib/facet/module/instance_methods.rb +1 -186
- data/lib/facet/module/integrate.rb +1 -51
- data/lib/facet/module/is.rb +1 -34
- data/lib/facet/module/memoize.rb +1 -95
- data/lib/facet/module/modspace.rb +1 -43
- data/lib/facet/module/namespace.rb +1 -61
- data/lib/facet/module/nesting.rb +1 -45
- data/lib/facet/module/redef.rb +1 -31
- data/lib/facet/module/redefine_method.rb +1 -57
- data/lib/facet/module/redirect.rb +1 -30
- data/lib/facet/module/redirect_method.rb +1 -64
- data/lib/facet/module/remove.rb +1 -29
- data/lib/facet/module/rename.rb +1 -31
- data/lib/facet/module/rename_method.rb +1 -38
- data/lib/facet/module/revisal.rb +1 -49
- data/lib/facet/module/shadow_all.rb +1 -17
- data/lib/facet/module/shadow_method.rb +1 -42
- data/lib/facet/module/sort_on.rb +1 -73
- data/lib/facet/module/undef.rb +1 -29
- data/lib/facet/module/wrap.rb +1 -30
- data/lib/facet/module/wrap_method.rb +1 -48
- data/lib/facet/multipliers.rb +1 -0
- data/lib/facet/multiton.rb +1 -0
- data/lib/facet/nackclass.rb +1 -0
- data/lib/facet/nil_as_emptiness.rb +1 -34
- data/lib/facet/nilclass.rb +1 -7
- data/lib/facet/nilclass/empty.rb +1 -32
- data/lib/facet/nilclass/include.rb +1 -32
- data/lib/facet/nilclass/length.rb +1 -2
- data/lib/facet/nilclass/op_fetch.rb +1 -37
- data/lib/facet/nilclass/size.rb +1 -44
- data/lib/facet/nilclass/to_f.rb +1 -32
- data/lib/facet/nilclass/to_h.rb +1 -33
- data/lib/facet/nilcomparable.rb +1 -0
- data/lib/facet/nullclass.rb +1 -0
- data/lib/facet/numeric.rb +1 -5
- data/lib/facet/numeric/ceil_multiple.rb +1 -40
- data/lib/facet/numeric/pred.rb +1 -2
- data/lib/facet/numeric/succ.rb +1 -69
- data/lib/facet/numeric/to_b.rb +1 -38
- data/lib/facet/one.rb +1 -0
- data/lib/facet/openobject.rb +1 -0
- data/lib/facet/orderedhash.rb +1 -0
- data/lib/facet/ormsupport.rb +1 -0
- data/lib/facet/ostruct.rb +1 -0
- data/lib/facet/ostruct/__merge__.rb +1 -52
- data/lib/facet/ostruct/__table__.rb +1 -17
- data/lib/facet/ostruct/__update__.rb +1 -45
- data/lib/facet/ostruct/op_fetch.rb +1 -40
- data/lib/facet/ostruct/op_store.rb +1 -42
- data/lib/facet/ostruct/to_h.rb +1 -8
- data/lib/facet/overload.rb +1 -0
- data/lib/facet/paramix.rb +1 -0
- data/lib/facet/pathlist.rb +1 -0
- data/lib/facet/pathname.rb +1 -2
- data/lib/facet/pathname/ascend.rb +1 -22
- data/lib/facet/pathname/descend.rb +1 -20
- data/lib/facet/pool.rb +1 -0
- data/lib/facet/preinitialize.rb +1 -0
- data/lib/facet/proc.rb +1 -3
- data/lib/facet/proc/compose.rb +1 -62
- data/lib/facet/proc/op_mul.rb +1 -2
- data/lib/facet/proc/to_method.rb +1 -74
- data/lib/facet/progressbar.rb +1 -0
- data/lib/facet/promoteself.rb +1 -0
- data/lib/facet/quaternion.rb +1 -0
- data/lib/facet/random.rb +1 -21
- data/lib/facet/range.rb +1 -4
- data/lib/facet/range/to_r.rb +1 -32
- data/lib/facet/range/to_range.rb +1 -36
- data/lib/facet/range/umbrella.rb +1 -67
- data/lib/facet/range/within.rb +1 -44
- data/lib/facet/reference.rb +1 -0
- data/lib/facet/regexp.rb +1 -3
- data/lib/facet/regexp/arity.rb +1 -41
- data/lib/facet/regexp/to_re.rb +1 -38
- data/lib/facet/regexp/to_regexp.rb +1 -36
- data/lib/facet/rtals.rb +1 -0
- data/lib/facet/semaphore.rb +1 -0
- data/lib/facet/snapshot.rb +1 -0
- data/lib/facet/stateparser.rb +1 -0
- data/lib/facet/statichash.rb +1 -0
- data/lib/facet/string.rb +1 -91
- data/lib/facet/string/align_center.rb +1 -87
- data/lib/facet/string/align_left.rb +1 -2
- data/lib/facet/string/align_right.rb +1 -2
- data/lib/facet/string/at.rb +1 -8
- data/lib/facet/string/at_rand.rb +1 -65
- data/lib/facet/string/basename.rb +1 -48
- data/lib/facet/string/blank.rb +1 -36
- data/lib/facet/string/bracket.rb +1 -70
- data/lib/facet/string/brief.rb +1 -33
- data/lib/facet/string/bytes.rb +1 -19
- data/lib/facet/string/camelcase.rb +1 -58
- data/lib/facet/string/camelize.rb +1 -35
- data/lib/facet/string/capitalized.rb +1 -38
- data/lib/facet/string/chars.rb +1 -34
- data/lib/facet/string/cmp.rb +1 -43
- data/lib/facet/string/demodulize.rb +1 -40
- data/lib/facet/string/dequote.rb +1 -29
- data/lib/facet/string/downcase.rb +1 -37
- data/lib/facet/string/dresner.rb +1 -49
- data/lib/facet/string/each_char.rb +1 -35
- data/lib/facet/string/each_word.rb +1 -50
- data/lib/facet/string/ends_with.rb +1 -2
- data/lib/facet/string/first.rb +1 -94
- data/lib/facet/string/first_char.rb +1 -20
- data/lib/facet/string/fold.rb +1 -67
- data/lib/facet/string/format.rb +1 -17
- data/lib/facet/string/frequency.rb +1 -39
- data/lib/facet/string/humanize.rb +1 -31
- data/lib/facet/string/indent.rb +1 -68
- data/lib/facet/string/index_all.rb +1 -40
- data/lib/facet/string/last.rb +1 -94
- data/lib/facet/string/last_char.rb +1 -22
- data/lib/facet/string/line_wrap.rb +1 -77
- data/lib/facet/string/lines.rb +1 -33
- data/lib/facet/string/lowercase.rb +1 -32
- data/lib/facet/string/margin.rb +1 -138
- data/lib/facet/string/methodize.rb +1 -44
- data/lib/facet/string/modulize.rb +1 -44
- data/lib/facet/string/mscan.rb +1 -42
- data/lib/facet/string/natcmp.rb +1 -108
- data/lib/facet/string/nchar.rb +1 -45
- data/lib/facet/string/ordinal.rb +1 -16
- data/lib/facet/string/pathize.rb +1 -46
- data/lib/facet/string/plural.rb +1 -2
- data/lib/facet/string/pop.rb +1 -54
- data/lib/facet/string/probability.rb +1 -34
- data/lib/facet/string/pull.rb +1 -17
- data/lib/facet/string/push.rb +1 -44
- data/lib/facet/string/quote.rb +1 -68
- data/lib/facet/string/rand_byte.rb +1 -55
- data/lib/facet/string/rand_index.rb +1 -29
- data/lib/facet/string/range.rb +1 -37
- data/lib/facet/string/range_all.rb +1 -48
- data/lib/facet/string/range_of_line.rb +1 -42
- data/lib/facet/string/regesc.rb +1 -32
- data/lib/facet/string/self/format.rb +1 -17
- data/lib/facet/string/self/interpolate.rb +1 -31
- data/lib/facet/string/self/patterns.rb +1 -51
- data/lib/facet/string/self/rand_letter.rb +1 -34
- data/lib/facet/string/self/random.rb +1 -37
- data/lib/facet/string/shatter.rb +1 -45
- data/lib/facet/string/shell_escape.rb +1 -0
- data/lib/facet/string/shift.rb +1 -42
- data/lib/facet/string/shuffle.rb +1 -42
- data/lib/facet/string/similarity.rb +1 -108
- data/lib/facet/string/singular.rb +1 -117
- data/lib/facet/string/slap.rb +1 -44
- data/lib/facet/string/soundex.rb +1 -102
- data/lib/facet/string/starts_with.rb +1 -24
- data/lib/facet/string/succ.rb +1 -38
- data/lib/facet/string/tab.rb +1 -2
- data/lib/facet/string/tabto.rb +1 -2
- data/lib/facet/string/to_a.rb +1 -35
- data/lib/facet/string/to_arr.rb +1 -55
- data/lib/facet/string/to_b.rb +1 -64
- data/lib/facet/string/to_const.rb +1 -39
- data/lib/facet/string/to_date.rb +1 -35
- data/lib/facet/string/to_proc.rb +1 -54
- data/lib/facet/string/to_re.rb +1 -46
- data/lib/facet/string/to_rx.rb +1 -2
- data/lib/facet/string/to_time.rb +1 -34
- data/lib/facet/string/unbracket.rb +1 -46
- data/lib/facet/string/underscore.rb +1 -18
- data/lib/facet/string/unix_crypt.rb +1 -41
- data/lib/facet/string/unpack.rb +1 -45
- data/lib/facet/string/unshift.rb +1 -42
- data/lib/facet/string/upcase.rb +1 -45
- data/lib/facet/string/uppercase.rb +1 -2
- data/lib/facet/string/whitespace.rb +1 -27
- data/lib/facet/string/word_filter.rb +1 -61
- data/lib/facet/string/word_wrap.rb +1 -90
- data/lib/facet/string/words.rb +1 -45
- data/lib/facet/string_as_array.rb +1 -16
- data/lib/facet/symbol.rb +1 -13
- data/lib/facet/symbol/camelcase.rb +1 -42
- data/lib/facet/symbol/camelize.rb +1 -33
- data/lib/facet/symbol/capitalize.rb +1 -31
- data/lib/facet/symbol/capitalized.rb +1 -33
- data/lib/facet/symbol/downcase.rb +1 -36
- data/lib/facet/symbol/not.rb +1 -40
- data/lib/facet/symbol/pad.rb +1 -43
- data/lib/facet/symbol/succ.rb +1 -42
- data/lib/facet/symbol/to_const.rb +1 -40
- data/lib/facet/symbol/to_proc.rb +1 -45
- data/lib/facet/symbol/to_str.rb +1 -39
- data/lib/facet/symbol/underscore.rb +1 -32
- data/lib/facet/symbol/upcase.rb +1 -37
- data/lib/facet/syncarray.rb +1 -0
- data/lib/facet/synchash.rb +1 -0
- data/lib/facet/system.rb +1 -0
- data/lib/facet/tagiterator.rb +1 -0
- data/lib/facet/time.rb +1 -8
- data/lib/facet/time/change.rb +1 -51
- data/lib/facet/time/elapse.rb +1 -41
- data/lib/facet/time/self/days_extrema.rb +1 -22
- data/lib/facet/time/self/stamp.rb +1 -2
- data/lib/facet/time/stamp.rb +1 -51
- data/lib/facet/time/to_date.rb +1 -37
- data/lib/facet/time/to_s.rb +1 -33
- data/lib/facet/time/to_time.rb +1 -36
- data/lib/facet/timer.rb +1 -0
- data/lib/facet/times.rb +1 -0
- data/lib/facet/tracepoint.rb +1 -0
- data/lib/facet/tuple.rb +1 -0
- data/lib/facet/typecast.rb +1 -0
- data/lib/facet/unboundmethod.rb +1 -1
- data/lib/facet/unboundmethod/name.rb +1 -8
- data/lib/facet/uninheritable.rb +1 -0
- data/lib/facet/units.rb +1 -0
- data/lib/facet/yamlstruct.rb +1 -0
- data/lib/facets.rb +77 -45
- data/lib/facets/core/array.rb +34 -0
- data/lib/facets/core/array/at_rand.rb +52 -0
- data/lib/facets/core/array/body.rb +2 -0
- data/lib/facets/core/array/delete_unless.rb +35 -0
- data/lib/facets/core/array/delete_values.rb +38 -0
- data/lib/facets/core/array/delete_values_at.rb +57 -0
- data/lib/facets/core/array/each_with_key.rb +9 -0
- data/lib/facets/core/array/first.rb +84 -0
- data/lib/facets/core/array/foot.rb +2 -0
- data/lib/facets/core/array/head.rb +80 -0
- data/lib/facets/core/array/last.rb +2 -0
- data/lib/facets/core/array/last_index.rb +35 -0
- data/lib/facets/core/array/merge.rb +40 -0
- data/lib/facets/core/array/mid.rb +50 -0
- data/lib/facets/core/array/middle.rb +45 -0
- data/lib/facets/core/array/op_fetch.rb +40 -0
- data/lib/facets/core/array/op_mod.rb +16 -0
- data/lib/facets/core/array/op_store.rb +47 -0
- data/lib/facets/core/array/pick.rb +68 -0
- data/lib/facets/core/array/pos.rb +39 -0
- data/lib/facets/core/array/pull.rb +37 -0
- data/lib/facets/core/array/rand_index.rb +30 -0
- data/lib/facets/core/array/rand_subset.rb +56 -0
- data/lib/facets/core/array/range.rb +47 -0
- data/lib/facets/core/array/rotate.rb +67 -0
- data/lib/facets/core/array/select.rb +37 -0
- data/lib/facets/core/array/shuffle.rb +66 -0
- data/lib/facets/core/array/slap.rb +37 -0
- data/lib/facets/core/array/store.rb +7 -0
- data/lib/facets/core/array/tail.rb +2 -0
- data/lib/facets/core/array/thru.rb +38 -0
- data/lib/facets/core/array/to_b.rb +31 -0
- data/lib/facets/core/array/to_h.rb +57 -0
- data/lib/facets/core/array/to_hash.rb +46 -0
- data/lib/facets/core/array/unzip.rb +20 -0
- data/lib/facets/core/binding.rb +14 -0
- data/lib/facets/core/binding/__DIR__.rb +2 -0
- data/lib/facets/core/binding/__FILE__.rb +2 -0
- data/lib/facets/core/binding/__LINE__.rb +58 -0
- data/lib/facets/core/binding/call_stack.rb +42 -0
- data/lib/facets/core/binding/called.rb +42 -0
- data/lib/facets/core/binding/caller.rb +42 -0
- data/lib/facets/core/binding/defined.rb +41 -0
- data/lib/facets/core/binding/eval.rb +42 -0
- data/lib/facets/core/binding/local_variables.rb +45 -0
- data/lib/facets/core/binding/method_name.rb +48 -0
- data/lib/facets/core/binding/op_fetch.rb +45 -0
- data/lib/facets/core/binding/op_store.rb +46 -0
- data/lib/facets/core/binding/self.rb +41 -0
- data/lib/facets/core/binding/self/of_caller.rb +122 -0
- data/lib/facets/core/class.rb +7 -0
- data/lib/facets/core/class/by_name.rb +1 -0
- data/lib/facets/core/class/descendents.rb +44 -0
- data/lib/facets/core/class/method_name.rb +33 -0
- data/lib/facets/core/class/remove_descendents.rb +46 -0
- data/lib/facets/core/class/remove_subclasses.rb +2 -0
- data/lib/facets/core/class/subclasses.rb +2 -0
- data/lib/facets/core/class/unix_path.rb +34 -0
- data/lib/facets/core/comparable.rb +5 -0
- data/lib/facets/core/comparable/at_least.rb +53 -0
- data/lib/facets/core/comparable/at_most.rb +2 -0
- data/lib/facets/core/comparable/cap.rb +2 -0
- data/lib/facets/core/comparable/clip.rb +72 -0
- data/lib/facets/core/comparable/cmp.rb +38 -0
- data/lib/facets/core/continuation.rb +1 -0
- data/lib/facets/core/continuation/self/create.rb +71 -0
- data/lib/facets/core/date.rb +0 -0
- data/lib/facets/core/date/days_in_month.rb +42 -0
- data/lib/facets/core/date/days_of_month.rb +34 -0
- data/lib/facets/core/date/stamp.rb +52 -0
- data/lib/facets/core/date/to_date.rb +36 -0
- data/lib/facets/core/date/to_s.rb +33 -0
- data/lib/facets/core/date/to_time.rb +36 -0
- data/lib/facets/core/dir.rb +4 -0
- data/lib/facets/core/dir/self/ancestor.rb +33 -0
- data/lib/facets/core/dir/self/ascend.rb +56 -0
- data/lib/facets/core/dir/self/ls_r.rb +76 -0
- data/lib/facets/core/dir/self/recurse.rb +2 -0
- data/lib/facets/core/enumerable.rb +39 -0
- data/lib/facets/core/enumerable/collect_with_counter.rb +2 -0
- data/lib/facets/core/enumerable/collect_with_index.rb +51 -0
- data/lib/facets/core/enumerable/commonality.rb +63 -0
- data/lib/facets/core/enumerable/compact_collect.rb +50 -0
- data/lib/facets/core/enumerable/compact_map.rb +2 -0
- data/lib/facets/core/enumerable/cross.rb +44 -0
- data/lib/facets/core/enumerable/each_by.rb +2 -0
- data/lib/facets/core/enumerable/each_combination.rb +59 -0
- data/lib/facets/core/enumerable/each_pair.rb +50 -0
- data/lib/facets/core/enumerable/each_permutation.rb +2 -0
- data/lib/facets/core/enumerable/each_slice.rb +131 -0
- data/lib/facets/core/enumerable/each_unique_pair.rb +66 -0
- data/lib/facets/core/enumerable/each_with_counter.rb +8 -0
- data/lib/facets/core/enumerable/elementwise.rb +2 -0
- data/lib/facets/core/enumerable/entropy.rb +52 -0
- data/lib/facets/core/enumerable/every.rb +65 -0
- data/lib/facets/core/enumerable/ew.rb +64 -0
- data/lib/facets/core/enumerable/filter_collect.rb +58 -0
- data/lib/facets/core/enumerable/filter_map.rb +2 -0
- data/lib/facets/core/enumerable/find_collisions.rb +41 -0
- data/lib/facets/core/enumerable/frequency.rb +39 -0
- data/lib/facets/core/enumerable/graph.rb +59 -0
- data/lib/facets/core/enumerable/ideal_entropy.rb +49 -0
- data/lib/facets/core/enumerable/map_with_counter.rb +2 -0
- data/lib/facets/core/enumerable/map_with_index.rb +2 -0
- data/lib/facets/core/enumerable/none.rb +56 -0
- data/lib/facets/core/enumerable/nonuniq.rb +39 -0
- data/lib/facets/core/enumerable/occur.rb +62 -0
- data/lib/facets/core/enumerable/one.rb +65 -0
- data/lib/facets/core/enumerable/op_pow.rb +38 -0
- data/lib/facets/core/enumerable/partition_by.rb +55 -0
- data/lib/facets/core/enumerable/permute.rb +135 -0
- data/lib/facets/core/enumerable/probability.rb +59 -0
- data/lib/facets/core/enumerable/project.rb +11 -0
- data/lib/facets/core/enumerable/self/combinations.rb +68 -0
- data/lib/facets/core/enumerable/self/cross.rb +79 -0
- data/lib/facets/core/enumerable/to_h.rb +50 -0
- data/lib/facets/core/enumerable/uniq_by.rb +39 -0
- data/lib/facets/core/enumerable/where.rb +12 -0
- data/lib/facets/core/file.rb +5 -0
- data/lib/facets/core/file/self/create.rb +52 -0
- data/lib/facets/core/file/self/open_as_string.rb +81 -0
- data/lib/facets/core/file/self/read_list.rb +47 -0
- data/lib/facets/core/file/self/sanitize.rb +50 -0
- data/lib/facets/core/file/self/split_all.rb +36 -0
- data/lib/facets/core/fileutils.rb +0 -0
- data/lib/facets/core/fileutils/head.rb +2 -0
- data/lib/facets/core/fileutils/safe_ln.rb +38 -0
- data/lib/facets/core/fileutils/slice.rb +152 -0
- data/lib/facets/core/fileutils/split_all.rb +29 -0
- data/lib/facets/core/fileutils/tail.rb +2 -0
- data/lib/facets/core/fileutils/wc.rb +128 -0
- data/lib/facets/core/fileutils/whereis.rb +76 -0
- data/lib/facets/core/fileutils/which.rb +117 -0
- data/lib/facets/core/float.rb +3 -0
- data/lib/facets/core/float/approx.rb +42 -0
- data/lib/facets/core/float/round_at.rb +72 -0
- data/lib/facets/core/float/round_to.rb +73 -0
- data/lib/facets/core/gem.rb +3 -0
- data/lib/facets/core/gem/self/active.rb +9 -0
- data/lib/facets/core/gem/self/gempath.rb +10 -0
- data/lib/facets/core/gem/self/gemspec.rb +10 -0
- data/lib/facets/core/hash.rb +40 -0
- data/lib/facets/core/hash/alias.rb +54 -0
- data/lib/facets/core/hash/assert_has_keys.rb +38 -0
- data/lib/facets/core/hash/assert_has_only_keys.rb +38 -0
- data/lib/facets/core/hash/at.rb +26 -0
- data/lib/facets/core/hash/collate.rb +53 -0
- data/lib/facets/core/hash/delete_unless.rb +15 -0
- data/lib/facets/core/hash/each.rb +61 -0
- data/lib/facets/core/hash/each_with_index.rb +35 -0
- data/lib/facets/core/hash/each_with_key.rb +32 -0
- data/lib/facets/core/hash/graph.rb +31 -0
- data/lib/facets/core/hash/has_keys.rb +37 -0
- data/lib/facets/core/hash/has_only_keys.rb +37 -0
- data/lib/facets/core/hash/inverse.rb +51 -0
- data/lib/facets/core/hash/join.rb +19 -0
- data/lib/facets/core/hash/keys_to_iv.rb +60 -0
- data/lib/facets/core/hash/keys_to_s.rb +80 -0
- data/lib/facets/core/hash/keys_to_sym.rb +91 -0
- data/lib/facets/core/hash/op_fetch.rb +146 -0
- data/lib/facets/core/hash/op_lshift.rb +28 -0
- data/lib/facets/core/hash/op_store.rb +2 -0
- data/lib/facets/core/hash/rand_key.rb +47 -0
- data/lib/facets/core/hash/rand_pair.rb +50 -0
- data/lib/facets/core/hash/rand_value.rb +60 -0
- data/lib/facets/core/hash/replace_each.rb +33 -0
- data/lib/facets/core/hash/self/zipnew.rb +37 -0
- data/lib/facets/core/hash/shuffle.rb +53 -0
- data/lib/facets/core/hash/slice.rb +33 -0
- data/lib/facets/core/hash/stringify_keys.rb +2 -0
- data/lib/facets/core/hash/swap.rb +36 -0
- data/lib/facets/core/hash/swapkey.rb +44 -0
- data/lib/facets/core/hash/symoblize_keys.rb +2 -0
- data/lib/facets/core/hash/to_h.rb +35 -0
- data/lib/facets/core/hash/to_ostruct.rb +40 -0
- data/lib/facets/core/hash/to_ostruct_recurse.rb +45 -0
- data/lib/facets/core/hash/traverse.rb +63 -0
- data/lib/facets/core/hash/update_each.rb +43 -0
- data/lib/facets/core/hash/update_keys.rb +31 -0
- data/lib/facets/core/hash/update_values.rb +32 -0
- data/lib/facets/core/hash/variablize_keys.rb +2 -0
- data/lib/facets/core/hash/weave.rb +88 -0
- data/lib/facets/core/inflect.rb +70 -0
- data/lib/facets/core/integer.rb +9 -0
- data/lib/facets/core/integer/even.rb +2 -0
- data/lib/facets/core/integer/fac.rb +2 -0
- data/lib/facets/core/integer/fact.rb +2 -0
- data/lib/facets/core/integer/factorial.rb +61 -0
- data/lib/facets/core/integer/multiple.rb +69 -0
- data/lib/facets/core/integer/odd.rb +2 -0
- data/lib/facets/core/integer/ordinal.rb +41 -0
- data/lib/facets/core/integer/times_collect.rb +39 -0
- data/lib/facets/core/integer/times_map.rb +2 -0
- data/lib/facets/core/kernel.rb +68 -0
- data/lib/facets/core/kernel/__DIR__.rb +11 -0
- data/lib/facets/core/kernel/__class__.rb +31 -0
- data/lib/facets/core/kernel/__meta__.rb +28 -0
- data/lib/facets/core/kernel/adhoc.rb +11 -0
- data/lib/facets/core/kernel/as.rb +87 -0
- data/lib/facets/core/kernel/assign_from.rb +82 -0
- data/lib/facets/core/kernel/assign_with.rb +75 -0
- data/lib/facets/core/kernel/autoreload.rb +124 -0
- data/lib/facets/core/kernel/autoreload_files.rb +2 -0
- data/lib/facets/core/kernel/autoreload_glob.rb +3 -0
- data/lib/facets/core/kernel/bool.rb +77 -0
- data/lib/facets/core/kernel/bug.rb +39 -0
- data/lib/facets/core/kernel/call_stack.rb +59 -0
- data/lib/facets/core/kernel/called.rb +40 -0
- data/lib/facets/core/kernel/complete.rb +6 -0
- data/lib/facets/core/kernel/constant.rb +52 -0
- data/lib/facets/core/kernel/copy.rb +48 -0
- data/lib/facets/core/kernel/deep_copy.rb +49 -0
- data/lib/facets/core/kernel/demo.rb +46 -0
- data/lib/facets/core/kernel/eigenclass.rb +17 -0
- data/lib/facets/core/kernel/false.rb +2 -0
- data/lib/facets/core/kernel/fn.rb +33 -0
- data/lib/facets/core/kernel/generate_method_name.rb +39 -0
- data/lib/facets/core/kernel/get_by_id.rb +33 -0
- data/lib/facets/core/kernel/here.rb +34 -0
- data/lib/facets/core/kernel/in.rb +35 -0
- data/lib/facets/core/kernel/instance_assign.rb +25 -0
- data/lib/facets/core/kernel/instvar.rb +13 -0
- data/lib/facets/core/kernel/is.rb +7 -0
- data/lib/facets/core/kernel/maybe.rb +41 -0
- data/lib/facets/core/kernel/me.rb +17 -0
- data/lib/facets/core/kernel/meta.rb +2 -0
- data/lib/facets/core/kernel/metaclass.rb +42 -0
- data/lib/facets/core/kernel/method.rb +76 -0
- data/lib/facets/core/kernel/method_name.rb +49 -0
- data/lib/facets/core/kernel/methods.rb +79 -0
- data/lib/facets/core/kernel/nack.rb +12 -0
- data/lib/facets/core/kernel/new.rb +40 -0
- data/lib/facets/core/kernel/object_class.rb +31 -0
- data/lib/facets/core/kernel/object_hexid.rb +35 -0
- data/lib/facets/core/kernel/op_esc.rb +37 -0
- data/lib/facets/core/kernel/own.rb +17 -0
- data/lib/facets/core/kernel/p.rb +12 -0
- data/lib/facets/core/kernel/require_all.rb +44 -0
- data/lib/facets/core/kernel/require_esc.rb +42 -0
- data/lib/facets/core/kernel/require_facet.rb +41 -0
- data/lib/facets/core/kernel/require_local.rb +25 -0
- data/lib/facets/core/kernel/resc.rb +32 -0
- data/lib/facets/core/kernel/returning.rb +49 -0
- data/lib/facets/core/kernel/send_as.rb +34 -0
- data/lib/facets/core/kernel/set_from.rb +69 -0
- data/lib/facets/core/kernel/set_with.rb +74 -0
- data/lib/facets/core/kernel/silence_warnings.rb +2 -0
- data/lib/facets/core/kernel/silently.rb +41 -0
- data/lib/facets/core/kernel/singleton.rb +47 -0
- data/lib/facets/core/kernel/superior.rb +53 -0
- data/lib/facets/core/kernel/supermethod.rb +44 -0
- data/lib/facets/core/kernel/this.rb +33 -0
- data/lib/facets/core/kernel/to_b.rb +41 -0
- data/lib/facets/core/kernel/to_bool.rb +47 -0
- data/lib/facets/core/kernel/true.rb +2 -0
- data/lib/facets/core/kernel/unuri.rb +2 -0
- data/lib/facets/core/kernel/uri.rb +38 -0
- data/lib/facets/core/kernel/val.rb +52 -0
- data/lib/facets/core/kernel/warn_with_line.rb +30 -0
- data/lib/facets/core/kernel/with_accessor.rb +94 -0
- data/lib/facets/core/kernel/with_reader.rb +2 -0
- data/lib/facets/core/kernel/with_writer.rb +2 -0
- data/lib/facets/core/logger.rb +0 -0
- data/lib/facets/core/logger/format.rb +28 -0
- data/lib/facets/core/logger/format_message.rb +1 -0
- data/lib/facets/core/matchdata.rb +3 -0
- data/lib/facets/core/matchdata/match.rb +37 -0
- data/lib/facets/core/matchdata/matchset.rb +2 -0
- data/lib/facets/core/matchdata/matchtree.rb +62 -0
- data/lib/facets/core/module.rb +40 -0
- data/lib/facets/core/module/abstract.rb +50 -0
- data/lib/facets/core/module/alias_module_function.rb +57 -0
- data/lib/facets/core/module/ancestor.rb +38 -0
- data/lib/facets/core/module/attr.rb +23 -0
- data/lib/facets/core/module/attr_setter.rb +48 -0
- data/lib/facets/core/module/attr_tester.rb +56 -0
- data/lib/facets/core/module/basename.rb +39 -0
- data/lib/facets/core/module/by_name.rb +68 -0
- data/lib/facets/core/module/cattr_accessor.rb +141 -0
- data/lib/facets/core/module/cattr_reader.rb +2 -0
- data/lib/facets/core/module/cattr_writer.rb +2 -0
- data/lib/facets/core/module/clone_removing.rb +2 -0
- data/lib/facets/core/module/clone_renaming.rb +2 -0
- data/lib/facets/core/module/clone_using.rb +87 -0
- data/lib/facets/core/module/dirname.rb +42 -0
- data/lib/facets/core/module/equate_on.rb +70 -0
- data/lib/facets/core/module/generate_instance_method_name.rb +47 -0
- data/lib/facets/core/module/include_as.rb +102 -0
- data/lib/facets/core/module/initializer.rb +65 -0
- data/lib/facets/core/module/instance_methods.rb +186 -0
- data/lib/facets/core/module/integrate.rb +51 -0
- data/lib/facets/core/module/is.rb +35 -0
- data/lib/facets/core/module/memoize.rb +95 -0
- data/lib/facets/core/module/modspace.rb +43 -0
- data/lib/facets/core/module/namespace.rb +61 -0
- data/lib/facets/core/module/nesting.rb +45 -0
- data/lib/facets/core/module/redef.rb +31 -0
- data/lib/facets/core/module/redefine_method.rb +57 -0
- data/lib/facets/core/module/redirect.rb +30 -0
- data/lib/facets/core/module/redirect_method.rb +64 -0
- data/lib/facets/core/module/remove.rb +29 -0
- data/lib/facets/core/module/rename.rb +31 -0
- data/lib/facets/core/module/rename_method.rb +38 -0
- data/lib/facets/core/module/revisal.rb +49 -0
- data/lib/facets/core/module/shadow_all.rb +17 -0
- data/lib/facets/core/module/shadow_method.rb +42 -0
- data/lib/facets/core/module/sort_on.rb +73 -0
- data/lib/facets/core/module/undef.rb +29 -0
- data/lib/facets/core/module/wrap.rb +30 -0
- data/lib/facets/core/module/wrap_method.rb +48 -0
- data/lib/facets/core/nil_as_emptiness.rb +34 -0
- data/lib/facets/core/nilclass.rb +7 -0
- data/lib/facets/core/nilclass/empty.rb +32 -0
- data/lib/facets/core/nilclass/include.rb +32 -0
- data/lib/facets/core/nilclass/length.rb +2 -0
- data/lib/facets/core/nilclass/op_fetch.rb +37 -0
- data/lib/facets/core/nilclass/size.rb +44 -0
- data/lib/facets/core/nilclass/to_f.rb +32 -0
- data/lib/facets/core/nilclass/to_h.rb +33 -0
- data/lib/facets/core/numeric.rb +5 -0
- data/lib/facets/core/numeric/ceil_multiple.rb +40 -0
- data/lib/facets/core/numeric/pred.rb +2 -0
- data/lib/facets/core/numeric/succ.rb +69 -0
- data/lib/facets/core/numeric/to_b.rb +38 -0
- data/lib/facets/core/ostruct.rb +0 -0
- data/lib/facets/core/ostruct/__merge__.rb +52 -0
- data/lib/facets/core/ostruct/__table__.rb +17 -0
- data/lib/facets/core/ostruct/__update__.rb +45 -0
- data/lib/facets/core/ostruct/op_fetch.rb +40 -0
- data/lib/facets/core/ostruct/op_store.rb +42 -0
- data/lib/facets/core/ostruct/to_h.rb +8 -0
- data/lib/facets/core/pathname.rb +2 -0
- data/lib/facets/core/pathname/ascend.rb +22 -0
- data/lib/facets/core/pathname/descend.rb +20 -0
- data/lib/facets/core/proc.rb +3 -0
- data/lib/facets/core/proc/compose.rb +62 -0
- data/lib/facets/core/proc/op_mul.rb +2 -0
- data/lib/facets/core/proc/to_method.rb +74 -0
- data/lib/facets/core/random.rb +21 -0
- data/lib/facets/core/range.rb +4 -0
- data/lib/facets/core/range/to_r.rb +32 -0
- data/lib/facets/core/range/to_range.rb +36 -0
- data/lib/facets/core/range/umbrella.rb +67 -0
- data/lib/facets/core/range/within.rb +44 -0
- data/lib/facets/core/regexp.rb +3 -0
- data/lib/facets/core/regexp/arity.rb +41 -0
- data/lib/facets/core/regexp/to_re.rb +38 -0
- data/lib/facets/core/regexp/to_regexp.rb +36 -0
- data/lib/facets/core/string.rb +92 -0
- data/lib/facets/core/string/align_center.rb +87 -0
- data/lib/facets/core/string/align_left.rb +2 -0
- data/lib/facets/core/string/align_right.rb +2 -0
- data/lib/facets/core/string/at.rb +8 -0
- data/lib/facets/core/string/at_rand.rb +65 -0
- data/lib/facets/core/string/basename.rb +48 -0
- data/lib/facets/core/string/blank.rb +36 -0
- data/lib/facets/core/string/bracket.rb +70 -0
- data/lib/facets/core/string/brief.rb +33 -0
- data/lib/facets/core/string/bytes.rb +19 -0
- data/lib/facets/core/string/camelcase.rb +58 -0
- data/lib/facets/core/string/camelize.rb +35 -0
- data/lib/facets/core/string/capitalized.rb +38 -0
- data/lib/facets/core/string/chars.rb +34 -0
- data/lib/facets/core/string/cmp.rb +43 -0
- data/lib/facets/core/string/demodulize.rb +40 -0
- data/lib/facets/core/string/dequote.rb +29 -0
- data/lib/facets/core/string/downcase.rb +37 -0
- data/lib/facets/core/string/dresner.rb +49 -0
- data/lib/facets/core/string/each_char.rb +35 -0
- data/lib/facets/core/string/each_word.rb +50 -0
- data/lib/facets/core/string/ends_with.rb +2 -0
- data/lib/facets/core/string/first.rb +94 -0
- data/lib/facets/core/string/first_char.rb +20 -0
- data/lib/facets/core/string/fold.rb +67 -0
- data/lib/facets/core/string/format.rb +17 -0
- data/lib/facets/core/string/frequency.rb +39 -0
- data/lib/facets/core/string/humanize.rb +31 -0
- data/lib/facets/core/string/indent.rb +68 -0
- data/lib/facets/core/string/index_all.rb +40 -0
- data/lib/facets/core/string/last.rb +94 -0
- data/lib/facets/core/string/last_char.rb +22 -0
- data/lib/facets/core/string/line_wrap.rb +77 -0
- data/lib/facets/core/string/lines.rb +33 -0
- data/lib/facets/core/string/lowercase.rb +32 -0
- data/lib/facets/core/string/margin.rb +138 -0
- data/lib/facets/core/string/methodize.rb +44 -0
- data/lib/facets/core/string/modulize.rb +44 -0
- data/lib/facets/core/string/mscan.rb +42 -0
- data/lib/facets/core/string/natcmp.rb +108 -0
- data/lib/facets/core/string/nchar.rb +45 -0
- data/lib/facets/core/string/ordinal.rb +16 -0
- data/lib/facets/core/string/pathize.rb +46 -0
- data/lib/facets/core/string/plural.rb +2 -0
- data/lib/facets/core/string/pop.rb +54 -0
- data/lib/facets/core/string/probability.rb +34 -0
- data/lib/facets/core/string/pull.rb +17 -0
- data/lib/facets/core/string/push.rb +44 -0
- data/lib/facets/core/string/quote.rb +68 -0
- data/lib/facets/core/string/rand_byte.rb +55 -0
- data/lib/facets/core/string/rand_index.rb +29 -0
- data/lib/facets/core/string/range.rb +37 -0
- data/lib/facets/core/string/range_all.rb +48 -0
- data/lib/facets/core/string/range_of_line.rb +42 -0
- data/lib/facets/core/string/regesc.rb +32 -0
- data/lib/facets/core/string/self/format.rb +17 -0
- data/lib/facets/core/string/self/interpolate.rb +31 -0
- data/lib/facets/core/string/self/patterns.rb +51 -0
- data/lib/facets/core/string/self/rand_letter.rb +34 -0
- data/lib/facets/core/string/self/random.rb +37 -0
- data/lib/facets/core/string/shatter.rb +45 -0
- data/lib/facets/core/string/shell_escape.rb +11 -0
- data/lib/facets/core/string/shift.rb +42 -0
- data/lib/facets/core/string/shuffle.rb +42 -0
- data/lib/facets/core/string/similarity.rb +108 -0
- data/lib/facets/core/string/singular.rb +117 -0
- data/lib/facets/core/string/slap.rb +44 -0
- data/lib/facets/core/string/soundex.rb +102 -0
- data/lib/facets/core/string/starts_with.rb +24 -0
- data/lib/facets/core/string/succ.rb +38 -0
- data/lib/facets/core/string/tab.rb +2 -0
- data/lib/facets/core/string/tabto.rb +2 -0
- data/lib/facets/core/string/to_a.rb +35 -0
- data/lib/facets/core/string/to_arr.rb +55 -0
- data/lib/facets/core/string/to_b.rb +64 -0
- data/lib/facets/core/string/to_const.rb +39 -0
- data/lib/facets/core/string/to_date.rb +35 -0
- data/lib/facets/core/string/to_proc.rb +54 -0
- data/lib/facets/core/string/to_re.rb +46 -0
- data/lib/facets/core/string/to_rx.rb +2 -0
- data/lib/facets/core/string/to_time.rb +34 -0
- data/lib/facets/core/string/unbracket.rb +46 -0
- data/lib/facets/core/string/underscore.rb +18 -0
- data/lib/facets/core/string/unix_crypt.rb +41 -0
- data/lib/facets/core/string/unpack.rb +45 -0
- data/lib/facets/core/string/unshift.rb +42 -0
- data/lib/facets/core/string/upcase.rb +45 -0
- data/lib/facets/core/string/uppercase.rb +2 -0
- data/lib/facets/core/string/whitespace.rb +27 -0
- data/lib/facets/core/string/word_filter.rb +61 -0
- data/lib/facets/core/string/word_wrap.rb +90 -0
- data/lib/facets/core/string/words.rb +45 -0
- data/lib/facets/core/string_as_array.rb +16 -0
- data/lib/facets/core/symbol.rb +13 -0
- data/lib/facets/core/symbol/camelcase.rb +42 -0
- data/lib/facets/core/symbol/camelize.rb +33 -0
- data/lib/facets/core/symbol/capitalize.rb +31 -0
- data/lib/facets/core/symbol/capitalized.rb +33 -0
- data/lib/facets/core/symbol/downcase.rb +36 -0
- data/lib/facets/core/symbol/not.rb +40 -0
- data/lib/facets/core/symbol/pad.rb +43 -0
- data/lib/facets/core/symbol/succ.rb +42 -0
- data/lib/facets/core/symbol/to_const.rb +40 -0
- data/lib/facets/core/symbol/to_proc.rb +45 -0
- data/lib/facets/core/symbol/to_str.rb +39 -0
- data/lib/facets/core/symbol/underscore.rb +32 -0
- data/lib/facets/core/symbol/upcase.rb +37 -0
- data/lib/facets/core/time.rb +8 -0
- data/lib/facets/core/time/change.rb +51 -0
- data/lib/facets/core/time/elapse.rb +41 -0
- data/lib/facets/core/time/self/days_extrema.rb +22 -0
- data/lib/facets/core/time/self/stamp.rb +2 -0
- data/lib/facets/core/time/stamp.rb +51 -0
- data/lib/facets/core/time/to_date.rb +37 -0
- data/lib/facets/core/time/to_s.rb +33 -0
- data/lib/facets/core/time/to_time.rb +36 -0
- data/lib/facets/core/unboundmethod.rb +1 -0
- data/lib/facets/core/unboundmethod/name.rb +8 -0
- data/lib/facets/more/annotation.rb +580 -0
- data/lib/facets/more/ansicode.rb +311 -0
- data/lib/facets/more/aspects.rb +230 -0
- data/lib/facets/more/association.rb +156 -0
- data/lib/facets/more/basicobject.rb +135 -0
- data/lib/facets/more/bbcode.rb +388 -0
- data/lib/facets/more/binaryreader.rb +246 -0
- data/lib/facets/more/bitmask.rb +112 -0
- data/lib/facets/more/blankslate.rb +3 -0
- data/lib/facets/more/bytes.rb +212 -0
- data/lib/facets/more/classinherit.rb +216 -0
- data/lib/facets/more/classmethods.rb +219 -0
- data/lib/facets/more/cloneable.rb +55 -0
- data/lib/facets/more/consoleapp.rb +123 -0
- data/lib/facets/more/coroutine.rb +172 -0
- data/lib/facets/more/crypt.rb +180 -0
- data/lib/facets/more/dictionary.rb +436 -0
- data/lib/facets/more/downloader.rb +272 -0
- data/lib/facets/more/enumerablepass.rb +285 -0
- data/lib/facets/more/expirable.rb +87 -0
- data/lib/facets/more/filelist.rb +486 -0
- data/lib/facets/more/floatstring.rb +179 -0
- data/lib/facets/more/functor.rb +105 -0
- data/lib/facets/more/heap.rb +226 -0
- data/lib/facets/more/inheritor.rb +239 -0
- data/lib/facets/more/interval.rb +424 -0
- data/lib/facets/more/ioredirect.rb +130 -0
- data/lib/facets/more/lisp.rb +387 -0
- data/lib/facets/more/lisp_format.rb +1843 -0
- data/lib/facets/more/lrucache.rb +183 -0
- data/lib/facets/more/mathconstants.rb +320 -0
- data/lib/facets/more/methodprobe.rb +215 -0
- data/lib/facets/more/mock.rb +233 -0
- data/lib/facets/more/multipliers.rb +192 -0
- data/lib/facets/more/multiton.rb +359 -0
- data/lib/facets/more/nackclass.rb +162 -0
- data/lib/facets/more/nilcomparable.rb +133 -0
- data/lib/facets/more/nullclass.rb +68 -0
- data/lib/facets/more/one.rb +117 -0
- data/lib/facets/more/openobject.rb +220 -0
- data/lib/facets/more/orderedhash.rb +3 -0
- data/lib/facets/more/ormsupport.rb +235 -0
- data/lib/facets/more/overload.rb +110 -0
- data/lib/facets/more/paramix.rb +243 -0
- data/lib/facets/more/pathlist.rb +105 -0
- data/lib/facets/more/pool.rb +98 -0
- data/lib/facets/more/preinitialize.rb +152 -0
- data/lib/facets/more/progressbar.rb +227 -0
- data/lib/facets/more/promoteself.rb +104 -0
- data/lib/facets/more/quaternion.rb +527 -0
- data/lib/facets/more/reference.rb +83 -0
- data/lib/facets/more/rtals.rb +14 -0
- data/lib/facets/more/semaphore.rb +103 -0
- data/lib/facets/more/snapshot.rb +190 -0
- data/lib/facets/more/stateparser.rb +579 -0
- data/lib/facets/more/statichash.rb +87 -0
- data/lib/facets/more/syncarray.rb +144 -0
- data/lib/facets/more/synchash.rb +173 -0
- data/lib/facets/more/system.rb +169 -0
- data/lib/facets/more/tagiterator.rb +387 -0
- data/lib/facets/more/timer.rb +307 -0
- data/lib/facets/more/times.rb +327 -0
- data/lib/facets/more/tracepoint.rb +183 -0
- data/lib/facets/more/tuple.rb +170 -0
- data/lib/facets/more/typecast.rb +280 -0
- data/lib/facets/more/uninheritable.rb +90 -0
- data/lib/facets/more/units.rb +938 -0
- data/lib/facets/more/yamlstruct.rb +90 -0
- metadata +680 -39
- data/data/facets/methods.yaml +0 -446
@@ -0,0 +1,39 @@
|
|
1
|
+
|
2
|
+
class Symbol
|
3
|
+
|
4
|
+
# Symbol's really are just simplified strings.
|
5
|
+
# Thus #to_str seems quite reasonable.
|
6
|
+
# This uses the Kernal#String method.
|
7
|
+
#--
|
8
|
+
# Maybe just change to #to_s?
|
9
|
+
# BTW: This would be lots faster, I bet, if implemented in core.
|
10
|
+
#++
|
11
|
+
def to_str
|
12
|
+
String( self )
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
# _____ _
|
20
|
+
# |_ _|__ ___| |_
|
21
|
+
# | |/ _ \/ __| __|
|
22
|
+
# | | __/\__ \ |_
|
23
|
+
# |_|\___||___/\__|
|
24
|
+
#
|
25
|
+
=begin test
|
26
|
+
|
27
|
+
require 'test/unit'
|
28
|
+
|
29
|
+
class TCSymbol < Test::Unit::TestCase
|
30
|
+
|
31
|
+
def test_to_str
|
32
|
+
assert_equal( "a", :a.to_str )
|
33
|
+
assert_equal( "abc", :abc.to_str )
|
34
|
+
assert_equal( '#$%', :'#$%'.to_str )
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
=end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
require 'facet/string/underscore'
|
3
|
+
|
4
|
+
class Symbol
|
5
|
+
|
6
|
+
def underscore
|
7
|
+
self.to_s.underscore.to_sym
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
# _____ _
|
15
|
+
# |_ _|__ ___| |_
|
16
|
+
# | |/ _ \/ __| __|
|
17
|
+
# | | __/\__ \ |_
|
18
|
+
# |_|\___||___/\__|
|
19
|
+
#
|
20
|
+
=begin test
|
21
|
+
|
22
|
+
require 'test/unit'
|
23
|
+
|
24
|
+
class TCSymbol < Test::Unit::TestCase
|
25
|
+
|
26
|
+
def test_underscore
|
27
|
+
assert_equal( :tis_a_test, :TisATest.underscore )
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
=end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
require 'facet/string/upcase'
|
3
|
+
|
4
|
+
class Symbol
|
5
|
+
|
6
|
+
def upcase
|
7
|
+
to_s.upcase.to_sym
|
8
|
+
end
|
9
|
+
|
10
|
+
def upcase?
|
11
|
+
to_s.upcase?
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
# _____ _
|
19
|
+
# |_ _|__ ___| |_
|
20
|
+
# | |/ _ \/ __| __|
|
21
|
+
# | | __/\__ \ |_
|
22
|
+
# |_|\___||___/\__|
|
23
|
+
#
|
24
|
+
=begin test
|
25
|
+
|
26
|
+
require 'test/unit'
|
27
|
+
|
28
|
+
class TCSymbol < Test::Unit::TestCase
|
29
|
+
|
30
|
+
def test_upcase?
|
31
|
+
assert( :TIS.upcase? )
|
32
|
+
assert( ! :Tis.upcase? )
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
=end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'facets/core/time/change'
|
2
|
+
require 'facets/core/time/elapse'
|
3
|
+
require 'facets/core/time/self/days_extrema'
|
4
|
+
require 'facets/core/time/self/stamp'
|
5
|
+
require 'facets/core/time/stamp'
|
6
|
+
require 'facets/core/time/to_date'
|
7
|
+
require 'facets/core/time/to_s'
|
8
|
+
require 'facets/core/time/to_time'
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class Time
|
2
|
+
|
3
|
+
# Returns a new Time where one or more of the elements
|
4
|
+
# have been changed according to the +options+ parameter.
|
5
|
+
# The time options (hour, minute, sec, usec) reset
|
6
|
+
# cascadingly, so if only the hour is passed, then
|
7
|
+
# minute, sec, and usec is set to 0. If the hour and
|
8
|
+
# minute is passed, then sec and usec is set to 0.
|
9
|
+
|
10
|
+
def change(options)
|
11
|
+
opts={}; options.each_pair{ |k,v| opts[k] = v.to_i }
|
12
|
+
self.class.send( self.utc? ? :utc : :local,
|
13
|
+
opts[:year] || self.year,
|
14
|
+
opts[:month] || self.month,
|
15
|
+
opts[:day] || self.day,
|
16
|
+
opts[:hour] || self.hour,
|
17
|
+
opts[:min] || (opts[:hour] ? 0 : self.min),
|
18
|
+
opts[:sec] || ((opts[:hour] || opts[:min]) ? 0 : self.sec),
|
19
|
+
opts[:usec] || ((opts[:hour] || opts[:min] || opts[:usec]) ? 0 : self.usec)
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
# _____ _
|
27
|
+
# |_ _|__ ___| |_
|
28
|
+
# | |/ _ \/ __| __|
|
29
|
+
# | | __/\__ \ |_
|
30
|
+
# |_|\___||___/\__|
|
31
|
+
#
|
32
|
+
=begin test
|
33
|
+
|
34
|
+
require 'test/unit'
|
35
|
+
require 'time'
|
36
|
+
|
37
|
+
class TCTime < Test::Unit::TestCase
|
38
|
+
|
39
|
+
def setup
|
40
|
+
@t = Time.parse('4/20/2006 15:37')
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_change
|
44
|
+
n = Time.now
|
45
|
+
n = n.change( :month=>4, :day=>20, :hour=>15, :min=>37, :year=>2006 )
|
46
|
+
assert_equal( @t, n )
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
=end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
class Time
|
3
|
+
|
4
|
+
# Tracks the elapse time of a code block.
|
5
|
+
#
|
6
|
+
# Time.elapse { sleep 1 } #=> 0.999188899993896
|
7
|
+
#
|
8
|
+
#--
|
9
|
+
# Credit goes to Hal Fulton.
|
10
|
+
#++
|
11
|
+
def self.elapse
|
12
|
+
raise "Need block" unless block_given?
|
13
|
+
t0 = Time.now.to_f
|
14
|
+
yield
|
15
|
+
Time.now.to_f - t0
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
# _____ _
|
22
|
+
# |_ _|__ ___| |_
|
23
|
+
# | |/ _ \/ __| __|
|
24
|
+
# | | __/\__ \ |_
|
25
|
+
# |_|\___||___/\__|
|
26
|
+
#
|
27
|
+
=begin test
|
28
|
+
|
29
|
+
require 'test/unit'
|
30
|
+
|
31
|
+
class TCTime < Test::Unit::TestCase
|
32
|
+
|
33
|
+
def test_elapse
|
34
|
+
t = Time.elapse { sleep 1 }
|
35
|
+
assert( (t > 0.9) && (t < 2.1 ))
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
=end
|
41
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# This method calculates the days extrema given two time objects.
|
2
|
+
# start time is the given time1 at 00:00:00
|
3
|
+
# end time is the given time2 at 23:59:59:999
|
4
|
+
#
|
5
|
+
# Input:
|
6
|
+
# - the two times (if only time1 is provided then you get an extrema
|
7
|
+
# of exactly one day extrema.
|
8
|
+
#
|
9
|
+
# Output:
|
10
|
+
# - the time range. you can get the start/end times using
|
11
|
+
# range methods.
|
12
|
+
#
|
13
|
+
#--
|
14
|
+
# Credit goes to George Moschovitis
|
15
|
+
#++
|
16
|
+
def Time.days_extrema(time1, time2=nil)
|
17
|
+
time2 = time1 if (not time2.valid? Time)
|
18
|
+
time2 = NEVER if (time2 <= time1)
|
19
|
+
start_time = Time.self.start_of_day(time1)
|
20
|
+
end_time = self.end_of_day(time2)
|
21
|
+
return (start_time..end_time)
|
22
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
|
2
|
+
class Time
|
3
|
+
|
4
|
+
def stamp( fmt = nil )
|
5
|
+
case fmt
|
6
|
+
when :db, :dbase, :database, :utc
|
7
|
+
strftime("%Y-%m-%d %H:%M:%S")
|
8
|
+
when :short
|
9
|
+
strftime("%e %b %H:%M")
|
10
|
+
when :long
|
11
|
+
strftime("%B %e, %Y %H:%M")
|
12
|
+
when :day1st, :dmYHM # TODO generalize
|
13
|
+
strftime("%d-%m-%Y %H:%M")
|
14
|
+
when String
|
15
|
+
strftime( fmt ).strip
|
16
|
+
else
|
17
|
+
strftime("%a %b %d %H:%M:%S %Z %Y")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.stamp(*args)
|
22
|
+
now.stamp(*args)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
# _____ _
|
29
|
+
# |_ _|__ ___| |_
|
30
|
+
# | |/ _ \/ __| __|
|
31
|
+
# | | __/\__ \ |_
|
32
|
+
# |_|\___||___/\__|
|
33
|
+
#
|
34
|
+
=begin test
|
35
|
+
|
36
|
+
require 'test/unit'
|
37
|
+
require 'time'
|
38
|
+
|
39
|
+
class TCTime < Test::Unit::TestCase
|
40
|
+
|
41
|
+
def setup
|
42
|
+
@t = Time.parse('4/20/2005 15:37')
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_stamp
|
46
|
+
assert_equal( "Wed Apr 20 15:37:00 EDT 2005", @t.stamp )
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
=end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
class Time
|
3
|
+
|
4
|
+
# Convert a Time to a Date. Time is a superset of Date.
|
5
|
+
# It is the year, month and day that are carried over.
|
6
|
+
def to_date
|
7
|
+
require 'date'
|
8
|
+
::Date.new(year, month, day)
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
# _____ _
|
15
|
+
# |_ _|__ ___| |_
|
16
|
+
# | |/ _ \/ __| __|
|
17
|
+
# | | __/\__ \ |_
|
18
|
+
# |_|\___||___/\__|
|
19
|
+
#
|
20
|
+
=begin test
|
21
|
+
|
22
|
+
require 'test/unit'
|
23
|
+
require 'time'
|
24
|
+
|
25
|
+
class TCTime < Test::Unit::TestCase
|
26
|
+
|
27
|
+
def setup
|
28
|
+
@t = Time.parse('4/20/2005 15:37')
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_to_date
|
32
|
+
assert_instance_of( ::Date, @t.to_date )
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
=end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'facet/time/stamp'
|
2
|
+
|
3
|
+
class Time
|
4
|
+
# Enhance #to_s by aliasing to #stamp.
|
5
|
+
alias_method :to_s, :stamp
|
6
|
+
end
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
# _____ _
|
11
|
+
# |_ _|__ ___| |_
|
12
|
+
# | |/ _ \/ __| __|
|
13
|
+
# | | __/\__ \ |_
|
14
|
+
# |_|\___||___/\__|
|
15
|
+
#
|
16
|
+
=begin test
|
17
|
+
|
18
|
+
require 'test/unit'
|
19
|
+
require 'time'
|
20
|
+
|
21
|
+
class TCTime < Test::Unit::TestCase
|
22
|
+
|
23
|
+
def setup
|
24
|
+
@t = Time.parse('4/20/2005 15:37')
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_to_s
|
28
|
+
assert_equal( "Wed Apr 20 15:37:00 EDT 2005", @t.to_s )
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
=end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
class Time
|
3
|
+
|
4
|
+
# To be able to keep Dates and Times interchangeable
|
5
|
+
# on conversions.
|
6
|
+
def to_time
|
7
|
+
self
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
# _____ _
|
14
|
+
# |_ _|__ ___| |_
|
15
|
+
# | |/ _ \/ __| __|
|
16
|
+
# | | __/\__ \ |_
|
17
|
+
# |_|\___||___/\__|
|
18
|
+
#
|
19
|
+
=begin test
|
20
|
+
|
21
|
+
require 'test/unit'
|
22
|
+
require 'time'
|
23
|
+
|
24
|
+
class TCTime < Test::Unit::TestCase
|
25
|
+
|
26
|
+
def setup
|
27
|
+
@t = Time.parse('4/20/2005 15:37')
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_to_time
|
31
|
+
assert_instance_of( ::Time, @t.to_time )
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
=end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'facets/core/unboundmethod/name'
|
@@ -0,0 +1,580 @@
|
|
1
|
+
#--
|
2
|
+
# Annotation
|
3
|
+
#
|
4
|
+
# Copyright (c) 2005 Thmas Sawyer
|
5
|
+
#
|
6
|
+
# Ruby License
|
7
|
+
#
|
8
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
9
|
+
# software under the same terms as Ruby.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
12
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
13
|
+
# FOR A PARTICULAR PURPOSE.
|
14
|
+
#
|
15
|
+
#================================================================================
|
16
|
+
# ChangeLog
|
17
|
+
#================================================================================
|
18
|
+
# 05.10.25 trans Initial release.
|
19
|
+
#================================================================================
|
20
|
+
#++
|
21
|
+
|
22
|
+
#:title: Annotations
|
23
|
+
#
|
24
|
+
# Annotations allows you to annontate objects, including methods with arbitrary
|
25
|
+
# "metadata". These annotations don't do anything in themselves. They are
|
26
|
+
# merely comments. But you can put them to use. For instance an attribute
|
27
|
+
# validator might check for an annotation called :valid and test against it.
|
28
|
+
#
|
29
|
+
# class X
|
30
|
+
# attr :a
|
31
|
+
# ann :@a, :valid => lambda{ |x| x.is_a?(Integer) }
|
32
|
+
#
|
33
|
+
# def validate
|
34
|
+
# instance_variables.each { |iv|
|
35
|
+
# if validator = self.class.ann(iv)[:valid]
|
36
|
+
# value = instance_variable_get(iv)
|
37
|
+
# unless validator.call(vale)
|
38
|
+
# raise "Invalid value #{value} for #{iv}"
|
39
|
+
# end
|
40
|
+
# end
|
41
|
+
# }
|
42
|
+
# end
|
43
|
+
#
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
# == Author(s)
|
47
|
+
#
|
48
|
+
# * Thomas Sawyer
|
49
|
+
#
|
50
|
+
|
51
|
+
require 'facets/core/array/merge'
|
52
|
+
|
53
|
+
require 'facets/more/openobject'
|
54
|
+
require 'facets/more/inheritor'
|
55
|
+
require 'facets/more/nullclass'
|
56
|
+
|
57
|
+
# Annotation is an OpenObject, and is used across the
|
58
|
+
# board for keeping annotations.
|
59
|
+
#
|
60
|
+
# Annotation class serves for both simple and
|
61
|
+
# and inherited cases depending on whether
|
62
|
+
# a base class is given.
|
63
|
+
#
|
64
|
+
class Annotation < OpenObject
|
65
|
+
|
66
|
+
def initialize( set={} )
|
67
|
+
super( set )
|
68
|
+
end
|
69
|
+
|
70
|
+
def inherits( base, &heritage )
|
71
|
+
@base = base
|
72
|
+
@heritage = heritage
|
73
|
+
self
|
74
|
+
end
|
75
|
+
|
76
|
+
def method_missing( sym, *args, &blk )
|
77
|
+
name = sym.to_s.gsub(/([=!?])$/, '').to_sym
|
78
|
+
type = sym.to_s[-1,1]
|
79
|
+
|
80
|
+
unless @base
|
81
|
+
r = super
|
82
|
+
return Kernel.null if r.nil? and type != '?'
|
83
|
+
return r
|
84
|
+
else
|
85
|
+
if type == '!'
|
86
|
+
unless __key__?( name )
|
87
|
+
parent = nil
|
88
|
+
@base.ancestors.each do |anc|
|
89
|
+
if ans = @heritage.call(anc) #anc.method_annotation[@key]
|
90
|
+
if parent = ans[name]
|
91
|
+
break
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
if parent
|
96
|
+
return __table__[name] = parent.dup #vs. __class__.new?
|
97
|
+
end
|
98
|
+
end
|
99
|
+
return super( name )
|
100
|
+
end
|
101
|
+
|
102
|
+
iob = dup
|
103
|
+
super
|
104
|
+
return inheritance if iob != self
|
105
|
+
return inheritance.__send__( sym, *args, &blk )
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def [](x)
|
110
|
+
@base ? inheritance[x] : super
|
111
|
+
end
|
112
|
+
|
113
|
+
def inheritance
|
114
|
+
return self unless @base
|
115
|
+
inh = @base.ancestors.collect{ |anc| @heritage.call(anc) }.compact
|
116
|
+
if inh
|
117
|
+
a = Annotation.new #( inh.pop.to_h )
|
118
|
+
#inh.push( a ) #.dup )
|
119
|
+
inh.reverse.inject(a){ |memo, i| memo.__merge__( i ) }
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
# This is a simple decorator for accessing a module's
|
127
|
+
# method annotations (and it's own annotations).
|
128
|
+
|
129
|
+
class Annotator < BasicObject #:nodoc:
|
130
|
+
def initialize( mod ) ; @mod = mod ; end
|
131
|
+
|
132
|
+
def inspect ; "#<Annotator #{@mod}>" ; end
|
133
|
+
|
134
|
+
def self ; @mod.annotation ; end
|
135
|
+
|
136
|
+
def [](sym)
|
137
|
+
sym == :self ? @mod.annotation : @mod.method_annotation( sym )
|
138
|
+
end
|
139
|
+
|
140
|
+
def method_missing( sym, *args, &blk )
|
141
|
+
type = sym.to_s[-1,1]
|
142
|
+
name = sym.to_s.gsub(/[=!?]$/, '').to_sym
|
143
|
+
|
144
|
+
return @mod.annotation if name == :self
|
145
|
+
|
146
|
+
r = @mod.method_annotation( name )
|
147
|
+
|
148
|
+
return nil if type == '?' and r == Kernel.null
|
149
|
+
return r
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
|
154
|
+
# Any object can be annotated.
|
155
|
+
|
156
|
+
module ::Kernel
|
157
|
+
# Store and retrieve annotations for an object.
|
158
|
+
def annotation( harg=nil )
|
159
|
+
@_annotation ||= Annotation.new
|
160
|
+
return @_annotation unless harg
|
161
|
+
@_annotation.__update__( harg )
|
162
|
+
end
|
163
|
+
|
164
|
+
#--
|
165
|
+
# Not sure about this. Perhaps is would be better to
|
166
|
+
# delegate to the singleton class instead?
|
167
|
+
# (Remarking out for the time being.)
|
168
|
+
#
|
169
|
+
#def ann( harg=nil )
|
170
|
+
# return annotation unless harg
|
171
|
+
# annotation.__update__( harg )
|
172
|
+
#end
|
173
|
+
#++
|
174
|
+
end
|
175
|
+
|
176
|
+
|
177
|
+
# Modules and Classes have more sifisticated annotation.
|
178
|
+
# They differ from normal object annotation in that
|
179
|
+
# the are inheritables.
|
180
|
+
|
181
|
+
class ::Module
|
182
|
+
|
183
|
+
#def annotation
|
184
|
+
# @_annotation ||= Annotation.new.inherits( self ){ |anc| anc.annotation }
|
185
|
+
#end
|
186
|
+
|
187
|
+
def annotation( harg=nil )
|
188
|
+
@_annotation ||= Annotation.new.inherits( self ){ |anc| anc.annotation }
|
189
|
+
return @_annotation unless harg
|
190
|
+
@_annotation.__update__( harg ) if harg
|
191
|
+
end
|
192
|
+
|
193
|
+
def method_annotation( key=nil )
|
194
|
+
@_method_annotation ||= {}
|
195
|
+
return @_method_annotation unless key
|
196
|
+
key = key.to_sym
|
197
|
+
if a = @_method_annotation[key]
|
198
|
+
return a
|
199
|
+
elsif ancestors.any? { |anc| anc.method_annotation[key] }
|
200
|
+
@_method_annotation[key] = Annotation.new.inherits( self ){ |anc| anc.method_annotation[key] }
|
201
|
+
else
|
202
|
+
null
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
# Does this module/class or its ancestors have any annotation
|
207
|
+
# for a given method?
|
208
|
+
def annotated?( key )
|
209
|
+
return annotation if self == key
|
210
|
+
r = method_annotation( key )
|
211
|
+
null == r ? nil : r
|
212
|
+
end
|
213
|
+
|
214
|
+
# Returns a list of all annotated methods.
|
215
|
+
def annotated_methods(include_ancestors=true)
|
216
|
+
annlist = []
|
217
|
+
if include_ancestors
|
218
|
+
ancestors.inject([]){ |memo, anc|
|
219
|
+
memo | anc.method_annotation.keys
|
220
|
+
}
|
221
|
+
else
|
222
|
+
method_annotation.keys
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
# Define annotation for a key. The note parameter must be
|
227
|
+
# a Hash or Hash-like object.
|
228
|
+
private
|
229
|
+
def define_annotation( key, note )
|
230
|
+
key = key.to_sym
|
231
|
+
method_annotation[key] = Annotation.new(note).inherits(self){ |anc| anc.method_annotation[key] }
|
232
|
+
method_annotation[key]
|
233
|
+
end
|
234
|
+
|
235
|
+
public
|
236
|
+
def ann(*args)
|
237
|
+
harg = args.last.is_a?(Hash) ? args.pop : {}
|
238
|
+
|
239
|
+
#return annotator if args.empty? and harg.empty?
|
240
|
+
return @_ann ||= Annotator.new( self ) if args.empty? and harg.empty?
|
241
|
+
|
242
|
+
# for array of "mini-hashes" format
|
243
|
+
if harg.empty? and Hash === args[0]
|
244
|
+
args.each{|e| e.each{|k,v| harg[k]=v}}
|
245
|
+
args = []
|
246
|
+
end
|
247
|
+
|
248
|
+
# querying a single annotation
|
249
|
+
if harg.empty? and args.size == 1
|
250
|
+
return annotation if self == args[0] or :self == args[0]
|
251
|
+
#return args[0].annotation unless args[0].is_a?(Symbol) or args[0].is_a?(String)
|
252
|
+
return method_annotation( args[0] ) #.inherit
|
253
|
+
end
|
254
|
+
|
255
|
+
# if last element is a class (and there are more then just the one element)
|
256
|
+
harg[:class] = args.pop if args.last.is_a?(Class) and args.size > 1
|
257
|
+
|
258
|
+
if args.empty? # hash format
|
259
|
+
harg.each do |key,hsh|
|
260
|
+
if key == :self
|
261
|
+
annotation.__update__( hsh )
|
262
|
+
next
|
263
|
+
end
|
264
|
+
note = annotated?( key )
|
265
|
+
if note and null != note
|
266
|
+
note.__update__( hsh )
|
267
|
+
else
|
268
|
+
define_annotation( key, hsh )
|
269
|
+
end
|
270
|
+
end
|
271
|
+
return harg.keys
|
272
|
+
else # name, hash format
|
273
|
+
args.each do |key|
|
274
|
+
if key == :self
|
275
|
+
annotation.__update__( harg )
|
276
|
+
next
|
277
|
+
end
|
278
|
+
note = annotated?( key )
|
279
|
+
if note and null != note
|
280
|
+
note.__update__( harg )
|
281
|
+
else
|
282
|
+
define_annotation( key, harg )
|
283
|
+
end
|
284
|
+
end
|
285
|
+
return args
|
286
|
+
end
|
287
|
+
|
288
|
+
end #def ann
|
289
|
+
|
290
|
+
end #class ::Module
|
291
|
+
|
292
|
+
|
293
|
+
# attr on steroids! Override the default implementations
|
294
|
+
# to support annotations.
|
295
|
+
|
296
|
+
class ::Module
|
297
|
+
|
298
|
+
inheritor :attributes, [], :|
|
299
|
+
|
300
|
+
def attr( *args )
|
301
|
+
args.flatten!
|
302
|
+
case args.last
|
303
|
+
when TrueClass
|
304
|
+
args.pop
|
305
|
+
attr_accessor( *args )
|
306
|
+
when FalseClass
|
307
|
+
args.pop
|
308
|
+
attr_reader( *args )
|
309
|
+
else
|
310
|
+
attr_reader( *args )
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
code = ''
|
315
|
+
[ :_reader, :_writer, :_accessor].each do |m|
|
316
|
+
|
317
|
+
d = case m
|
318
|
+
when :_reader
|
319
|
+
%{def %1$s; @%1$s; end}
|
320
|
+
when :_writer
|
321
|
+
%{def %1$s=(x); @%1$s = x; end}
|
322
|
+
when :_accessor
|
323
|
+
%{def %1$s; @%1$s; end ; def %1$s=(x); @%1$s = x; end}
|
324
|
+
else
|
325
|
+
%{def %1$s; @%1$s; end}
|
326
|
+
end
|
327
|
+
|
328
|
+
code << %{
|
329
|
+
def attr#{m}(*args)
|
330
|
+
args.flatten!
|
331
|
+
|
332
|
+
harg = {}
|
333
|
+
while args.last.is_a?(Hash) ; harg.update(args.pop) ; end
|
334
|
+
|
335
|
+
harg[:class] = args.pop if args.last.is_a?(Class)
|
336
|
+
|
337
|
+
raise if args.empty? and harg.empty?
|
338
|
+
|
339
|
+
if args.empty?
|
340
|
+
harg.each { |a,h|
|
341
|
+
module_eval( "#{d}" % a)
|
342
|
+
a = a.to_sym
|
343
|
+
define_annotation( a, h )
|
344
|
+
}
|
345
|
+
attributes!.merge!( harg.keys )
|
346
|
+
# return the names of the attributes created
|
347
|
+
return harg.keys
|
348
|
+
else
|
349
|
+
args.each { |a|
|
350
|
+
module_eval( "#{d}" % a)
|
351
|
+
a = a.to_sym
|
352
|
+
define_annotation( a, harg )
|
353
|
+
}
|
354
|
+
attributes!.merge!( args )
|
355
|
+
# return the names of the attributes created
|
356
|
+
return args
|
357
|
+
end
|
358
|
+
end
|
359
|
+
}
|
360
|
+
|
361
|
+
end
|
362
|
+
|
363
|
+
class_eval( code )
|
364
|
+
|
365
|
+
alias_method :attribute, :attr_accessor
|
366
|
+
|
367
|
+
end
|
368
|
+
|
369
|
+
|
370
|
+
# _____ _
|
371
|
+
# |_ _|__ ___| |_
|
372
|
+
# | |/ _ \/ __| __|
|
373
|
+
# | | __/\__ \ |_
|
374
|
+
# |_|\___||___/\__|
|
375
|
+
#
|
376
|
+
|
377
|
+
=begin testing
|
378
|
+
|
379
|
+
require 'test/unit'
|
380
|
+
|
381
|
+
class TC01 < Test::Unit::TestCase
|
382
|
+
class X
|
383
|
+
def x1 ; end
|
384
|
+
ann :x1, :q=>3
|
385
|
+
ann :x1, :a=>1
|
386
|
+
end
|
387
|
+
|
388
|
+
def test_01_001
|
389
|
+
assert_equal( 1, X.ann(:x1)[:a] )
|
390
|
+
assert_equal( 3, X.ann(:x1)[:q] )
|
391
|
+
assert_equal( null, X.ann(:x2) )
|
392
|
+
end
|
393
|
+
def test_01_002
|
394
|
+
assert_equal( 1, X.ann(:x1)[:a] )
|
395
|
+
assert_equal( 3, X.ann(:x1)[:q] )
|
396
|
+
assert_equal( nil, X.ann(:x1)[:c] )
|
397
|
+
end
|
398
|
+
def test_01_003
|
399
|
+
assert_equal( 1, X.ann.x1[:a] )
|
400
|
+
assert_equal( 3, X.ann.x1[:q] )
|
401
|
+
end
|
402
|
+
def test_01_004
|
403
|
+
assert_equal( 1, X.ann.x1.a )
|
404
|
+
assert_equal( 3, X.ann.x1.q )
|
405
|
+
end
|
406
|
+
def test_01_005
|
407
|
+
assert_equal( null, X.ann.x2 )
|
408
|
+
assert_equal( null, X.ann.x1.r )
|
409
|
+
end
|
410
|
+
def test_02_007
|
411
|
+
X.ann.x1.a = 2
|
412
|
+
assert_equal(2, X.ann.x1.a)
|
413
|
+
end
|
414
|
+
end
|
415
|
+
|
416
|
+
class TC02 < Test::Unit::TestCase
|
417
|
+
class X
|
418
|
+
def x ; end
|
419
|
+
ann :x, :z=>1
|
420
|
+
end
|
421
|
+
class Y < X
|
422
|
+
#ann :x, :y=>2
|
423
|
+
end
|
424
|
+
|
425
|
+
def test_02_001
|
426
|
+
assert( Y.annotated?( :x ) )
|
427
|
+
end
|
428
|
+
def test_02_002
|
429
|
+
#assert_equal( [:x1], Y.annotated_methods )
|
430
|
+
end
|
431
|
+
def test_02_003
|
432
|
+
#assert_equal( 1, Y.ann(:x).inheritance )
|
433
|
+
#assert_equal( 1, Y.ann(:x) )
|
434
|
+
end
|
435
|
+
def test_02_004
|
436
|
+
assert_equal(1, X.ann(:x)[:z])
|
437
|
+
assert_equal(1, Y.ann(:x)[:z])
|
438
|
+
end
|
439
|
+
def test_02_005
|
440
|
+
assert_equal(1, Y.ann(:x).z)
|
441
|
+
end
|
442
|
+
def test_02_006
|
443
|
+
assert_equal(1, Y.ann.x.z)
|
444
|
+
end
|
445
|
+
def test_02_007
|
446
|
+
Y.ann.x.z = 2
|
447
|
+
assert_equal(2, Y.ann.x.z)
|
448
|
+
end
|
449
|
+
end
|
450
|
+
|
451
|
+
class TC03 < Test::Unit::TestCase
|
452
|
+
class X
|
453
|
+
def n ; end
|
454
|
+
ann :n, :v=>1
|
455
|
+
ann :n, :p=>3
|
456
|
+
end
|
457
|
+
class Y < X
|
458
|
+
ann :n, :b=>2
|
459
|
+
end
|
460
|
+
|
461
|
+
def test_03_001
|
462
|
+
assert_equal(2, Y.ann(:n)[:b])
|
463
|
+
assert_equal(1, Y.ann(:n)[:v])
|
464
|
+
end
|
465
|
+
def test_03_002
|
466
|
+
assert_equal(2, Y.ann(:n).b)
|
467
|
+
end
|
468
|
+
def test_03_003
|
469
|
+
assert_equal(2, Y.ann.n.b)
|
470
|
+
end
|
471
|
+
def test_03_004
|
472
|
+
#assert_equal( [:n], Y.annotated_methods )
|
473
|
+
end
|
474
|
+
end
|
475
|
+
|
476
|
+
class TC04 < Test::Unit::TestCase
|
477
|
+
module M
|
478
|
+
ann :m, :c=>3
|
479
|
+
end
|
480
|
+
|
481
|
+
def test_04_001
|
482
|
+
assert_equal(3, M.ann.m.c)
|
483
|
+
end
|
484
|
+
end
|
485
|
+
|
486
|
+
class TC05 < Test::Unit::TestCase
|
487
|
+
module M
|
488
|
+
ann :m, :c=>3
|
489
|
+
end
|
490
|
+
class Y ; end
|
491
|
+
class Z < Y
|
492
|
+
include M
|
493
|
+
end
|
494
|
+
|
495
|
+
def test_05_001
|
496
|
+
assert_equal( 3, Z.ann.m.c )
|
497
|
+
end
|
498
|
+
end
|
499
|
+
|
500
|
+
class TC06 < Test::Unit::TestCase
|
501
|
+
module M
|
502
|
+
ann :m, String
|
503
|
+
end
|
504
|
+
|
505
|
+
def test_06_001
|
506
|
+
assert_equal( String, M.ann.m.class )
|
507
|
+
end
|
508
|
+
end
|
509
|
+
|
510
|
+
class TC07 < Test::Unit::TestCase
|
511
|
+
class K
|
512
|
+
ann self, :oid => 'key'
|
513
|
+
ann :w, String
|
514
|
+
end
|
515
|
+
|
516
|
+
def test_07_001
|
517
|
+
assert_equal( String, K.ann.w.class )
|
518
|
+
end
|
519
|
+
|
520
|
+
def test_07_002
|
521
|
+
assert_equal( 'key', K.ann.self.oid )
|
522
|
+
end
|
523
|
+
|
524
|
+
def test_07_003
|
525
|
+
#assert_equal( K.ann.self, K.ann(:self) )
|
526
|
+
#assert_equal( K.ann(K), K.annotation )
|
527
|
+
#assert_equal( K.ann.self.to_h, K.ann(K).to_h )
|
528
|
+
#assert_equal( K.ann.self, K.ann(K) )
|
529
|
+
end
|
530
|
+
end
|
531
|
+
|
532
|
+
class TC08 < Test::Unit::TestCase
|
533
|
+
module M
|
534
|
+
ann :this, :koko => []
|
535
|
+
ann.this.koko! << 1
|
536
|
+
end
|
537
|
+
class C1
|
538
|
+
#ann :this, :koko => []
|
539
|
+
include M
|
540
|
+
ann.this.koko! << 2
|
541
|
+
ann.this.koko! << 3
|
542
|
+
end
|
543
|
+
class C2
|
544
|
+
include M
|
545
|
+
ann.this.koko! << 4
|
546
|
+
end
|
547
|
+
|
548
|
+
def test_08_001
|
549
|
+
assert_equal( [1], M.ann.this.koko )
|
550
|
+
end
|
551
|
+
def test_08_002
|
552
|
+
assert_equal( [1,2,3], C1.ann.this.koko )
|
553
|
+
end
|
554
|
+
def test_08_003
|
555
|
+
assert_equal( [1,4], C2.ann.this.koko )
|
556
|
+
end
|
557
|
+
end
|
558
|
+
|
559
|
+
class TC09 < Test::Unit::TestCase
|
560
|
+
class A
|
561
|
+
attr_accessor :x, :cast=>"to_s"
|
562
|
+
end
|
563
|
+
|
564
|
+
def test_09_001
|
565
|
+
a = A.new
|
566
|
+
assert_equal( [:x], A.attributes )
|
567
|
+
end
|
568
|
+
end
|
569
|
+
|
570
|
+
class TC10 < Test::Unit::TestCase
|
571
|
+
class A
|
572
|
+
attr :x, :cast=>"to_s"
|
573
|
+
end
|
574
|
+
|
575
|
+
def test_10_001
|
576
|
+
assert_equal( "to_s", A.ann.x.cast )
|
577
|
+
end
|
578
|
+
end
|
579
|
+
|
580
|
+
=end
|