mack-facets 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gems.rb +25 -0
- data/lib/gems/english-0.3.1/VERSION +1 -0
- data/lib/gems/english-0.3.1/lib/english/array.rb +48 -0
- data/lib/gems/english-0.3.1/lib/english/censor.rb +76 -0
- data/lib/gems/english-0.3.1/lib/english/double_metaphone.rb +353 -0
- data/lib/gems/english-0.3.1/lib/english/dresner.rb +47 -0
- data/lib/gems/english-0.3.1/lib/english/inflect.rb +299 -0
- data/lib/gems/english-0.3.1/lib/english/jumble.rb +37 -0
- data/lib/gems/english-0.3.1/lib/english/levenshtein.rb +78 -0
- data/lib/gems/english-0.3.1/lib/english/metaphone.rb +110 -0
- data/lib/gems/english-0.3.1/lib/english/numerals.rb +71 -0
- data/lib/gems/english-0.3.1/lib/english/patterns.rb +49 -0
- data/lib/gems/english-0.3.1/lib/english/porter_stemming.rb +188 -0
- data/lib/gems/english-0.3.1/lib/english/roman.rb +174 -0
- data/lib/gems/english-0.3.1/lib/english/similarity.rb +103 -0
- data/lib/gems/english-0.3.1/lib/english/soundex.rb +70 -0
- data/lib/gems/english-0.3.1/lib/english/string.rb +210 -0
- data/lib/gems/english-0.3.1/lib/english/style.rb +294 -0
- data/lib/gems/english-0.3.1/lib/english/style_orm.rb +143 -0
- data/lib/gems/english-0.3.1/lib/english/textfilter.rb +91 -0
- data/lib/gems/extlib-0.9.8/lib/extlib.rb +56 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/assertions.rb +8 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/blank.rb +59 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/boolean.rb +11 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/class.rb +175 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/datetime.rb +9 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/dictionary.rb +433 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/hash.rb +419 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/hook.rb +366 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/inflection.rb +435 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/lazy_array.rb +106 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/logger.rb +202 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/mash.rb +148 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/module.rb +41 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/nil.rb +5 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/numeric.rb +5 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/object.rb +175 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/object_space.rb +13 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/pathname.rb +5 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/pooling.rb +239 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/rubygems.rb +38 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/simple_set.rb +39 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/string.rb +132 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/struct.rb +8 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/symbol.rb +17 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/tasks/release.rb +15 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/time.rb +19 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/version.rb +3 -0
- data/lib/gems/extlib-0.9.8/lib/extlib/virtual_file.rb +10 -0
- data/lib/gems/facets-2.4.5/VERSION +1 -0
- data/lib/gems/facets-2.4.5/lib/core/facets-live.rb +17 -0
- data/lib/gems/facets-2.4.5/lib/core/facets-load.rb +12 -0
- data/lib/gems/facets-2.4.5/lib/core/facets.rb +11 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/array.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/array/combination.rb +59 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/array/conjoin.rb +58 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/array/delete.rb +61 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/array/index.rb +48 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/array/indexable.rb +73 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/array/merge.rb +21 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/array/not_empty.rb +13 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/array/only.rb +21 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/array/pad.rb +41 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/array/permutation.rb +30 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/array/product.rb +57 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/array/recursively.rb +30 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/array/rotate.rb +42 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/array/select.rb +16 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/array/splice.rb +30 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/array/stackable.rb +33 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/array/traverse.rb +22 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/binding.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/binding/caller.rb +54 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/binding/defined.rb +13 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/binding/eval.rb +18 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/binding/local_variables.rb +15 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/binding/self.rb +12 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/bitmask.rb +104 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/blank.rb +60 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/boolean.rb +156 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/callstack.rb +52 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/cattr.rb +2 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/class.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/class/cattr.rb +115 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/class/cattr_accessor.rb +1 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/class/cattr_reader.rb +1 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/class/cattr_writer.rb +1 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/class/descendents.rb +36 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/class/methodize.rb +14 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/class/pathize.rb +14 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/class/prepend.rb +50 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/class/subclasses.rb +2 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/class/to_proc.rb +42 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/comparable.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/comparable/bound.rb +65 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/comparable/cmp.rb +38 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/comparable/comparable.rb +42 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/dir.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/dir/ascend.rb +59 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/dir/descend.rb +1 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/dir/multiglob.rb +92 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/dir/parent.rb +13 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/dir/recurse.rb +29 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/accumulate.rb +21 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/cluster_by.rb +21 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/collect.rb +54 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/commonality.rb +33 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/count.rb +26 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/divide.rb +33 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/duplicates.rb +38 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/each_by.rb +33 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/entropy.rb +37 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/frequency.rb +18 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/group_by.rb +27 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/inject.rb +31 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/map_send.rb +12 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/mash.rb +32 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/mode.rb +16 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/modulate.rb +22 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/none.rb +31 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/occur.rb +38 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/one.rb +38 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/probability.rb +36 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/split.rb +27 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/sum.rb +16 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/uniq_by.rb +18 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/exception.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/exception/detail.rb +19 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/exception/suppress.rb +21 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/file.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/file/append.rb +14 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/file/create.rb +21 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/file/null.rb +21 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/file/read.rb +41 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/file/rewrite.rb +88 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/file/rootname.rb +33 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/file/split_root.rb +10 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/file/write.rb +22 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/file/writelines.rb +24 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/filetest.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/filetest/root.rb +17 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/float.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/float/round.rb +2 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/functor.rb +77 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/alias.rb +31 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/argumentize.rb +22 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/at.rb +8 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/autonew.rb +42 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/collate.rb +45 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/delete.rb +47 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/diff.rb +11 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/except.rb +27 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/insert.rb +19 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/inverse.rb +27 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/join.rb +14 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/keys.rb +45 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/mash.rb +18 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/merge.rb +30 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/op.rb +7 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/op_add.rb +12 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/op_and.rb +33 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/op_mul.rb +18 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/op_or.rb +12 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/op_push.rb +17 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/op_sub.rb +26 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/recursive_merge.rb +33 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/recursively.rb +29 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/rekey.rb +59 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/select.rb +14 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/slice.rb +33 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/swap.rb +17 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/to_h.rb +1 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/to_proc.rb +41 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/to_struct.rb +17 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/traverse.rb +41 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/update.rb +81 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/weave.rb +81 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/hash/zipnew.rb +2 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/indexable.rb +251 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/integer.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/integer/even.rb +1 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/integer/factorial.rb +30 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/integer/multiple.rb +15 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/integer/odd.rb +35 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/integer/of.rb +18 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/integer/ordinal.rb +24 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/__callee__.rb +1 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/__class__.rb +9 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/__dir__.rb +12 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/__get__.rb +10 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/__method__.rb +36 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/__set__.rb +1 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/as.rb +100 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/ask.rb +27 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/attr_singleton.rb +62 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/complete.rb +18 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/constant.rb +24 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/d.rb +26 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/deep_copy.rb +13 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/demo.rb +23 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/ergo.rb +42 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/here.rb +12 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/in.rb +13 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/instance.rb +19 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/instance_assign.rb +41 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/instance_class.rb +24 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/instance_exec.rb +40 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/instance_send.rb +7 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/instance_variables.rb +99 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/maybe.rb +18 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/not_nil.rb +17 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/object_class.rb +10 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/object_hexid.rb +12 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/object_send.rb +32 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/p.rb +24 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/populate.rb +73 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/qua_class.rb +19 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/require_all.rb +21 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/require_local.rb +24 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/resc.rb +16 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/respond.rb +23 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/returning.rb +23 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/silence.rb +75 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/singleton_class.rb +19 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/tap.rb +32 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/try.rb +23 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/val.rb +19 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/kernel/with.rb +20 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/lazy.rb +238 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/matchdata.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/matchdata/match.rb +15 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/matchdata/matchset.rb +44 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/metaid.rb +94 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/abstract.rb +21 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/alias_accessor.rb +45 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/alias_method_chain.rb +50 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/alias_module_function.rb +30 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/ancestor.rb +16 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/basename.rb +31 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/can.rb +14 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/class.rb +12 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/conflict.rb +63 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/include_function_module.rb +25 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/instance_methods.rb +40 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/integrate.rb +2 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/is.rb +57 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/methodize.rb +14 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/modspace.rb +22 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/module_load.rb +56 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/nesting.rb +18 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/op.rb +95 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/pathize.rb +22 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/prepend.rb +26 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/redefine_method.rb +35 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/redirect_method.rb +45 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/rename_method.rb +20 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/revise.rb +62 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/spacename.rb +25 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/module/wrap_method.rb +28 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/nilclass.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/nilclass/ergo.rb +1 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/nilclass/to_f.rb +17 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/numeric.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/numeric/approx.rb +15 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/numeric/distance.rb +14 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/numeric/round.rb +72 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/proc.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/proc/bind.rb +22 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/proc/compose.rb +42 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/proc/curry.rb +31 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/proc/to_method.rb +33 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/proc/update.rb +9 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/range.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/range/combine.rb +47 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/range/overlap.rb +13 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/range/to_r.rb +26 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/range/umbrella.rb +1 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/range/within.rb +66 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/regexp.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/regexp/arity.rb +17 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/regexp/to_re.rb +28 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/stackable.rb +86 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/align.rb +106 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/bracket.rb +105 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/bytes.rb +15 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/camelcase.rb +26 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/capitalized.rb +46 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/chars.rb +16 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/chomp.rb +33 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/cleave.rb +36 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/divide.rb +21 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/each_char.rb +29 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/each_word.rb +13 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/end_with.rb +1 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/fold.rb +39 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/interpolate.rb +20 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/line_wrap.rb +21 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/lines.rb +16 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/methodize.rb +17 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/modulize.rb +21 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/mscan.rb +19 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/natcmp.rb +88 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/nchar.rb +28 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/op_sub.rb +14 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/pathize.rb +16 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/range.rb +77 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/rewrite.rb +28 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/shatter.rb +22 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/snakecase.rb +21 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/splice.rb +37 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/start_with.rb +32 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/subtract.rb +4 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/tab.rb +103 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/titlecase.rb +15 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/to_re.rb +26 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/variablize.rb +13 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/word_wrap.rb +34 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/words.rb +12 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/string/xor.rb +22 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/symbol.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/symbol/chomp.rb +24 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/symbol/generate.rb +24 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/symbol/not.rb +29 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/symbol/plain.rb +17 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/symbol/query.rb +1 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/symbol/re_s.rb +18 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/symbol/setter.rb +1 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/symbol/succ.rb +19 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/symbol/to_proc.rb +38 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/symbol/variablize.rb +12 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/time.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/time/advance.rb +17 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/time/ago.rb +1 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/time/change.rb +41 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/time/elapse.rb +16 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/time/hence.rb +94 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/time/round.rb +17 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/time/set.rb +21 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/time/stamp.rb +44 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/time/to_time.rb +21 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/time/trunc.rb +15 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/to_hash.rb +87 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/unboundmethod.rb +6 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/unboundmethod/arguments.rb +44 -0
- data/lib/gems/facets-2.4.5/lib/core/facets/unboundmethod/name.rb +25 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/basicobject.rb +14 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/cgi.rb +50 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/continuation.rb +57 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/date.rb +396 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils.rb +27 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils/head.rb +1 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils/safe_ln.rb +28 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils/slice.rb +141 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils/tail.rb +1 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils/wc.rb +114 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils/whereis.rb +64 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils/which.rb +101 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/getoptlong.rb +71 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/logger.rb +291 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/ostruct.rb +238 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/pathname.rb +172 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/rbconfig.rb +45 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/set.rb +27 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/shellwords.rb +89 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/uri.rb +249 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/yaml.rb +75 -0
- data/lib/gems/facets-2.4.5/lib/lore/facets/zlib.rb +38 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/1stclassmethod.rb +140 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/advisable.rb +162 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/annotations.rb +302 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/ansicode.rb +315 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/arguments.rb +365 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/argvector.rb +353 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/association.rb +194 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/attr.rb +208 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/autoarray.rb +62 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/autoreload.rb +150 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/basex.rb +37 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/bbcode.rb +397 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/bicrypt.rb +265 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/binding/opvars.rb +24 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/binreadable.rb +221 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/blankslate.rb +66 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/buildable.rb +344 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/bytes.rb +175 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/cachedecorator.rb +117 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/capsule.rb +258 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/chain.rb +58 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/class_extension.rb +114 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/classmethods.rb +199 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/cloneable.rb +76 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/command.rb +439 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/consoleutils.rb +113 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/coroutine.rb +159 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/crypt.rb +166 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/cssfilter.rb +254 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/daemonize.rb +44 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/dependency.rb +151 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/dictionary.rb +478 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/dictionarymatcher.rb +136 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/downloader.rb +281 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/duplicable.rb +43 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/duration.rb +540 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/elementor.rb +133 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/elementwise.rb +61 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/enumerablepass.rb +217 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/equatable.rb +120 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/eventhook.rb +132 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/expirable.rb +82 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/fileable.rb +162 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/filelist.rb +497 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/fileshell.rb +202 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/hash/stringify_keys.rb +1 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/hash/symbolize_keys.rb +94 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/heap.rb +22 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/htmlfilter.rb +595 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/infinity.rb +193 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/inheritor.rb +130 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/ini.rb +264 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/instantiable.rb +47 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/instantise.rb +1 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/instantize.rb +95 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/interval.rb +282 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/ioredirect.rb +130 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/iteration.rb +65 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/kernel/meta.rb +32 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/linkedlist.rb +222 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/lrucache.rb +157 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/main.rb +70 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/memoize.rb +116 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/methodspace.rb +141 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/minitar.rb +1063 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/multipliers.rb +109 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/multiton.rb +386 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/nackclass.rb +41 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/net/smtp_tls.rb +131 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/nilstatus.rb +47 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/nullclass.rb +74 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/opencascade.rb +94 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/opencollection.rb +43 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/openhash.rb +39 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/openobject.rb +267 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/opesc.rb +60 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/orderedhash.rb +37 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/overload.rb +94 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/paramix.rb +202 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/partial.rb +37 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/pathlist.rb +112 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/platform.rb +192 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/pool.rb +91 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/pqueue.rb +449 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/progressbar.rb +253 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/prototype.rb +88 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/random.rb +451 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/rbsystem.rb +222 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/recorder.rb +109 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/reference.rb +99 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/reflection.rb +145 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/registerable.rb +35 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/rwdelegator.rb +74 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/semaphore.rb +92 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/settings.rb +248 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/snapshot.rb +209 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/string/mask.rb +278 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/string/words.rb +173 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/succ.rb +44 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/syncarray.rb +114 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/synchash.rb +157 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/tagiter.rb +366 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/thread.rb +51 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/timer.rb +274 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/times.rb +431 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/tracepoint.rb +209 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/tuple.rb +325 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/typecast.rb +261 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/uninheritable.rb +50 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/uploadutils.rb +464 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/version.rb +136 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/xmlhash.rb +112 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/xoxo.rb +259 -0
- data/lib/gems/facets-2.4.5/lib/more/facets/ziputils.rb +349 -0
- data/lib/mack-facets.rb +4 -2
- data/lib/mack-facets/english_extensions/inflect.rb +50 -50
- data/lib/mack-facets/extensions/string.rb +10 -1
- data/lib/mack-facets/utils/inflections.rb +50 -47
- data/lib/mack-facets/utils/inflector.rb +19 -19
- metadata +547 -36
@@ -0,0 +1,47 @@
|
|
1
|
+
# = Instantiable
|
2
|
+
#
|
3
|
+
# Initialize modules, almost as if they were classes.
|
4
|
+
#
|
5
|
+
# == Authors
|
6
|
+
#
|
7
|
+
# * Thomas Sawyer
|
8
|
+
#
|
9
|
+
# == Copying
|
10
|
+
#
|
11
|
+
# Copyright (c) 2006 Thomas Sawyer
|
12
|
+
#
|
13
|
+
# Ruby License
|
14
|
+
#
|
15
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
16
|
+
# software under the same terms as Ruby.
|
17
|
+
#
|
18
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
19
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
20
|
+
# FOR A PARTICULAR PURPOSE.
|
21
|
+
|
22
|
+
|
23
|
+
# = Instantiable
|
24
|
+
#
|
25
|
+
# Initialize modules, almost as if they were classes.
|
26
|
+
#
|
27
|
+
# Alows a module to be used much like a class, by defining
|
28
|
+
# a #new method that creates a class on demand.
|
29
|
+
#
|
30
|
+
module Instantiable
|
31
|
+
|
32
|
+
def self.append_features(mod)
|
33
|
+
mod.extend self
|
34
|
+
end
|
35
|
+
|
36
|
+
# Never use a class agian! ;)
|
37
|
+
|
38
|
+
def new(*args,&blk)
|
39
|
+
mod = self
|
40
|
+
@instantiable_class ||= Class.new{include mod}
|
41
|
+
@instantiable_class.new(*args,&blk)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'facets/instantize'
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# = Instantize
|
2
|
+
#
|
3
|
+
# Instantize converts module methods into instance methods
|
4
|
+
# such that the first parameter is passed self at the instance level.
|
5
|
+
# This promotes DRY programming when wishing to offer both an inheritable
|
6
|
+
# and a module callable procedure.
|
7
|
+
#
|
8
|
+
# module MyModule
|
9
|
+
# extend Instantize
|
10
|
+
#
|
11
|
+
# def self.jumble( obj, arg )
|
12
|
+
# obj + arg
|
13
|
+
# end
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# class String
|
17
|
+
# include MyModule
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# MyModule.jumble( "Try", "Me" ) #=> "TryMe"
|
21
|
+
#
|
22
|
+
# "Try".jumble( "Me" ) #=> 'TryMe'
|
23
|
+
#
|
24
|
+
# == Notes
|
25
|
+
#
|
26
|
+
# This module used to be called PromoteSelf. Instantize is more descriptive, but
|
27
|
+
# a better name is probably still out there.
|
28
|
+
#
|
29
|
+
# == Authors
|
30
|
+
#
|
31
|
+
# * Thomas Sawyer
|
32
|
+
#
|
33
|
+
# == Copying
|
34
|
+
#
|
35
|
+
# Copyright (c) 2005 Thomas Sawyer
|
36
|
+
#
|
37
|
+
# Ruby License
|
38
|
+
#
|
39
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
40
|
+
# software under the same terms as Ruby.
|
41
|
+
#
|
42
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
43
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
44
|
+
# FOR A PARTICULAR PURPOSE.
|
45
|
+
|
46
|
+
|
47
|
+
# = Instantize
|
48
|
+
#
|
49
|
+
# Instantize converts module methods into instance methods
|
50
|
+
# such that the first parameter is passed self at the instance level.
|
51
|
+
# This promotes DRY programming when wishing to offer both an inheritable
|
52
|
+
# and a module callable procedure.
|
53
|
+
#
|
54
|
+
# module MyModule
|
55
|
+
# extend Instantize
|
56
|
+
#
|
57
|
+
# def self.jumble( obj, arg )
|
58
|
+
# obj + arg
|
59
|
+
# end
|
60
|
+
# end
|
61
|
+
#
|
62
|
+
# class String
|
63
|
+
# include MyModule
|
64
|
+
# end
|
65
|
+
#
|
66
|
+
# MyModule.jumble( "Try", "Me" ) #=> "TryMe"
|
67
|
+
#
|
68
|
+
# "Try".jumble( "Me" ) #=> 'TryMe'
|
69
|
+
#
|
70
|
+
# == Notes
|
71
|
+
#
|
72
|
+
# This module used to be called PromoteSelf. Instantize is more descriptive, but
|
73
|
+
# a better name is probably still out there.
|
74
|
+
#
|
75
|
+
module Instantize
|
76
|
+
|
77
|
+
def self.append_features(mod)
|
78
|
+
mod.extend self
|
79
|
+
end
|
80
|
+
|
81
|
+
def singleton_method_added( meth )
|
82
|
+
d = %{
|
83
|
+
def #{meth}(*args)
|
84
|
+
#{self.name}.#{meth}(self,*args)
|
85
|
+
end
|
86
|
+
}
|
87
|
+
self.class_eval d
|
88
|
+
super(meth)
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
# Constant Alias
|
94
|
+
Instantise = Instantize
|
95
|
+
|
@@ -0,0 +1,282 @@
|
|
1
|
+
# = Interval
|
2
|
+
#
|
3
|
+
# While Ruby support the Range class out of the box, is does not quite
|
4
|
+
# fullfil the role od a real Interval class. For instance, it does
|
5
|
+
# not support excluding the front sentinel. This is because Range
|
6
|
+
# also tries to do triple duty as a simple Sequence and as a simple Tuple-Pair,
|
7
|
+
# thus limiting its potential as an Interval. The Interval class remedies
|
8
|
+
# the situation by commiting to interval behavior, and then extends the class'
|
9
|
+
# capabilites beyond that of the standard Range in ways that naturally
|
10
|
+
# fall out of that.
|
11
|
+
#
|
12
|
+
# Range depends on two methods: #succ and #<=>. If numeric
|
13
|
+
# ranges were the only concern, those could just as well be #+ and #<=>,
|
14
|
+
# but esoteric forms make that unfeasible --the obvious example being a String
|
15
|
+
# range. But a proper Interval class requires mathematical continuation,
|
16
|
+
# thus the Interval depends on #+ and #<=>, as well as #- as the inverse of #+.
|
17
|
+
#
|
18
|
+
# i = Interval.new(1,5)
|
19
|
+
# i.to_a #=> [1,2,3,4,5]
|
20
|
+
#
|
21
|
+
# i = Interval[0,5]
|
22
|
+
# i.to_a(2) #=> [0,2,4]
|
23
|
+
#
|
24
|
+
# i = Interval[1,5]
|
25
|
+
# i.to_a(-1) #=> [5,4,3,2,1]
|
26
|
+
#
|
27
|
+
# i = Interval[1,3]
|
28
|
+
# i.to_a(1,2) #=> [1.0,1.5,2.0,2.5,3.0]
|
29
|
+
#
|
30
|
+
# == Authors
|
31
|
+
#
|
32
|
+
# * Thomas Sawyer
|
33
|
+
#
|
34
|
+
# == Todo
|
35
|
+
#
|
36
|
+
# * Still need to tie in Infinity.
|
37
|
+
#
|
38
|
+
# == Copying
|
39
|
+
#
|
40
|
+
# Copyright (c) 2004 Thomas Sawyer
|
41
|
+
#
|
42
|
+
# Ruby License
|
43
|
+
#
|
44
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
45
|
+
# software under the same terms as Ruby.
|
46
|
+
#
|
47
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
48
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
49
|
+
# FOR A PARTICULAR PURPOSE.
|
50
|
+
|
51
|
+
require 'facets/multiton'
|
52
|
+
require 'facets/enumerablepass'
|
53
|
+
#require 'facets/infinity'
|
54
|
+
|
55
|
+
# = Interval
|
56
|
+
#
|
57
|
+
# While Ruby support the Range class out of the box, is does not quite
|
58
|
+
# fullfil the role od a real Interval class. For instance, it does
|
59
|
+
# not support excluding the front sentinel. This is because Range
|
60
|
+
# also tries to do triple duty as a simple Sequence and as a simple Tuple-Pair,
|
61
|
+
# thus limiting its potential as an Interval. The Interval class remedies
|
62
|
+
# the situation by commiting to interval behavior, and then extends the class'
|
63
|
+
# capabilites beyond that of the standard Range in ways that naturally
|
64
|
+
# fall out of that.
|
65
|
+
#
|
66
|
+
# Range depends on two methods: #succ and #<=>. If numeric
|
67
|
+
# ranges were the only concern, those could just as well be #+ and #<=>,
|
68
|
+
# but esoteric forms make that unfeasible --the obvious example being a String
|
69
|
+
# range. But a proper Interval class requires mathematical continuation,
|
70
|
+
# thus the Interval depends on #+ and #<=>, as well as #- as the inverse of #+.
|
71
|
+
#
|
72
|
+
# i = Interval.new(1,5)
|
73
|
+
# i.to_a #=> [1,2,3,4,5]
|
74
|
+
#
|
75
|
+
# i = Interval[0,5]
|
76
|
+
# i.to_a(2) #=> [0,2,4]
|
77
|
+
#
|
78
|
+
# i = Interval[1,5]
|
79
|
+
# i.to_a(-1) #=> [5,4,3,2,1]
|
80
|
+
#
|
81
|
+
# i = Interval[1,3]
|
82
|
+
# i.to_a(1,2) #=> [1.0,1.5,2.0,2.5,3.0]
|
83
|
+
|
84
|
+
class Interval
|
85
|
+
|
86
|
+
include Multiton
|
87
|
+
include EnumerablePass
|
88
|
+
|
89
|
+
def self.[]( *args )
|
90
|
+
self.new( *args )
|
91
|
+
end
|
92
|
+
|
93
|
+
def initialize(first, last, exclude_first=false, exclude_last=false )
|
94
|
+
raise ArgumentError, "bad value for interval" if first.class != last.class
|
95
|
+
@first = first
|
96
|
+
@last = last
|
97
|
+
@exclude_first = exclude_first
|
98
|
+
@exclude_last = exclude_last
|
99
|
+
@direction = (@last <=> @first)
|
100
|
+
end
|
101
|
+
|
102
|
+
# Returns a two element array of first and last sentinels.
|
103
|
+
#
|
104
|
+
# (0..10).sentinels #=> [0,10]
|
105
|
+
#
|
106
|
+
def sentinels
|
107
|
+
return [@first, @last]
|
108
|
+
end
|
109
|
+
|
110
|
+
# Returns the first or last sentinal of the interval.
|
111
|
+
def first ; @first ; end
|
112
|
+
def last ; @last ; end
|
113
|
+
|
114
|
+
#
|
115
|
+
def exclude_first? ; @exclude_first ; end
|
116
|
+
def exclude_last? ; @exclude_last ; end
|
117
|
+
|
118
|
+
# (IMHO) these should be deprectated
|
119
|
+
alias_method( :begin, :first )
|
120
|
+
alias_method( :end, :last )
|
121
|
+
alias_method( :exclude_begin?, :exclude_first? )
|
122
|
+
alias_method( :exclude_end?, :exclude_last? )
|
123
|
+
|
124
|
+
# Returns +true+ if the start and end sentinels are equal and the interval is closed; otherwise +false+.
|
125
|
+
def degenerate? ; @direction == 0 and ! (@exclusive_first or @exclusive_last) ; end
|
126
|
+
|
127
|
+
# Returns +true+ if the start and end sentinels are equal and the interval is open; otherwise +false+.
|
128
|
+
def null? ; @direction == 0 and @exclusive_first and @exclusive_last ; end
|
129
|
+
|
130
|
+
# Returns the direction of the interval indicated by +1, 0 or -1.
|
131
|
+
#
|
132
|
+
# (1..5).direction #=> 1
|
133
|
+
# (5..1).direction #=> -1
|
134
|
+
# (1..1).direction #=> 0
|
135
|
+
#
|
136
|
+
def direction ; @direction ; end
|
137
|
+
|
138
|
+
# Returns a new interval inclusive of of both sentinels.
|
139
|
+
def closed; Interval.new(@first, @last, true, true) ; end
|
140
|
+
|
141
|
+
# Returns a new interval exclusive of both sentinels.
|
142
|
+
def opened; Interval.new(@first, @last, true, true) ; end
|
143
|
+
|
144
|
+
# Returns a new interval with either the first or the last sentinel exclusive.
|
145
|
+
# If the parameter is false, the deafult, then the first sentinel is excluded;
|
146
|
+
# if the parameter is true, the last sentinel is excluded.
|
147
|
+
def half_closed(e=false)
|
148
|
+
e ? Interval.new(@first, @last, true, false) : Interval.new(@first, @last, false, true)
|
149
|
+
end
|
150
|
+
|
151
|
+
# Returns a new interval with one of the two sentinels opened or closed
|
152
|
+
def first_closed ; Interval.new(@first, @last, false, true) ; end
|
153
|
+
def last_closed ; Interval.new(@first, @last, true, false) ; end
|
154
|
+
def first_opened ; Interval.new(@first, @last, true, false) ; end
|
155
|
+
def last_opened ; Interval.new(@first, @last, false, true) ; end
|
156
|
+
|
157
|
+
# Unary shorthands. These return a new interval exclusive of first,
|
158
|
+
# last or both sentinels, repectively.
|
159
|
+
def +@ ; Interval.new(first, last, true, false) ; end
|
160
|
+
def -@ ; Interval.new(first, last, false, true) ; end
|
161
|
+
def ~@ ; Interval.new(first, last, true, true) ; end
|
162
|
+
|
163
|
+
# Returns a new interval with the sentinels reversed.
|
164
|
+
#
|
165
|
+
# (0..10).reversed #=> 10..0
|
166
|
+
#
|
167
|
+
def reversed
|
168
|
+
Interval.new(@last, @first, true, true)
|
169
|
+
end
|
170
|
+
|
171
|
+
# Returns the length of the interval as the difference between
|
172
|
+
# the first and last elements. Returns +nil+ if the sentinal objects
|
173
|
+
# do not support distance comparison (#distance).
|
174
|
+
# TODO: Add +n+ parameter to count segmentations like those produced by #each.
|
175
|
+
def distance
|
176
|
+
@last - @first
|
177
|
+
#if @last.respond_to?( :distance )
|
178
|
+
# @last.distance( @first )
|
179
|
+
#else
|
180
|
+
# #self.to_a.length
|
181
|
+
#end
|
182
|
+
end
|
183
|
+
alias_method( :length, :distance )
|
184
|
+
alias_method( :size, :distance )
|
185
|
+
|
186
|
+
# Returns the lesser of the first and last sentinals.
|
187
|
+
def min
|
188
|
+
((@first <=> @last) == -1) ? @first : @last
|
189
|
+
end
|
190
|
+
|
191
|
+
# Returns the greater of the first and last sentinals.
|
192
|
+
def max
|
193
|
+
((@first <=> @last) == 1) ? @first : @last
|
194
|
+
end
|
195
|
+
|
196
|
+
# Returns true or false if the element is part of the interval.
|
197
|
+
def include?(x)
|
198
|
+
# todo: infinity?
|
199
|
+
tf = exclude_first? ? 1 : 0
|
200
|
+
tl = exclude_last? ? -1 : 0
|
201
|
+
(x <=> first) >= tf and (x <=> last) <= tl
|
202
|
+
end
|
203
|
+
alias_method( :===, :include? )
|
204
|
+
alias_method( :member?, :include? )
|
205
|
+
|
206
|
+
=begin
|
207
|
+
# def include?(x)
|
208
|
+
# tf = exclude_first? ? 1 : 0
|
209
|
+
# tl = exclude_last? ? -1 : 0
|
210
|
+
# # if other classes handled Infinity in their <=> method
|
211
|
+
# # (which probably they should) this clause would not be required
|
212
|
+
# if first.kind_of?(InfinityClass)
|
213
|
+
# ft = ((first <=> x) <= tf)
|
214
|
+
# else
|
215
|
+
# ft = (x <=> first) >= tf
|
216
|
+
# end
|
217
|
+
# if last.kind_of?(InfinityClass)
|
218
|
+
# fl = ((last <=> x) >= tl)
|
219
|
+
# else
|
220
|
+
# fl = (x <=> last) <= tl
|
221
|
+
# end
|
222
|
+
# ft && fl
|
223
|
+
# end
|
224
|
+
=end
|
225
|
+
|
226
|
+
# Iterates over the interval, passing each _n_th element to the block.
|
227
|
+
# If n is not given then n defaults to 1. Each _n_th step is determined
|
228
|
+
# by invoking +\++ or +\-+ n, depending on the direction of the interval.
|
229
|
+
# If n is negative the iteration is preformed in reverse form end sentinal
|
230
|
+
# to front sentinal. A second parameter, d, can be given in which case
|
231
|
+
# the applied step is calculated as a fraction of the interval's length
|
232
|
+
# times n / d. This allows iteration over the whole interval in equal sized
|
233
|
+
# segments.
|
234
|
+
#
|
235
|
+
# 1..5.each { |e| ... } #=> 1 2 3 4 5
|
236
|
+
# 1..5.each(2) { |e| ... } #=> 1 3 5
|
237
|
+
# 1..5.each(1,2) { |e| ... } #=> 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0
|
238
|
+
#
|
239
|
+
def each(n=1, d=nil) # :yield:
|
240
|
+
return (n < 0 ? @last : @first) if degenerate? # is this right for all values of n ?
|
241
|
+
s = d ? self.length.to_f * (n.to_f / d.to_f) : n.abs
|
242
|
+
raise "Cannot iterate over zero length steps." if s == 0
|
243
|
+
s = s * @direction
|
244
|
+
if n < 0
|
245
|
+
e = @exclude_last ? @last - s : @last
|
246
|
+
#e = @exclude_last ? @last.pred(s) : @last
|
247
|
+
t = @exclude_last ? 1 : 0
|
248
|
+
#while e.cmp(@first) >= t
|
249
|
+
while (e <=> @first) >= t
|
250
|
+
yield(e)
|
251
|
+
e -= s
|
252
|
+
#e = e.pred(s)
|
253
|
+
end
|
254
|
+
else
|
255
|
+
e = @exclude_first ? @first + s : @first
|
256
|
+
#e = @exclude_first ? @first.succ(s) : @first
|
257
|
+
t = @exclude_last ? -1 : 0
|
258
|
+
#while e.cmp(@last) <= t
|
259
|
+
while (e <=> @last) <= t
|
260
|
+
yield(e)
|
261
|
+
e += s
|
262
|
+
#e = e.succ(s)
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
alias_method( :step, :each )
|
267
|
+
|
268
|
+
# Should there be a #reverse_each ?
|
269
|
+
# Since #each can now take a negative argument, this isn't really needed.
|
270
|
+
# Should it exist anyway and routed to #each?
|
271
|
+
# Also, alias_method( :reverse_step, :reverse_each )
|
272
|
+
|
273
|
+
# Compares two intervals to see if they are equal
|
274
|
+
def eql?(other)
|
275
|
+
return false unless @first == other.first
|
276
|
+
return false unless @last == other.last
|
277
|
+
return false unless @exclude_first == other.exclude_first?
|
278
|
+
return false unless @exclude_last == other.exclude_last?
|
279
|
+
true
|
280
|
+
end
|
281
|
+
|
282
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
# = IORedirect
|
2
|
+
#
|
3
|
+
# A class to redirect $stdout, or other IO object, to a StringIO object,
|
4
|
+
# or any other object with a write() method.
|
5
|
+
#
|
6
|
+
# s = StringIO.new
|
7
|
+
# r = Redirector.redirect($stdout, s) do
|
8
|
+
# $stdout.puts "this is a test"
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# == History
|
12
|
+
#
|
13
|
+
# * IORedirect was ported from Paul Brannan's Ruby Treasures.
|
14
|
+
#
|
15
|
+
# == Authors
|
16
|
+
#
|
17
|
+
# * Paul Brannan <paul@atdesk.com>
|
18
|
+
#
|
19
|
+
# = Copying
|
20
|
+
#
|
21
|
+
# Copyright (C) 2002 Paul Brannan <paul@atdesk.com>
|
22
|
+
#
|
23
|
+
# Ruby License
|
24
|
+
#
|
25
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
26
|
+
# software under the same terms as Ruby.
|
27
|
+
#
|
28
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
29
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
30
|
+
# FOR A PARTICULAR PURPOSE.
|
31
|
+
|
32
|
+
|
33
|
+
# = IORedirect
|
34
|
+
#
|
35
|
+
# A class to redirect $stdout, or other IO object, to a StringIO object,
|
36
|
+
# or any other object with a write() method.
|
37
|
+
#
|
38
|
+
# s = StringIO.new
|
39
|
+
# r = Redirector.redirect($stdout, s) do
|
40
|
+
# $stdout.puts "this is a test"
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
class IORedirect
|
44
|
+
|
45
|
+
# Start redirection from one IO object to any other object with a
|
46
|
+
# write() method. +from+ is the IO object to redirect from,
|
47
|
+
# and +to+ is the object to redirect to.
|
48
|
+
def initialize(from, to)
|
49
|
+
@from = from
|
50
|
+
@to = to
|
51
|
+
start()
|
52
|
+
end
|
53
|
+
|
54
|
+
# Start redirection, if it has not already been started.
|
55
|
+
def start
|
56
|
+
raise "Redirection already in progress" if @t
|
57
|
+
tmp = @from.dup
|
58
|
+
r, w = IO.pipe
|
59
|
+
@from.reopen(w)
|
60
|
+
@t = Thread.new do
|
61
|
+
begin
|
62
|
+
loop do
|
63
|
+
s = r.read(1) # TODO: can I make this buffered?
|
64
|
+
@to.write(s)
|
65
|
+
end
|
66
|
+
ensure
|
67
|
+
@from.reopen(tmp)
|
68
|
+
@t = nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Stop redirection, if it is occurring
|
74
|
+
def stop
|
75
|
+
raise "Redirection already stopped" if not @t
|
76
|
+
@t.kill
|
77
|
+
end
|
78
|
+
|
79
|
+
# An exception-safe class method for redirection
|
80
|
+
def self.redirect(from, to)
|
81
|
+
s = self.new(from, to)
|
82
|
+
begin
|
83
|
+
yield
|
84
|
+
ensure
|
85
|
+
s.stop
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
# --- test ---
|
92
|
+
|
93
|
+
if __FILE__ == $0 then
|
94
|
+
|
95
|
+
class SimpleStringIO
|
96
|
+
attr_reader :str
|
97
|
+
def initialize; @str = ''; end
|
98
|
+
def write(str); @str << str; end
|
99
|
+
end
|
100
|
+
|
101
|
+
Thread.abort_on_exception = true
|
102
|
+
s = SimpleStringIO.new
|
103
|
+
r = Redirector.redirect($stdout, s) do
|
104
|
+
$stdout.puts "this is a test"
|
105
|
+
$stdout.puts "of the StringIO redirection system"
|
106
|
+
end
|
107
|
+
puts "Done redirecting."
|
108
|
+
puts "Result:\n#{s.str}"
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
# _____ _
|
115
|
+
# |_ _|__ ___| |_
|
116
|
+
# | |/ _ \/ __| __|
|
117
|
+
# | | __/\__ \ |_
|
118
|
+
# |_|\___||___/\__|
|
119
|
+
#
|
120
|
+
|
121
|
+
# TODO
|
122
|
+
|
123
|
+
=begin #testing
|
124
|
+
|
125
|
+
require 'test/unit'
|
126
|
+
|
127
|
+
=end
|
128
|
+
|
129
|
+
|
130
|
+
|