facets 1.3.3 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{doc/AUTHORS → AUTHORS} +12 -3
- data/README +35 -29
- data/WARNING +56 -0
- data/demo/annotation/demo_annotation.rb +22 -0
- data/demo/ansicolor/cdiff.rb +20 -0
- data/demo/ansicolor/example.rb +82 -0
- data/demo/io-reactor/chatserver.rb +347 -0
- data/demo/lisp/game.rb +47 -0
- data/lib/facet/all.rb +1 -0
- data/lib/facet/annattr.rb +1 -0
- data/lib/facet/class/to_proc.rb +1 -0
- data/lib/facet/cookie.rb +1 -0
- data/lib/facet/dir/self/descend.rb +1 -0
- data/lib/facet/enumerable/count.rb +1 -0
- data/lib/facet/hash/to_proc.rb +1 -0
- data/lib/facet/hashbuilder.rb +1 -0
- data/lib/facet/http.rb +1 -0
- data/lib/facet/httpaccess.rb +1 -0
- data/lib/facet/kernel/__get__.rb +1 -0
- data/lib/facet/kernel/__set__.rb +1 -0
- data/lib/facet/kernel/cache.rb +1 -0
- data/lib/facet/kernel/respond.rb +1 -0
- data/lib/facet/lazy.rb +1 -0
- data/lib/facet/module/class.rb +1 -0
- data/lib/facet/module/nodef.rb +1 -0
- data/lib/facet/opencascade.rb +1 -0
- data/lib/facet/pqueue.rb +1 -0
- data/lib/facet/taskable.rb +1 -0
- data/lib/facets.rb +98 -37
- data/lib/facets/core/all.rb +5 -0
- data/lib/facets/core/class/to_proc.rb +25 -0
- data/lib/facets/core/dir/self/ascend.rb +2 -1
- data/lib/facets/core/dir/self/descend.rb +11 -0
- data/lib/facets/core/enumerable/accumulate.rb +2 -2
- data/lib/facets/core/enumerable/count.rb +54 -0
- data/lib/facets/core/enumerable/cross.rb +3 -0
- data/lib/facets/core/enumerable/graph.rb +8 -4
- data/lib/facets/core/enumerable/self/cross.rb +11 -5
- data/lib/facets/core/hash/to_proc.rb +34 -0
- data/lib/facets/core/hash/traverse.rb +10 -5
- data/lib/facets/core/kernel/__class__.rb +1 -1
- data/lib/facets/core/kernel/__get__.rb +5 -0
- data/lib/facets/core/kernel/__set__.rb +2 -0
- data/lib/facets/core/kernel/assign_from.rb +1 -1
- data/lib/facets/core/kernel/assign_with.rb +11 -3
- data/lib/facets/core/kernel/bool.rb +1 -1
- data/lib/facets/core/kernel/cache.rb +31 -0
- data/lib/facets/core/kernel/demo.rb +4 -0
- data/lib/facets/core/kernel/get_by_id.rb +1 -0
- data/lib/facets/core/kernel/in.rb +1 -1
- data/lib/facets/core/kernel/instance_assign.rb +2 -3
- data/lib/facets/core/kernel/method.rb +25 -7
- data/lib/facets/core/kernel/methods.rb +1 -1
- data/lib/facets/core/kernel/new.rb +1 -1
- data/lib/facets/core/kernel/object_class.rb +1 -1
- data/lib/facets/core/kernel/object_hexid.rb +1 -1
- data/lib/facets/core/kernel/own.rb +1 -1
- data/lib/facets/core/kernel/require_all.rb +1 -0
- data/lib/facets/core/kernel/require_esc.rb +4 -2
- data/lib/facets/core/kernel/require_facet.rb +2 -0
- data/lib/facets/core/kernel/require_local.rb +1 -0
- data/lib/facets/core/kernel/respond.rb +14 -0
- data/lib/facets/core/kernel/send_as.rb +1 -1
- data/lib/facets/core/kernel/silence_warnings.rb +1 -1
- data/lib/facets/core/kernel/singleton.rb +3 -1
- data/lib/facets/core/matchdata/matchtree.rb +13 -3
- data/lib/facets/core/module/class.rb +3 -0
- data/lib/facets/core/module/integrate.rb +31 -4
- data/lib/facets/core/module/{undef.rb → nodef.rb} +8 -3
- data/lib/facets/core/module/revisal.rb +5 -5
- data/lib/facets/more/annattr.rb +147 -0
- data/lib/facets/more/annotation.rb +32 -136
- data/lib/facets/more/ansicode.rb +89 -100
- data/lib/facets/more/aspects.rb +28 -0
- data/lib/facets/more/association.rb +88 -47
- data/lib/facets/more/basicobject.rb +51 -33
- data/lib/facets/more/bbcode.rb +21 -34
- data/lib/facets/more/binaryreader.rb +62 -33
- data/lib/facets/more/bitmask.rb +24 -24
- data/lib/facets/more/blankslate.rb +4 -0
- data/lib/facets/more/builderobject.rb +16 -20
- data/lib/facets/more/bytes.rb +43 -24
- data/lib/facets/more/classinherit.rb +15 -31
- data/lib/facets/more/classmethods.rb +19 -29
- data/lib/facets/more/cloneable.rb +42 -30
- data/lib/facets/more/consoleapp.rb +42 -22
- data/lib/facets/more/cookie.rb +565 -0
- data/lib/facets/more/coroutine.rb +17 -21
- data/lib/facets/more/crypt.rb +33 -12
- data/lib/facets/more/dictionary.rb +27 -36
- data/lib/facets/more/downloader.rb +21 -17
- data/lib/facets/more/elementor.rb +22 -0
- data/lib/facets/more/enumerablepass.rb +19 -27
- data/lib/facets/more/expirable.rb +18 -28
- data/lib/facets/more/filelist.rb +33 -32
- data/lib/facets/more/floatstring.rb +31 -40
- data/lib/facets/more/functor.rb +15 -25
- data/lib/facets/more/hashbuilder.rb +76 -0
- data/lib/facets/more/heap.rb +29 -36
- data/lib/facets/more/htmlbuilder.rb +22 -24
- data/lib/facets/more/htmlhelper.rb +89 -0
- data/lib/facets/more/http.rb +570 -0
- data/lib/facets/more/httpaccess.rb +1608 -0
- data/lib/facets/more/inheritor.rb +29 -21
- data/lib/facets/more/interval.rb +21 -25
- data/lib/facets/more/ioredirect.rb +21 -25
- data/lib/facets/more/json.rb +27 -17
- data/lib/facets/more/lazy.rb +238 -0
- data/lib/facets/more/lisp.rb +24 -27
- data/lib/facets/more/lisp_format.rb +93 -85
- data/lib/facets/more/lrucache.rb +17 -27
- data/lib/facets/more/mathconstants.rb +22 -40
- data/lib/facets/more/methodprobe.rb +56 -61
- data/lib/facets/more/mock.rb +24 -17
- data/lib/facets/more/multipliers.rb +21 -17
- data/lib/facets/more/multiton.rb +18 -24
- data/lib/facets/more/nackclass.rb +17 -21
- data/lib/facets/more/nilcomparable.rb +28 -30
- data/lib/facets/more/nullclass.rb +16 -15
- data/lib/facets/more/one.rb +94 -58
- data/lib/facets/more/opencascade.rb +187 -0
- data/lib/facets/more/openobject.rb +89 -66
- data/lib/facets/more/orderedhash.rb +4 -0
- data/lib/facets/more/ormsupport.rb +18 -29
- data/lib/facets/more/overload.rb +39 -3
- data/lib/facets/more/paramix.rb +16 -24
- data/lib/facets/more/pathlist.rb +17 -23
- data/lib/facets/more/pool.rb +21 -29
- data/lib/facets/more/pqueue.rb +190 -0
- data/lib/facets/more/preinitialize.rb +17 -18
- data/lib/facets/more/progressbar.rb +19 -15
- data/lib/facets/more/promoteself.rb +17 -21
- data/lib/facets/more/quaternion.rb +379 -346
- data/lib/facets/more/recorder.rb +15 -20
- data/lib/facets/more/reference.rb +25 -22
- data/lib/facets/more/rexmlbuilder.rb +21 -6
- data/lib/facets/more/rtals.rb +27 -24
- data/lib/facets/more/semaphore.rb +15 -28
- data/lib/facets/more/snapshot.rb +45 -41
- data/lib/facets/more/stateparser.rb +25 -35
- data/lib/facets/more/statichash.rb +37 -29
- data/lib/facets/more/syncarray.rb +18 -26
- data/lib/facets/more/synchash.rb +17 -26
- data/lib/facets/more/system.rb +25 -17
- data/lib/facets/more/tagiterator.rb +15 -39
- data/lib/facets/more/taskable.rb +417 -0
- data/lib/facets/more/timer.rb +22 -26
- data/lib/facets/more/times.rb +23 -23
- data/lib/facets/more/tracepoint.rb +25 -24
- data/lib/facets/more/tuple.rb +25 -42
- data/lib/facets/more/typecast.rb +27 -29
- data/lib/facets/more/uninheritable.rb +15 -22
- data/lib/facets/more/units.rb +23 -29
- data/lib/facets/more/xmlbuilder.rb +20 -22
- data/lib/facets/more/xmlhelper.rb +18 -21
- data/lib/facets/more/xoxo.rb +23 -11
- data/lib/facets/more/yamlstruct.rb +25 -22
- 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_pot.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_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/class/test_cattr.rb +1 -1
- 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_count.rb +38 -0
- 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 +1 -1
- data/test/lib/facets/core/file/self/test_open_as_string.rb +1 -1
- data/test/lib/facets/core/file/self/test_read_list.rb +1 -1
- 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_methodname.rb +1 -1
- 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 +7 -2
- 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 +1 -1
- 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_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_undef.rb → test_nodef.rb} +5 -5
- data/test/lib/facets/core/module/test_on_included.rb +1 -1
- 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_this.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_blank.rb +1 -1
- 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/numeric/test_approx.rb +1 -1
- 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_pot.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_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_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_annattr.rb +39 -0
- data/test/lib/facets/more/test_annotatedattr.rb +39 -0
- data/test/lib/facets/more/test_annotation.rb +1 -22
- data/test/lib/facets/more/test_ansicode.rb +1 -1
- data/test/lib/facets/more/test_association.rb +6 -1
- data/test/lib/facets/more/test_basicobject.rb +1 -1
- data/test/lib/facets/more/test_bbcode.rb +1 -1
- data/test/lib/facets/more/test_binaryreader.rb +64 -0
- 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 +1 -1
- 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_htmlbuilder.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 +1 -1
- 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 +1 -1
- data/test/lib/facets/more/test_opencascade.rb +66 -0
- data/test/lib/facets/more/test_openobject.rb +14 -2
- 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_pqueue.rb +39 -0
- 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 +1 -1
- data/test/lib/facets/more/test_snapshot.rb +1 -1
- data/test/lib/facets/more/test_statichash.rb +11 -11
- 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_taskable.rb +151 -0
- 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 +1 -1
- data/test/lib/facets/more/test_uninheritable.rb +1 -1
- data/test/lib/facets/more/test_units.rb +1 -1
- data/test/lib/facets/more/test_xmlbuilder.rb +1 -1
- data/test/lib/facets/more/test_xmlhelper.rb +1 -1
- data/test/lib/facets/more/test_xoxo.rb +1 -1
- data/test/lib/facets/more/test_yamlstruct.rb +1 -1
- metadata +1243 -1247
- data/ProjectInfo +0 -89
- data/Rakefile +0 -181
- data/doc/CHANGELOG +0 -284
- data/doc/TODO +0 -73
- data/doc/noauto +0 -63
- data/lib/facet/array.rb +0 -1
- data/lib/facet/class.rb +0 -1
- data/lib/facet/comparable.rb +0 -1
- data/lib/facet/continuation.rb +0 -1
- data/lib/facet/date.rb +0 -1
- data/lib/facet/dir.rb +0 -1
- data/lib/facet/enumerable.rb +0 -1
- data/lib/facet/file.rb +0 -1
- data/lib/facet/fileutils.rb +0 -1
- data/lib/facet/float.rb +0 -1
- data/lib/facet/gem.rb +0 -1
- data/lib/facet/hash.rb +0 -1
- data/lib/facet/integer.rb +0 -1
- data/lib/facet/kernel.rb +0 -1
- data/lib/facet/logger.rb +0 -1
- data/lib/facet/matchdata.rb +0 -1
- data/lib/facet/module.rb +0 -1
- data/lib/facet/module/undef.rb +0 -1
- data/lib/facet/nilclass.rb +0 -1
- data/lib/facet/numeric.rb +0 -1
- data/lib/facet/pathname.rb +0 -1
- data/lib/facet/proc.rb +0 -1
- data/lib/facet/range.rb +0 -1
- data/lib/facet/regexp.rb +0 -1
- data/lib/facet/string.rb +0 -1
- data/lib/facet/symbol.rb +0 -1
- data/lib/facet/time.rb +0 -1
- data/lib/facet/unboundmethod.rb +0 -1
- data/lib/facets/core/array.rb +0 -35
- data/lib/facets/core/class.rb +0 -11
- data/lib/facets/core/comparable.rb +0 -5
- data/lib/facets/core/continuation.rb +0 -1
- data/lib/facets/core/date.rb +0 -6
- data/lib/facets/core/dir.rb +0 -4
- data/lib/facets/core/enumerable.rb +0 -42
- data/lib/facets/core/file.rb +0 -8
- data/lib/facets/core/fileutils.rb +0 -8
- data/lib/facets/core/float.rb +0 -4
- data/lib/facets/core/gem.rb +0 -4
- data/lib/facets/core/hash.rb +0 -40
- data/lib/facets/core/integer.rb +0 -9
- data/lib/facets/core/kernel.rb +0 -69
- data/lib/facets/core/logger.rb +0 -2
- data/lib/facets/core/matchdata.rb +0 -3
- data/lib/facets/core/module.rb +0 -43
- data/lib/facets/core/nilclass.rb +0 -9
- data/lib/facets/core/numeric.rb +0 -6
- data/lib/facets/core/pathname.rb +0 -2
- data/lib/facets/core/proc.rb +0 -3
- data/lib/facets/core/range.rb +0 -4
- data/lib/facets/core/regexp.rb +0 -3
- data/lib/facets/core/string.rb +0 -91
- data/lib/facets/core/symbol.rb +0 -13
- data/lib/facets/core/time.rb +0 -8
- data/lib/facets/core/unboundmethod.rb +0 -1
data/{doc/AUTHORS → AUTHORS}
RENAMED
@@ -1,5 +1,11 @@
|
|
1
|
+
= Facets Contributing Authors
|
1
2
|
|
2
|
-
|
3
|
+
== Main Developers
|
4
|
+
|
5
|
+
* Trans (Thomas Sawyer)
|
6
|
+
* Florian Gross
|
7
|
+
* George Moschovitis
|
8
|
+
* Peter Vanbroekhoven
|
3
9
|
|
4
10
|
== Rubyists of Distinction
|
5
11
|
|
@@ -9,13 +15,15 @@
|
|
9
15
|
* Jamis Buck
|
10
16
|
* Renald Buter
|
11
17
|
* Shashank Date
|
18
|
+
* Robert Feldt
|
12
19
|
* Florian Frank
|
13
20
|
* Hal Fulton
|
14
21
|
* Michael Granger
|
15
22
|
* Florian Gross
|
16
23
|
* Thomas-Ivo Heinen
|
17
|
-
* David
|
24
|
+
* David Heinemeier Hansson
|
18
25
|
* Ara T. Howard
|
26
|
+
* MenTaLguY
|
19
27
|
* Mohammad Khan
|
20
28
|
* Derek Lewis
|
21
29
|
* Jan Molic
|
@@ -30,7 +38,8 @@
|
|
30
38
|
* Jim Weirich
|
31
39
|
* Jeff Wood
|
32
40
|
* Austin Ziegler
|
33
|
-
*
|
41
|
+
* Why The Lucky Stiff
|
34
42
|
|
35
43
|
If any names are missing from this list, please let me know
|
36
44
|
and I will correct immediately.
|
45
|
+
|
data/README
CHANGED
@@ -8,9 +8,10 @@
|
|
8
8
|
|
9
9
|
Ruby Facets
|
10
10
|
|
11
|
+
Facets is set of two libraries Facets/CORE and Facets/MORE.
|
12
|
+
|
11
13
|
Facets/CORE is a vast collection of methods which extend the core
|
12
14
|
capabilities of Ruby's built-in classes and modules.
|
13
|
-
|
14
15
|
This collection of extension methods is unique by virtue of its atomicity.
|
15
16
|
The methods are stored individually so that each can be required
|
16
17
|
independently. This gives developers fine-grain control over which
|
@@ -18,10 +19,9 @@ extra methods to bring into his or her code. The collection currently
|
|
18
19
|
contains over 400 methods spanning 28 classes and modules.
|
19
20
|
|
20
21
|
Facets/MORE is a collection of additioanl classes, modules and microframeworks.
|
21
|
-
|
22
22
|
The class, module and microframework additions consitute an ever growing
|
23
|
-
and improving source of reusable components. Some very nice
|
24
|
-
|
23
|
+
and improving source of reusable components. Some very nice additions
|
24
|
+
are available, from an amazing Units system to an elegant
|
25
25
|
annotations systems. And of course there are all the more typical goodies
|
26
26
|
like Tuple, Functor and Multiton.
|
27
27
|
|
@@ -29,7 +29,7 @@ like Tuple, Functor and Multiton.
|
|
29
29
|
|
30
30
|
Facets holds to the notion that the more we can reasonably integrate into
|
31
31
|
a common foundation directed toward general needs, the better that foundation
|
32
|
-
will be able to serve
|
32
|
+
will be able to serve everyone. There are a number of advantages here:
|
33
33
|
|
34
34
|
* Better Code-reuse
|
35
35
|
* Collaborative Improvements
|
@@ -39,18 +39,17 @@ will be able to serve us. There are a number of advantages here:
|
|
39
39
|
|
40
40
|
== Status
|
41
41
|
|
42
|
-
The current status is quite good. While
|
43
|
-
|
42
|
+
The current status is quite good. While some parts are still considered
|
43
|
+
beta, everything is relatively usable.
|
44
44
|
|
45
45
|
|
46
46
|
== Installation
|
47
47
|
|
48
|
-
|
49
48
|
The easiest way to install is via RubyGems. On the command line enter:
|
50
49
|
|
51
50
|
> gem install facets
|
52
51
|
|
53
|
-
To manually install, unpack the .
|
52
|
+
To manually install, unpack the .tar.bz2 package and use the included
|
54
53
|
setup.rb script. For example:
|
55
54
|
|
56
55
|
> tar -xvzf facets,YYYY-MM-DD.tbz
|
@@ -63,24 +62,27 @@ setup.rb script. For example:
|
|
63
62
|
For detailed usage of any given method or module please refer to the
|
64
63
|
API RDocs. Most are well documented.
|
65
64
|
|
66
|
-
To use a single facet you simply require the method by name, for example:
|
65
|
+
To use a single CORE facet you simply require the method by name, for example:
|
67
66
|
|
68
67
|
require 'facet/time/stamp'
|
69
68
|
|
70
69
|
Techinally this requires a redirection file to the core method itself.
|
71
|
-
|
70
|
+
Redirection can be bypassed. Eg.
|
72
71
|
|
73
72
|
require 'facets/core/time/stamp'
|
74
73
|
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
But this usage is discouraged and should only be used if it is for some
|
75
|
+
reason neccessary or you are developing a library for Facets itself.
|
76
|
+
|
77
|
+
If you are using more then a few facets it is recommended that before
|
78
|
+
requiring any of them you first require the main facility.
|
78
79
|
|
79
80
|
require 'facets'
|
80
81
|
|
81
|
-
This loads
|
82
|
-
and
|
83
|
-
allows you to require facets without
|
82
|
+
This loads a set of facets considered "base" --currently a couple dozen
|
83
|
+
very basic methods, and adds the facets library directories to the end
|
84
|
+
of Ruby's load path. This allows you to require facets without even using
|
85
|
+
the 'facet/...' prefix. Eg.
|
84
86
|
|
85
87
|
require 'string/blank'
|
86
88
|
|
@@ -88,14 +90,20 @@ A handful of extension sets are also available. For example,
|
|
88
90
|
|
89
91
|
require 'facet/string_as_array'
|
90
92
|
|
91
|
-
adds some methods to Array that
|
92
|
-
an array of characters. Other useful sets include, 'random' which
|
93
|
+
adds some methods to Array that allow a String to behave more like
|
94
|
+
an array of characters. Other useful sets include, 'random' which
|
93
95
|
loads every facet method related to randomness and 'inflect' which
|
94
96
|
loads a number of methods for manipulating strings in high-level
|
95
97
|
ways, like #camelize and #pluralize.
|
96
98
|
|
97
|
-
|
98
|
-
|
99
|
+
It also should be pointed out that class methods are stored under
|
100
|
+
the 'self' directory of a class. For example, to load the
|
101
|
+
File::read_list method.
|
102
|
+
|
103
|
+
require 'facet/file/self/read_list'
|
104
|
+
|
105
|
+
Using a Facets/MORE library of modules, classes or microframeworks
|
106
|
+
is essentially the same. You can use the redirection path. Eg.
|
99
107
|
|
100
108
|
require 'facet/basicobject'
|
101
109
|
|
@@ -108,9 +116,9 @@ Again, if you load the main facility, you can eliminate the need for the 'facet/
|
|
108
116
|
require 'facets'
|
109
117
|
require 'basicobject'
|
110
118
|
|
111
|
-
Understand that on the off chance that
|
112
|
-
one of Facets' everything will still work fine. You will not be able to use the
|
113
|
-
prefixless shorcut to require
|
119
|
+
Understand that on the off chance that another library has the same name as
|
120
|
+
one of Facets' everything will still work fine. You will just not be able to use the
|
121
|
+
prefixless shorcut to require it.
|
114
122
|
|
115
123
|
For details pertaining to the functionality of each feature, please see the API Docs.
|
116
124
|
|
@@ -119,7 +127,7 @@ For details pertaining to the functionality of each feature, please see the API
|
|
119
127
|
|
120
128
|
=== Directories
|
121
129
|
|
122
|
-
There are
|
130
|
+
There are two subdirectories in Facets library, 'core', which stores
|
123
131
|
the method extensions and 'more' which store the modules, classes and
|
124
132
|
micorframeworks.
|
125
133
|
|
@@ -224,10 +232,8 @@ A copy of both licenses accompany this document (see COPYING).
|
|
224
232
|
|
225
233
|
Credit and Copyrights for particular borrowed code segments are
|
226
234
|
given in their respective source. All licenses are either compatible
|
227
|
-
with the Ruby
|
228
|
-
permission for inclusion of their code under
|
229
|
-
|
230
|
-
Any code file not specifically labeled shall fall under the Ruby License.
|
235
|
+
with the Ruby license (namely the GPL) or the original author has given
|
236
|
+
permission for inclusion of their code under such lincense.</p>
|
231
237
|
|
232
238
|
|
233
239
|
== Pitch
|
data/WARNING
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
|
2
|
+
# Some caution should be taken when using certain facets.
|
3
|
+
# What follows ois list of such facets and the reasons
|
4
|
+
# these particular facets should given special consideration.
|
5
|
+
|
6
|
+
# Some facets require other files to be loaded first
|
7
|
+
# that are not loaded automatically, like fileutils
|
8
|
+
# (i.e. they are part of the standard lib, not core).
|
9
|
+
# The file include all of the following.
|
10
|
+
|
11
|
+
date/*
|
12
|
+
fileutils/*
|
13
|
+
ostruct/*
|
14
|
+
logger/*
|
15
|
+
gem/*
|
16
|
+
|
17
|
+
# Others effect the system in slightly non-standard ways.
|
18
|
+
# Though such changes are kept to a minumim and intended
|
19
|
+
# to be backward compatible, there still may be edge cases
|
20
|
+
# that could cause another library to misbehave.
|
21
|
+
# The following is a list known facets that may have
|
22
|
+
# this potential.
|
23
|
+
|
24
|
+
array/op_fetch.rb
|
25
|
+
array/op_store.rb
|
26
|
+
binding/self/of_caller.rb
|
27
|
+
hash/op_fetch.rb
|
28
|
+
hash/op_store.rb
|
29
|
+
numeric/succ.rb
|
30
|
+
numeric/pred.rb
|
31
|
+
string/succ.rb
|
32
|
+
string/unpack.rb
|
33
|
+
module/attr.rb
|
34
|
+
#module/attr_reader.rb
|
35
|
+
#module/attr_writer.rb
|
36
|
+
#module/attr_accessor.rb
|
37
|
+
|
38
|
+
# There are also some facets that are potentially unsafe b/c
|
39
|
+
# they change Ruby's default behavior in a nonconvential
|
40
|
+
# manner and hence are not designed to be backward compatible.
|
41
|
+
# Using these with a pre-existent program may cause the program
|
42
|
+
# to misbehave. So while they can be useful, be sure to
|
43
|
+
# understand exactly what they do before putting them to
|
44
|
+
# serious use.
|
45
|
+
|
46
|
+
hash/each.rb
|
47
|
+
module/methods.rb
|
48
|
+
object/method.rb
|
49
|
+
nilclass/op_fetch.rb
|
50
|
+
nilclass/empty.rb
|
51
|
+
nilclass/include.rb
|
52
|
+
nilclass/size.rb
|
53
|
+
nilclass/length.rb
|
54
|
+
nilclass/method_missing.rb
|
55
|
+
|
56
|
+
#
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'mega/annotation'
|
2
|
+
|
3
|
+
module M
|
4
|
+
ann :this, :koko => []
|
5
|
+
ann.this.koko! << 1
|
6
|
+
end
|
7
|
+
|
8
|
+
class C1
|
9
|
+
include M
|
10
|
+
ann.this.koko! << 2
|
11
|
+
ann.this.koko! << 3
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
class C2
|
16
|
+
include M
|
17
|
+
ann.this.koko! << 4
|
18
|
+
end
|
19
|
+
|
20
|
+
p M.ann.this.koko # => expected [1]
|
21
|
+
p C1.ann.this.koko # => expected [1, 2, 3]
|
22
|
+
p C2.ann.this.koko # => expectes [1, 4]
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
## Little unix filter that colorizes diff output
|
4
|
+
#
|
5
|
+
|
6
|
+
require 'term/ansicolor'
|
7
|
+
|
8
|
+
include Term::ANSIColor
|
9
|
+
|
10
|
+
ARGF.each do |line|
|
11
|
+
print(
|
12
|
+
case line
|
13
|
+
when /^\+/ then green { line }
|
14
|
+
when /^-/ then red { line }
|
15
|
+
when /^(@@|diff)/ then blue { line }
|
16
|
+
else line
|
17
|
+
end
|
18
|
+
)
|
19
|
+
end
|
20
|
+
# vim: set et sw=2 ts=2:
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'term/ansicolor'
|
2
|
+
|
3
|
+
# Use this trick to work around namespace cluttering that
|
4
|
+
# happens if you just include Term::ANSIColor:
|
5
|
+
|
6
|
+
class Color
|
7
|
+
class << self
|
8
|
+
include Term::ANSIColor
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
print Color.red, Color.bold, "No Namespace cluttering:", Color.clear, "\n"
|
13
|
+
print Color.green + "green" + Color.clear, "\n"
|
14
|
+
print Color.on_red(Color.green("green")), "\n"
|
15
|
+
print Color.yellow { Color.on_black { "yellow on_black" } }, "\n\n"
|
16
|
+
|
17
|
+
# Anyway, I don't define any of Term::ANSIColor's methods in this example
|
18
|
+
# and I want to keep it short:
|
19
|
+
include Term::ANSIColor
|
20
|
+
|
21
|
+
print red, bold, "Usage as constants:", reset, "\n"
|
22
|
+
print clear, "clear", reset, reset, "reset", reset,
|
23
|
+
bold, "bold", reset, dark, "dark", reset,
|
24
|
+
underscore, "underscore", reset, blink, "blink", reset,
|
25
|
+
negative, "negative", reset, concealed, "concealed", reset, "|\n",
|
26
|
+
black, "black", reset, red, "red", reset, green, "green", reset,
|
27
|
+
yellow, "yellow", reset, blue, "blue", reset, magenta, "magenta", reset,
|
28
|
+
cyan, "cyan", reset, white, "white", reset, "|\n",
|
29
|
+
on_black, "on_black", reset, on_red, "on_red", reset,
|
30
|
+
on_green, "on_green", reset, on_yellow, "on_yellow", reset,
|
31
|
+
on_blue, "on_blue", reset, on_magenta, "on_magenta", reset,
|
32
|
+
on_cyan, "on_cyan", reset, on_white, "on_white", reset, "|\n\n"
|
33
|
+
|
34
|
+
print red, bold, "Usage as unary functions:", reset, "\n"
|
35
|
+
print clear("clear"), reset("reset"), bold("bold"), dark("dark"),
|
36
|
+
underscore("underscore"), blink("blink"), negative("negative"),
|
37
|
+
concealed("concealed"), "|\n",
|
38
|
+
black("black"), red("red"), green("green"), yellow("yellow"),
|
39
|
+
blue("blue"), magenta("magenta"), cyan("cyan"), white("white"), "|\n",
|
40
|
+
on_black("on_black"), on_red("on_red"), on_green("on_green"),#
|
41
|
+
on_yellow("on_yellow"), on_blue("on_blue"), on_magenta("on_magenta"),
|
42
|
+
on_cyan("on_cyan"), on_white("on_white"), "|\n\n"
|
43
|
+
|
44
|
+
print red { bold { "Usage as block forms:" } }, "\n"
|
45
|
+
print clear { "clear" }, reset { "reset" }, bold { "bold" },
|
46
|
+
dark { "dark" }, underscore { "underscore" }, blink { "blink" },
|
47
|
+
negative { "negative" }, concealed { "concealed" }, "|\n",
|
48
|
+
black { "black" }, red { "red" }, green { "green" },
|
49
|
+
yellow { "yellow" }, blue { "blue" }, magenta { "magenta" },
|
50
|
+
cyan { "cyan" }, white { "white" }, "|\n",
|
51
|
+
on_black { "on_black" }, on_red { "on_red" }, on_green { "on_green" },
|
52
|
+
on_yellow { "on_yellow" }, on_blue { "on_blue" },
|
53
|
+
on_magenta { "on_magenta" }, on_cyan { "on_cyan" },
|
54
|
+
on_white { "on_white" }, "|\n\n"
|
55
|
+
|
56
|
+
# Usage as Mixin into String or its Subclasses
|
57
|
+
class String
|
58
|
+
include Term::ANSIColor
|
59
|
+
end
|
60
|
+
|
61
|
+
print "Usage as String Mixins:".red.bold, "\n"
|
62
|
+
print "clear".clear, "reset".reset, "bold".bold, "dark".dark,
|
63
|
+
"underscore".underscore, "blink".blink, "negative".negative,
|
64
|
+
"concealed".concealed, "|\n",
|
65
|
+
"black".black, "red".red, "green".green, "yellow".yellow,
|
66
|
+
"blue".blue, "magenta".magenta, "cyan".cyan, "white".white, "|\n",
|
67
|
+
"on_black".on_black, "on_red".on_red, "on_green".on_green,
|
68
|
+
"on_yellow".on_yellow, "on_blue".on_blue, "on_magenta".on_magenta,
|
69
|
+
"on_cyan".on_cyan, "on_white".on_white, "|\n\n"
|
70
|
+
|
71
|
+
symbols = Term::ANSIColor::attributes
|
72
|
+
print red { bold { "All supported attributes = " } },
|
73
|
+
blue { symbols.inspect }, "\n\n"
|
74
|
+
|
75
|
+
print "Send symbols to strings:".send(:red).send(:bold), "\n"
|
76
|
+
print symbols[12, 8].map { |c| c.to_s.send(c) }, "\n\n"
|
77
|
+
|
78
|
+
print red { bold { "Make strings monochromatic again:" } }, "\n"
|
79
|
+
print [ "red".red, "not red anymore".red.uncolored,
|
80
|
+
uncolored { "not red anymore".red }, uncolored("not red anymore".red)
|
81
|
+
].map { |x| x + "\n" }
|
82
|
+
# vim: set et sw=2 ts=2:
|
@@ -0,0 +1,347 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# = chatserver.rb
|
3
|
+
#
|
4
|
+
# This is an extremely crude and simple single-threaded multiplexing chat
|
5
|
+
# server. It (hopefully) demonstrates how to use a IO::Reactor object to do IO
|
6
|
+
# multiplexing with events.
|
7
|
+
#
|
8
|
+
# == Synopsis
|
9
|
+
#
|
10
|
+
# $ chatserver.rb [HOST [PORT [LOOPTIMEOUT]]]
|
11
|
+
#
|
12
|
+
# [HOST]
|
13
|
+
# The host or IP the server will bind to
|
14
|
+
#
|
15
|
+
# [PORT]
|
16
|
+
# The port the server will listen on
|
17
|
+
#
|
18
|
+
# [LOOPTIMEOUT]
|
19
|
+
# The number of floating-point seconds between polls. Specifying -1 (or any
|
20
|
+
# negative number, really) here will make the server's event loop block on the
|
21
|
+
# call to #poll.
|
22
|
+
#
|
23
|
+
# == Author
|
24
|
+
#
|
25
|
+
# Michael Granger <ged@FaerieMUD.org>
|
26
|
+
#
|
27
|
+
# Copyright (c) 2002, 2003 The FaerieMUD Consortium. All rights reserved.
|
28
|
+
#
|
29
|
+
# This program is free software. You may use, modify, and/or redistribute this
|
30
|
+
# software under the same terms as Ruby itself.
|
31
|
+
#
|
32
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
33
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
34
|
+
# FOR A PARTICULAR PURPOSE.
|
35
|
+
#
|
36
|
+
# == Version
|
37
|
+
#
|
38
|
+
# $Id: chatserver.rb,v 1.4 2003/08/04 23:53:32 deveiant Exp $
|
39
|
+
#
|
40
|
+
|
41
|
+
require 'io/reactor'
|
42
|
+
require 'socket'
|
43
|
+
|
44
|
+
module Example
|
45
|
+
|
46
|
+
### Chatserver user class -- part of the chatserver example.
|
47
|
+
class User
|
48
|
+
|
49
|
+
MTU = 4096
|
50
|
+
CR = "\015"
|
51
|
+
LF = "\012"
|
52
|
+
EOL = CR + LF
|
53
|
+
|
54
|
+
PROMPT = 'chat> '
|
55
|
+
|
56
|
+
### Create and return a user object which will use the specified
|
57
|
+
### <tt>socket</tt> and <tt>pollObj</tt>.
|
58
|
+
def initialize( socket, server )
|
59
|
+
@socket = socket
|
60
|
+
@server = server
|
61
|
+
@obuffer = ''
|
62
|
+
@ibuffer = ''
|
63
|
+
@peerHost = @socket.peeraddr[2]
|
64
|
+
@peerPort = @socket.peeraddr[1]
|
65
|
+
@connected = true
|
66
|
+
end
|
67
|
+
|
68
|
+
# Object attribute
|
69
|
+
attr_reader :socket, :server, :ibuffer, :obuffer
|
70
|
+
|
71
|
+
|
72
|
+
### Return a stringified version of the user
|
73
|
+
def to_s
|
74
|
+
"%s:%d" % [ @peerHost, @peerPort ]
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
### Add the specified string to the user's output buffer and turn on
|
79
|
+
### output events.
|
80
|
+
def addOutput( string )
|
81
|
+
@obuffer << string.chomp << EOL
|
82
|
+
@server.reactor.enableEvents( @socket, :write )
|
83
|
+
end
|
84
|
+
alias :<< :addOutput
|
85
|
+
|
86
|
+
|
87
|
+
### Write as much of the output buffer to the socket as possible, and return
|
88
|
+
### the number of bytes remaining to be sent.
|
89
|
+
def writeOutput
|
90
|
+
bytes = @socket.syswrite( @obuffer )
|
91
|
+
@obuffer[ 0, bytes ] = '' if bytes.nonzero?
|
92
|
+
return @obuffer.length
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
### Write a prompt to the user
|
97
|
+
def prompt
|
98
|
+
@obuffer << PROMPT
|
99
|
+
@server.reactor.enableEvents( @socket, :write )
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
### Read at most MTU bytes from the socket and append them to the input
|
104
|
+
### buffer. Split off any complete lines (one that end with EOL) and return
|
105
|
+
### them as an Array of Strings.
|
106
|
+
def readInput
|
107
|
+
rary = []
|
108
|
+
@ibuffer << @socket.sysread( MTU )
|
109
|
+
$stderr.puts "Input buffer for user #{self} now: #@ibuffer" if $VERBOSE
|
110
|
+
while (( pos = @ibuffer.index EOL ))
|
111
|
+
$stderr.puts "Found terminating EOL. "\
|
112
|
+
"Splitting off 0..#{pos} of the input buffer." if $VERBOSE
|
113
|
+
rary << @ibuffer[ 0, pos ]
|
114
|
+
@ibuffer[ 0, pos + EOL.length ] = ''
|
115
|
+
end
|
116
|
+
|
117
|
+
return rary
|
118
|
+
rescue EOFError
|
119
|
+
@server.disconnectUser( self )
|
120
|
+
return []
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
### Handle poll events on the socket
|
125
|
+
def handleIOEvent( io, event )
|
126
|
+
case event
|
127
|
+
|
128
|
+
when :error
|
129
|
+
@server.disconnectUser( self )
|
130
|
+
|
131
|
+
when :read
|
132
|
+
input = readInput()
|
133
|
+
@server.processInput( self, *input ) unless input.empty?
|
134
|
+
|
135
|
+
when :write
|
136
|
+
bytesLeft = writeOutput()
|
137
|
+
@server.reactor.disableEvents( @socket, :write ) if bytesLeft.zero?
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
|
144
|
+
### Disconnect the user
|
145
|
+
def disconnect( msg='' )
|
146
|
+
@connected = false
|
147
|
+
unless msg.empty?
|
148
|
+
@obuffer = ">>> Disconnected: #{msg} <<<" + EOL
|
149
|
+
else
|
150
|
+
@obuffer = ">>> Disconnected <<<" + EOL
|
151
|
+
end
|
152
|
+
writeOutput()
|
153
|
+
@socket.close
|
154
|
+
end
|
155
|
+
|
156
|
+
|
157
|
+
### Returns true if the user is still connected
|
158
|
+
def connected?
|
159
|
+
@connected
|
160
|
+
end
|
161
|
+
end # class User
|
162
|
+
|
163
|
+
|
164
|
+
### Example chatserver class -- an extremely crude and simple chat server that
|
165
|
+
### demonstrates how to use Poll to do multiplexing IO in a single thread.
|
166
|
+
class Server
|
167
|
+
|
168
|
+
BANNER = <<-EOF
|
169
|
+
[[ IO::Reactor Example Chatserver ]]
|
170
|
+
Commands: '/quit' to quit, '/shutdown' to shut the server down
|
171
|
+
EOF
|
172
|
+
|
173
|
+
### Instantiate and return a chatserver on the specified host and port
|
174
|
+
def initialize( listenHost="0.0.0.0", listenPort=1138, interval=0.20 )
|
175
|
+
@socket = TCPServer::new( listenHost, listenPort )
|
176
|
+
@users = []
|
177
|
+
@reactor = IO::Reactor::new
|
178
|
+
@pollInterval = interval
|
179
|
+
@shuttingDown = false
|
180
|
+
|
181
|
+
@reactor.register @socket, :read, &method(:handlePollEvent)
|
182
|
+
end
|
183
|
+
|
184
|
+
# Server attributes
|
185
|
+
attr_reader :reactor, :users, :socket
|
186
|
+
|
187
|
+
|
188
|
+
### Main server loop
|
189
|
+
def eventLoop
|
190
|
+
trap( "INT" ) { shutdown("Server caught SIGINT") }
|
191
|
+
trap( "TERM" ) { shutdown("Server caught SIGTERM") }
|
192
|
+
trap( "HUP" ) { disconnectAllUsers(">>> Server reset <<<") }
|
193
|
+
|
194
|
+
until @shuttingDown
|
195
|
+
eventCount = @reactor.poll( @pollInterval )
|
196
|
+
end
|
197
|
+
|
198
|
+
rescue StandardError => e
|
199
|
+
$stderr.puts "Error in server: #{e.message}"
|
200
|
+
$stderr.puts "\t" + e.backtrace.join( "\n\t" )
|
201
|
+
shutdown( "Server error: #{e.message}" )
|
202
|
+
rescue SignalException => e
|
203
|
+
shutdown( "Server caught #{e.type.name}" )
|
204
|
+
ensure
|
205
|
+
trap( "INT", "SIG_IGN" )
|
206
|
+
trap( "TERM", "SIG_IGN" )
|
207
|
+
trap( "HUP", "SIG_IGN" )
|
208
|
+
|
209
|
+
$stderr.puts "Server exiting event loop."
|
210
|
+
end
|
211
|
+
|
212
|
+
|
213
|
+
### Handle a poll event specified by <tt>event</tt> on the specified
|
214
|
+
### <tt>socket</tt>
|
215
|
+
def handlePollEvent( socket, event )
|
216
|
+
$stderr.puts "Got #{event.inspect} event for #{socket.inspect}"
|
217
|
+
|
218
|
+
case event
|
219
|
+
when :error
|
220
|
+
$stderr.puts "Socket error on the listener socket."
|
221
|
+
shutdown()
|
222
|
+
|
223
|
+
when :read
|
224
|
+
clSock = socket.accept
|
225
|
+
user = User::new( clSock, self )
|
226
|
+
$stderr.puts "Accepted connection from #{user}"
|
227
|
+
@reactor.register clSock, :read, &user.method(:handleIOEvent)
|
228
|
+
user.addOutput( BANNER )
|
229
|
+
user.prompt
|
230
|
+
broadcastMsg( "[New connection: #{user}]" )
|
231
|
+
@users << user
|
232
|
+
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
|
237
|
+
### Process the specified input from the specified user
|
238
|
+
def processInput( user, *inputStrings )
|
239
|
+
inputStrings.each {|str|
|
240
|
+
case str
|
241
|
+
|
242
|
+
when %r{^/(\w+)\s*(.*)}
|
243
|
+
handleCommand( user, $1, $2 )
|
244
|
+
|
245
|
+
else
|
246
|
+
user.addOutput( "You>> #{str}" )
|
247
|
+
broadcastMsgFrom( user, str )
|
248
|
+
end
|
249
|
+
}
|
250
|
+
|
251
|
+
user.prompt if user.connected?
|
252
|
+
end
|
253
|
+
|
254
|
+
|
255
|
+
### Handle the specified command from the specified user
|
256
|
+
def handleCommand( user, command, args )
|
257
|
+
case command
|
258
|
+
|
259
|
+
when /quit/
|
260
|
+
disconnectUser( user, 'Quit' )
|
261
|
+
|
262
|
+
when /shutdown/
|
263
|
+
shutdown()
|
264
|
+
|
265
|
+
when /who/
|
266
|
+
user.addOutput( self.wholist(user) )
|
267
|
+
|
268
|
+
else
|
269
|
+
user.addOutput("Unknown command '#{command}'")
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
|
274
|
+
### Broadcast the specified message to all connected users
|
275
|
+
def broadcastMsg( msg )
|
276
|
+
@users.each {|cl|
|
277
|
+
cl.addOutput( msg )
|
278
|
+
}
|
279
|
+
end
|
280
|
+
|
281
|
+
|
282
|
+
### Broadcast the specified message from the specified user
|
283
|
+
def broadcastMsgFrom( user, msg )
|
284
|
+
userDesc = user.to_s
|
285
|
+
|
286
|
+
@users.each {|cl|
|
287
|
+
next if cl == user
|
288
|
+
cl.addOutput( "#{userDesc}>> #{msg}" )
|
289
|
+
}
|
290
|
+
end
|
291
|
+
|
292
|
+
|
293
|
+
### Disconnect the specified user
|
294
|
+
def disconnectUser( user, msg='' )
|
295
|
+
@users -= [ user ]
|
296
|
+
@reactor.unregister( user.socket )
|
297
|
+
user.disconnect( msg )
|
298
|
+
broadcastMsg( "#{user.to_s} Disconnected." )
|
299
|
+
end
|
300
|
+
|
301
|
+
|
302
|
+
### Disconnect all connected users
|
303
|
+
def disconnectAllUsers( msg )
|
304
|
+
@users.each {|user|
|
305
|
+
@reactor.unregister( user.socket )
|
306
|
+
user.disconnect( msg )
|
307
|
+
}
|
308
|
+
@users.clear
|
309
|
+
end
|
310
|
+
|
311
|
+
|
312
|
+
### Shut the server down
|
313
|
+
def shutdown( msg="Server shutdown" )
|
314
|
+
$stderr.puts "Shutting down: #{msg}"
|
315
|
+
@shuttingDown = true
|
316
|
+
@reactor.clear
|
317
|
+
begin
|
318
|
+
@socket.shutdown
|
319
|
+
rescue
|
320
|
+
end
|
321
|
+
disconnectAllUsers( msg )
|
322
|
+
begin
|
323
|
+
@socket.close
|
324
|
+
rescue
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
### Build and return a list of connected users for the specified user.
|
329
|
+
def wholist( user )
|
330
|
+
rval = "[Connected Users]\n" <<
|
331
|
+
" *#{user}*\n"
|
332
|
+
@users.each {|u|
|
333
|
+
next if u == user
|
334
|
+
rval << " #{u}\n"
|
335
|
+
}
|
336
|
+
|
337
|
+
return rval
|
338
|
+
end
|
339
|
+
|
340
|
+
end # class Server
|
341
|
+
end # module Example
|
342
|
+
|
343
|
+
srv = Example::Server::new( *ARGV )
|
344
|
+
$stderr.puts "Chat server listening on #{srv.socket.addr[2]} port #{srv.socket.addr[1]}"
|
345
|
+
srv.eventLoop
|
346
|
+
$stderr.puts "Chat server finished."
|
347
|
+
|