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,325 @@
|
|
1
|
+
# = Tuple
|
2
|
+
#
|
3
|
+
# Tuple is essentially an Array, but Comaparable and Immutable.
|
4
|
+
#
|
5
|
+
# A tuple can be made using #new or #[] just as one builds an array,
|
6
|
+
# or using the #to_t method on a string or array. With a string tuple
|
7
|
+
# remembers the first non-alphanumeric character as the tuple divider.
|
8
|
+
#
|
9
|
+
# == Usage
|
10
|
+
#
|
11
|
+
# t1 = Tuple[1,2,3]
|
12
|
+
# t2 = Tuple[2,3,4]
|
13
|
+
#
|
14
|
+
# t1 < t2 #=> true
|
15
|
+
# t1 > t2 #=> false
|
16
|
+
#
|
17
|
+
# t1 = '1.2.3'.to_t
|
18
|
+
# t2 = '1-2-3'.to_t
|
19
|
+
#
|
20
|
+
# puts t1 #=> 1.2.3
|
21
|
+
# puts t2 #=> 1-2-3
|
22
|
+
#
|
23
|
+
# t1 == t2 #=> true
|
24
|
+
#
|
25
|
+
# Keep in mind that Tuple[1,2,3] is not the same as Tuple['1','2','3'].
|
26
|
+
#
|
27
|
+
# == Todo
|
28
|
+
#
|
29
|
+
# * The #hash method needs a touch-up.
|
30
|
+
#
|
31
|
+
# * There are a few more methods yet to borrow from Array.
|
32
|
+
# Consider how #+, #-, etc. ought to work.
|
33
|
+
#
|
34
|
+
# == Author
|
35
|
+
#
|
36
|
+
# * Thomas Sawyer
|
37
|
+
#
|
38
|
+
# == Copying
|
39
|
+
#
|
40
|
+
# Copyright (c) 2005 Thomas Sawyer
|
41
|
+
#
|
42
|
+
# Ruby License
|
43
|
+
#
|
44
|
+
# This module is free software. You may use, modify, and/or
|
45
|
+
# redistribute this software under the same terms as Ruby.
|
46
|
+
#
|
47
|
+
# This program is distributed in the hope that it will be useful,
|
48
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
49
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
50
|
+
|
51
|
+
require 'facets/multiton'
|
52
|
+
|
53
|
+
# = Tuple
|
54
|
+
#
|
55
|
+
# A tuple can be made using #new or #[] just as one builds an array,
|
56
|
+
# or using the #to_t method on a string or array. With a string tuple
|
57
|
+
# remembers the first non-alphanumeric character as the tuple divider.
|
58
|
+
#
|
59
|
+
# == Usage
|
60
|
+
#
|
61
|
+
# t1 = Tuple[1,2,3]
|
62
|
+
# t2 = Tuple[2,3,4]
|
63
|
+
#
|
64
|
+
# t1 < t2 #=> true
|
65
|
+
# t1 > t2 #=> false
|
66
|
+
#
|
67
|
+
# t1 = '1.2.3'.to_t
|
68
|
+
# t2 = '1-2-3'.to_t
|
69
|
+
#
|
70
|
+
# puts t1 #=> 1.2.3
|
71
|
+
# puts t2 #=> 1-2-3
|
72
|
+
#
|
73
|
+
# t1 == t2 #=> true
|
74
|
+
#
|
75
|
+
# Keep in mind that Tuple[1,2,3] is not the same as Tuple['1','2','3'].
|
76
|
+
|
77
|
+
class Tuple
|
78
|
+
|
79
|
+
include ::Multiton
|
80
|
+
include ::Enumerable
|
81
|
+
include ::Comparable
|
82
|
+
|
83
|
+
def self.multiton_id(arg=0, default=0, &block)
|
84
|
+
if block_given?
|
85
|
+
values = []
|
86
|
+
arg.times { |i| values << block[i] }
|
87
|
+
elseif Integer === arg
|
88
|
+
values = [ default ] * arg
|
89
|
+
else
|
90
|
+
values = arg.to_ary
|
91
|
+
end
|
92
|
+
values
|
93
|
+
end
|
94
|
+
|
95
|
+
def initialize(arg=0, default=0, &blk)
|
96
|
+
if block_given?
|
97
|
+
@values = []
|
98
|
+
arg.times { |i| @values << blk[i] }
|
99
|
+
elseif Integer === arg
|
100
|
+
@values = [ default ] * arg
|
101
|
+
else
|
102
|
+
@values = arg.to_ary
|
103
|
+
end
|
104
|
+
@default = default
|
105
|
+
@divider = '.'
|
106
|
+
end
|
107
|
+
|
108
|
+
attr_accessor :default
|
109
|
+
|
110
|
+
def divider( set=nil )
|
111
|
+
return @divider unless set
|
112
|
+
@divider = set
|
113
|
+
self
|
114
|
+
end
|
115
|
+
|
116
|
+
protected
|
117
|
+
|
118
|
+
def values() @values end
|
119
|
+
|
120
|
+
public
|
121
|
+
|
122
|
+
def inspect() to_a.inspect end
|
123
|
+
|
124
|
+
def to_t() self end
|
125
|
+
def to_tuple() self end
|
126
|
+
|
127
|
+
def to_a() Array(@values) end
|
128
|
+
def to_ary() Array(@values) end
|
129
|
+
|
130
|
+
def to_s( divider=nil )
|
131
|
+
@values.join(divider||@divider)
|
132
|
+
end
|
133
|
+
|
134
|
+
def size() @values.size end
|
135
|
+
def length() @values.size end
|
136
|
+
|
137
|
+
def empty?()
|
138
|
+
return true if @values.empty?
|
139
|
+
return true if @values == [ @default ] * @values.size
|
140
|
+
false
|
141
|
+
end
|
142
|
+
|
143
|
+
def each( &block )
|
144
|
+
@values.each( &block )
|
145
|
+
end
|
146
|
+
|
147
|
+
def each_index( &block )
|
148
|
+
@values.each_index( &block )
|
149
|
+
end
|
150
|
+
|
151
|
+
def [](i)
|
152
|
+
@values.fetch(i,@default)
|
153
|
+
end
|
154
|
+
|
155
|
+
def []=(i,v)
|
156
|
+
@values[i] = v
|
157
|
+
end
|
158
|
+
|
159
|
+
def index() @values.index end
|
160
|
+
def rindex() @values.rindex end
|
161
|
+
|
162
|
+
# Unlike Array, Tuple#<< cannot act in place
|
163
|
+
# becuase Tuple's are immutable.
|
164
|
+
def <<( obj )
|
165
|
+
self.class.instance( to_a << obj )
|
166
|
+
end
|
167
|
+
|
168
|
+
def pop() Tuple.instance( to_a.pop ) end
|
169
|
+
|
170
|
+
def push( obj ) Tuple.instance( to_a.push(obj) ) end
|
171
|
+
|
172
|
+
# Pulls a value off the beginning of a tuple.
|
173
|
+
# This method is otherwsie known as #shift.
|
174
|
+
def pull() Tuple.instance( to_a.shift ) end
|
175
|
+
|
176
|
+
# Stands for "Put On Top". This method is the opposite of #pull and is
|
177
|
+
# otherwise known as #unshift.
|
178
|
+
def pot( obj ) Tuple.instance( to_a.unshift(obj) ) end
|
179
|
+
|
180
|
+
alias_method :unshift, :pot
|
181
|
+
alias_method :shift, :pull
|
182
|
+
|
183
|
+
# Returns true if two tuple references are for the
|
184
|
+
# very same tuple.
|
185
|
+
def eql?( other )
|
186
|
+
return true if object_id == other.object_id
|
187
|
+
#return true if values.eql? other.values
|
188
|
+
end
|
189
|
+
|
190
|
+
def <=>( other )
|
191
|
+
other = other.to_t
|
192
|
+
[size, other.size].max.times do |i|
|
193
|
+
c = self[i] <=> other[i]
|
194
|
+
return c if c != 0
|
195
|
+
end
|
196
|
+
0
|
197
|
+
end
|
198
|
+
|
199
|
+
# For pessimistic constraint (like '~>' in gems)
|
200
|
+
def =~( other )
|
201
|
+
other = other.to_t
|
202
|
+
upver = other.dup
|
203
|
+
upver[0] += 1
|
204
|
+
self >= other and self < upver
|
205
|
+
end
|
206
|
+
|
207
|
+
def first() @values.first end
|
208
|
+
def last() @values.last end
|
209
|
+
|
210
|
+
# These are useful for using a Tuple as a version.
|
211
|
+
def major() @values.first end
|
212
|
+
def minor() @values.at(1) end
|
213
|
+
def teeny() @values.at(2) end
|
214
|
+
|
215
|
+
# Unique hash value.
|
216
|
+
def hash
|
217
|
+
# TODO This needs to take into account the default
|
218
|
+
# and maybe the divider too.
|
219
|
+
to_a.hash
|
220
|
+
end
|
221
|
+
|
222
|
+
# class-level -----------------------------------------------
|
223
|
+
|
224
|
+
class << self
|
225
|
+
|
226
|
+
def []( *args )
|
227
|
+
instance( args )
|
228
|
+
end
|
229
|
+
|
230
|
+
# Translates a string in the form on a set of numerical and/or
|
231
|
+
# alphanumerical characters separated by non-word characters (eg \W+)
|
232
|
+
# into a Tuple. The values of the tuple will be converted to integers
|
233
|
+
# if they are purely numerical.
|
234
|
+
#
|
235
|
+
# Tuple.cast_from_string('1.2.3a') #=> [1,2,"3a"]
|
236
|
+
#
|
237
|
+
# It you would like to control the interpretation of each value
|
238
|
+
# as it is added to the tuple you can supply a block.
|
239
|
+
#
|
240
|
+
# Tuple.cast_from_string('1.2.3a'){ |v| v.upcase } #=> ["1","2","3A"]
|
241
|
+
#
|
242
|
+
# This method is called by String#to_t.
|
243
|
+
|
244
|
+
def cast_from_string( str, &yld )
|
245
|
+
args = str.to_s.split(/\W+/)
|
246
|
+
div = /\W+/.match( str.to_s )[0]
|
247
|
+
if block_given?
|
248
|
+
args = args.collect{ |a| yld[a] }
|
249
|
+
else
|
250
|
+
args = args.collect { |i| /^[0-9]+$/ =~ i ? i.to_i : i }
|
251
|
+
end
|
252
|
+
self.instance( args ).divider( div )
|
253
|
+
end
|
254
|
+
|
255
|
+
#
|
256
|
+
|
257
|
+
def cast_from_array( arr )
|
258
|
+
self.instance( arr )
|
259
|
+
end
|
260
|
+
|
261
|
+
# Parses a constraint returning the operation as a lambda.
|
262
|
+
|
263
|
+
def constraint_to_lambda( constraint, &yld )
|
264
|
+
op, val = *parse_constraint( constraint, &yld )
|
265
|
+
lambda { |t| t.send(op, val) }
|
266
|
+
end
|
267
|
+
|
268
|
+
def parse_constraint( constraint, &yld )
|
269
|
+
constraint = constraint.strip
|
270
|
+
re = %r{^(=~|~>|<=|>=|==|=|<|>)?\s*(\d+(:?[-.]\d+)*)$}
|
271
|
+
if md = re.match( constraint )
|
272
|
+
if op = md[1]
|
273
|
+
op = '=~' if op == '~>'
|
274
|
+
op = '==' if op == '='
|
275
|
+
val = cast_from_string( md[2], &yld ) #instance( md[2] )
|
276
|
+
else
|
277
|
+
op = '=='
|
278
|
+
val = cast_from_string( constraint, &yld ) #instance( constraint )
|
279
|
+
end
|
280
|
+
else
|
281
|
+
raise ArgumentError, "invalid constraint"
|
282
|
+
end
|
283
|
+
return op, val
|
284
|
+
end
|
285
|
+
|
286
|
+
end
|
287
|
+
|
288
|
+
end
|
289
|
+
|
290
|
+
|
291
|
+
# Conveniently turn a string into a tuple.
|
292
|
+
|
293
|
+
class ::String
|
294
|
+
|
295
|
+
# Translates a string in the form on a set of numerical and/or
|
296
|
+
# alphanumerical characters separated by non-word characters (eg \W+)
|
297
|
+
# into a Tuple. The values of the tuple will be converted to integers
|
298
|
+
# if they are purely numerical.
|
299
|
+
#
|
300
|
+
# '1.2.3a'.to_t #=> [1,2,"3a"]
|
301
|
+
#
|
302
|
+
# It you would like to control the interpretation of each value
|
303
|
+
# as it is added to the tuple you can supply a block.
|
304
|
+
#
|
305
|
+
# '1.2.3a'.to_t { |v| v.upcase } #=> ["1","2","3A"]
|
306
|
+
#
|
307
|
+
# This method calls Tuple.cast_from_string.
|
308
|
+
|
309
|
+
def to_t( &yld )
|
310
|
+
Tuple.cast_from_string( self, &yld )
|
311
|
+
end
|
312
|
+
|
313
|
+
end
|
314
|
+
|
315
|
+
|
316
|
+
# Convert and array into a tuple.
|
317
|
+
|
318
|
+
class ::Array
|
319
|
+
|
320
|
+
def to_t
|
321
|
+
Tuple.cast_from_array( self )
|
322
|
+
end
|
323
|
+
|
324
|
+
end
|
325
|
+
|
@@ -0,0 +1,261 @@
|
|
1
|
+
# = TypeCast
|
2
|
+
#
|
3
|
+
# Provides a generic simple type conversion utility. All the ruby core
|
4
|
+
# conversions are available by default.
|
5
|
+
#
|
6
|
+
# "1234".cast_to Float => 1234.0 (Float)
|
7
|
+
# Time.cast_from("6:30") => 1234.0 (Time)
|
8
|
+
#
|
9
|
+
# To implement a new type conversion, you have two choices, take:
|
10
|
+
#
|
11
|
+
# class CustomType
|
12
|
+
# def initialize(my_var)
|
13
|
+
# @my_var = my_var
|
14
|
+
# end
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# Define a to_class_name instance method
|
18
|
+
#
|
19
|
+
# class CustomType
|
20
|
+
# def to_string
|
21
|
+
# my_var.to_s
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# c = CustomType.new 1234
|
26
|
+
# s.cast_to String => "1234" (String)
|
27
|
+
#
|
28
|
+
# Define a from_class_name class method
|
29
|
+
#
|
30
|
+
# class CustomType
|
31
|
+
# def self.from_string(str)
|
32
|
+
# self.new(str)
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# "1234".cast_to CustomType => #<CustomType:0xb7d1958c @my_var="1234">
|
37
|
+
#
|
38
|
+
# Those two methods are equivalent in the result. It was coded like that to
|
39
|
+
# avoid the pollution of core classes with tons of to_* methods.
|
40
|
+
#
|
41
|
+
# The standard methods to_s, to_f, to_i, to_a and to_sym are also used by
|
42
|
+
# this system if available.
|
43
|
+
#
|
44
|
+
# == Faq
|
45
|
+
#
|
46
|
+
# Q. Why didn't you name the `cast_to` method to `to` ?
|
47
|
+
#
|
48
|
+
# A. Even if it would make the syntax more friendly, I suspect it could cause
|
49
|
+
# a lot of collisions with already existing code. The goal is that each
|
50
|
+
# time you call cast_to, you either get your result, either a
|
51
|
+
# TypeCastException
|
52
|
+
#
|
53
|
+
# == Authors
|
54
|
+
#
|
55
|
+
# * Jonas Pfenniger
|
56
|
+
#
|
57
|
+
# == History
|
58
|
+
#
|
59
|
+
# * 2006-06-06 3v1l_d4y:
|
60
|
+
# * Removed transformation options.
|
61
|
+
# * Removed StringIO typecast. It is not required by default.
|
62
|
+
# * Added TypeCastException for better error reporting while coding.
|
63
|
+
#
|
64
|
+
# == Todo
|
65
|
+
#
|
66
|
+
# * Consider how this might fit in with method signitures, overloading,
|
67
|
+
# and expiremental euphoria-like type system.
|
68
|
+
#
|
69
|
+
# * Look to implement to_int, to_mailtext, to_r, to_rfc822text and to_str.
|
70
|
+
#
|
71
|
+
# == Copying
|
72
|
+
#
|
73
|
+
# Copyright (c) 2004 Jonas Pfenniger
|
74
|
+
#
|
75
|
+
# Ruby License
|
76
|
+
#
|
77
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
78
|
+
# software under the same terms as Ruby.
|
79
|
+
#
|
80
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
81
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
82
|
+
# FOR A PARTICULAR PURPOSE.
|
83
|
+
|
84
|
+
require 'time'
|
85
|
+
require 'facets/string/methodize'
|
86
|
+
require 'facets/string/camelcase' #modulize'
|
87
|
+
|
88
|
+
# = Typecast
|
89
|
+
#
|
90
|
+
# Provides a generic simple type conversion utility. All the ruby core
|
91
|
+
# conversions are available by default.
|
92
|
+
#
|
93
|
+
# "1234".cast_to Float => 1234.0 (Float)
|
94
|
+
# Time.cast_from("6:30") => 1234.0 (Time)
|
95
|
+
#
|
96
|
+
# To implement a new type conversion, you have two choices, take:
|
97
|
+
#
|
98
|
+
# class CustomType
|
99
|
+
# def initialize(my_var)
|
100
|
+
# @my_var = my_var
|
101
|
+
# end
|
102
|
+
# end
|
103
|
+
#
|
104
|
+
# Define a to_class_name instance method
|
105
|
+
#
|
106
|
+
# class CustomType
|
107
|
+
# def to_string
|
108
|
+
# my_var.to_s
|
109
|
+
# end
|
110
|
+
# end
|
111
|
+
#
|
112
|
+
# c = CustomType.new 1234
|
113
|
+
# s.cast_to String => "1234" (String)
|
114
|
+
#
|
115
|
+
# Define a from_class_name class method
|
116
|
+
#
|
117
|
+
# class CustomType
|
118
|
+
# def self.from_string(str)
|
119
|
+
# self.new(str)
|
120
|
+
# end
|
121
|
+
# end
|
122
|
+
#
|
123
|
+
# "1234".cast_to CustomType => #<CustomType:0xb7d1958c @my_var="1234">
|
124
|
+
#
|
125
|
+
# Those two methods are equivalent in the result. It was coded like that to
|
126
|
+
# avoid the pollution of core classes with tons of to_* methods.
|
127
|
+
#
|
128
|
+
# The standard methods to_s, to_f, to_i, to_a and to_sym are also used by
|
129
|
+
# this system if available.
|
130
|
+
#
|
131
|
+
# == Faq
|
132
|
+
#
|
133
|
+
# Q. Why didn't you name the `cast_to` method to `to` ?
|
134
|
+
#
|
135
|
+
# A. Even if it would make the syntax more friendly, I suspect it could cause
|
136
|
+
# a lot of collisions with already existing code. The goal is that each
|
137
|
+
# time you call cast_to, you either get your result, either a
|
138
|
+
# TypeCastException
|
139
|
+
#
|
140
|
+
module TypeCast
|
141
|
+
|
142
|
+
# Typecast method extensions for Object class.
|
143
|
+
|
144
|
+
module Object
|
145
|
+
# Cast an object to another
|
146
|
+
#
|
147
|
+
# 1234.cast_to(String) => "1234"
|
148
|
+
#
|
149
|
+
def cast_to(klass)
|
150
|
+
klass.cast_from(self)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
# Typecast method extensions for Class class.
|
155
|
+
|
156
|
+
module Class
|
157
|
+
# Cast on object from another.
|
158
|
+
#
|
159
|
+
# String.cast_from(1234) => "1234"
|
160
|
+
#
|
161
|
+
def cast_from(object)
|
162
|
+
method_to = "to_#{self.name.methodize}".to_sym
|
163
|
+
if object.respond_to? method_to
|
164
|
+
retval = object.send(method_to)
|
165
|
+
return retval
|
166
|
+
end
|
167
|
+
method_from = "from_#{object.class.name.methodize}".to_sym
|
168
|
+
if respond_to? method_from
|
169
|
+
retval = send(method_from, object)
|
170
|
+
return retval
|
171
|
+
end
|
172
|
+
raise TypeCastException, "TypeCasting from #{object.class.name} to #{self.name} not supported"
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|
177
|
+
|
178
|
+
# TypeCast Exception error.
|
179
|
+
#
|
180
|
+
class TypeCastException < Exception; end
|
181
|
+
|
182
|
+
class Object #:nodoc:
|
183
|
+
include TypeCast::Object
|
184
|
+
end
|
185
|
+
|
186
|
+
class Class #:nodoc:
|
187
|
+
include TypeCast::Class
|
188
|
+
end
|
189
|
+
|
190
|
+
class Array #:nodoc:
|
191
|
+
def self.cast_from(object)
|
192
|
+
return super
|
193
|
+
rescue TypeCastException
|
194
|
+
return object.to_a if object.respond_to? :to_a
|
195
|
+
raise
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
class Float #:nodoc:
|
200
|
+
def self.cast_from(object)
|
201
|
+
return super
|
202
|
+
rescue TypeCastException
|
203
|
+
return object.to_f if object.respond_to? :to_f
|
204
|
+
raise
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
class Integer #:nodoc:
|
209
|
+
def self.cast_from(object)
|
210
|
+
return super
|
211
|
+
rescue TypeCastException
|
212
|
+
return object.to_i if object.respond_to? :to_i
|
213
|
+
raise
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
class String #:nodoc:
|
218
|
+
def self.cast_from(object)
|
219
|
+
return super
|
220
|
+
rescue TypeCastException
|
221
|
+
return object.to_s if object.respond_to? :to_s
|
222
|
+
raise
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
class Symbol #:nodoc:
|
227
|
+
def self.cast_from(object)
|
228
|
+
return super
|
229
|
+
rescue TypeCastException
|
230
|
+
return object.to_sym if object.respond_to? :to_sym
|
231
|
+
raise
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
# Special Extensions
|
236
|
+
|
237
|
+
class Class #:nodoc:
|
238
|
+
# "string".cast_to Class #=> String
|
239
|
+
def self.from_string(string)
|
240
|
+
string = string.to_s.camelcase #modulize
|
241
|
+
base = string.sub!(/^::/, '') ? Object : (self.kind_of?(Module) ? self : self.class )
|
242
|
+
klass = string.split(/::/).inject(base){ |mod, name| mod.const_get(name) }
|
243
|
+
return klass if klass.kind_of? Class
|
244
|
+
nil
|
245
|
+
rescue
|
246
|
+
nil
|
247
|
+
end
|
248
|
+
|
249
|
+
class << self
|
250
|
+
alias_method :from_symbol, :from_string
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
class Time #:nodoc:
|
255
|
+
def self.from_string(string, options={})
|
256
|
+
parse(string)
|
257
|
+
rescue
|
258
|
+
nil
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|