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,132 @@
|
|
1
|
+
# = Event Hook
|
2
|
+
#
|
3
|
+
# Exception-based Event Hooks provides an Event Hooks system designed
|
4
|
+
# on top of Ruby's built-in Exception system.
|
5
|
+
#
|
6
|
+
# def dothis2
|
7
|
+
# puts 'pre'
|
8
|
+
# hook :quitit
|
9
|
+
# puts 'post'
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# def tryit2
|
13
|
+
# begin
|
14
|
+
# puts "BEFORE"
|
15
|
+
# dothis2
|
16
|
+
# puts "AFTER"
|
17
|
+
# rescue EventHook
|
18
|
+
# event :quitit do
|
19
|
+
# puts "HERE"
|
20
|
+
# end
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# tryit2
|
25
|
+
#
|
26
|
+
# == Authors
|
27
|
+
#
|
28
|
+
# * Thomas Sawyer
|
29
|
+
#
|
30
|
+
# == Copying
|
31
|
+
#
|
32
|
+
# Copyright (c) 2004 Thomas Sawyer
|
33
|
+
#
|
34
|
+
# Ruby License
|
35
|
+
#
|
36
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
37
|
+
# software under the same terms as Ruby.
|
38
|
+
#
|
39
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
40
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
41
|
+
# FOR A PARTICULAR PURPOSE.
|
42
|
+
|
43
|
+
|
44
|
+
# = Event Hook
|
45
|
+
#
|
46
|
+
# Exception-based Event Hooks provides an Event Hooks system designed
|
47
|
+
# on top of Ruby's built-in Exception system.
|
48
|
+
#
|
49
|
+
# def dothis2
|
50
|
+
# puts 'pre'
|
51
|
+
# hook :quitit
|
52
|
+
# puts 'post'
|
53
|
+
# end
|
54
|
+
#
|
55
|
+
# def tryit2
|
56
|
+
# begin
|
57
|
+
# puts "BEFORE"
|
58
|
+
# dothis2
|
59
|
+
# puts "AFTER"
|
60
|
+
# rescue EventHook
|
61
|
+
# event :quitit do
|
62
|
+
# puts "HERE"
|
63
|
+
# end
|
64
|
+
# end
|
65
|
+
# end
|
66
|
+
#
|
67
|
+
# tryit2
|
68
|
+
#
|
69
|
+
class EventHook < Exception
|
70
|
+
attr_reader :name, :cc
|
71
|
+
def initialize(name, cc)
|
72
|
+
@name = name
|
73
|
+
@cc = cc
|
74
|
+
end
|
75
|
+
def call
|
76
|
+
@cc.call
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
module Kernel
|
81
|
+
def hook(sym)
|
82
|
+
callcc{ |c| raise EventHook.new(sym, c) }
|
83
|
+
end
|
84
|
+
def event(sym)
|
85
|
+
if $!.name == sym
|
86
|
+
yield
|
87
|
+
$!.call
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
#
|
94
|
+
# Test
|
95
|
+
#
|
96
|
+
|
97
|
+
=begin
|
98
|
+
|
99
|
+
require 'test/unit'
|
100
|
+
|
101
|
+
class TestEventHook < Test::Unit::TestCase
|
102
|
+
|
103
|
+
class T
|
104
|
+
attr_reader :a
|
105
|
+
def dothis
|
106
|
+
@a << '{'
|
107
|
+
hook :here
|
108
|
+
@a << '}'
|
109
|
+
end
|
110
|
+
def tryit
|
111
|
+
@a = ''
|
112
|
+
begin
|
113
|
+
@a << "["
|
114
|
+
dothis
|
115
|
+
@a << "]"
|
116
|
+
rescue EventHook
|
117
|
+
event :here do
|
118
|
+
@a << "HERE"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_run
|
125
|
+
t = T.new
|
126
|
+
t.tryit
|
127
|
+
assert_equal('[{HERE}]', t.a)
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
=end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# = Expirable
|
2
|
+
#
|
3
|
+
# Generic expirability mixin.
|
4
|
+
#
|
5
|
+
# == Authors
|
6
|
+
#
|
7
|
+
# * George Moschovitis
|
8
|
+
#
|
9
|
+
# == Copying
|
10
|
+
#
|
11
|
+
# Copyright (c) 2004 George Moschovitis
|
12
|
+
#
|
13
|
+
# Ruby License
|
14
|
+
#
|
15
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
16
|
+
# software under the same terms as Ruby.
|
17
|
+
#
|
18
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
19
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
20
|
+
# FOR A PARTICULAR PURPOSE.
|
21
|
+
|
22
|
+
# = Expirable
|
23
|
+
#
|
24
|
+
# Generic expirability mixin.
|
25
|
+
#
|
26
|
+
module Expirable
|
27
|
+
|
28
|
+
attr_accessor :expires
|
29
|
+
|
30
|
+
# Set the expires timeout for this entry.
|
31
|
+
|
32
|
+
def expires_after(timeout = (60*60*24))
|
33
|
+
@expires = Time.now + timeout
|
34
|
+
end
|
35
|
+
|
36
|
+
# Set the expire timeout for this entry. The timeout happens
|
37
|
+
# after (base + rand(spread)) seconds.
|
38
|
+
|
39
|
+
def expires_spread(base, spread)
|
40
|
+
@expires = Time.now + base + rand(spread)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Is this entry expired?
|
44
|
+
|
45
|
+
def expired?
|
46
|
+
if @expires.nil? or (Time.now > @expires)
|
47
|
+
return true
|
48
|
+
else
|
49
|
+
return false
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Update the expiration period. Override in your application.
|
54
|
+
|
55
|
+
def touch!
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
# _____ _
|
63
|
+
# |_ _|__ ___| |_
|
64
|
+
# | |/ _ \/ __| __|
|
65
|
+
# | | __/\__ \ |_
|
66
|
+
# |_|\___||___/\__|
|
67
|
+
#
|
68
|
+
|
69
|
+
# TODO
|
70
|
+
|
71
|
+
=begin #test
|
72
|
+
|
73
|
+
require 'test/unit'
|
74
|
+
|
75
|
+
class TC_Expirable < Test::Unit::TestCase
|
76
|
+
|
77
|
+
def test_01
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
=end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
# = Fileable
|
2
|
+
#
|
3
|
+
# Make File-esque classes. Fileable makes it easy to
|
4
|
+
# create classes that can load from files.
|
5
|
+
#
|
6
|
+
# Class level mixin for loading/opening file classes.
|
7
|
+
# You will generally want to use extend with this.
|
8
|
+
#
|
9
|
+
# NOTE: This is an expiremental library, and is still
|
10
|
+
# undergoing revision.
|
11
|
+
#
|
12
|
+
# = Copying
|
13
|
+
#
|
14
|
+
# Copyright (c) 2007 Thomas Sawyer
|
15
|
+
#
|
16
|
+
# Ruby License
|
17
|
+
#
|
18
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
19
|
+
# software under the same terms as Ruby.
|
20
|
+
#
|
21
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
22
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
23
|
+
# FOR A PARTICULAR PURPOSE.
|
24
|
+
#
|
25
|
+
# == Authors
|
26
|
+
#
|
27
|
+
# * Thomas Sawyer
|
28
|
+
#
|
29
|
+
# == Todo
|
30
|
+
#
|
31
|
+
# * Consider cachable version of Fileable.
|
32
|
+
|
33
|
+
|
34
|
+
# = Fileable
|
35
|
+
#
|
36
|
+
# Make File-esque classes. Fileable makes it easy to
|
37
|
+
# create classes that can load from files.
|
38
|
+
#
|
39
|
+
# Class level mixin for loading/opening file classes.
|
40
|
+
# You will generally want to use extend with this.
|
41
|
+
#
|
42
|
+
# NOTE: This is an expiremental library, and is still
|
43
|
+
# undergoing revision.
|
44
|
+
#
|
45
|
+
#
|
46
|
+
module Fileable
|
47
|
+
|
48
|
+
# When included extend DSL too.
|
49
|
+
|
50
|
+
def self.included(base)
|
51
|
+
base.extend DSL
|
52
|
+
end
|
53
|
+
|
54
|
+
# Store raw content of file.
|
55
|
+
|
56
|
+
#attr_reader :content
|
57
|
+
|
58
|
+
# New fileable object. By default this is called
|
59
|
+
# by #read passing the file contents. Override it
|
60
|
+
# if need is differnt.
|
61
|
+
|
62
|
+
def initialize(content)
|
63
|
+
@content = content
|
64
|
+
end
|
65
|
+
|
66
|
+
# Override this if reading is differnt.
|
67
|
+
|
68
|
+
def read(file)
|
69
|
+
self.file = file if defined?(:file=)
|
70
|
+
initialize(File.read(file))
|
71
|
+
end
|
72
|
+
|
73
|
+
#
|
74
|
+
module DSL
|
75
|
+
|
76
|
+
# While this doesn't allpy to classes, for modules
|
77
|
+
# it is needed to keep the DSL inheritance going.
|
78
|
+
|
79
|
+
def included(base)
|
80
|
+
base.extend DSL
|
81
|
+
end
|
82
|
+
|
83
|
+
# Override this with the name or name-glob of
|
84
|
+
# the default file. If no default, return nil.
|
85
|
+
|
86
|
+
def filename; nil; end
|
87
|
+
|
88
|
+
# Load from file(s).
|
89
|
+
|
90
|
+
def open(path=nil)
|
91
|
+
file = file(path)
|
92
|
+
if file
|
93
|
+
fobj = new
|
94
|
+
fobj.send(:read, file)
|
95
|
+
return fobj
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# An initializer that can take either a File, Pathname
|
100
|
+
# or raw data. This works much like YAML::load does.
|
101
|
+
# Unlike +open+, +load+ requires an exact path parameter.
|
102
|
+
|
103
|
+
def load(path_or_data)
|
104
|
+
case path_or_data
|
105
|
+
when File
|
106
|
+
open(path_or_data.path)
|
107
|
+
when Pathname
|
108
|
+
open(path_or_data.realpath)
|
109
|
+
else
|
110
|
+
new(path_or_data)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Lookup file.
|
115
|
+
|
116
|
+
def lookup(name=nil)
|
117
|
+
file = locate(name)
|
118
|
+
file ? open(file) : nil #raise LoadError
|
119
|
+
end
|
120
|
+
|
121
|
+
# Locate file (case insensitive).
|
122
|
+
|
123
|
+
def locate(name=nil)
|
124
|
+
name ||= filename
|
125
|
+
raise LoadError unless name
|
126
|
+
Dir.ascend(Dir.pwd) do |dir|
|
127
|
+
match = File.join(dir, name)
|
128
|
+
files = Dir.glob(match, File::FNM_CASEFOLD)
|
129
|
+
if file = files[0]
|
130
|
+
return file
|
131
|
+
end
|
132
|
+
end
|
133
|
+
return nil
|
134
|
+
end
|
135
|
+
|
136
|
+
# Find file. The +path+ has to be either the
|
137
|
+
# exact path or the directory where a
|
138
|
+
# standard-named file resides.
|
139
|
+
|
140
|
+
def file(path=nil)
|
141
|
+
if !path
|
142
|
+
raise LoadError unless filename
|
143
|
+
path = filename
|
144
|
+
elsif File.directory?(path)
|
145
|
+
raise LoadError unless filename
|
146
|
+
path = File.join(path, filename)
|
147
|
+
end
|
148
|
+
if file = Dir.glob(path, File::FNM_CASEFOLD)[0]
|
149
|
+
File.expand_path(file)
|
150
|
+
else
|
151
|
+
raise Errno::ENOENT
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
# Load cache. PackageInfo is multiton when loaded by file.
|
156
|
+
|
157
|
+
def load_cache
|
158
|
+
@load_cache ||= {}
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
@@ -0,0 +1,497 @@
|
|
1
|
+
# = FileList
|
2
|
+
#
|
3
|
+
# A FileList is essentially an array with helper methods
|
4
|
+
# to make file manipulation easier.
|
5
|
+
#
|
6
|
+
# FileLists are lazy. When given a list of glob patterns for
|
7
|
+
# possible files to be included in the file list, instead of
|
8
|
+
# searching the file structures to find the files, a FileList holds
|
9
|
+
# the pattern for latter use.
|
10
|
+
#
|
11
|
+
# This allows us to define a number of FileList to match any number of
|
12
|
+
# files, but only search out the actual files when then FileList
|
13
|
+
# itself is actually used. The key is that the first time an
|
14
|
+
# element of the FileList/Array is requested, the pending patterns
|
15
|
+
# are resolved into a real list of file names.
|
16
|
+
#
|
17
|
+
# fl = FileList.new
|
18
|
+
# fl.include('./**/*')
|
19
|
+
# fl.exclude('./*~')
|
20
|
+
#
|
21
|
+
# == History
|
22
|
+
#
|
23
|
+
# FileList was ported from Jim Weirich's Rake.
|
24
|
+
#
|
25
|
+
# == Authors
|
26
|
+
#
|
27
|
+
# * Jim Weirich
|
28
|
+
#
|
29
|
+
# == Todo
|
30
|
+
#
|
31
|
+
# * Should the exclusions really be the default?
|
32
|
+
# Maybe have #exclude_typical instead.
|
33
|
+
#
|
34
|
+
# == Copying
|
35
|
+
#
|
36
|
+
# Copyright (C) 2002 Jim Weirich
|
37
|
+
#
|
38
|
+
# General Public License (GPL)
|
39
|
+
#
|
40
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
41
|
+
# a copy of this software and associated documentation files (the
|
42
|
+
# "Software"), to deal in the Software without restriction, including
|
43
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
44
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
45
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
46
|
+
# the following conditions:
|
47
|
+
#
|
48
|
+
# The above copyright notice and this permission notice shall be
|
49
|
+
# included in all copies or substantial portions of the Software.
|
50
|
+
#
|
51
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
52
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
53
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
54
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
55
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
56
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
57
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
58
|
+
|
59
|
+
# = FileList
|
60
|
+
#
|
61
|
+
# A FileList is essentially an array with helper methods
|
62
|
+
# to make file manipulation easier.
|
63
|
+
#
|
64
|
+
# FileLists are lazy. When given a list of glob patterns for
|
65
|
+
# possible files to be included in the file list, instead of
|
66
|
+
# searching the file structures to find the files, a FileList holds
|
67
|
+
# the pattern for latter use.
|
68
|
+
#
|
69
|
+
# This allows us to define a number of FileList to match any number of
|
70
|
+
# files, but only search out the actual files when then FileList
|
71
|
+
# itself is actually used. The key is that the first time an
|
72
|
+
# element of the FileList/Array is requested, the pending patterns
|
73
|
+
# are resolved into a real list of file names.
|
74
|
+
#
|
75
|
+
# fl = FileList.new
|
76
|
+
# fl.include('./**/*')
|
77
|
+
# fl.exclude('./*~')
|
78
|
+
#
|
79
|
+
class FileList
|
80
|
+
|
81
|
+
# TODO: Add glob options.
|
82
|
+
#attr :glob_options
|
83
|
+
|
84
|
+
#include Cloneable
|
85
|
+
def clone
|
86
|
+
sibling = self.class.new
|
87
|
+
instance_variables.each do |ivar|
|
88
|
+
value = self.instance_variable_get(ivar)
|
89
|
+
sibling.instance_variable_set(ivar, value.rake_dup)
|
90
|
+
end
|
91
|
+
sibling
|
92
|
+
end
|
93
|
+
alias_method :dup, :clone
|
94
|
+
|
95
|
+
# == Method Delegation
|
96
|
+
#
|
97
|
+
# The lazy evaluation magic of FileLists happens by implementing
|
98
|
+
# all the array specific methods to call +resolve+ before
|
99
|
+
# delegating the heavy lifting to an embedded array object
|
100
|
+
# (@items).
|
101
|
+
#
|
102
|
+
# In addition, there are two kinds of delegation calls. The
|
103
|
+
# regular kind delegates to the @items array and returns the
|
104
|
+
# result directly. Well, almost directly. It checks if the
|
105
|
+
# returned value is the @items object itself, and if so will
|
106
|
+
# return the FileList object instead.
|
107
|
+
#
|
108
|
+
# The second kind of delegation call is used in methods that
|
109
|
+
# normally return a new Array object. We want to capture the
|
110
|
+
# return value of these methods and wrap them in a new FileList
|
111
|
+
# object. We enumerate these methods in the +SPECIAL_RETURN+ list
|
112
|
+
# below.
|
113
|
+
|
114
|
+
# List of array methods (that are not in +Object+) that need to be
|
115
|
+
# delegated.
|
116
|
+
ARRAY_METHODS = Array.instance_methods - Object.instance_methods
|
117
|
+
|
118
|
+
# List of additional methods that must be delegated.
|
119
|
+
MUST_DEFINE = %w[to_a inspect]
|
120
|
+
|
121
|
+
# List of methods that should not be delegated here (we define
|
122
|
+
# special versions of them explicitly below).
|
123
|
+
MUST_NOT_DEFINE = %w[to_a to_ary partition *]
|
124
|
+
|
125
|
+
# List of delegated methods that return new array values which
|
126
|
+
# need wrapping.
|
127
|
+
SPECIAL_RETURN = %w[
|
128
|
+
map collect sort sort_by select find_all reject grep
|
129
|
+
compact flatten uniq values_at
|
130
|
+
+ - & |
|
131
|
+
]
|
132
|
+
|
133
|
+
DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).sort.uniq
|
134
|
+
|
135
|
+
# Now do the delegation.
|
136
|
+
DELEGATING_METHODS.each_with_index do |sym, i|
|
137
|
+
if SPECIAL_RETURN.include?(sym)
|
138
|
+
ln = __LINE__+1
|
139
|
+
class_eval %{
|
140
|
+
def #{sym}(*args, &block)
|
141
|
+
resolve if @pending
|
142
|
+
result = @items.send(:#{sym}, *args, &block)
|
143
|
+
FileList.new.import(result)
|
144
|
+
end
|
145
|
+
}, __FILE__, ln
|
146
|
+
else
|
147
|
+
ln = __LINE__+1
|
148
|
+
class_eval %{
|
149
|
+
def #{sym}(*args, &block)
|
150
|
+
resolve if @pending
|
151
|
+
result = @items.send(:#{sym}, *args, &block)
|
152
|
+
result.object_id == @items.object_id ? self : result
|
153
|
+
end
|
154
|
+
}, __FILE__, ln
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
# Create a file list from the globbable patterns given. If you
|
159
|
+
# wish to perform multiple includes or excludes at object build
|
160
|
+
# time, use the "yield self" pattern.
|
161
|
+
#
|
162
|
+
# Example:
|
163
|
+
# file_list = FileList.new['lib/**/*.rb', 'test/test*.rb']
|
164
|
+
#
|
165
|
+
# pkg_files = FileList.new['lib/**/*'] do |fl|
|
166
|
+
# fl.exclude(/\bCVS\b/)
|
167
|
+
# end
|
168
|
+
#
|
169
|
+
def initialize(*patterns)
|
170
|
+
@pending_add = []
|
171
|
+
@pending = false
|
172
|
+
@exclude_patterns = DEFAULT_IGNORE_PATTERNS.dup
|
173
|
+
@exclude_re = nil
|
174
|
+
@items = []
|
175
|
+
patterns.each { |pattern| include(pattern) }
|
176
|
+
yield self if block_given?
|
177
|
+
end
|
178
|
+
|
179
|
+
# Add file names defined by glob patterns to the file list. If an
|
180
|
+
# array is given, add each element of the array.
|
181
|
+
#
|
182
|
+
# Example:
|
183
|
+
# file_list.include("*.java", "*.cfg")
|
184
|
+
# file_list.include %w( math.c lib.h *.o )
|
185
|
+
#
|
186
|
+
def include(*filenames)
|
187
|
+
# TODO: check for pending
|
188
|
+
filenames.each do |fn|
|
189
|
+
if fn.respond_to? :to_ary
|
190
|
+
include(*fn.to_ary)
|
191
|
+
else
|
192
|
+
@pending_add << fn
|
193
|
+
end
|
194
|
+
end
|
195
|
+
@pending = true
|
196
|
+
self
|
197
|
+
end
|
198
|
+
alias :add :include
|
199
|
+
|
200
|
+
# Register a list of file name patterns that should be excluded
|
201
|
+
# from the list. Patterns may be regular expressions, glob
|
202
|
+
# patterns or regular strings.
|
203
|
+
#
|
204
|
+
# Note that glob patterns are expanded against the file system.
|
205
|
+
# If a file is explicitly added to a file list, but does not exist
|
206
|
+
# in the file system, then an glob pattern in the exclude list
|
207
|
+
# will not exclude the file.
|
208
|
+
#
|
209
|
+
# Examples:
|
210
|
+
# FileList['a.c', 'b.c'].exclude("a.c") => ['b.c']
|
211
|
+
# FileList['a.c', 'b.c'].exclude(/^a/) => ['b.c']
|
212
|
+
#
|
213
|
+
# If "a.c" is a file, then ...
|
214
|
+
# FileList['a.c', 'b.c'].exclude("a.*") => ['b.c']
|
215
|
+
#
|
216
|
+
# If "a.c" is not a file, then ...
|
217
|
+
# FileList['a.c', 'b.c'].exclude("a.*") => ['a.c', 'b.c']
|
218
|
+
#
|
219
|
+
def exclude(*patterns)
|
220
|
+
patterns.each do |pat| @exclude_patterns << pat end
|
221
|
+
if ! @pending
|
222
|
+
calculate_exclude_regexp
|
223
|
+
reject! { |fn| fn =~ @exclude_re }
|
224
|
+
end
|
225
|
+
self
|
226
|
+
end
|
227
|
+
|
228
|
+
# Clear all the exclude patterns so that we exclude nothing.
|
229
|
+
def clear_exclude
|
230
|
+
@exclude_patterns = []
|
231
|
+
calculate_exclude_regexp if ! @pending
|
232
|
+
end
|
233
|
+
|
234
|
+
# Define equality.
|
235
|
+
def ==(array)
|
236
|
+
to_ary == array
|
237
|
+
end
|
238
|
+
|
239
|
+
# Return the internal array object.
|
240
|
+
def to_a
|
241
|
+
resolve
|
242
|
+
@items
|
243
|
+
end
|
244
|
+
|
245
|
+
# Return the internal array object.
|
246
|
+
def to_ary
|
247
|
+
resolve
|
248
|
+
@items
|
249
|
+
end
|
250
|
+
|
251
|
+
# Redefine * to return either a string or a new file list.
|
252
|
+
def *(other)
|
253
|
+
result = @items * other
|
254
|
+
case result
|
255
|
+
when Array
|
256
|
+
FileList.new.import(result)
|
257
|
+
else
|
258
|
+
result
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
# Resolve all the pending adds now.
|
263
|
+
def resolve
|
264
|
+
if @pending
|
265
|
+
@pending = false
|
266
|
+
@pending_add.each do |fn| resolve_add(fn) end
|
267
|
+
@pending_add = []
|
268
|
+
resolve_exclude
|
269
|
+
end
|
270
|
+
self
|
271
|
+
end
|
272
|
+
|
273
|
+
def calculate_exclude_regexp
|
274
|
+
ignores = []
|
275
|
+
@exclude_patterns.each do |pat|
|
276
|
+
case pat
|
277
|
+
when Regexp
|
278
|
+
ignores << pat
|
279
|
+
when /[*.]/
|
280
|
+
Dir[pat].each do |p| ignores << p end
|
281
|
+
else
|
282
|
+
ignores << Regexp.quote(pat)
|
283
|
+
end
|
284
|
+
end
|
285
|
+
if ignores.empty?
|
286
|
+
@exclude_re = /^$/
|
287
|
+
else
|
288
|
+
re_str = ignores.collect { |p| "(" + p.to_s + ")" }.join("|")
|
289
|
+
@exclude_re = Regexp.new(re_str)
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
def resolve_add(fn)
|
294
|
+
case fn
|
295
|
+
when Array
|
296
|
+
fn.each { |f| self.resolve_add(f) }
|
297
|
+
when %r{[*?]}
|
298
|
+
add_matching(fn)
|
299
|
+
else
|
300
|
+
self << fn
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
def resolve_exclude
|
305
|
+
@exclude_patterns.each do |pat|
|
306
|
+
case pat
|
307
|
+
when Regexp
|
308
|
+
reject! { |fn| fn =~ pat }
|
309
|
+
when /[*.]/
|
310
|
+
reject_list = Dir[pat]
|
311
|
+
reject! { |fn| reject_list.include?(fn) }
|
312
|
+
else
|
313
|
+
reject! { |fn| fn == pat }
|
314
|
+
end
|
315
|
+
end
|
316
|
+
self
|
317
|
+
end
|
318
|
+
|
319
|
+
# Return a new FileList with the results of running +sub+ against
|
320
|
+
# each element of the oringal list.
|
321
|
+
#
|
322
|
+
# Example:
|
323
|
+
# FileList['a.c', 'b.c'].sub(/\.c$/, '.o') => ['a.o', 'b.o']
|
324
|
+
#
|
325
|
+
def sub(pat, rep)
|
326
|
+
inject(FileList.new) { |res, fn| res << fn.sub(pat,rep) }
|
327
|
+
end
|
328
|
+
|
329
|
+
# Return a new FileList with the results of running +gsub+ against
|
330
|
+
# each element of the original list.
|
331
|
+
#
|
332
|
+
# Example:
|
333
|
+
# FileList['lib/test/file', 'x/y'].gsub(/\//, "\\")
|
334
|
+
# => ['lib\\test\\file', 'x\\y']
|
335
|
+
#
|
336
|
+
def gsub(pat, rep)
|
337
|
+
inject(FileList.new) { |res, fn| res << fn.gsub(pat,rep) }
|
338
|
+
end
|
339
|
+
|
340
|
+
# Same as +sub+ except that the oringal file list is modified.
|
341
|
+
def sub!(pat, rep)
|
342
|
+
each_with_index { |fn, i| self[i] = fn.sub(pat,rep) }
|
343
|
+
self
|
344
|
+
end
|
345
|
+
|
346
|
+
# Same as +gsub+ except that the original file list is modified.
|
347
|
+
def gsub!(pat, rep)
|
348
|
+
each_with_index { |fn, i| self[i] = fn.gsub(pat,rep) }
|
349
|
+
self
|
350
|
+
end
|
351
|
+
|
352
|
+
# Return a new array with <tt>String#ext</tt> method applied to
|
353
|
+
# each member of the array.
|
354
|
+
#
|
355
|
+
# This method is a shortcut for:
|
356
|
+
#
|
357
|
+
# array.collect { |item| item.ext(newext) }
|
358
|
+
#
|
359
|
+
# +ext+ is a user added method for the Array class.
|
360
|
+
def ext(newext='')
|
361
|
+
collect { |fn| fn.ext(newext) }
|
362
|
+
end
|
363
|
+
|
364
|
+
# Grep each of the files in the filelist using the given pattern.
|
365
|
+
# If a block is given, call the block on each matching line,
|
366
|
+
# passing the file name, line number, and the matching line of
|
367
|
+
# text. If no block is given, a standard emac style
|
368
|
+
# file:linenumber:line message will be printed to standard out.
|
369
|
+
def egrep(pattern)
|
370
|
+
each do |fn|
|
371
|
+
open(fn) do |inf|
|
372
|
+
count = 0
|
373
|
+
|
374
|
+
inf.each do |line|
|
375
|
+
count += 1
|
376
|
+
if pattern.match(line)
|
377
|
+
if block_given?
|
378
|
+
yield fn, count, line
|
379
|
+
else
|
380
|
+
puts "#{fn}:#{count}:#{line}"
|
381
|
+
end
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
end
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
# FileList version of partition. Needed because the nested arrays
|
390
|
+
# should be FileLists in this version.
|
391
|
+
def partition(&block) # :nodoc:
|
392
|
+
resolve
|
393
|
+
result = @items.partition(&block)
|
394
|
+
[
|
395
|
+
FileList.new.import(result[0]),
|
396
|
+
FileList.new.import(result[1]),
|
397
|
+
]
|
398
|
+
end
|
399
|
+
|
400
|
+
# Convert a FileList to a string by joining all elements with a space.
|
401
|
+
def to_s
|
402
|
+
resolve if @pending
|
403
|
+
self.join(' ')
|
404
|
+
end
|
405
|
+
|
406
|
+
# Add matching glob patterns.
|
407
|
+
def add_matching(pattern)
|
408
|
+
Dir[pattern].each do |fn|
|
409
|
+
self << fn unless exclude?(fn)
|
410
|
+
end
|
411
|
+
end
|
412
|
+
private :add_matching
|
413
|
+
|
414
|
+
# Should the given file name be excluded?
|
415
|
+
def exclude?(fn)
|
416
|
+
calculate_exclude_regexp unless @exclude_re
|
417
|
+
fn =~ @exclude_re
|
418
|
+
end
|
419
|
+
|
420
|
+
DEFAULT_IGNORE_PATTERNS = [
|
421
|
+
/(^|[\/\\])CVS([\/\\]|$)/,
|
422
|
+
/(^|[\/\\])\.svn([\/\\]|$)/,
|
423
|
+
/(^|[\/\\])_darcs([\/\\]|$)/,
|
424
|
+
/\.bak$/,
|
425
|
+
/~$/,
|
426
|
+
/(^|[\/\\])core$/
|
427
|
+
]
|
428
|
+
@exclude_patterns = DEFAULT_IGNORE_PATTERNS.dup
|
429
|
+
|
430
|
+
def import(array)
|
431
|
+
@items = array
|
432
|
+
self
|
433
|
+
end
|
434
|
+
|
435
|
+
class << self
|
436
|
+
# Create a new file list including the files listed. Similar to:
|
437
|
+
#
|
438
|
+
# FileList.new(*args)
|
439
|
+
def [](*args)
|
440
|
+
new(*args)
|
441
|
+
end
|
442
|
+
|
443
|
+
# Set the ignore patterns back to the default value. The
|
444
|
+
# default patterns will ignore files
|
445
|
+
# * containing "CVS" in the file path
|
446
|
+
# * containing ".svn" in the file path
|
447
|
+
# * containing "_darcs" in the file path
|
448
|
+
# * ending with ".bak"
|
449
|
+
# * ending with "~"
|
450
|
+
# * named "core"
|
451
|
+
#
|
452
|
+
# Note that file names beginning with "." are automatically
|
453
|
+
# ignored by Ruby's glob patterns and are not specifically
|
454
|
+
# listed in the ignore patterns.
|
455
|
+
def select_default_ignore_patterns
|
456
|
+
@exclude_patterns = DEFAULT_IGNORE_PATTERNS.dup
|
457
|
+
end
|
458
|
+
|
459
|
+
# Clear the ignore patterns.
|
460
|
+
def clear_ignore_patterns
|
461
|
+
@exclude_patterns = [ /^$/ ]
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
465
|
+
end # FileList
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
# = TEST
|
470
|
+
#
|
471
|
+
# TODO This test needs a mock File class.
|
472
|
+
|
473
|
+
# FileList can't be tested without a FIXTURE setup.
|
474
|
+
# So don't bother running it directly from here, but
|
475
|
+
# transfer it over to the test directory.
|
476
|
+
# Need a better solution, is there a way to fake the
|
477
|
+
# filesystem?
|
478
|
+
|
479
|
+
=begin #no test
|
480
|
+
|
481
|
+
require 'test/unit'
|
482
|
+
|
483
|
+
class TC_FileList < Test::Unit::TestCase
|
484
|
+
|
485
|
+
def test_filelist
|
486
|
+
Dir.chdir File.join( $TESTDIR, 'filelist' ) do
|
487
|
+
fl = FileList.new
|
488
|
+
fl.include('*')
|
489
|
+
assert_equal( ['testfile.txt', 'testfile2.txt'], fl.to_a )
|
490
|
+
fl.exclude('*2.txt')
|
491
|
+
assert_equal( ['testfile.txt'], fl.to_a )
|
492
|
+
end
|
493
|
+
end
|
494
|
+
|
495
|
+
end
|
496
|
+
|
497
|
+
=end
|