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,175 @@
|
|
1
|
+
warn "use rich_units for future version"
|
2
|
+
|
3
|
+
# = Bytes
|
4
|
+
#
|
5
|
+
# WARNING: Use Rich Units package for future compatibilty!
|
6
|
+
#
|
7
|
+
# == Synopisis
|
8
|
+
#
|
9
|
+
# Additional methods for Numeric class to make working with
|
10
|
+
# bits and bytes easier.
|
11
|
+
#
|
12
|
+
# Additional methods for Numeric class to make working with
|
13
|
+
# bits and bytes easier. Bits are used as the base value and
|
14
|
+
# these methods can be used to convert between different
|
15
|
+
# magnitudes.
|
16
|
+
#
|
17
|
+
# 1.byte #=> 8
|
18
|
+
# 2.bytes #=> 16
|
19
|
+
# 1.kilobit #=> 1024
|
20
|
+
# 1.kilobyte #=> 8192
|
21
|
+
#
|
22
|
+
# Use the in_* methods to perform the inverse operations.
|
23
|
+
#
|
24
|
+
# 8192.in_kilobytes #=> 1
|
25
|
+
# 1024.in_kilobits #=> 1
|
26
|
+
#
|
27
|
+
# == History
|
28
|
+
#
|
29
|
+
# Special thanks to Richard Kilmer for the orignal work.
|
30
|
+
# This library is based on the original library bytes.rb
|
31
|
+
# Copyright (c) 2004 by Rich Kilmer.
|
32
|
+
#
|
33
|
+
# Also thanks to Alexander Kellett for suggesting it be
|
34
|
+
# included in Facets.
|
35
|
+
#
|
36
|
+
# == Authors
|
37
|
+
#
|
38
|
+
# * Rich Kilmer
|
39
|
+
# * Thomas Sawyer
|
40
|
+
#
|
41
|
+
# == NOTES
|
42
|
+
#
|
43
|
+
# This library is not compatible with STICK's units.rb (an spin-off
|
44
|
+
# of Facets old units.rb library). Do not attempt to use both at the same time.
|
45
|
+
#
|
46
|
+
# == Todo
|
47
|
+
#
|
48
|
+
# * Currently kilo, mega, etc. are all powers of two and not ten,
|
49
|
+
# which technically isn't corrent even though it is common usage.
|
50
|
+
# * The in_* notation is weak. If a better nomentclature is thought
|
51
|
+
# of then consider changing this.
|
52
|
+
#
|
53
|
+
# == Copying
|
54
|
+
#
|
55
|
+
# Copyright (c) 2005 Rich Kilmer
|
56
|
+
#
|
57
|
+
# Ruby License
|
58
|
+
#
|
59
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
60
|
+
# software under the same terms as Ruby.
|
61
|
+
#
|
62
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
63
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
64
|
+
# FOR A PARTICULAR PURPOSE.
|
65
|
+
|
66
|
+
|
67
|
+
# = Bytes
|
68
|
+
#
|
69
|
+
# Additional methods for Numeric class to make working with
|
70
|
+
# bits and bytes easier. Bits are used as the base value and
|
71
|
+
# these methods can be used to convert between different
|
72
|
+
# magnitudes.
|
73
|
+
#
|
74
|
+
# 1.byte #=> 8
|
75
|
+
# 2.bytes #=> 16
|
76
|
+
# 1.kilobit #=> 1024
|
77
|
+
# 1.kilobyte #=> 8192
|
78
|
+
#
|
79
|
+
# Use the in_* methods to perform the inverse operations.
|
80
|
+
#
|
81
|
+
# 8192.in_kilobytes #=> 1
|
82
|
+
# 1024.in_kilobits #=> 1
|
83
|
+
#
|
84
|
+
class Numeric
|
85
|
+
|
86
|
+
def bit ; self ; end
|
87
|
+
def bits ; self ; end
|
88
|
+
def byte ; self * 8 ; end
|
89
|
+
def bytes ; self * 8 ; end
|
90
|
+
|
91
|
+
[ 'kilo', 'mega', 'giga', 'tera', 'peta', 'exa' ].each_with_index do |m, i|
|
92
|
+
j = i + 1
|
93
|
+
class_eval %{
|
94
|
+
def #{m}bit ; self * #{1024**j} ; end
|
95
|
+
def #{m}byte ; self * #{1024**j*8} ; end
|
96
|
+
def in_#{m}bits ; self / #{1024**j} ; end
|
97
|
+
def in_#{m}bytes ; self / #{1024**j*8} ; end
|
98
|
+
alias_method :#{m}bits, :#{m}bit
|
99
|
+
alias_method :#{m}bytes, :#{m}byte
|
100
|
+
}
|
101
|
+
end
|
102
|
+
|
103
|
+
[ 'kibi', 'mebi', 'gibi', 'tebi', 'pebi', 'exbi' ].each_with_index do |m, i|
|
104
|
+
j = i + 1
|
105
|
+
class_eval %{
|
106
|
+
def #{m}bit ; self * #{1024**j} ; end
|
107
|
+
def #{m}byte ; self * #{1024**j*8} ; end
|
108
|
+
def in_#{m}bits ; self / #{1024**j} ; end
|
109
|
+
def in_#{m}bytes ; self / #{1024**j*8} ; end
|
110
|
+
alias_method :#{m}bits, :#{m}bit
|
111
|
+
alias_method :#{m}bytes, :#{m}byte
|
112
|
+
}
|
113
|
+
end
|
114
|
+
|
115
|
+
# Formated string of bits proportial to size.
|
116
|
+
#
|
117
|
+
# 1024.bits_to_s #=> "1.00 kb"
|
118
|
+
# 1048576.bits_to_s #=> "1.00 mb"
|
119
|
+
# 1073741824.bits_to_s #=> "1.00 gb"
|
120
|
+
# 1099511627776.bits_to_s #=> "1.00 tb"
|
121
|
+
#
|
122
|
+
# Takes a format string to adjust output.
|
123
|
+
#
|
124
|
+
# 1024.bits_to_s('%.0f') #=> "1 kb"
|
125
|
+
#
|
126
|
+
def strfbits(fmt='%.2f')
|
127
|
+
case
|
128
|
+
when self < 1024
|
129
|
+
"#{self} bits"
|
130
|
+
when self < 1024**2
|
131
|
+
"#{fmt % (self.to_f / 1024)} kb"
|
132
|
+
when self < 1024**3
|
133
|
+
"#{fmt % (self.to_f / 1024**2)} mb"
|
134
|
+
when self < 1024**4
|
135
|
+
"#{fmt % (self.to_f / 1024**3)} gb"
|
136
|
+
when self < 1024**5
|
137
|
+
"#{fmt % (self.to_f / 1024**4)} tb"
|
138
|
+
else
|
139
|
+
"#{self} bits"
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
# Formated string of bytes proportial to size.
|
144
|
+
#
|
145
|
+
# 1024.bytes_to_s #=> "1.00 KB"
|
146
|
+
# 1048576.bytes_to_s #=> "1.00 MB"
|
147
|
+
# 1073741824.bytes_to_s #=> "1.00 GB"
|
148
|
+
# 1099511627776.bytes_to_s #=> "1.00 TB"
|
149
|
+
#
|
150
|
+
# Takes a format string to adjust output.
|
151
|
+
#
|
152
|
+
# 1024.bytes_to_s('%.0f') #=> "1 KB"
|
153
|
+
#
|
154
|
+
def strfbytes(fmt='%.2f')
|
155
|
+
case
|
156
|
+
when self < 1024
|
157
|
+
"#{self} bytes"
|
158
|
+
when self < 1024**2
|
159
|
+
"#{fmt % (self.to_f / 1024)} KB"
|
160
|
+
when self < 1024**3
|
161
|
+
"#{fmt % (self.to_f / 1024**2)} MB"
|
162
|
+
when self < 1024**4
|
163
|
+
"#{fmt % (self.to_f / 1024**3)} GB"
|
164
|
+
when self < 1024**5
|
165
|
+
"#{fmt % (self.to_f / 1024**4)} TB"
|
166
|
+
else
|
167
|
+
"#{self} bytes"
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# deprecated
|
172
|
+
alias_method :octet_units, :strfbytes
|
173
|
+
|
174
|
+
end
|
175
|
+
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# = CacheDecorator
|
2
|
+
#
|
3
|
+
# == Synopsis
|
4
|
+
#
|
5
|
+
# CacheDecorator wrap objects to provide cached versions of method calls.
|
6
|
+
#
|
7
|
+
# class X
|
8
|
+
# def initialize ; @tick = 0 ; end
|
9
|
+
# def tick; @tick + 1; end
|
10
|
+
# def cached; @cache ||= CacheDecorator.new(self) ; end
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# x = X.new
|
14
|
+
# x.tick #=> 1
|
15
|
+
# x.cached.tick #=> 2
|
16
|
+
# x.tick #=> 3
|
17
|
+
# x.cached.tick #=> 2
|
18
|
+
# x.tick #=> 4
|
19
|
+
# x.cached.tick #=> 2
|
20
|
+
#
|
21
|
+
# You can also use to cache a collections of objects to gain code
|
22
|
+
# speed ups.
|
23
|
+
#
|
24
|
+
# points = points.collect{|point| Cache.cache(point)}
|
25
|
+
#
|
26
|
+
# After our algorithm has finished using points, we want to get rid of
|
27
|
+
# these Cache objects. That's easy:
|
28
|
+
#
|
29
|
+
# points = points.collect{|point| point.self }
|
30
|
+
#
|
31
|
+
# Or if you prefer (it is ever so slightly safer):
|
32
|
+
#
|
33
|
+
# points = points.collect{|point| Cache.uncache(point)}
|
34
|
+
#
|
35
|
+
# == Authors
|
36
|
+
#
|
37
|
+
# * Erik Veenstra
|
38
|
+
# * Thomas Sawyer
|
39
|
+
#
|
40
|
+
# == Copying
|
41
|
+
#
|
42
|
+
# Copyright (c) 2006 Erik Veenstra
|
43
|
+
#
|
44
|
+
# Ruby License
|
45
|
+
#
|
46
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
47
|
+
# software under the same terms as Ruby.
|
48
|
+
#
|
49
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
50
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
51
|
+
# FOR A PARTICULAR PURPOSE.
|
52
|
+
|
53
|
+
# = CacheDecorator
|
54
|
+
#
|
55
|
+
# CacheDecorator wrap objects to provide cached versions of method calls.
|
56
|
+
#
|
57
|
+
# == Usage
|
58
|
+
#
|
59
|
+
# class X
|
60
|
+
# def initialize ; @tick = 0 ; end
|
61
|
+
# def tick; @tick + 1; end
|
62
|
+
# def cached; @cache ||= CacheDecorator.new(self) ; end
|
63
|
+
# end
|
64
|
+
#
|
65
|
+
# x = X.new
|
66
|
+
# x.tick #=> 1
|
67
|
+
# x.cached.tick #=> 2
|
68
|
+
# x.tick #=> 3
|
69
|
+
# x.cached.tick #=> 2
|
70
|
+
# x.tick #=> 4
|
71
|
+
# x.cached.tick #=> 2
|
72
|
+
#
|
73
|
+
# You can also use to cache a collections of objects to gain code
|
74
|
+
# speed ups.
|
75
|
+
#
|
76
|
+
# points = points.collect{|point| Cache.cache(point)}
|
77
|
+
#
|
78
|
+
# After our algorithm has finished using points, we want to get rid of
|
79
|
+
# these Cache objects. That's easy:
|
80
|
+
#
|
81
|
+
# points = points.collect{|point| point.self }
|
82
|
+
#
|
83
|
+
# Or if you prefer (it is ever so slightly safer):
|
84
|
+
#
|
85
|
+
# points = points.collect{|point| Cache.uncache(point)}
|
86
|
+
#
|
87
|
+
class CacheDecorator
|
88
|
+
|
89
|
+
#private :class, :clone, :display, :type, :method, :to_a, :to_s
|
90
|
+
private *instance_methods(true).select{ |m| m.to_s !~ /^__/ }
|
91
|
+
|
92
|
+
def initialize(object)
|
93
|
+
@self = object
|
94
|
+
@cache = {}
|
95
|
+
end
|
96
|
+
|
97
|
+
def method_missing(method_name, *args, &block)
|
98
|
+
# Not thread-safe! Speed is important in caches... ;]
|
99
|
+
@cache[[method_name, args, block]] ||= @self.__send__(method_name, *args, &block)
|
100
|
+
end
|
101
|
+
|
102
|
+
def self; @self; end
|
103
|
+
|
104
|
+
def self.cache(object)
|
105
|
+
Cache.new(object)
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.uncache(cached_object)
|
109
|
+
cached_object.self
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
# These are for backward compatibility (to be DEPRECATED)
|
115
|
+
Cache = CacheDecorator
|
116
|
+
CacheDelegator = Cache
|
117
|
+
|
@@ -0,0 +1,258 @@
|
|
1
|
+
# = Capsule
|
2
|
+
#
|
3
|
+
# A Capsule is subclass of Module. It encapsulates an extenal script
|
4
|
+
# as a funcitons module.
|
5
|
+
#
|
6
|
+
# A module which is an instance of the Capsule class encapsulates in its scope
|
7
|
+
# the top-level methods, top-level constants, and instance variables defined in
|
8
|
+
# a ruby script file (and its subfiles) loaded by a ruby program. This allows
|
9
|
+
# use of script files to define objects that can be loaded into a program in
|
10
|
+
# much the same way that objects can be loaded from YAML or Marshal files.
|
11
|
+
#
|
12
|
+
# See intro.txt[link:files/intro_txt.html] for an overview.
|
13
|
+
#
|
14
|
+
# == Authors
|
15
|
+
#
|
16
|
+
# * Joel VanderWerf
|
17
|
+
# * Thomas Sawyer
|
18
|
+
#
|
19
|
+
# == Todo
|
20
|
+
#
|
21
|
+
# * The name of this is rather weak. Think of a better one.
|
22
|
+
#
|
23
|
+
# == Copying
|
24
|
+
#
|
25
|
+
# Copyright (c) 2005 Thomas Sawyer, Joel VanderWerf
|
26
|
+
#
|
27
|
+
# Ruby License
|
28
|
+
#
|
29
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
30
|
+
# software under the same terms as Ruby.
|
31
|
+
#
|
32
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
33
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
34
|
+
# FOR A PARTICULAR PURPOSE.
|
35
|
+
|
36
|
+
#require 'rbconfig'
|
37
|
+
|
38
|
+
# = Capsule
|
39
|
+
#
|
40
|
+
# A Capsule is subclass of Module. It encapsulates an extenal script
|
41
|
+
# as a funcitons module.
|
42
|
+
#
|
43
|
+
# A module which is an instance of the Capsule class encapsulates in its scope
|
44
|
+
# the top-level methods, top-level constants, and instance variables defined in
|
45
|
+
# a ruby script file (and its subfiles) loaded by a ruby program. This allows
|
46
|
+
# use of script files to define objects that can be loaded into a program in
|
47
|
+
# much the same way that objects can be loaded from YAML or Marshal files.
|
48
|
+
#
|
49
|
+
# See intro.txt[link:files/intro_txt.html] for an overview.
|
50
|
+
|
51
|
+
class Capsule < Module
|
52
|
+
|
53
|
+
#DLEXT = Config::CONFIG['DLEXT']
|
54
|
+
|
55
|
+
# The script file with which the Import was instantiated.
|
56
|
+
attr_reader :main_file
|
57
|
+
|
58
|
+
# The directory in which main_file is located, and relative to which
|
59
|
+
# #load searches for files before falling back to Kernel#load.
|
60
|
+
#attr_reader :dir
|
61
|
+
|
62
|
+
# An array of paths to search for scripts. This has the same
|
63
|
+
# semantics as <tt>$:</tt>, alias <tt>$LOAD_PATH</tt>, excpet
|
64
|
+
# that it is local to this script. The path of the current
|
65
|
+
# script is added automatically (equivalent to '.')
|
66
|
+
attr_reader :load_path
|
67
|
+
|
68
|
+
# A hash that maps <tt>filename=>true</tt> for each file that has been
|
69
|
+
# required locally by the script. This has the same semantics as <tt>$"</tt>,
|
70
|
+
# alias <tt>$LOADED_FEATURES</tt>, except that it is local to this script.
|
71
|
+
attr_reader :loaded_features
|
72
|
+
|
73
|
+
class << self
|
74
|
+
# As with #new but will search Ruby's $LOAD_PATH first.
|
75
|
+
#--
|
76
|
+
# Will also try .rb, .so, .dll, et al extensions, like require does.
|
77
|
+
#++
|
78
|
+
def load(main_file, options=nil, &block)
|
79
|
+
file = nil
|
80
|
+
$LOAD_PATH.each do |path|
|
81
|
+
break if file = File.file?(File.join(path, main_file))
|
82
|
+
#break if file = Dir.glob(File.join(path, main_file)+'{,.rb,.'+DLEXT+'}')[0]
|
83
|
+
end
|
84
|
+
new(file || main_file, options=nil, &block)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Creates new Capsule, and loads _main_file_ in the scope of the script. If a
|
89
|
+
# block is given, the script is passed to it before loading from the file, and
|
90
|
+
# constants can be defined as inputs to the script.
|
91
|
+
|
92
|
+
def initialize(main_file, options=nil, &block)
|
93
|
+
extend self
|
94
|
+
|
95
|
+
options ||= {}
|
96
|
+
|
97
|
+
@main_file = File.expand_path(main_file)
|
98
|
+
@load_path = options[:load_path] || []
|
99
|
+
#@load_path |= [File.dirname(@main_file)] # before or after?
|
100
|
+
@loaded_features = options[:loaded_features] || {}
|
101
|
+
|
102
|
+
# TODO In order to load/require at the instance level.
|
103
|
+
# This needs to be in a separate namespace however
|
104
|
+
# b/c it can interfere with what is expected.
|
105
|
+
#[ :require, :load ].each{ |meth|
|
106
|
+
# m = method(meth)
|
107
|
+
# define_method(meth) do |*args| m.call(*args) end
|
108
|
+
#}
|
109
|
+
|
110
|
+
module_eval(&block) if block
|
111
|
+
extend self
|
112
|
+
|
113
|
+
load_in_module(main_file)
|
114
|
+
end
|
115
|
+
|
116
|
+
# Lookup feature in load path.
|
117
|
+
|
118
|
+
def load_path_lookup(feature)
|
119
|
+
paths = File.join('{' + @load_path.join(',') + '}', feature + '{,.rb,.rbs}')
|
120
|
+
files = Dir.glob(paths)
|
121
|
+
match = files.find{ |f| ! @loaded_features.include?(f) }
|
122
|
+
return match
|
123
|
+
end
|
124
|
+
|
125
|
+
# Loads _file_ into the capsule. Searches relative to the local dir, that is,
|
126
|
+
# the dir of the file given in the original call to
|
127
|
+
# <tt>Capsule.load(file)</tt>, loads the file, if found, into this Capsule's
|
128
|
+
# scope, and returns true. If the file is not found, falls back to
|
129
|
+
# <tt>Kernel.load</tt>, which searches on <tt>$LOAD_PATH</tt>, loads the file,
|
130
|
+
# if found, into global scope, and returns true. Otherwise, raises
|
131
|
+
# <tt>LoadError</tt>.
|
132
|
+
#
|
133
|
+
# The _wrap_ argument is passed to <tt>Kernel.load</tt> in the fallback case,
|
134
|
+
# when the file is not found locally.
|
135
|
+
#
|
136
|
+
# Typically called from within the main file to load additional sub files, or
|
137
|
+
# from those sub files.
|
138
|
+
#
|
139
|
+
#--
|
140
|
+
# TODO Need to add load_path lookup.
|
141
|
+
#++
|
142
|
+
|
143
|
+
def load(file, wrap = false)
|
144
|
+
load_in_module(File.join(@dir, file))
|
145
|
+
true
|
146
|
+
rescue MissingFile
|
147
|
+
super
|
148
|
+
end
|
149
|
+
|
150
|
+
# Analogous to <tt>Kernel#require</tt>. First tries the local dir, then falls
|
151
|
+
# back to <tt>Kernel#require</tt>. Will load a given _feature_ only once.
|
152
|
+
#
|
153
|
+
# Note that extensions (*.so, *.dll) can be required in the global scope, as
|
154
|
+
# usual, but not in the local scope. (This is not much of a limitation in
|
155
|
+
# practice--you wouldn't want to load an extension more than once.) This
|
156
|
+
# implementation falls back to <tt>Kernel#require</tt> when the argument is an
|
157
|
+
# extension or is not found locally.
|
158
|
+
#
|
159
|
+
#--
|
160
|
+
# This was using load_in_module rather than include_script. Maybe is still should
|
161
|
+
# and one should have to call include_script instead? Think about this.
|
162
|
+
#++
|
163
|
+
|
164
|
+
def require(feature)
|
165
|
+
file = load_path_lookup(feature)
|
166
|
+
return super unless file
|
167
|
+
begin
|
168
|
+
@loaded_features[file] = true
|
169
|
+
load_in_module(file)
|
170
|
+
rescue MissingFile
|
171
|
+
@loaded_features[file] = false
|
172
|
+
super
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
# Raised by #load_in_module, caught by #load and #require.
|
177
|
+
class MissingFile < LoadError; end
|
178
|
+
|
179
|
+
# Loads _file_ in this module's context. Note that <tt>\_\_FILE\_\_</tt> and
|
180
|
+
# <tt>\_\_LINE\_\_</tt> work correctly in _file_.
|
181
|
+
# Called by #load and #require; not normally called directly.
|
182
|
+
|
183
|
+
def load_in_module(file)
|
184
|
+
module_eval(IO.read(file), File.expand_path(file))
|
185
|
+
rescue Errno::ENOENT => e
|
186
|
+
if /#{file}$/ =~ e.message
|
187
|
+
raise MissingFile, e.message
|
188
|
+
else
|
189
|
+
raise
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def include_script(file)
|
194
|
+
include self.class.new(file, :load_path=>load_path, :loaded_features=>loaded_features)
|
195
|
+
rescue Errno::ENOENT => e
|
196
|
+
if /#{file}$/ =~ e.message
|
197
|
+
raise MissingFile, e.message
|
198
|
+
else
|
199
|
+
raise
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
#
|
204
|
+
def include(*mods)
|
205
|
+
super
|
206
|
+
extend self
|
207
|
+
end
|
208
|
+
|
209
|
+
def to_s # :nodoc:
|
210
|
+
"#<#{self.class}:#{main_file}>"
|
211
|
+
end
|
212
|
+
|
213
|
+
end
|
214
|
+
|
215
|
+
# TODO Is autoimport bets name for this?
|
216
|
+
|
217
|
+
class Module
|
218
|
+
|
219
|
+
const_missing_definition_for_autoimport = lambda do
|
220
|
+
#$autoimport_activated = true
|
221
|
+
alias const_missing_before_autoimport const_missing
|
222
|
+
|
223
|
+
def const_missing(sym) # :nodoc:
|
224
|
+
filename = @autoimport && @autoimport[sym]
|
225
|
+
if filename
|
226
|
+
mod = Import.load(filename)
|
227
|
+
const_set sym, mod
|
228
|
+
else
|
229
|
+
const_missing_before_autoimport(sym)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
# When the constant named by symbol +mod+ is referenced, loads the script
|
235
|
+
# in filename using Capsule.load and defines the constant to be equal to the
|
236
|
+
# resulting Capsule module.
|
237
|
+
#
|
238
|
+
# Use like Module#autoload--however, the underlying opertation is #load rather
|
239
|
+
# than #require, because scripts, unlike libraries, can be loaded more than
|
240
|
+
# once. See examples/autoscript-example.rb
|
241
|
+
|
242
|
+
define_method(:autoimport) do |mod, file|
|
243
|
+
if @autoimport.empty? #unless $autoimport_activated
|
244
|
+
const_missing_definition_for_autoimport.call
|
245
|
+
end
|
246
|
+
(@autoimport ||= {})[mod] = file
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
|
251
|
+
module Kernel
|
252
|
+
|
253
|
+
# Calls Object.autoimport
|
254
|
+
def autoimport(mod, file)
|
255
|
+
Object.autoimport(mod, file)
|
256
|
+
end
|
257
|
+
|
258
|
+
end
|