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,75 @@
|
|
1
|
+
# = YAML Extensions
|
2
|
+
#
|
3
|
+
# YAML related extenstions.
|
4
|
+
#
|
5
|
+
# The Kernel method #yaml is a shortcut to YAML::load.
|
6
|
+
#
|
7
|
+
# yaml %{
|
8
|
+
# a: 1
|
9
|
+
# b: 2
|
10
|
+
# }
|
11
|
+
#
|
12
|
+
# produes
|
13
|
+
#
|
14
|
+
# {:a=>1, :b=>2}
|
15
|
+
#
|
16
|
+
# File.yaml? provides a way to check if a file is a YAML
|
17
|
+
# formatted file.
|
18
|
+
#
|
19
|
+
# File.yaml?('project.yaml') #=> true
|
20
|
+
# File.yaml?('project.xml') #=> false
|
21
|
+
#
|
22
|
+
# == Authors
|
23
|
+
#
|
24
|
+
# * Thomas Sawyer
|
25
|
+
#
|
26
|
+
# == Copyright
|
27
|
+
#
|
28
|
+
# Copyright (c) 2006 Thomas Sawyer
|
29
|
+
#
|
30
|
+
# Ruby License
|
31
|
+
#
|
32
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
33
|
+
# software under the same terms as Ruby.
|
34
|
+
#
|
35
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
36
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
37
|
+
# FOR A PARTICULAR PURPOSE.
|
38
|
+
|
39
|
+
require 'yaml'
|
40
|
+
|
41
|
+
module Kernel
|
42
|
+
# Convenience method for loading YAML.
|
43
|
+
#
|
44
|
+
def yaml(*args,&blk)
|
45
|
+
YAML.load(*args,&blk)
|
46
|
+
end
|
47
|
+
|
48
|
+
# As with #to_yaml but removes the header line (i.e. '---') to create a "YAML fragment".
|
49
|
+
#
|
50
|
+
def to_yamlfrag
|
51
|
+
y = to_yaml
|
52
|
+
y.sub!(/---\ */, '')
|
53
|
+
y
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class File
|
58
|
+
# Is a file a YAML file?
|
59
|
+
#
|
60
|
+
# Note this isn't perfect. At present it depends on the use
|
61
|
+
# use of an initial document separator (eg. '---'). With
|
62
|
+
# YAML 1.1 the %YAML delaration will be manditory, so in the
|
63
|
+
# future this can be adapted to fit that standard.
|
64
|
+
#
|
65
|
+
def self.yaml?(file)
|
66
|
+
File.open(file) do |f|
|
67
|
+
until f.eof?
|
68
|
+
line = f.gets
|
69
|
+
break true if line =~ /^---/
|
70
|
+
break false unless line =~ /^(\s*#.*?|\s*)$/
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# A convenient wrapper for the zlib standard library that allows
|
2
|
+
# compression/decompression of strings with gzip.
|
3
|
+
|
4
|
+
module Zlib
|
5
|
+
|
6
|
+
#class Stream < StringIO
|
7
|
+
# def close; rewind; end
|
8
|
+
#end
|
9
|
+
|
10
|
+
# Decompresses a gzipped string.
|
11
|
+
def self.decompress(source)
|
12
|
+
GzipReader.new(StringIO.new(source)).read
|
13
|
+
end
|
14
|
+
|
15
|
+
# Compresses a string using gzip.
|
16
|
+
def self.compress(source)
|
17
|
+
output = StringIO.new
|
18
|
+
class << output
|
19
|
+
def close; rewind; end
|
20
|
+
end
|
21
|
+
gz = GzipWriter.new(output)
|
22
|
+
gz.write(source)
|
23
|
+
gz.close
|
24
|
+
output.string
|
25
|
+
end
|
26
|
+
|
27
|
+
# Inflate a deflated sting.
|
28
|
+
def self.inflate(string)
|
29
|
+
Inflate.inflate(string)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Deflate a string.
|
33
|
+
def self.deflate(string, level=DEFAULT_COMPRESSION)
|
34
|
+
Deflate.deflate(string, level)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# = First Class Methods
|
2
|
+
#
|
3
|
+
# Gives Ruby 1st class methods.
|
4
|
+
#
|
5
|
+
# Easy access to method as objects, and they retain state!
|
6
|
+
#
|
7
|
+
# def hello
|
8
|
+
# puts "Hello World!"
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# m1 = method!(:hello) #=> <Method: #hello>
|
12
|
+
#
|
13
|
+
# def m1.annotate
|
14
|
+
# "simple example"
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# m2 = method!(:hello)
|
18
|
+
# m2.annotate #=> "simple example"
|
19
|
+
#
|
20
|
+
# Easy access to method as objects, and they retain state!
|
21
|
+
#
|
22
|
+
# module K
|
23
|
+
# def hello
|
24
|
+
# puts "Hello World!"
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
# p K.instance_method!(:hello) #=> <UnboundMethod: #hello>
|
28
|
+
#
|
29
|
+
# CAUTION! This it is currently limited to the scope of the
|
30
|
+
# current module/class.
|
31
|
+
#
|
32
|
+
# == Notes
|
33
|
+
#
|
34
|
+
# Should 1st Class Methods be part of Ruby proper?
|
35
|
+
#
|
36
|
+
# Perhaps the best solution would be using the notation
|
37
|
+
# <tt>::ameth</tt>. This would require some minor changes
|
38
|
+
# to Ruby, but with few backward incompatabilites if
|
39
|
+
# parantheticals revert back to the actual method invocation.
|
40
|
+
# Although this later stipulation means capitalized methods
|
41
|
+
# would not be accessible in this way b/c they would intefere with
|
42
|
+
# constant lookup. It's a trade off.
|
43
|
+
#
|
44
|
+
# Current Proposed Alternate
|
45
|
+
# ----------------- ------------------ -------------------
|
46
|
+
# Foo.Bar() method call method call method call
|
47
|
+
# Foo.Bar method call method call method call
|
48
|
+
# Foo.bar() method call method call method call
|
49
|
+
# Foo.bar method call method call method call
|
50
|
+
# Foo::Bar() method call method call 1st class method
|
51
|
+
# Foo::Bar constant lookup constant lookup constant lookup
|
52
|
+
# Foo::bar() method call method call 1st class method
|
53
|
+
# Foo::bar method call 1st class method 1st class method
|
54
|
+
#
|
55
|
+
# Then again this dosen't address bound versus unbound.
|
56
|
+
#
|
57
|
+
# Which do you prefer?
|
58
|
+
#
|
59
|
+
# == Authors
|
60
|
+
#
|
61
|
+
# * Thomas Sawyer
|
62
|
+
#
|
63
|
+
# == Copying
|
64
|
+
#
|
65
|
+
# Copyright (c) 2005 Thomas Sawyer
|
66
|
+
#
|
67
|
+
# Ruby License
|
68
|
+
#
|
69
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
70
|
+
# software under the same terms as Ruby.
|
71
|
+
#
|
72
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
73
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
74
|
+
# FOR A PARTICULAR PURPOSE.
|
75
|
+
|
76
|
+
#
|
77
|
+
module Kernel
|
78
|
+
|
79
|
+
# Easy access to method as objects, and they retain state!
|
80
|
+
#
|
81
|
+
# def hello
|
82
|
+
# puts "Hello World!"
|
83
|
+
# end
|
84
|
+
#
|
85
|
+
# m1 = method!(:hello) #=> <Method: #hello>
|
86
|
+
#
|
87
|
+
# def m1.annotate
|
88
|
+
# "simple example"
|
89
|
+
# end
|
90
|
+
#
|
91
|
+
# m2 = method!(:hello)
|
92
|
+
# m2.annotate #=> "simple example"
|
93
|
+
|
94
|
+
def method!(s)
|
95
|
+
( @__methods__ ||= {} )[s] ||= method(s)
|
96
|
+
end
|
97
|
+
|
98
|
+
private
|
99
|
+
|
100
|
+
# Returns the method object of the current method.
|
101
|
+
#--
|
102
|
+
# TODO Should there be a #this! ?
|
103
|
+
#++
|
104
|
+
def this
|
105
|
+
line = nil
|
106
|
+
caller(1).each do |line|
|
107
|
+
line = /\`([^\']+)\'/.match(line)
|
108
|
+
break if line
|
109
|
+
end
|
110
|
+
if line
|
111
|
+
name = line[1]
|
112
|
+
return method(name)
|
113
|
+
else
|
114
|
+
nil # ?
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
#
|
121
|
+
class Module
|
122
|
+
|
123
|
+
# Easy access to method as objects, and they retain state!
|
124
|
+
#
|
125
|
+
# module K
|
126
|
+
# def hello
|
127
|
+
# puts "Hello World!"
|
128
|
+
# end
|
129
|
+
# end
|
130
|
+
# p K.instance_method!(:hello) #=> <UnboundMethod: #hello>
|
131
|
+
#
|
132
|
+
# NOTE: This is limited to the scope of the current module/class.
|
133
|
+
|
134
|
+
def instance_method!(s)
|
135
|
+
#( @@__instance_methods__ ||= {} )[s] ||= instance_method(s) # TODO when fixed
|
136
|
+
( @__instance_methods__ ||= {} )[s] ||= instance_method(s)
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
|
@@ -0,0 +1,162 @@
|
|
1
|
+
# = Advisable
|
2
|
+
#
|
3
|
+
# Add before, after and around advice in dynamic fashion.
|
4
|
+
#
|
5
|
+
# == Authors
|
6
|
+
#
|
7
|
+
# * TransAspect
|
8
|
+
#
|
9
|
+
# == Copying
|
10
|
+
#
|
11
|
+
# Copyright (c) 2007 Thomas Sawyer
|
12
|
+
#
|
13
|
+
# Ruby License
|
14
|
+
#
|
15
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
16
|
+
# software under the same terms as Ruby.
|
17
|
+
#
|
18
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
19
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
20
|
+
# FOR A PARTICULAR PURPOSE.
|
21
|
+
|
22
|
+
require 'facets/1stclassmethod'
|
23
|
+
require 'facets/unboundmethod/arguments'
|
24
|
+
|
25
|
+
# = Advisable
|
26
|
+
#
|
27
|
+
# Advisable provides a means of using before, after and
|
28
|
+
# around adivce.
|
29
|
+
|
30
|
+
module Advisable
|
31
|
+
|
32
|
+
def advice_before
|
33
|
+
@advice_before ||= {} #Hash.new{|h,k| h[k] = []}
|
34
|
+
end
|
35
|
+
|
36
|
+
def advice_after
|
37
|
+
@advice_after ||= {} #Hash.new{|h,k| h[k] = []}
|
38
|
+
end
|
39
|
+
|
40
|
+
def advice_around
|
41
|
+
@advice_around ||= {} #Hash.new{|h,k| h[k] = []}
|
42
|
+
end
|
43
|
+
|
44
|
+
def before(meth, &block)
|
45
|
+
name = "#{meth}:before#{block.object_id}"
|
46
|
+
define_method(name, &block)
|
47
|
+
(advice_before[meth.to_sym] ||= []) << name
|
48
|
+
end
|
49
|
+
|
50
|
+
def after(meth, &block)
|
51
|
+
name = "#{meth}:after#{block.object_id}"
|
52
|
+
define_method(name, &block)
|
53
|
+
(advice_after[meth.to_sym] ||= []) << name
|
54
|
+
end
|
55
|
+
|
56
|
+
def around(meth, &block)
|
57
|
+
name = "#{meth}:around#{block.object_id}"
|
58
|
+
define_method(name, &block)
|
59
|
+
(advice_around[meth.to_sym] ||= []) << name
|
60
|
+
end
|
61
|
+
|
62
|
+
# Advise a method.
|
63
|
+
|
64
|
+
def advise(meth)
|
65
|
+
#return false if defined?(meth_origin)
|
66
|
+
args = instance_method(meth).arguments
|
67
|
+
|
68
|
+
module_eval(<<-END, __FILE__, __LINE__)
|
69
|
+
alias_method '#{meth}_origin', '#{meth}'
|
70
|
+
def #{meth}(#{args})
|
71
|
+
target = method!('#{meth}_origin')
|
72
|
+
|
73
|
+
unless target.advised
|
74
|
+
ancs = self.class.ancestors.select{ |anc| anc.respond_to?(:advice_before) }
|
75
|
+
target.advice_before = ancs.collect{ |anc| anc.advice_before[:'#{meth}'] }
|
76
|
+
target.advice_after = ancs.collect{ |anc| anc.advice_after[:'#{meth}'] }
|
77
|
+
target.advice_around = ancs.collect{ |anc| anc.advice_around[:'#{meth}'] }
|
78
|
+
target.advised = true
|
79
|
+
end
|
80
|
+
|
81
|
+
target.call_with_advice(self, *[#{args}])
|
82
|
+
end
|
83
|
+
END
|
84
|
+
end
|
85
|
+
|
86
|
+
#advise(:method_added)
|
87
|
+
|
88
|
+
#after :method_added do |meth|
|
89
|
+
# advise(meth) unless defined?("#{meth}_orig")
|
90
|
+
#end
|
91
|
+
|
92
|
+
def method_added(meth)
|
93
|
+
return if meth == :method_added
|
94
|
+
@added_stack ||= []
|
95
|
+
return if @added_stack.last == meth
|
96
|
+
return if /_(origin)$/ =~ meth.to_s
|
97
|
+
return if /:(before|after|around)/ =~ meth.to_s
|
98
|
+
@added_stack << meth
|
99
|
+
#return if instance_methods(false).include?("#{meth}_orig")
|
100
|
+
advise(meth)
|
101
|
+
@added_stack.pop
|
102
|
+
end
|
103
|
+
|
104
|
+
# Extensions for Method class.
|
105
|
+
|
106
|
+
module Method
|
107
|
+
|
108
|
+
attr_accessor :advised
|
109
|
+
|
110
|
+
attr_reader :advice_before
|
111
|
+
attr_reader :advice_after
|
112
|
+
attr_reader :advice_around
|
113
|
+
|
114
|
+
def advised?
|
115
|
+
@advised
|
116
|
+
end
|
117
|
+
|
118
|
+
def advice_before=(set); @advice_before = set.flatten.compact; end
|
119
|
+
def advice_after=(set) ; @advice_after = set.flatten.compact; end
|
120
|
+
def advice_around=(set); @advice_around = set.flatten.compact; end
|
121
|
+
|
122
|
+
# Call with advice.
|
123
|
+
|
124
|
+
def call_with_advice(obj, *args, &blk)
|
125
|
+
advice_before.each do |name|
|
126
|
+
#advice.call(*args, &blk)
|
127
|
+
obj.send(name, *args, &blk)
|
128
|
+
end
|
129
|
+
|
130
|
+
target = lambda{ call(*args, &blk) }
|
131
|
+
advice_around.each do |name|
|
132
|
+
target = lambda_target(obj, name, target, *args, &blk)
|
133
|
+
end
|
134
|
+
ret = target.call
|
135
|
+
|
136
|
+
advice_after.reverse_each do |name|
|
137
|
+
#advice.call(*args, &blk)
|
138
|
+
obj.send(name, *args, &blk)
|
139
|
+
end
|
140
|
+
|
141
|
+
return ret
|
142
|
+
end
|
143
|
+
|
144
|
+
private
|
145
|
+
|
146
|
+
# Using separate method for this prevents infinite loop.
|
147
|
+
|
148
|
+
def lambda_target(obj, name, target, *args, &blk)
|
149
|
+
lambda do
|
150
|
+
#advice.call(target, *args, &blk)
|
151
|
+
obj.send(name, target, *args, &blk)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
end
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
class Method #:nodoc:
|
160
|
+
include Advisable::Method
|
161
|
+
end
|
162
|
+
|
@@ -0,0 +1,302 @@
|
|
1
|
+
# = Annotation
|
2
|
+
#
|
3
|
+
# Annotations allows you to annontate objects, including methods with arbitrary
|
4
|
+
# "metadata". These annotations don't do anything in themselves. They are
|
5
|
+
# merely comments. But you can put them to use. For instance an attribute
|
6
|
+
# validator might check for an annotation called :valid and test against it.
|
7
|
+
#
|
8
|
+
# Annotation is an OpenObject, and is used across the board for keeping annotations.
|
9
|
+
#
|
10
|
+
# Annotation class serves for both simple and inherited cases depending on whether
|
11
|
+
# a base class is given.
|
12
|
+
#
|
13
|
+
# class X
|
14
|
+
# attr :a
|
15
|
+
# ann :@a, :valid => lambda{ |x| x.is_a?(Integer) }
|
16
|
+
#
|
17
|
+
# def validate
|
18
|
+
# instance_variables.each { |iv|
|
19
|
+
# if validator = self.class.ann(iv)[:valid]
|
20
|
+
# value = instance_variable_get(iv)
|
21
|
+
# unless validator.call(vale)
|
22
|
+
# raise "Invalid value #{value} for #{iv}"
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
# }
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# == Authors
|
31
|
+
#
|
32
|
+
# * Thomas Sawyer
|
33
|
+
# * George Moschovitis
|
34
|
+
#
|
35
|
+
# == History
|
36
|
+
#
|
37
|
+
# * 2006-11-07 trans Created this ultra-concise version of annotations.
|
38
|
+
#
|
39
|
+
# == Todo
|
40
|
+
#
|
41
|
+
# * Might be nice to have a default object of annotation, eg. the next
|
42
|
+
# method defined, like how +desc+ annotates a rake +task+.
|
43
|
+
# * The ann(x).name notation is kind of nice. Would like to add that
|
44
|
+
# back-in if reasonable. Basically this require heritage to be an OpenObject
|
45
|
+
# rather than just a hash.
|
46
|
+
#
|
47
|
+
# == Copying
|
48
|
+
#
|
49
|
+
# Copyright (c) 2005 Thomas Sawyer, George Moschovitis
|
50
|
+
#
|
51
|
+
# Ruby License
|
52
|
+
#
|
53
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
54
|
+
# software under the same terms as Ruby.
|
55
|
+
#
|
56
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
57
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
58
|
+
# FOR A PARTICULAR PURPOSE.
|
59
|
+
|
60
|
+
warn "Libary facets/annotations.rb will be deprecated and spun spun off as new project."
|
61
|
+
|
62
|
+
require 'facets/hash/to_h'
|
63
|
+
require 'facets/hash/rekey'
|
64
|
+
require 'facets/hash/op'
|
65
|
+
|
66
|
+
# = Annotation
|
67
|
+
#
|
68
|
+
# Annotations allows you to annontate objects, including methods with arbitrary
|
69
|
+
# "metadata". These annotations don't do anything in themselves. They are
|
70
|
+
# merely comments. But you can put them to use. For instance an attribute
|
71
|
+
# validator might check for an annotation called :valid and test against it.
|
72
|
+
#
|
73
|
+
# Annotation is an OpenObject, and is used across the board for keeping annotations.
|
74
|
+
#
|
75
|
+
# Annotation class serves for both simple and inherited cases depending on whether
|
76
|
+
# a base class is given.
|
77
|
+
#
|
78
|
+
# == Synopsis
|
79
|
+
#
|
80
|
+
# class X
|
81
|
+
# attr :a
|
82
|
+
# ann :@a, :valid => lambda{ |x| x.is_a?(Integer) }
|
83
|
+
#
|
84
|
+
# def validate
|
85
|
+
# instance_variables.each { |iv|
|
86
|
+
# if validator = self.class.ann(iv)[:valid]
|
87
|
+
# value = instance_variable_get(iv)
|
88
|
+
# unless validator.call(vale)
|
89
|
+
# raise "Invalid value #{value} for #{iv}"
|
90
|
+
# end
|
91
|
+
# end
|
92
|
+
# }
|
93
|
+
# end
|
94
|
+
#
|
95
|
+
# end
|
96
|
+
|
97
|
+
#--
|
98
|
+
# By using a global veriable rather the definining a class instance variable
|
99
|
+
# for each class/module, it is possible to quicky scan all annotations for the
|
100
|
+
# entire system. To do the same without this would require scanning through
|
101
|
+
# the ObjectSpace. (Still which is better?)
|
102
|
+
#
|
103
|
+
#$annotations = Hash.new { |h,k| h[k] = {} }
|
104
|
+
#++
|
105
|
+
|
106
|
+
class Module
|
107
|
+
|
108
|
+
def annotations
|
109
|
+
#$annotations[self]
|
110
|
+
@annotations ||= {}
|
111
|
+
end
|
112
|
+
|
113
|
+
def heritage(ref)
|
114
|
+
ref = ref.to_sym
|
115
|
+
ancestors.inject({}) { |memo, ancestor|
|
116
|
+
ancestor.annotations[ref] ||= {}
|
117
|
+
ancestor.annotations[ref] + memo
|
118
|
+
}
|
119
|
+
end
|
120
|
+
|
121
|
+
# Set or read annotations.
|
122
|
+
|
123
|
+
def ann( ref, keys_or_class=nil, keys=nil )
|
124
|
+
return heritage(ref) unless keys_or_class or keys
|
125
|
+
|
126
|
+
if Class === keys_or_class
|
127
|
+
keys ||= {}
|
128
|
+
keys[:class] = keys_or_class
|
129
|
+
else
|
130
|
+
keys = keys_or_class
|
131
|
+
end
|
132
|
+
|
133
|
+
if Hash === keys
|
134
|
+
ref = ref.to_sym
|
135
|
+
annotations[ref] ||= {}
|
136
|
+
annotations[ref].update(keys.rekey)
|
137
|
+
else
|
138
|
+
key = keys.to_sym
|
139
|
+
heritage(ref)[key]
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
# To change an annotation's value in place for a given class or module
|
144
|
+
# it first must be duplicated, otherwise the change may effect annotations
|
145
|
+
# in the class or module's ancestors.
|
146
|
+
|
147
|
+
def ann!( ref, keys_or_class=nil, keys=nil )
|
148
|
+
#return heritage(ref) unless keys_or_class or keys
|
149
|
+
return annotations[ref] unless keys_or_class or keys
|
150
|
+
|
151
|
+
if Class === keys_or_class
|
152
|
+
keys ||= {}
|
153
|
+
keys[:class] = keys_or_class
|
154
|
+
else
|
155
|
+
keys = keys_or_class
|
156
|
+
end
|
157
|
+
|
158
|
+
if Hash === keys
|
159
|
+
ref = ref.to_sym
|
160
|
+
annotations[ref] ||= {}
|
161
|
+
annotations[ref].update(keys.rekey)
|
162
|
+
else
|
163
|
+
key = keys.to_sym
|
164
|
+
annotations[ref][key] = heritage(ref)[key].dup
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
# TITLE
|
171
|
+
#
|
172
|
+
# Annotated Attributes
|
173
|
+
#
|
174
|
+
# DESCRIPTION:
|
175
|
+
#
|
176
|
+
# This framework modifies the attr_* methods to allow easy
|
177
|
+
# addition of annotations.
|
178
|
+
#
|
179
|
+
# COPYRIGHT:
|
180
|
+
#
|
181
|
+
# Copyright (c) 2005 Thomas Sawyer
|
182
|
+
#
|
183
|
+
# LICENSE:
|
184
|
+
#
|
185
|
+
# Ruby License
|
186
|
+
#
|
187
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
188
|
+
# software under the same terms as Ruby.
|
189
|
+
#
|
190
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
191
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
192
|
+
# FOR A PARTICULAR PURPOSE.
|
193
|
+
#
|
194
|
+
# AUTHORS:
|
195
|
+
#
|
196
|
+
# - Thomas Sawyer
|
197
|
+
# - George Moschovitis
|
198
|
+
|
199
|
+
require 'facets/annotations.rb'
|
200
|
+
require 'facets/inheritor.rb'
|
201
|
+
|
202
|
+
# = Annotated Attributes
|
203
|
+
#
|
204
|
+
# This framework modifies the attr_* methods to allow easy addition of annotations.
|
205
|
+
# It the built in attribute methods (attr, attr_reader, attr_writer and attr_accessor),
|
206
|
+
# to allow annotations to added to them directly rather than requireing a separate
|
207
|
+
# #ann statement.
|
208
|
+
#
|
209
|
+
# class X
|
210
|
+
# attr :a, :valid => lambda{ |x| x.is_a?(Integer) }
|
211
|
+
# end
|
212
|
+
#
|
213
|
+
# See annotation.rb for more information.
|
214
|
+
#
|
215
|
+
# NOTE This library was designed to be backward compatible with the
|
216
|
+
# standard versions of the same methods.
|
217
|
+
|
218
|
+
class ::Module
|
219
|
+
|
220
|
+
inheritor :instance_attributes, [], :|
|
221
|
+
|
222
|
+
def attr( *args )
|
223
|
+
args.flatten!
|
224
|
+
case args.last
|
225
|
+
when TrueClass
|
226
|
+
args.pop
|
227
|
+
attr_accessor( *args )
|
228
|
+
when FalseClass
|
229
|
+
args.pop
|
230
|
+
attr_reader( *args )
|
231
|
+
else
|
232
|
+
attr_reader( *args )
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
alias :plain_reader :attr_reader
|
237
|
+
alias :plain_writer :attr_writer
|
238
|
+
alias :plain_accessor :attr_accessor
|
239
|
+
|
240
|
+
code = ''
|
241
|
+
|
242
|
+
[ :_reader, :_writer, :_accessor].each do |m|
|
243
|
+
|
244
|
+
code << %{
|
245
|
+
def attr#{m}(*args)
|
246
|
+
args.flatten!
|
247
|
+
|
248
|
+
harg={}; while args.last.is_a?(Hash)
|
249
|
+
harg.update(args.pop)
|
250
|
+
end
|
251
|
+
|
252
|
+
raise ArgumentError if args.empty? and harg.empty?
|
253
|
+
|
254
|
+
if args.empty? # hash mode
|
255
|
+
harg.each { |a,h| attr#{m}(a,h) }
|
256
|
+
else
|
257
|
+
klass = harg[:class] = args.pop if args.last.is_a?(Class)
|
258
|
+
|
259
|
+
args.each { |a|
|
260
|
+
plain#{m} a
|
261
|
+
a = a.to_sym
|
262
|
+
ann(a,harg)
|
263
|
+
}
|
264
|
+
instance_attributes!.concat( args ) #merge!
|
265
|
+
|
266
|
+
# Use this callback to customize for your needs.
|
267
|
+
if respond_to?(:attr_callback)
|
268
|
+
attr_callback(self, args, harg)
|
269
|
+
end
|
270
|
+
|
271
|
+
# return the names of the attributes created
|
272
|
+
return args
|
273
|
+
end
|
274
|
+
end
|
275
|
+
}
|
276
|
+
|
277
|
+
end
|
278
|
+
|
279
|
+
class_eval( code )
|
280
|
+
|
281
|
+
# TODO Should attribute alias be kept?
|
282
|
+
alias_method :attribute, :attr_accessor
|
283
|
+
|
284
|
+
# Return list of attributes that have a :class annotation.
|
285
|
+
#
|
286
|
+
# class MyClass
|
287
|
+
# attr_accessor :test
|
288
|
+
# attr_accessor :name, String, :doc => 'Hello'
|
289
|
+
# attr_accessor :age, Fixnum
|
290
|
+
# end
|
291
|
+
#
|
292
|
+
# MyClass.instance_attributes # => [:test, :name, :age, :body]
|
293
|
+
# MyClass.classified_attributes # => [:name, :age]
|
294
|
+
|
295
|
+
def classified_attributes
|
296
|
+
instance_attributes.find_all do |a|
|
297
|
+
self.ann(a, :class)
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
end
|
302
|
+
|