├── .gitignore ├── .index ├── .travis.yml ├── .yardopts ├── Assembly ├── CONTRIBUTING.md ├── Gemfile ├── Guardfile ├── HISTORY.md ├── Indexfile ├── LICENSE.txt ├── MANIFEST ├── NOTICE.rdoc ├── README.md ├── Rakefile ├── demo ├── applique │ ├── assertion_framework.rb │ └── file_helpers.rb ├── core │ ├── array │ │ ├── after.md │ │ ├── arrange.md │ │ ├── before.md │ │ ├── collapse.md │ │ ├── collisions.md │ │ ├── commonality.md │ │ ├── conjoin.md │ │ ├── contains.md │ │ ├── delete_unless.md │ │ ├── delete_values.md │ │ ├── delete_values_at.md │ │ ├── divide.md │ │ ├── duplicates.md │ │ ├── each_overlap.md │ │ ├── each_pair.md │ │ ├── each_value.md │ │ ├── entropy.md │ │ ├── extract_options.md │ │ ├── first.md │ │ ├── from.md │ │ ├── ideal_entropy.md │ │ ├── intersection.md │ │ ├── last.md │ │ ├── median.md │ │ ├── merge.md │ │ ├── missing.md │ │ ├── mode.md │ │ ├── nonuniq.md │ │ ├── not_empty.md │ │ ├── occur.md │ │ ├── occurrence.md │ │ ├── only.md │ │ ├── op_pow.md │ │ ├── pad.md │ │ ├── peek.md │ │ ├── poke.md │ │ ├── probability │ │ ├── pull.md │ │ ├── recurse.md │ │ ├── recursively.md │ │ ├── reject_values.md │ │ ├── span.md │ │ ├── splice.md │ │ ├── split.md │ │ ├── split_at.md │ │ ├── squeeze.md │ │ ├── step.md │ │ ├── store.md │ │ ├── thru.md │ │ ├── to_h.md │ │ ├── traverse.md │ │ ├── uniq_by.md │ │ ├── unique_permutation.md │ │ └── zip.md │ ├── binding │ │ ├── caller.md │ │ ├── defined.md │ │ ├── opvars.md │ │ └── self.md │ ├── class │ │ ├── descendants.md │ │ └── to_proc.md │ ├── comparable │ │ ├── at_least.md │ │ ├── at_most.md │ │ ├── bound.md │ │ ├── cap.md │ │ ├── clip.md │ │ ├── cmp.md │ │ └── op_get.md │ ├── dir │ │ ├── ascend.md │ │ ├── descend.md │ │ ├── multiglob.md │ │ ├── parent.md │ │ └── recurse.md │ ├── exception │ │ └── detail.md │ ├── facets.md │ ├── filetest │ │ └── root.md │ ├── hash │ │ └── recursively.md │ ├── indexable.md │ ├── integer │ │ ├── bitmask.md │ │ ├── factorial.md │ │ ├── length.md │ │ ├── multiple.md │ │ ├── of.md │ │ ├── ordinal.md │ │ └── times_collect.md │ ├── matchdata │ │ ├── match.md │ │ ├── matchset.md │ │ └── matchtree.md │ ├── module │ │ ├── cattr.md │ │ ├── class_extend.md │ │ ├── class_inheritor.md │ │ ├── copy_inheritor.md │ │ ├── include_as.md │ │ └── method_space.md │ └── string │ │ ├── acronym.md │ │ ├── align.md │ │ ├── ascii_only.md │ │ ├── bracket.md │ │ ├── camelcase.md │ │ ├── capitalized.md │ │ ├── cleanlines.md │ │ ├── cleave.md │ │ ├── compress_lines.md │ │ ├── crypt.md │ │ ├── divide.md │ │ ├── each_word.md │ │ ├── edit_distance.md │ │ ├── exclude.md │ │ ├── expand_tabs.md │ │ ├── fold.md │ │ ├── indent.md │ │ ├── index_all.md │ │ ├── interpolate.md │ │ ├── lchomp.md │ │ ├── line_wrap.md │ │ ├── lowercase.md │ │ ├── methodize.md │ │ ├── modulize.md │ │ ├── mscan.md │ │ ├── natcmp.md │ │ ├── nchar.md │ │ ├── newlines.md │ │ ├── number.md │ │ ├── op_div.md │ │ ├── op_sub.md │ │ ├── pathize.md │ │ ├── quote.md │ │ ├── random.md │ │ ├── range.md │ │ ├── remove.md │ │ ├── rewrite.md │ │ ├── shatter.md │ │ ├── similarity.md │ │ ├── snakecase.md │ │ ├── splice.md │ │ ├── squish.md │ │ ├── store.md │ │ ├── subtract.md │ │ ├── titlecase.md │ │ ├── to_re.md │ │ ├── trim.md │ │ ├── unbracket.md │ │ ├── underscore.md │ │ ├── unfold.md │ │ ├── unindent.md │ │ ├── unquote.md │ │ ├── uppercase.md │ │ ├── variablize.md │ │ ├── word_wrap.md │ │ ├── words.md │ │ └── xor.md └── standard │ ├── 02_cloneable.rdoc │ ├── 03_enumargs.rdoc │ ├── 04_equitable.rdoc │ ├── 05_instantiable.rdoc │ ├── date │ └── comparison.md │ ├── memoizable.rdoc │ └── mulititon.rdoc ├── etc ├── locat.rb └── test.rb ├── facets.gemspec ├── lib ├── core │ ├── facets.rb │ ├── facets.yml │ └── facets │ │ ├── applique │ │ └── file_helpers.rb │ │ ├── array.rb │ │ ├── array │ │ ├── after.rb │ │ ├── arrange.rb │ │ ├── average.rb │ │ ├── before.rb │ │ ├── collapse.rb │ │ ├── collisions.rb │ │ ├── commonality.rb │ │ ├── conjoin.rb │ │ ├── contains.rb │ │ ├── delete.rb │ │ ├── delete_unless.rb │ │ ├── delete_values.rb │ │ ├── delete_values_at.rb │ │ ├── divide.rb │ │ ├── duplicates.rb │ │ ├── each_overlap.rb │ │ ├── each_pair.rb │ │ ├── each_value.rb │ │ ├── entropy.rb │ │ ├── extract_options.rb │ │ ├── first.rb │ │ ├── from.rb │ │ ├── indexable.rb │ │ ├── intersection.rb │ │ ├── last.rb │ │ ├── median.rb │ │ ├── merge.rb │ │ ├── missing.rb │ │ ├── mode.rb │ │ ├── nonuniq.rb │ │ ├── not_empty.rb │ │ ├── occur.rb │ │ ├── occurrence.rb │ │ ├── only.rb │ │ ├── op_pow.rb │ │ ├── pad.rb │ │ ├── peek.rb │ │ ├── poke.rb │ │ ├── probability.rb │ │ ├── pull.rb │ │ ├── recurse.rb │ │ ├── recursively.rb │ │ ├── reject_values.rb │ │ ├── span.rb │ │ ├── splice.rb │ │ ├── split.rb │ │ ├── split_at.rb │ │ ├── squeeze.rb │ │ ├── standard_deviation.rb │ │ ├── step.rb │ │ ├── store.rb │ │ ├── thru.rb │ │ ├── to_h.rb │ │ ├── traverse.rb │ │ ├── uniq_by.rb │ │ ├── unique_permutation.rb │ │ ├── variance.rb │ │ └── zip.rb │ │ ├── binding.rb │ │ ├── binding │ │ ├── __callee__.rb │ │ ├── __method__.rb │ │ ├── call_stack.rb │ │ ├── caller.rb │ │ ├── callstack.rb │ │ ├── defined.rb │ │ ├── op.rb │ │ ├── op_get.rb │ │ ├── op_set.rb │ │ ├── self.rb │ │ └── with.rb │ │ ├── boolean.rb │ │ ├── cattr.rb │ │ ├── class.rb │ │ ├── class │ │ ├── cattr.rb │ │ ├── descendants.rb │ │ ├── hierarchically.rb │ │ ├── methodize.rb │ │ ├── pathize.rb │ │ ├── preallocate.rb │ │ ├── singleton.rb │ │ ├── singleton_class.rb │ │ ├── subclasses.rb │ │ └── to_proc.rb │ │ ├── comparable.rb │ │ ├── comparable │ │ ├── at_least.rb │ │ ├── at_most.rb │ │ ├── bound.rb │ │ ├── cap.rb │ │ ├── clip.rb │ │ ├── cmp.rb │ │ └── op_get.rb │ │ ├── denumerable.rb │ │ ├── dir.rb │ │ ├── dir │ │ ├── ascend.rb │ │ ├── descend.rb │ │ ├── each_child.rb │ │ ├── lookup.rb │ │ ├── multiglob.rb │ │ ├── parent.rb │ │ └── recurse.rb │ │ ├── enumerable.rb │ │ ├── enumerable │ │ ├── accumulate.rb │ │ ├── apply.rb │ │ ├── associate.rb │ │ ├── cluster.rb │ │ ├── collect_with_index.rb │ │ ├── compact_map.rb │ │ ├── defer.rb │ │ ├── each_by.rb │ │ ├── every.rb │ │ ├── ewise.rb │ │ ├── exclude.rb │ │ ├── expand.rb │ │ ├── filter.rb │ │ ├── find_yield.rb │ │ ├── frequency.rb │ │ ├── graph.rb │ │ ├── hashify.rb │ │ ├── hinge.rb │ │ ├── incase.rb │ │ ├── key_by.rb │ │ ├── map_by.rb │ │ ├── map_detect.rb │ │ ├── map_send.rb │ │ ├── map_to.rb │ │ ├── map_with.rb │ │ ├── map_with_index.rb │ │ ├── mash.rb │ │ ├── modulate.rb │ │ ├── occur.rb │ │ ├── only.rb │ │ ├── organize_by.rb │ │ ├── pair.rb │ │ ├── per.rb │ │ ├── purge.rb │ │ ├── recursively.rb │ │ ├── squeeze.rb │ │ ├── sum.rb │ │ ├── unassociate.rb │ │ ├── uniq_by.rb │ │ ├── value_by.rb │ │ ├── visit.rb │ │ ├── with_position.rb │ │ └── zip_map.rb │ │ ├── enumerator.rb │ │ ├── enumerator │ │ ├── fx.rb │ │ └── lazy │ │ │ └── squeeze.rb │ │ ├── essentials.rb │ │ ├── exception.rb │ │ ├── exception │ │ ├── detail.rb │ │ ├── error_print.rb │ │ ├── raised.rb │ │ ├── set_message.rb │ │ └── suppress.rb │ │ ├── file.rb │ │ ├── file │ │ ├── append.rb │ │ ├── atomic_id.rb │ │ ├── atomic_open.rb │ │ ├── atomic_write.rb │ │ ├── common_path.rb │ │ ├── create.rb │ │ ├── ext.rb │ │ ├── null.rb │ │ ├── read_binary.rb │ │ ├── read_list.rb │ │ ├── rewrite.rb │ │ ├── rootname.rb │ │ ├── sanitize.rb │ │ ├── split_all.rb │ │ ├── split_root.rb │ │ ├── write.rb │ │ └── writelines.rb │ │ ├── filetest.rb │ │ ├── filetest │ │ ├── absolute.rb │ │ ├── contains.rb │ │ ├── relative.rb │ │ ├── root.rb │ │ ├── safe.rb │ │ └── separator_pattern.rb │ │ ├── float.rb │ │ ├── float │ │ └── round_to.rb │ │ ├── functor.rb │ │ ├── hash.rb │ │ ├── hash │ │ ├── alias.rb │ │ ├── argumentize.rb │ │ ├── at.rb │ │ ├── autonew.rb │ │ ├── collate.rb │ │ ├── count.rb │ │ ├── data.rb │ │ ├── dearray_values.rb │ │ ├── deep_merge.rb │ │ ├── deep_rekey.rb │ │ ├── delete.rb │ │ ├── delete_at.rb │ │ ├── delete_unless.rb │ │ ├── delete_values.rb │ │ ├── diff.rb │ │ ├── each_with_key.rb │ │ ├── except.rb │ │ ├── fetch_nested.rb │ │ ├── graph.rb │ │ ├── insert.rb │ │ ├── inverse.rb │ │ ├── join.rb │ │ ├── keys.rb │ │ ├── mash.rb │ │ ├── new_with.rb │ │ ├── only_keys.rb │ │ ├── op.rb │ │ ├── op_add.rb │ │ ├── op_and.rb │ │ ├── op_mul.rb │ │ ├── op_or.rb │ │ ├── op_push.rb │ │ ├── op_sub.rb │ │ ├── recurse.rb │ │ ├── recursively.rb │ │ ├── rekey.rb │ │ ├── replace_each.rb │ │ ├── revalue.rb │ │ ├── reverse_merge.rb │ │ ├── slice.rb │ │ ├── stringify_keys.rb │ │ ├── subset.rb │ │ ├── swap.rb │ │ ├── symbolize_keys.rb │ │ ├── to_mod.rb │ │ ├── to_options.rb │ │ ├── to_proc.rb │ │ ├── to_struct.rb │ │ ├── traverse.rb │ │ ├── update.rb │ │ ├── update_each.rb │ │ ├── update_keys.rb │ │ ├── update_values.rb │ │ ├── weave.rb │ │ └── zip.rb │ │ ├── indexable.rb │ │ ├── integer.rb │ │ ├── integer │ │ ├── bit.rb │ │ ├── bitmask.rb │ │ ├── factorial.rb │ │ ├── multiple.rb │ │ ├── of.rb │ │ ├── ordinal.rb │ │ └── roman.rb │ │ ├── kernel.rb │ │ ├── kernel │ │ ├── __class__.rb │ │ ├── __dir__.rb │ │ ├── __get__.rb │ │ ├── __set__.rb │ │ ├── as.rb │ │ ├── ask.rb │ │ ├── assign.rb │ │ ├── assign_from.rb │ │ ├── attr_singleton.rb │ │ ├── blank.rb │ │ ├── call_stack.rb │ │ ├── callstack.rb │ │ ├── case.rb │ │ ├── complete.rb │ │ ├── d.rb │ │ ├── deep_clone.rb │ │ ├── deep_copy.rb │ │ ├── demo.rb │ │ ├── disable_warnings.rb │ │ ├── eigen.rb │ │ ├── eigenclass.rb │ │ ├── enable_warnings.rb │ │ ├── ergo.rb │ │ ├── extend.rb │ │ ├── extension.rb │ │ ├── false.rb │ │ ├── here.rb │ │ ├── hierarchical_send.rb │ │ ├── identical.rb │ │ ├── in.rb │ │ ├── instance_assign.rb │ │ ├── instance_class.rb │ │ ├── instance_exec.rb │ │ ├── instance_extract.rb │ │ ├── instance_replace.rb │ │ ├── instance_send.rb │ │ ├── like.rb │ │ ├── load_all.rb │ │ ├── load_relative.rb │ │ ├── maybe.rb │ │ ├── memo.rb │ │ ├── meta.rb │ │ ├── meta_alias.rb │ │ ├── meta_class.rb │ │ ├── meta_def.rb │ │ ├── meta_eval.rb │ │ ├── method.rb │ │ ├── no.rb │ │ ├── not.rb │ │ ├── not_nil.rb │ │ ├── object_class.rb │ │ ├── object_hexid.rb │ │ ├── object_send.rb │ │ ├── p.rb │ │ ├── presence.rb │ │ ├── present.rb │ │ ├── qua_class.rb │ │ ├── require_all.rb │ │ ├── respond.rb │ │ ├── returning.rb │ │ ├── silence.rb │ │ ├── silence_warnings.rb │ │ ├── singleton_class.rb │ │ ├── super_method.rb │ │ ├── tap.rb │ │ ├── temporarily.rb │ │ ├── trap_chain.rb │ │ ├── true.rb │ │ ├── try.rb │ │ ├── val.rb │ │ ├── with.rb │ │ ├── writers.rb │ │ ├── y.rb │ │ └── yes.rb │ │ ├── lazy.rb │ │ ├── load_path.rb │ │ ├── load_path │ │ └── search.rb │ │ ├── matchdata.rb │ │ ├── matchdata │ │ ├── match.rb │ │ ├── matchset.rb │ │ └── matchtree.rb │ │ ├── metaid.rb │ │ ├── method.rb │ │ ├── method │ │ ├── composition.rb │ │ ├── curry.rb │ │ ├── memoize.rb │ │ ├── op_mul.rb │ │ ├── op_pow.rb │ │ ├── partial.rb │ │ └── public.rb │ │ ├── module.rb │ │ ├── module │ │ ├── abstract.rb │ │ ├── alias_accessor.rb │ │ ├── alias_class_method.rb │ │ ├── alias_method_chain.rb │ │ ├── alias_module_function.rb │ │ ├── all_instance_methods.rb │ │ ├── ancestor.rb │ │ ├── anonymous.rb │ │ ├── attr_class_accessor.rb │ │ ├── attr_setter.rb │ │ ├── attr_tester.rb │ │ ├── attr_validator.rb │ │ ├── basename.rb │ │ ├── can.rb │ │ ├── cattr.rb │ │ ├── class.rb │ │ ├── class_accessor.rb │ │ ├── class_def.rb │ │ ├── class_extend.rb │ │ ├── class_inheritor.rb │ │ ├── class_method_defined.rb │ │ ├── copy_inheritor.rb │ │ ├── enclosure.rb │ │ ├── enclosures.rb │ │ ├── extend.rb │ │ ├── home.rb │ │ ├── homename.rb │ │ ├── housing.rb │ │ ├── include_as.rb │ │ ├── include_function_module.rb │ │ ├── instance_function.rb │ │ ├── instance_method.rb │ │ ├── instance_method_defined.rb │ │ ├── integrate.rb │ │ ├── is.rb │ │ ├── lastname.rb │ │ ├── let.rb │ │ ├── mattr.rb │ │ ├── memoize.rb │ │ ├── method_clash.rb │ │ ├── method_space.rb │ │ ├── methodize.rb │ │ ├── modname.rb │ │ ├── module_def.rb │ │ ├── module_load.rb │ │ ├── nodef.rb │ │ ├── op.rb │ │ ├── op_add.rb │ │ ├── op_mul.rb │ │ ├── op_sub.rb │ │ ├── pathize.rb │ │ ├── preextend.rb │ │ ├── redefine_method.rb │ │ ├── redirect_method.rb │ │ ├── remove.rb │ │ ├── rename_method.rb │ │ ├── revise.rb │ │ ├── set.rb │ │ ├── singleton_method_defined.rb │ │ ├── spacename.rb │ │ ├── to_obj.rb │ │ └── wrap_method.rb │ │ ├── na.rb │ │ ├── nilclass.rb │ │ ├── nilclass │ │ └── ergo.rb │ │ ├── numeric.rb │ │ ├── numeric │ │ ├── approx.rb │ │ ├── close.rb │ │ ├── delimit.rb │ │ ├── distance.rb │ │ ├── length.rb │ │ ├── negative.rb │ │ ├── positive.rb │ │ ├── range.rb │ │ ├── round_to.rb │ │ └── spacing.rb │ │ ├── object.rb │ │ ├── object │ │ ├── clone.rb │ │ ├── dup.rb │ │ ├── itself.rb │ │ ├── object_state.rb │ │ └── try_dup.rb │ │ ├── objectspace.rb │ │ ├── objectspace │ │ ├── classes.rb │ │ └── op_fetch.rb │ │ ├── proc.rb │ │ ├── proc │ │ ├── bind.rb │ │ ├── bind_to.rb │ │ ├── compose.rb │ │ ├── partial.rb │ │ ├── to_method.rb │ │ ├── update.rb │ │ └── wrap.rb │ │ ├── process.rb │ │ ├── process │ │ └── daemon.rb │ │ ├── range.rb │ │ ├── range │ │ ├── combine.rb │ │ ├── nudge.rb │ │ ├── op_add.rb │ │ ├── op_sub.rb │ │ ├── overlap.rb │ │ ├── quantile.rb │ │ ├── to_rng.rb │ │ ├── umbrella.rb │ │ └── within.rb │ │ ├── regexp.rb │ │ ├── regexp │ │ ├── arity.rb │ │ ├── multiline.rb │ │ ├── op_add.rb │ │ ├── op_or.rb │ │ ├── to_proc.rb │ │ └── to_re.rb │ │ ├── roman.rb │ │ ├── string.rb │ │ ├── string │ │ ├── acronym.rb │ │ ├── align.rb │ │ ├── ascii_only.rb │ │ ├── bracket.rb │ │ ├── briefcase.rb │ │ ├── camelcase.rb │ │ ├── capitalized.rb │ │ ├── cleanlines.rb │ │ ├── cleave.rb │ │ ├── cmp.rb │ │ ├── compress_lines.rb │ │ ├── crypt.rb │ │ ├── divide.rb │ │ ├── each_match.rb │ │ ├── each_word.rb │ │ ├── edit_distance.rb │ │ ├── ends_with.rb │ │ ├── exclude.rb │ │ ├── expand_tab.rb │ │ ├── file.rb │ │ ├── fold.rb │ │ ├── indent.rb │ │ ├── index_all.rb │ │ ├── indexable.rb │ │ ├── interpolate.rb │ │ ├── lchomp.rb │ │ ├── line_wrap.rb │ │ ├── linear.rb │ │ ├── lowercase.rb │ │ ├── margin.rb │ │ ├── methodize.rb │ │ ├── modulize.rb │ │ ├── mscan.rb │ │ ├── natcmp.rb │ │ ├── nchar.rb │ │ ├── newlines.rb │ │ ├── number.rb │ │ ├── op_div.rb │ │ ├── op_sub.rb │ │ ├── outdent.rb │ │ ├── pathize.rb │ │ ├── quote.rb │ │ ├── random.rb │ │ ├── range.rb │ │ ├── range_all.rb │ │ ├── range_of_line.rb │ │ ├── remove.rb │ │ ├── rewrite.rb │ │ ├── roman.rb │ │ ├── rotate.rb │ │ ├── shatter.rb │ │ ├── similarity.rb │ │ ├── snakecase.rb │ │ ├── splice.rb │ │ ├── squish.rb │ │ ├── starts_with.rb │ │ ├── store.rb │ │ ├── subtract.rb │ │ ├── titlecase.rb │ │ ├── to_re.rb │ │ ├── to_rx.rb │ │ ├── trim.rb │ │ ├── unbracket.rb │ │ ├── underscore.rb │ │ ├── unfold.rb │ │ ├── unindent.rb │ │ ├── unquote.rb │ │ ├── uppercase.rb │ │ ├── variablize.rb │ │ ├── word_wrap.rb │ │ ├── words.rb │ │ └── xor.rb │ │ ├── struct.rb │ │ ├── struct │ │ ├── attributes.rb │ │ └── replace.rb │ │ ├── symbol.rb │ │ ├── symbol │ │ ├── as_s.rb │ │ ├── bang.rb │ │ ├── call.rb │ │ ├── chomp.rb │ │ ├── generate.rb │ │ ├── not.rb │ │ ├── op_div.rb │ │ ├── plain.rb │ │ ├── query.rb │ │ ├── reader.rb │ │ ├── setter.rb │ │ ├── succ.rb │ │ ├── thrown.rb │ │ ├── variablize.rb │ │ └── writer.rb │ │ ├── time.rb │ │ ├── time │ │ ├── ago.rb │ │ ├── change.rb │ │ ├── dst_adjustment.rb │ │ ├── elapse.rb │ │ ├── future.rb │ │ ├── hence.rb │ │ ├── in.rb │ │ ├── less.rb │ │ ├── past.rb │ │ ├── round_to.rb │ │ ├── set.rb │ │ ├── shift.rb │ │ ├── stamp.rb │ │ ├── to_time.rb │ │ └── trunc.rb │ │ ├── unboundmethod.rb │ │ ├── unboundmethod │ │ └── arguments.rb │ │ └── version.rb └── standard │ └── facets │ ├── against.rb │ ├── argvector.rb │ ├── binding │ └── block_exec.rb │ ├── cgi.rb │ ├── cgi │ ├── esc.rb │ ├── escape_html.rb │ └── marshal.rb │ ├── cli.rb │ ├── cloneable.rb │ ├── continuation.rb │ ├── date.rb │ ├── date │ └── cmp.rb │ ├── digest.rb │ ├── digest │ ├── base64digest.rb │ └── salted_digest.rb │ ├── enumargs.rb │ ├── equitable.rb │ ├── erb.rb │ ├── fileutils.rb │ ├── fileutils │ ├── amass.rb │ ├── cp_rx.rb │ ├── head.rb │ ├── ln_r.rb │ ├── outofdate.rb │ ├── safe_ln.rb │ ├── slice.rb │ ├── stage.rb │ ├── tail.rb │ ├── wc.rb │ ├── whereis.rb │ └── which.rb │ ├── find.rb │ ├── find │ └── select.rb │ ├── gem │ ├── search.rb │ └── specification │ │ ├── current_specs.rb │ │ └── find_requireable_file.rb │ ├── getoptlong.rb │ ├── hash_builder.rb │ ├── instantiable.rb │ ├── interval.rb │ ├── load_monitor.rb │ ├── math.rb │ ├── math │ ├── abs.rb │ ├── acosec.rb │ ├── acot.rb │ ├── acoth.rb │ ├── acsc.rb │ ├── acsch.rb │ ├── amd.rb │ ├── approx_equal.rb │ ├── asec.rb │ ├── asech.rb │ ├── atkinson_index.rb │ ├── beta.rb │ ├── cdf.rb │ ├── ceil.rb │ ├── cosec.rb │ ├── cosech.rb │ ├── cot.rb │ ├── coth.rb │ ├── csc.rb │ ├── csch.rb │ ├── delta.rb │ ├── distance.rb │ ├── ec.rb │ ├── epsilon.rb │ ├── exp10.rb │ ├── exp2.rb │ ├── factorial.rb │ ├── floor.rb │ ├── gcd.rb │ ├── gini_coefficient.rb │ ├── kldivergence.rb │ ├── lcm.rb │ ├── lgamma.rb │ ├── linsolve.rb │ ├── lngamma.rb │ ├── log2.rb │ ├── max.rb │ ├── mean.rb │ ├── median.rb │ ├── min.rb │ ├── percentile.rb │ ├── pow.rb │ ├── pstd.rb │ ├── pvariance.rb │ ├── rmd.rb │ ├── root.rb │ ├── round.rb │ ├── sec.rb │ ├── sech.rb │ ├── sign.rb │ ├── sinc.rb │ ├── sqr.rb │ ├── sqsolve.rb │ ├── std.rb │ ├── stderr.rb │ ├── sum.rb │ ├── summed_sqdevs.rb │ ├── tau.rb │ ├── tgamma.rb │ ├── theil_index.rb │ └── variance.rb │ ├── memoizable.rb │ ├── memoizer.rb │ ├── multipliers.rb │ ├── multiton.rb │ ├── net │ └── http.rb │ ├── nullclass.rb │ ├── opesc.rb │ ├── ostruct.rb │ ├── ostruct │ ├── each.rb │ ├── initialize.rb │ ├── merge.rb │ ├── op_fetch.rb │ ├── op_store.rb │ ├── to_h.rb │ └── to_ostruct.rb │ ├── pathname.rb │ ├── pathname │ ├── chdir.rb │ ├── empty.rb │ ├── exists.rb │ ├── glob.rb │ ├── home.rb │ ├── null.rb │ ├── op_div.rb │ ├── op_fetch.rb │ ├── outofdate.rb │ ├── readline.rb │ ├── root.rb │ ├── rootname.rb │ ├── safe.rb │ ├── split_root.rb │ ├── to_path.rb │ ├── to_str.rb │ ├── uptodate.rb │ ├── visit.rb │ └── work.rb │ ├── platform.rb │ ├── random.rb │ ├── rbconfig.rb │ ├── set.rb │ ├── shellwords.rb │ ├── strscan.rb │ ├── thread.rb │ ├── timer.rb │ ├── tuple.rb │ ├── uri.rb │ ├── uri │ ├── cgi_escape.rb │ ├── cgi_parse.rb │ ├── cgi_unescape.rb │ ├── decode.rb │ ├── parameters.rb │ └── query.rb │ ├── yaml.rb │ ├── yaml │ ├── file.rb │ ├── kernel.rb │ └── read.rb │ └── zlib.rb ├── test ├── core │ ├── array │ │ ├── test_arrange.rb │ │ ├── test_average.rb │ │ ├── test_before.rb │ │ ├── test_collapse.rb │ │ ├── test_commonality.rb │ │ ├── test_conjoin.rb │ │ ├── test_contains.rb │ │ ├── test_delete.rb │ │ ├── test_delete_unless.rb │ │ ├── test_delete_values.rb │ │ ├── test_divide.rb │ │ ├── test_duplicates.rb │ │ ├── test_each_overlap.rb │ │ ├── test_each_pair.rb │ │ ├── test_each_value.rb │ │ ├── test_entropy.rb │ │ ├── test_extract_options.rb │ │ ├── test_first.rb │ │ ├── test_from.rb │ │ ├── test_intersection.rb │ │ ├── test_last.rb │ │ ├── test_median.rb │ │ ├── test_merge.rb │ │ ├── test_missing.rb │ │ ├── test_mode.rb │ │ ├── test_nonuniq.rb │ │ ├── test_not_empty.rb │ │ ├── test_occur.rb │ │ ├── test_occurrence.rb │ │ ├── test_only.rb │ │ ├── test_op_pow.rb │ │ ├── test_pad.rb │ │ ├── test_peek.rb │ │ ├── test_poke.rb │ │ ├── test_probability.rb │ │ ├── test_pull.rb │ │ ├── test_recurse.rb │ │ ├── test_recursively.rb │ │ ├── test_reject_values.rb │ │ ├── test_span.rb │ │ ├── test_splice.rb │ │ ├── test_split.rb │ │ ├── test_split_at.rb │ │ ├── test_squeeze.rb │ │ ├── test_standard_deviation.rb │ │ ├── test_step.rb │ │ ├── test_store.rb │ │ ├── test_to_h.rb │ │ ├── test_traverse.rb │ │ ├── test_uniq_by.rb │ │ ├── test_unique_permutation.rb │ │ ├── test_variance.rb │ │ └── test_zip.rb │ ├── binding │ │ ├── test_caller.rb │ │ ├── test_defined.rb │ │ ├── test_op.rb │ │ └── test_self.rb │ ├── class │ │ ├── test_descendents.rb │ │ ├── test_preallocate.rb │ │ ├── test_subclasses.rb │ │ └── test_to_proc.rb │ ├── comparable │ │ ├── test_bound.rb │ │ ├── test_cap.rb │ │ ├── test_clip.rb │ │ ├── test_cmp.rb │ │ └── test_op_get.rb │ ├── denumerable_tc.rb │ ├── dir │ │ ├── test_ascend.rb │ │ ├── test_descend.rb │ │ ├── test_each_child.rb │ │ ├── test_multiglob.rb │ │ ├── test_parent.rb │ │ └── test_recurse.rb │ ├── enumerable │ │ ├── test_accumulate.rb │ │ ├── test_cluster.rb │ │ ├── test_compact_map.rb │ │ ├── test_defer.rb │ │ ├── test_each_by.rb │ │ ├── test_every.rb │ │ ├── test_ewise.rb │ │ ├── test_exclude.rb │ │ ├── test_expand.rb │ │ ├── test_filter.rb │ │ ├── test_find_yield.rb │ │ ├── test_frequency.rb │ │ ├── test_graph.rb │ │ ├── test_hashify.rb │ │ ├── test_key_by.rb │ │ ├── test_map_by.rb │ │ ├── test_map_send.rb │ │ ├── test_map_with_index.rb │ │ ├── test_mash.rb │ │ ├── test_modulate.rb │ │ ├── test_occur.rb │ │ ├── test_only.rb │ │ ├── test_per.rb │ │ ├── test_purge.rb │ │ ├── test_recursively.rb │ │ ├── test_squeeze.rb │ │ ├── test_sum.rb │ │ ├── test_uniq_by.rb │ │ ├── test_visit.rb │ │ └── test_with_position.rb │ ├── enumerator │ │ ├── lazy │ │ │ └── test_squeeze.rb │ │ ├── test_fx.rb │ │ └── test_new.rb │ ├── enumerator_tc.rb │ ├── exception │ │ ├── test_detail.rb │ │ ├── test_raised.rb │ │ └── test_suppress.rb │ ├── file │ │ ├── test_append.rb │ │ ├── test_create.rb │ │ ├── test_ext.rb │ │ ├── test_null.rb │ │ ├── test_read_binary.rb │ │ ├── test_read_list.rb │ │ ├── test_rewrite.rb │ │ ├── test_rootname.rb │ │ ├── test_sanitize.rb │ │ ├── test_split_all.rb │ │ ├── test_write.rb │ │ └── test_writelines.rb │ ├── filetest │ │ └── test_root.rb │ ├── functor_tc.rb │ ├── hash │ │ ├── test_alias.rb │ │ ├── test_argumentize.rb │ │ ├── test_at.rb │ │ ├── test_autonew.rb │ │ ├── test_collate.rb │ │ ├── test_count.rb │ │ ├── test_data.rb │ │ ├── test_dearray_values.rb │ │ ├── test_deep_merge.rb │ │ ├── test_deep_rekey.rb │ │ ├── test_delete_at.rb │ │ ├── test_delete_unless.rb │ │ ├── test_delete_values.rb │ │ ├── test_diff.rb │ │ ├── test_each_with_key.rb │ │ ├── test_expect.rb │ │ ├── test_fetch_nested.rb │ │ ├── test_graph.rb │ │ ├── test_insert.rb │ │ ├── test_inverse.rb │ │ ├── test_join.rb │ │ ├── test_keys.rb │ │ ├── test_new_with.rb │ │ ├── test_op_add.rb │ │ ├── test_op_and.rb │ │ ├── test_op_mul.rb │ │ ├── test_op_or.rb │ │ ├── test_op_push.rb │ │ ├── test_op_sub.rb │ │ ├── test_recurse.rb │ │ ├── test_recursively.rb │ │ ├── test_rekey.rb │ │ ├── test_replace_each.rb │ │ ├── test_revalue.rb │ │ ├── test_reverse_merge.rb │ │ ├── test_slice.rb │ │ ├── test_stringify_keys.rb │ │ ├── test_swap.rb │ │ ├── test_symbolize_keys.rb │ │ ├── test_to_mod.rb │ │ ├── test_to_proc.rb │ │ ├── test_to_struct.rb │ │ ├── test_traverse.rb │ │ ├── test_update_each.rb │ │ ├── test_update_keys.rb │ │ ├── test_update_values.rb │ │ ├── test_weave.rb │ │ └── test_zip.rb │ ├── indexable_tc.rb │ ├── integer │ │ ├── test_bitmask.rb │ │ ├── test_factorial.rb │ │ ├── test_multiple.rb │ │ ├── test_of.rb │ │ └── test_ordinal.rb │ ├── kernel │ │ ├── test_as.rb │ │ ├── test_ask.rb │ │ ├── test_assign.rb │ │ ├── test_assign_from.rb │ │ ├── test_attr_singleton.rb │ │ ├── test_blank.rb │ │ ├── test_callstack.rb │ │ ├── test_class.rb │ │ ├── test_complete.rb │ │ ├── test_d.rb │ │ ├── test_deep_clone.rb │ │ ├── test_deep_copy.rb │ │ ├── test_dir.rb │ │ ├── test_disable_warnings.rb │ │ ├── test_ergo.rb │ │ ├── test_extension.rb │ │ ├── test_get.rb │ │ ├── test_here.rb │ │ ├── test_hierarchical_send.rb │ │ ├── test_in.rb │ │ ├── test_instance_assign.rb │ │ ├── test_instance_class.rb │ │ ├── test_instance_extract.rb │ │ ├── test_instance_replace.rb │ │ ├── test_instance_send.rb │ │ ├── test_maybe.rb │ │ ├── test_meta_alias.rb │ │ ├── test_meta_class.rb │ │ ├── test_meta_def.rb │ │ ├── test_meta_eval.rb │ │ ├── test_method.rb │ │ ├── test_not.rb │ │ ├── test_not_nil.rb │ │ ├── test_object_class.rb │ │ ├── test_object_hexid.rb │ │ ├── test_object_send.rb │ │ ├── test_presence.rb │ │ ├── test_qua_class.rb │ │ ├── test_require_all.rb │ │ ├── test_respond.rb │ │ ├── test_returning.rb │ │ ├── test_silence.rb │ │ ├── test_singleton_class.rb │ │ ├── test_super_method.rb │ │ ├── test_tap.rb │ │ ├── test_temporarily.rb │ │ ├── test_true.rb │ │ ├── test_try.rb │ │ ├── test_val.rb │ │ ├── test_with.rb │ │ └── test_writers.rb │ ├── matchdata │ │ ├── test_match.rb │ │ └── test_matchset.rb │ ├── method │ │ └── test_composition.rb │ ├── module │ │ ├── test_abstract.rb │ │ ├── test_alias_accessor.rb │ │ ├── test_alias_method_chain.rb │ │ ├── test_alias_module_function.rb │ │ ├── test_all_instance_methods.rb │ │ ├── test_ancestor.rb │ │ ├── test_anonymous.rb │ │ ├── test_attr_setter.rb │ │ ├── test_basename.rb │ │ ├── test_can.rb │ │ ├── test_class.rb │ │ ├── test_class_def.rb │ │ ├── test_class_extend.rb │ │ ├── test_class_inheritor.rb │ │ ├── test_copy_inheritor.rb │ │ ├── test_enclosure.rb │ │ ├── test_instance_function.rb │ │ ├── test_instance_method.rb │ │ ├── test_instance_method_defined.rb │ │ ├── test_integrate.rb │ │ ├── test_is.rb │ │ ├── test_memoize.rb │ │ ├── test_method_clash.rb │ │ ├── test_method_space.rb │ │ ├── test_methodize.rb │ │ ├── test_modname.rb │ │ ├── test_module_def.rb │ │ ├── test_module_load.rb │ │ ├── test_nodef.rb │ │ ├── test_op.rb │ │ ├── test_pathize.rb │ │ ├── test_preextend.rb │ │ ├── test_redefine_method.rb │ │ ├── test_redirect_method.rb │ │ ├── test_remove.rb │ │ ├── test_rename_method.rb │ │ ├── test_revise.rb │ │ ├── test_set.rb │ │ ├── test_spacename.rb │ │ ├── test_to_obj.rb │ │ └── test_wrap_method.rb │ ├── numeric │ │ ├── test_approx.rb │ │ ├── test_delimit.rb │ │ ├── test_distance.rb │ │ ├── test_length.rb │ │ ├── test_round_to.rb │ │ └── test_spacing.rb │ ├── object │ │ ├── test_dup.rb │ │ ├── test_object_state.rb │ │ └── test_try_dup.rb │ ├── proc │ │ ├── test_bind.rb │ │ ├── test_bind_to.rb │ │ ├── test_compose.rb │ │ ├── test_partial.rb │ │ ├── test_to_method.rb │ │ └── test_update.rb │ ├── range │ │ ├── test_combine.rb │ │ ├── test_nudge.rb │ │ ├── test_op_add.rb │ │ ├── test_op_sub.rb │ │ ├── test_overlap.rb │ │ ├── test_to_rng.rb │ │ ├── test_umbrella.rb │ │ └── test_within.rb │ ├── regexp │ │ ├── test_arity.rb │ │ ├── test_multiline.rb │ │ ├── test_op_add.rb │ │ ├── test_op_or.rb │ │ └── test_to_re.rb │ ├── string │ │ ├── test_acronym.rb │ │ ├── test_align.rb │ │ ├── test_ascii_only.rb │ │ ├── test_bracket.rb │ │ ├── test_camelcase.rb │ │ ├── test_capitalized.rb │ │ ├── test_cleanlines.rb │ │ ├── test_cleave.rb │ │ ├── test_cmp.rb │ │ ├── test_compress_lines.rb │ │ ├── test_crypt.rb │ │ ├── test_divide.rb │ │ ├── test_each_word.rb │ │ ├── test_edit_distance.rb │ │ ├── test_exclude.rb │ │ ├── test_expand_tabs.rb │ │ ├── test_file.rb │ │ ├── test_fold.rb │ │ ├── test_indent.rb │ │ ├── test_index_all.rb │ │ ├── test_interpolate.rb │ │ ├── test_lchomp.rb │ │ ├── test_line_wrap.rb │ │ ├── test_lowercase.rb │ │ ├── test_margin.rb │ │ ├── test_methodize.rb │ │ ├── test_modulize.rb │ │ ├── test_mscan.rb │ │ ├── test_natcmp.rb │ │ ├── test_nchar.rb │ │ ├── test_newlines.rb │ │ ├── test_number.rb │ │ ├── test_op_div.rb │ │ ├── test_op_sub.rb │ │ ├── test_pathize.rb │ │ ├── test_quote.rb │ │ ├── test_random.rb │ │ ├── test_range.rb │ │ ├── test_remove.rb │ │ ├── test_rewrite.rb │ │ ├── test_rotate.rb │ │ ├── test_shatter.rb │ │ ├── test_similarity.rb │ │ ├── test_snakecase.rb │ │ ├── test_splice.rb │ │ ├── test_squish.rb │ │ ├── test_store.rb │ │ ├── test_subtract.rb │ │ ├── test_titlecase.rb │ │ ├── test_to_re.rb │ │ ├── test_trim.rb │ │ ├── test_unbracket.rb │ │ ├── test_underscore.rb │ │ ├── test_unfold.rb │ │ ├── test_unindent.rb │ │ ├── test_unquote.rb │ │ ├── test_uppercase.rb │ │ ├── test_variablize.rb │ │ ├── test_word_wrap.rb │ │ ├── test_words.rb │ │ └── test_xor.rb │ ├── struct │ │ └── test_replace.rb │ ├── symbol │ │ ├── test_as_s.rb │ │ ├── test_bang.rb │ │ ├── test_chomp.rb │ │ ├── test_generate.rb │ │ ├── test_not.rb │ │ ├── test_op_div.rb │ │ ├── test_plain.rb │ │ ├── test_query.rb │ │ ├── test_setter.rb │ │ ├── test_succ.rb │ │ ├── test_thrown.rb │ │ └── test_variablize.rb │ ├── time │ │ ├── test_ago.rb │ │ ├── test_change.rb │ │ ├── test_dst_adjustment.rb │ │ ├── test_elapse.rb │ │ ├── test_future.rb │ │ ├── test_hence.rb │ │ ├── test_in.rb │ │ ├── test_less.rb │ │ ├── test_past.rb │ │ ├── test_round_to.rb │ │ ├── test_set.rb │ │ ├── test_shift.rb │ │ ├── test_stamp.rb │ │ ├── test_to_time.rb │ │ └── test_trunc.rb │ └── unboundmethod │ │ └── test_arguments.rb └── standard │ ├── binding │ └── test_block_exec.rb │ ├── date │ └── test_cmp.rb │ ├── math │ ├── test_abs.rb │ ├── test_acot.rb │ ├── test_acoth.rb │ ├── test_beta.rb │ ├── test_ceil.rb │ ├── test_cosec.rb │ ├── test_cosech.rb │ ├── test_cot.rb │ ├── test_coth.rb │ ├── test_distance.rb │ ├── test_exp10.rb │ ├── test_exp2.rb │ ├── test_factorial.rb │ ├── test_floor.rb │ ├── test_gcd.rb │ ├── test_lcm.rb │ ├── test_median.rb │ ├── test_percentile.rb │ ├── test_pow.rb │ ├── test_root.rb │ ├── test_sec.rb │ ├── test_sech.rb │ ├── test_sign.rb │ ├── test_sinc.rb │ └── test_srq.rb │ ├── pathname │ ├── test_chdir.rb │ └── test_readline.rb │ ├── test_argvector.rb │ ├── test_cloneable.rb │ ├── test_date.rb │ ├── test_enumargs.rb │ ├── test_equitable.rb │ ├── test_instantiable.rb │ ├── test_math.rb │ ├── test_memoizable.rb │ ├── test_multipliers.rb │ ├── test_ostruct.rb │ ├── test_random.rb │ ├── test_shellwords.rb │ ├── test_thread.rb │ ├── test_timer.rb │ ├── test_tuple.rb │ └── test_uri.rb └── work ├── CHANGES ├── Compare.txt ├── HISTORY-0.rdoc ├── NOTES.rdoc ├── OLD_COMPARE └── facets │ └── string │ ├── align_center.rb │ ├── align_left.rb │ ├── align_right.rb │ ├── at.rb │ ├── at_rand.rb │ ├── basename.rb │ ├── blank.rb │ ├── bracket.rb │ ├── brief.rb │ ├── bytes.rb │ ├── camelcase.rb │ ├── camelize.rb │ ├── capitalize_all.rb │ ├── capitalized.rb │ ├── chars.rb │ ├── cleave.rb │ ├── cmp.rb │ ├── demodulize.rb │ ├── dequote.rb │ ├── divide.rb │ ├── downcase.rb │ ├── dresner.rb │ ├── each_char.rb │ ├── each_word.rb │ ├── ends_with.rb │ ├── first.rb │ ├── first_char.rb │ ├── fold.rb │ ├── format.rb │ ├── humanize.rb │ ├── indent.rb │ ├── index_all.rb │ ├── interpolate.rb │ ├── last.rb │ ├── last_char.rb │ ├── line_wrap.rb │ ├── lines.rb │ ├── lowercase.rb │ ├── margin.rb │ ├── methodize.rb │ ├── modulize.rb │ ├── mscan.rb │ ├── natcmp.rb │ ├── nchar.rb │ ├── ordinal.rb │ ├── pathize.rb │ ├── patterns.rb │ ├── plural.rb │ ├── pop.rb │ ├── pot.rb │ ├── pull.rb │ ├── push.rb │ ├── quote.rb │ ├── rand_byte.rb │ ├── rand_index.rb │ ├── rand_letter.rb │ ├── random.rb │ ├── range.rb │ ├── range_all.rb │ ├── range_of_line.rb │ ├── regesc.rb │ ├── rewrite.rb │ ├── shatter.rb │ ├── shell_escape.rb │ ├── shift.rb │ ├── shuffle.rb │ ├── similarity.rb │ ├── singular.rb │ ├── soundex.rb │ ├── starts_with.rb │ ├── succ.rb │ ├── tab.rb │ ├── tabto.rb │ ├── to_a.rb │ ├── to_b.rb │ ├── to_const.rb │ ├── to_date.rb │ ├── to_proc.rb │ ├── to_re.rb │ ├── to_rx.rb │ ├── to_time.rb │ ├── unbracket.rb │ ├── underscore.rb │ ├── unix_crypt.rb │ ├── unpack.rb │ ├── unshift.rb │ ├── upcase.rb │ ├── uppercase.rb │ ├── whitespace.rb │ ├── word_filter.rb │ ├── word_wrap.rb │ └── words.rb ├── bench ├── array │ ├── bench_index_all.rb │ └── bench_unique_permutation.rb ├── bench_load.rb ├── enumerable │ ├── bench_accumulate.rb │ ├── bench_collect.rb │ ├── bench_count.rb │ ├── bench_index.rb │ └── bench_mash.rb ├── general │ ├── bench_calls.rb │ ├── bench_includes.rb │ ├── bench_methods.rb │ ├── bench_pathname.rb │ ├── bench_range.rb │ ├── bench_return.rb │ ├── bench_yield.rb │ └── comment_loading │ │ ├── bench.rb │ │ ├── comments_begin.rb │ │ ├── comments_end.rb │ │ ├── comments_none.rb │ │ └── comments_sharp.rb ├── hash │ └── bench_slice.rb └── integer │ └── bench_factorial.rb ├── consider ├── andand.rb ├── cgi-exception-0.1.0 │ ├── README.txt │ ├── cgi-exception.gemspec │ ├── lib │ │ └── cgi_exception.rb │ └── setup.rb ├── core │ ├── array │ │ ├── mapcar.rb │ │ └── outline.rb │ ├── enumerable │ │ └── apply.rb │ ├── enumerator.rb │ ├── hash │ │ └── invert_hash.rb │ ├── kernel │ │ └── deep_dup.rb │ ├── knowself.rb │ ├── module │ │ ├── aliased_methods.rb │ │ ├── attr_inheritor.rb │ │ ├── attribute.rb │ │ ├── bool_accessor.rb │ │ ├── bool_attr_accessor.rb │ │ ├── cattr.rb │ │ ├── inheritable_class_attr.rb │ │ ├── instance_class_method.rb │ │ ├── mapped_accessor.rb │ │ ├── prepend.rb │ │ ├── subfield_accessors.rb │ │ ├── test_cattr.rb │ │ └── test_prepend.rb │ ├── object │ │ └── class_def.rb │ ├── range │ │ └── random.rb │ ├── string │ │ └── trim.rb │ ├── succ.rb │ └── test_succ.rb └── standard │ ├── 01_advisable.rdoc │ ├── advisable.rb │ ├── argv.rb │ ├── aspects.rb │ ├── duration.rb │ ├── extendmatrix.rb │ ├── file │ ├── finder.rb │ └── test_file_find.rb │ ├── forwardable_chain.patch │ ├── gem.rb │ ├── infinity.rb │ ├── interface.rb │ ├── mapcar.rb │ ├── math │ ├── algebra.rb │ ├── finance.rb │ ├── logarithms.rb │ ├── probability.rb │ ├── solvers.rb │ └── trigonometry.rb │ ├── matrix.rb │ ├── matrix │ ├── core.rb │ ├── exception.rb │ ├── givens.rb │ ├── hessenberg.rb │ ├── householder.rb │ ├── jacobi.rb │ └── lu.rb │ ├── plugin.rb │ ├── quaternion.rb │ ├── tasksystem.rb │ └── vector.rb ├── reference ├── extension.rb ├── matrix.rb ├── task │ ├── rdoc.assembly │ ├── setup.rake │ └── yard.assembly ├── tmatrix.rb ├── to_hash.rb └── trash-matrix.rb ├── rejected ├── 09_preinitialize.rdoc ├── array │ ├── fetch.rb │ └── permutation_number.rb ├── class │ ├── initializer.rb │ └── remove_descendents.rb ├── duration.rb ├── enumerable │ ├── cascade.rb │ ├── each.rb │ ├── enumx.rb │ ├── to_hash.rb │ └── visit.rb ├── filetest │ └── bin.rb ├── hash │ ├── access.rb │ ├── data.rb │ ├── group_by_value.rb │ ├── normalize_keys.rb │ ├── op_div.rb │ └── variablize_keys.rb ├── kernel │ ├── __assign__.rb │ ├── __real__.rb │ ├── deep_clone.rb │ ├── instance_assume.rb │ ├── once.rb │ └── warn_with_line.rb ├── logger.rb ├── module │ ├── attr_toggler.rb │ ├── bool_attr_accessor.rb │ ├── by_name.rb │ ├── compare_on.rb │ ├── equate_on.rb │ ├── methodize.rb │ ├── module_method.rb │ ├── namespace.rb │ └── on_included.rb ├── multiton.rb ├── multiton2.rb ├── preinitialize.rb ├── proc │ ├── bind.rb │ └── to_h.rb ├── string │ ├── camelcase.rb │ ├── indexable.rb │ ├── stackable.rb │ ├── test_indexable.rb │ ├── test_stackable.rb │ ├── test_stylize.rb │ └── to_proc.rb ├── symbol │ └── shadow.rb ├── test_continuation.rb ├── test_ioredirect.rb └── uploadutils.rb ├── sandbox ├── multiton2.rb └── safe-study │ ├── safe_extension.rb │ └── safe_study.rb ├── site ├── endorse.page ├── posts │ ├── 2010-01-25-test_rails_with_facets.post │ ├── enumargs.md │ ├── tomslib.rb │ └── weblog.xml └── sidebar.txt ├── todo ├── test_extmath.rb ├── test_fileutils_slice.rb ├── test_fileutils_wc.rb ├── test_fileutils_which.rb ├── test_getoptlong.rb └── test_multiton.rb └── trash ├── hook.rdoc ├── site-jekyll ├── .htaccess ├── .rsync-filter ├── .till ├── _config.yml ├── _layouts │ ├── default.html │ └── post.html ├── _posts │ ├── 2008-01-01-how-facets-was-born.markdown │ ├── 2008-04-04-times-collect.markdown │ ├── 2008-10-10-string-margin.markdown │ ├── 2009-07-21-new-website.markdown │ ├── 2009-08-22-release-2-7.markdown │ └── 2009-11-09-release-2-8.markdown ├── about.html ├── assets │ ├── scripts │ │ ├── hover.js │ │ └── rdocs.js │ └── styles │ │ ├── site.css │ │ └── syntax.css ├── atom.xml ├── community.html ├── download.html ├── endorse.html ├── index.html ├── learn.html └── source.html ├── site ├── .htaccess ├── .rsync-filter ├── js │ ├── hover.js │ └── rdocs.js ├── quick.html └── splash.html └── task ├── methods ├── publish └── tag /.gitignore: -------------------------------------------------------------------------------- 1 | .rbx/ 2 | .rdoc/ 3 | .yardoc/ 4 | log/ 5 | doc/ 6 | pkg/ 7 | tmp/ 8 | web/ 9 | work/rails 10 | work/sandbox 11 | work/trash 12 | Gemfile.lock 13 | .rvmrc 14 | *.gem 15 | .bundle/ 16 | vendor/ 17 | -------------------------------------------------------------------------------- /.yardopts: -------------------------------------------------------------------------------- 1 | --title "Ruby Facets" 2 | --readme README.rdoc 3 | --protected 4 | --private 5 | --tag uncommon:Uncommon 6 | --tag standard:Standard 7 | lib/core 8 | lib/standard 9 | - 10 | [A-Z]*.* 11 | -------------------------------------------------------------------------------- /demo/applique/assertion_framework.rb: -------------------------------------------------------------------------------- 1 | require 'ae' 2 | -------------------------------------------------------------------------------- /demo/core/array/collapse.md: -------------------------------------------------------------------------------- 1 | ## Array#collapse 2 | 3 | require 'facets/array/collapse' 4 | 5 | Simplify an array by flattening it then compacting it. 6 | 7 | [1,[2,nil,[3]],nil,4].collapse.assert == [1,2,3,4] 8 | 9 | ## Array#collapse! 10 | 11 | Simplify an array by flattening it in place then compacting it in place. 12 | 13 | a = [1, nil, [1, 2], nil, [[3]]] 14 | a.collapse! 15 | a.assert == [1, 1, 2, 3] 16 | -------------------------------------------------------------------------------- /demo/core/array/contains.md: -------------------------------------------------------------------------------- 1 | ## Array#contains? 2 | 3 | _alias of Array#include? _ 4 | 5 | require 'facets/array/contains' 6 | 7 | [1,2,3,4].assert.contains?(2) 8 | [1,2,3,4].refute.contains?(9) 9 | 10 | -------------------------------------------------------------------------------- /demo/core/array/delete_unless.md: -------------------------------------------------------------------------------- 1 | ## Array#delete_unless 2 | 3 | require 'facets/array/delete_unless' 4 | 5 | The method `#delete_unless` is the inverse of `#delete_if`. 6 | 7 | a = [1,2,3] 8 | a.delete_unless{ |e| e == 2 } 9 | a.assert == [2] 10 | 11 | [1,2,3].delete_unless{ |x| x < 2 }.assert == [1] 12 | [1,2,3].delete_unless(&:even?).assert == [2] 13 | 14 | -------------------------------------------------------------------------------- /demo/core/array/delete_values.md: -------------------------------------------------------------------------------- 1 | ## Array#delete_values 2 | 3 | require 'facets/array/delete_values' 4 | 5 | Delete multiple values from array. 6 | 7 | a = [1,2,3,4] 8 | a.delete_values(1,2) #=> [1,2] 9 | a #=> [3,4] 10 | 11 | -------------------------------------------------------------------------------- /demo/core/array/duplicates.md: -------------------------------------------------------------------------------- 1 | ## Array#duplicates 2 | 3 | require 'facets/array/duplicates' 4 | 5 | Return list of duplicate elements. 6 | 7 | [1,1,2,3].duplicates #=> [1] 8 | 9 | Return list of those duplicated min times. 10 | 11 | [1,1,2,3,2,4,5,4,2].duplicates(3) #=> [2] 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /demo/core/array/each_value.md: -------------------------------------------------------------------------------- 1 | ## Array#each_value 2 | 3 | require 'facets/array/each_value' 4 | 5 | This is an alias of Alias#each, and is provided to provide polymorphism with 6 | Hash#each_value. 7 | 8 | a = [ "a", "b", "c" ] 9 | out = '' 10 | a.each_value {|x| out += "#{x} -- " } 11 | out.assert == 'a -- b -- c -- ' 12 | 13 | -------------------------------------------------------------------------------- /demo/core/array/entropy.md: -------------------------------------------------------------------------------- 1 | ## Array#entropy 2 | 3 | require 'facets/array/entropy' 4 | 5 | Shannon's entropy for an array - returns the average 6 | bits per symbol required to encode the array. 7 | Lower values mean less "entropy" - i.e. less unique 8 | information in the array. 9 | 10 | e = %w{ a b c d e e e }.entropy 11 | 12 | ("%.3f" % e) #=> "2.128" 13 | 14 | -------------------------------------------------------------------------------- /demo/core/array/first.md: -------------------------------------------------------------------------------- 1 | ## Array#first! 2 | 3 | require 'facets/array/indexable' 4 | 5 | Alias for shift, which removes and returns the first element in an array 6 | 7 | a = ['a','y','z'] 8 | a.first!.assert == 'a' 9 | a.assert ['y','z'] 10 | 11 | 12 | -------------------------------------------------------------------------------- /demo/core/array/from.md: -------------------------------------------------------------------------------- 1 | ## Array#thru 2 | 3 | require 'facets/array/from' 4 | 5 | Returns elements from index i until the end. 6 | 7 | %w{W o r l d}.from(3).assert == %w{l d} 8 | 9 | Returns entire array for i > length 10 | 11 | %w{W o r l d}.from(7).assert == nil 12 | -------------------------------------------------------------------------------- /demo/core/array/ideal_entropy.md: -------------------------------------------------------------------------------- 1 | ## Array#ideal_entropy 2 | 3 | require 'facets/array/entropy' 4 | 5 | Returns the maximum possible Shannon entropy of the array 6 | with given size assuming that it is an "order-0" source 7 | (each element is selected independently of the next). 8 | 9 | %w{ a b }.ideal_entropy.assert == 1.0 10 | %w{ a a b b }.ideal_entropy.assert == 2.0 11 | 12 | -------------------------------------------------------------------------------- /demo/core/array/last.md: -------------------------------------------------------------------------------- 1 | ## Array#last! 2 | 3 | require 'facets/array/indexable' 4 | 5 | Alias for pop, which removes and returns the last element in an 6 | array. 7 | 8 | a = [1,2,3] 9 | a.last!.assert == 3 10 | a.assert == [1,2] 11 | -------------------------------------------------------------------------------- /demo/core/array/merge.md: -------------------------------------------------------------------------------- 1 | ## Array#merge 2 | 3 | require 'facets/array/merge' 4 | 5 | a = [1,2,3] 6 | b = [3,4,5] 7 | a.merge(b).assert == [1,2,3,4,5] 8 | 9 | ## Array#merge! 10 | 11 | a = [1,2,3] 12 | b = [3,4,5] 13 | a.merge!(b) 14 | a.assert == [1,2,3,4,5] 15 | 16 | -------------------------------------------------------------------------------- /demo/core/array/missing.md: -------------------------------------------------------------------------------- 1 | ## Array#missing 2 | 3 | require 'facets/array/missing' 4 | 5 | Determine the 'holes' in the values of an array. Returns the missing elements 6 | in an array set. 7 | 8 | [1,3..3].missing.assert == [2] 9 | [1..5,10..12].missing.assert == [6..9] 10 | [100, 9..11, 14, 1..5, 16, 10..12, 17..17].missing.assert == [6..8, 13, 15, 18..99] 11 | -------------------------------------------------------------------------------- /demo/core/array/mode.md: -------------------------------------------------------------------------------- 1 | ## Array#mode 2 | 3 | require 'facets/array/mode' 4 | 5 | In Statistics, mode is the value that occurs most frequently in a given set of 6 | data. This method returns an array in case there is a tie. 7 | 8 | [1, 1, 2, 3].mode.assert == [1] 9 | [1, 1, 2, 2, 3].mode.assert == [1,2] 10 | -------------------------------------------------------------------------------- /demo/core/array/nonuniq.md: -------------------------------------------------------------------------------- 1 | ## Array#nonuniq 2 | 3 | require 'facets/array/nonuniq' 4 | 5 | Returns a list of non uniq elements. 6 | 7 | a = [1, 1, 2, 2, 3, 4, 5] 8 | a.nonuniq.sort.assert == [1, 2] 9 | 10 | ## Array#nonuniq! 11 | 12 | Same as #nonuniq but acts in place. 13 | 14 | a = [1, 1, 2, 2, 3, 4, 5] 15 | a.nonuniq! 16 | a.sort.assert == [1,2] 17 | -------------------------------------------------------------------------------- /demo/core/array/not_empty.md: -------------------------------------------------------------------------------- 1 | ## Array#not_empty? 2 | 3 | require 'facets/array/not_empty' 4 | 5 | Array is not empty? 6 | 7 | [1,2].assert.not_empty? 8 | [].refute.not_empty? 9 | -------------------------------------------------------------------------------- /demo/core/array/occurrence.md: -------------------------------------------------------------------------------- 1 | ## Array#occurrence 2 | 3 | require 'facets/array/occurrence' 4 | 5 | Create a hash of each uniq element of the array 6 | and how many time each appears. 7 | 8 | r = [:a,:a,:b,:c,:c,:c].occurrence 9 | r.assert == { :a => 2, :b => 1, :c => 3 } 10 | 11 | r = [2,2,3,4,4,4].occurrence{|i| i % 2} 12 | r.assert == { 0 => 5, 1 => 1 } 13 | 14 | -------------------------------------------------------------------------------- /demo/core/array/only.md: -------------------------------------------------------------------------------- 1 | ## Array#only 2 | 3 | require 'facets/array/only' 4 | 5 | [5].only.assert == 5 6 | [nil].only.assert == nil 7 | expect(IndexError){ [].only } 8 | expect(IndexError){ [1,2,3].only } 9 | 10 | -------------------------------------------------------------------------------- /demo/core/array/op_pow.md: -------------------------------------------------------------------------------- 1 | ## Array#** 2 | 3 | require 'facets/array/op_pow' 4 | 5 | Alias for Array#product 6 | 7 | NOTE: This method is not a common core extension and is not loaded automatically 8 | when using ```require 'facets'``` 9 | 10 | ([1,2] ** [3,4]).assert == [[1, 3], [1, 4], [2, 3], [2, 4]] 11 | -------------------------------------------------------------------------------- /demo/core/array/peek.md: -------------------------------------------------------------------------------- 1 | ## Array#peek 2 | 3 | require 'facets/array/peek' 4 | 5 | Provide an index to inspect the array from back to front. 6 | 7 | [1,2,3].peek .assert == 3 8 | [1,2,3].peek(1) .assert == 2 9 | [1,2,3].peek(-1).assert == 1 10 | 11 | -------------------------------------------------------------------------------- /demo/core/array/poke.md: -------------------------------------------------------------------------------- 1 | ## Array#poke 2 | 3 | require 'facets/array/poke' 4 | 5 | Put an object on the bottom of the stack (front of the array). 6 | 7 | a = [2,3] 8 | a.poke(1) 9 | a.assert == [1,2,3] 10 | 11 | Or supply an index and #poke works like insert. 12 | 13 | a = [1,3] 14 | a.poke(2,1) 15 | a.assert == [1,2,3] 16 | -------------------------------------------------------------------------------- /demo/core/array/probability: -------------------------------------------------------------------------------- 1 | ## Array#probability 2 | 3 | require 'facets/array/probability' 4 | 5 | Generates a hash mapping each unique element in the array to the relative 6 | frequency, i.e. the probability, of it's appearance. 7 | 8 | [:a, :b, :c, :c].probability.assert == {a: 0.25, b: 0.25, c: 0.50} 9 | -------------------------------------------------------------------------------- /demo/core/array/pull.md: -------------------------------------------------------------------------------- 1 | ## Array#pull 2 | 3 | require 'facets/array/pull' 4 | 5 | Alias for Array#shift which removes an object off the first slot of an array. 6 | This is the opposite of pop. 7 | 8 | a = [1,2,3] 9 | a.pull.assert == 1 10 | a.assert == [2,3] 11 | -------------------------------------------------------------------------------- /demo/core/array/recurse.md: -------------------------------------------------------------------------------- 1 | ## Array#recurse 2 | 3 | require 'facets/array/recurse' 4 | 5 | Apply a block to array, and recursively apply that block to each sub-array 6 | or +type+. 7 | 8 | a = ["a", ["b", "c", nil], nil] 9 | r = a.recurse{|a| a.compact!} 10 | r.assert == ["a", ["b", "c"]] 11 | -------------------------------------------------------------------------------- /demo/core/array/reject_values.md: -------------------------------------------------------------------------------- 1 | ## Array#reject_values 2 | 3 | require 'facets/array/reject_values' 4 | 5 | Non-destructive form of Array#delete_values. Unlike delete_values this method 6 | returns a new array. 7 | 8 | a = [1,2,3,4,5] 9 | a.reject_values(2,4).assert == [1,3,5] 10 | a.assert [1,2,3,4,5] 11 | -------------------------------------------------------------------------------- /demo/core/array/splice.md: -------------------------------------------------------------------------------- 1 | ## Array#splice 2 | 3 | require 'facets/array/splice' 4 | 5 | Splice acts as a combination of #slice! and #store. If one argument is given it 6 | calls #slice!, if two are given it calls #store. 7 | 8 | a = [1,2,3] 9 | a.splice(1).assert == 2 10 | a.assert == [1,3] 11 | 12 | b = [1,2,3] 13 | b.splice(1,4).assert == 4 14 | b.assert == [1,4,3] 15 | -------------------------------------------------------------------------------- /demo/core/array/split.md: -------------------------------------------------------------------------------- 1 | ## Array#split 2 | 3 | require 'facets/array/split' 4 | 5 | Split on matching pattern. Unlike #divide, this does not include matching 6 | elements. 7 | 8 | ['a','b','c'].split('b').assert == [['a'],['c']] 9 | 10 | a = ['a1','a2','b1','a3','b2','a4'] 11 | a.split(/^b/).assert == [['a1','a2'],['a3'],['a4']] 12 | 13 | 14 | -------------------------------------------------------------------------------- /demo/core/array/split_at.md: -------------------------------------------------------------------------------- 1 | ## Array#split_at 2 | 3 | require 'facets/array/split_at' 4 | 5 | Split on the first element that matches using Array#index. 6 | 7 | ['a','b','c'].split_at('b').assert == [['a'],'b',['c']] 8 | 9 | a = ['a1','a2','b12','a3','b2','a4'] 10 | a.split_at{|e| e.size == 3}.assert == [['a1','a2'],'b12',['a3','b2','a4']] 11 | 12 | 13 | -------------------------------------------------------------------------------- /demo/core/array/squeeze.md: -------------------------------------------------------------------------------- 1 | ## Array#squeeze! 2 | 3 | require 'facets/array/squeeze' 4 | 5 | Destructive version of Enumerable#squeeze. 6 | 7 | a = [1,2,2,3,3,2,1] 8 | a.squeeze! 9 | a.assert == [1,2,3,2,1] 10 | 11 | a = [1,2,2,3,3,2,1] 12 | a.squeeze!(3) 13 | a.assert == [1,2,2,3,2,1] 14 | 15 | -------------------------------------------------------------------------------- /demo/core/array/store.md: -------------------------------------------------------------------------------- 1 | ## Array#store 2 | 3 | require 'facets/array/store' 4 | 5 | Store a value at a given index. Store is an alias for #[]= 6 | 7 | a = [] 8 | a.store(1,"A") 9 | a[1].assert == "A" 10 | -------------------------------------------------------------------------------- /demo/core/array/thru.md: -------------------------------------------------------------------------------- 1 | ## Array#thru 2 | 3 | require 'facets/array/thru' 4 | 5 | Fetch Values from a start index thru an end index. 6 | 7 | [1,2,3,4,5].thru(0,2) #=> [1,2,3] 8 | [1,2,3,4,5].thru(2,4) #=> [3,4,5] 9 | 10 | [1,2,3,4,5].thru(2) #=> [1,2,3] 11 | [1,2,3,4,5].thru(4) #=> [1,2,3,4,5] 12 | 13 | -------------------------------------------------------------------------------- /demo/core/array/to_h.md: -------------------------------------------------------------------------------- 1 | ## Array#to_h 2 | 3 | require 'facets/array/to_h' 4 | 5 | Convert an associative array to a Hash. Each element of the associative array 6 | should be a 1 or 2 element array 7 | 8 | Note this is built into ruby as of 2.1.0 9 | 10 | arr = [[:a, 1], [:b, 2]] 11 | arr.to_h.assert == {:a => 1, :b => 2} 12 | -------------------------------------------------------------------------------- /demo/core/array/zip.md: -------------------------------------------------------------------------------- 1 | ## Array::zip 2 | 3 | require 'facets/array/zip' 4 | 5 | Class level rendition of Array#zip 6 | 7 | Array.zip([1,2], [3,4]).assert == [[1,3],[2,4]] 8 | 9 | -------------------------------------------------------------------------------- /demo/core/binding/defined.md: -------------------------------------------------------------------------------- 1 | ## Binding#defined? 2 | 3 | require 'facets/binding/defined' 4 | 5 | a = 1 6 | b = 2 7 | x = "hello" 8 | 9 | binding.assert.defined?("x") 10 | 11 | -------------------------------------------------------------------------------- /demo/core/binding/opvars.md: -------------------------------------------------------------------------------- 1 | ## Binding#[] 2 | 3 | require 'facets/binding/op' 4 | 5 | a = 1 6 | b = 2 7 | x = "hello" 8 | 9 | binding["x"].assert == "hello" 10 | 11 | ## Binding#[]= 12 | 13 | binding["x"] = "goodbye" 14 | 15 | binding["x"].assert == "goodbye" 16 | 17 | -------------------------------------------------------------------------------- /demo/core/binding/self.md: -------------------------------------------------------------------------------- 1 | ## Binding#self 2 | 3 | require 'facets/binding/self' 4 | 5 | binding.self == self 6 | 7 | -------------------------------------------------------------------------------- /demo/core/class/descendants.md: -------------------------------------------------------------------------------- 1 | ## Class#descendants 2 | 3 | require 'facets/class/descendants' 4 | 5 | The `Class#descendants` method returns a list of classes that are subclasses 6 | of a class. 7 | 8 | a = Class.new 9 | b = Class.new(a) 10 | c = Class.new(b) 11 | 12 | a.descendants.assert == [b,c] 13 | 14 | -------------------------------------------------------------------------------- /demo/core/class/to_proc.md: -------------------------------------------------------------------------------- 1 | ## Class#to_proc 2 | 3 | require 'facets/class/to_proc' 4 | 5 | The `Class#to_proc` method provides a convenient way to create new 6 | instances from a set of initialization data. 7 | 8 | person = Struct.new(:name) 9 | people = ["joe"].map(&person) 10 | people[0].name.assert == "joe" 11 | 12 | -------------------------------------------------------------------------------- /demo/core/comparable/at_least.md: -------------------------------------------------------------------------------- 1 | ## Comparable#at_least 2 | 3 | require 'facets/comparable/at_least' 4 | 5 | Limits a number to at least a given amount. 6 | 7 | 3.at_least(4).assert == 4 8 | 4.at_least(4).assert == 4 9 | 5.at_least(4).assert == 5 10 | 11 | This is similar to `#clip`. 12 | -------------------------------------------------------------------------------- /demo/core/comparable/at_most.md: -------------------------------------------------------------------------------- 1 | ## Comparable#at_most 2 | 3 | require 'facets/comparable/at_most' 4 | 5 | Limits a number to at most a given amount. 6 | 7 | 3.at_most(4).assert == 3 8 | 4.at_most(4).assert == 4 9 | 5.at_most(4).assert == 4 10 | 11 | This is similar to `#cap`. 12 | -------------------------------------------------------------------------------- /demo/core/comparable/bound.md: -------------------------------------------------------------------------------- 1 | ## Comparable#bound 2 | 3 | require 'facets/comparable/bound' 4 | 5 | The `#bound` method is an alias for `#clip`. It is the original name 6 | of the method before the `clip`/`cap` duo was decided upon. 7 | 8 | 3.bound(4).assert == 4 9 | 10 | 4.bound(3,5).assert == 4 11 | 12 | 'd'.bound('c','e').assert == 'd' 13 | 14 | -------------------------------------------------------------------------------- /demo/core/comparable/cap.md: -------------------------------------------------------------------------------- 1 | ## Comparable#cap 2 | 3 | require 'facets/comparable/cap' 4 | 5 | Put a cap on what a number can be. 6 | 7 | 3.cap(4).assert == 3 8 | 4.cap(4).assert == 4 9 | 5.cap(4).assert == 4 10 | 11 | This is very similar to `#at_most`. 12 | -------------------------------------------------------------------------------- /demo/core/dir/ascend.md: -------------------------------------------------------------------------------- 1 | ## Dir#ascend 2 | 3 | require 'facets/dir/ascend' 4 | 5 | path = 'A/B/C' 6 | 7 | tmp = [] 8 | 9 | Dir.ascend(path) do |d| 10 | tmp << d 11 | end 12 | 13 | tmp.assert == %w{A/B/C A/B A} 14 | 15 | Exclude current path. 16 | 17 | tmp = [] 18 | 19 | Dir.ascend(path, false) do |d| 20 | tmp << d 21 | end 22 | 23 | tmp.assert == %w{A/B A} 24 | 25 | -------------------------------------------------------------------------------- /demo/core/dir/descend.md: -------------------------------------------------------------------------------- 1 | ## Dir#descend 2 | 3 | require 'facets/dir/descend' 4 | 5 | Descend thru a file path. 6 | 7 | path = 'A/B/C' 8 | 9 | tmp = [] 10 | 11 | Dir.descend(path) do |d| 12 | tmp << d 13 | end 14 | 15 | tmp.assert == %w{A A/B A/B/C} 16 | 17 | -------------------------------------------------------------------------------- /demo/core/dir/parent.md: -------------------------------------------------------------------------------- 1 | ## Dir#parent 2 | 3 | require 'facets/dir/parent' 4 | 5 | Dir.assert.parent?("a/b/c", "a/b/c/d") 6 | 7 | -------------------------------------------------------------------------------- /demo/core/facets.md: -------------------------------------------------------------------------------- 1 | # Requiring Facets 2 | 3 | We should be able to require all the core libraries by simply calling, 4 | 5 | require 'facets' 6 | 7 | -------------------------------------------------------------------------------- /demo/core/filetest/root.md: -------------------------------------------------------------------------------- 1 | ## FileTest#root? 2 | 3 | require 'facets/filetest/root' 4 | 5 | Returns true if the given directory is the file system root. 6 | Obviously on a Linux system them means `/`. 7 | 8 | FileTest.assert.root?('/') 9 | 10 | Anything else will return false. 11 | 12 | FileTest.refute.root?('/home') 13 | 14 | -------------------------------------------------------------------------------- /demo/core/integer/factorial.md: -------------------------------------------------------------------------------- 1 | ## Integer#factorial 2 | 3 | require 'facets/integer/factorial' 4 | 5 | 0.factorial.assert == 1 6 | 1.factorial.assert == 1 7 | 2.factorial.assert == 2 8 | 3.factorial.assert == 6 9 | 4.factorial.assert == 24 10 | 11 | -------------------------------------------------------------------------------- /demo/core/integer/length.md: -------------------------------------------------------------------------------- 1 | ## Numeric#length 2 | 3 | require 'facets/numeric/length' 4 | 5 | 10.length.assert == 10 6 | 10.0.length.assert == 10 7 | 8 | -------------------------------------------------------------------------------- /demo/core/integer/multiple.md: -------------------------------------------------------------------------------- 1 | ## Integer#multiple? 2 | 3 | require 'facets/integer/multiple' 4 | 5 | Is a number an even multiple of another? 6 | 7 | 1.multiple?(2) #=> false 8 | 5.multiple?(3) #=> false 9 | 10 | 2.multiple?(2) #=> true 11 | 6.multiple?(3) #=> true 12 | 13 | -------------------------------------------------------------------------------- /demo/core/integer/of.md: -------------------------------------------------------------------------------- 1 | ## Integer#of 2 | 3 | require 'facets/integer/of' 4 | 5 | Similar to `Enumerable#map` and `Enumerable#collect` but for a number 6 | of times. 7 | 8 | a = 4 9 | b = a.of{ |i| i*2 } 10 | b.assert == [0,2,4,6] 11 | 12 | -------------------------------------------------------------------------------- /demo/core/integer/ordinal.md: -------------------------------------------------------------------------------- 1 | ## Integer#ordinal 2 | 3 | require 'facets/integer/ordinal' 4 | 5 | Produce the ordinal name of a number. 6 | 7 | 1.ordinal.assert == '1st' 8 | 2.ordinal.assert == '2nd' 9 | 3.ordinal.assert == '3rd' 10 | 4.ordinal.assert == '4th' 11 | 12 | -------------------------------------------------------------------------------- /demo/core/integer/times_collect.md: -------------------------------------------------------------------------------- 1 | ## Integer#times_collect 2 | 3 | require 'facets/integer/of' 4 | 5 | a = 4 6 | b = a.times_collect{ |i| i*2 } 7 | b.assert == [0,2,4,6] 8 | 9 | See `Integer#of` which is an alias. 10 | -------------------------------------------------------------------------------- /demo/core/matchdata/match.md: -------------------------------------------------------------------------------- 1 | ## MatchData#match 2 | 3 | require 'facets/matchdata/match' 4 | 5 | md = /X(a)(b)(c)X/.match("YXabcXY") 6 | md.match.assert == "XabcX" 7 | 8 | -------------------------------------------------------------------------------- /demo/core/matchdata/matchset.md: -------------------------------------------------------------------------------- 1 | ## MatchData#matchset 2 | 3 | require 'facets/matchdata/matchset' 4 | 5 | md = /(bb)(cc(dd))(ee)/.match "XXaabbccddeeffXX" 6 | md.matchset.assert == ["XXaa", [["bb"], ["cc", ["dd"]], ["ee"]], "ffXX"] 7 | 8 | -------------------------------------------------------------------------------- /demo/core/matchdata/matchtree.md: -------------------------------------------------------------------------------- 1 | ## MatchData#matchtree 2 | 3 | require 'facets/matchdata/matchtree' 4 | 5 | md = /(bb)(cc(dd))(ee)/.match "XXaabbccddeeffXX" 6 | md.matchtree.assert == [["bb"], ["cc", ["dd"]], ["ee"]] 7 | 8 | md = /(bb)c(c(dd))(ee)/.match "XXaabbccddeeffXX" 9 | md.matchtree.assert == [["bb"], "c", ["c", ["dd"]], ["ee"]] 10 | 11 | -------------------------------------------------------------------------------- /demo/core/string/acronym.md: -------------------------------------------------------------------------------- 1 | ## String#acronym 2 | 3 | require 'facets/string/acronym' 4 | 5 | Transform a string into an acronym. 6 | 7 | 'abc'.acronym.assert == 'a' 8 | 'abc def'.acronym.assert == 'ad' 9 | 'abc def ghi'.acronym.assert == 'adg' 10 | -------------------------------------------------------------------------------- /demo/core/string/cleanlines.md: -------------------------------------------------------------------------------- 1 | ## String#cleanlines 2 | 3 | Thre String#cleanlines method works essentially the same as String#lines, 4 | returning an Array of line strings, but it also removes trailing whitespace 5 | from each line. 6 | 7 | require 'facets/string/cleanlines' 8 | 9 | "a \n b \nc".cleanlines.to_a.assert == ["a","b","c"] 10 | 11 | -------------------------------------------------------------------------------- /demo/core/string/divide.md: -------------------------------------------------------------------------------- 1 | ## String#divide 2 | 3 | require 'facets/string/divide' 4 | 5 | s = "
Thisisa test.
" 6 | d = s.divide(/<.*?>/) 7 | e = ["This", "is", "a test.", "
"] 8 | d.assert == e 9 | 10 | -------------------------------------------------------------------------------- /demo/core/string/each_word.md: -------------------------------------------------------------------------------- 1 | ## String#each_word 2 | 3 | require 'facets/string/each_word' 4 | 5 | a = [] 6 | i = "this is a test" 7 | 8 | i.each_word{ |w| a << w } 9 | 10 | a.assert == ['this', 'is', 'a', 'test'] 11 | 12 | -------------------------------------------------------------------------------- /demo/core/string/exclude.md: -------------------------------------------------------------------------------- 1 | ## String#exclude? 2 | 3 | require 'facets/string/exclude' 4 | 5 | The inverse of include?. 6 | 7 | "aaaa".assert.exclude?('bb') 8 | "aaab".assert.exclude?('bb') 9 | "aaba".assert.exclude?('bb') 10 | "baaa".assert.exclude?('bb') 11 | 12 | "abba".refute.exclude?('bb') 13 | "aabb".refute.exclude?('bb') 14 | "bbaa".refute.exclude?('bb') 15 | 16 | -------------------------------------------------------------------------------- /demo/core/string/interpolate.md: -------------------------------------------------------------------------------- 1 | ## String#interpolate 2 | 3 | require 'facets/string/interpolate' 4 | 5 | a = 1 6 | 7 | String.interpolate{ 'this is #{a}' }.assert == 'this is 1' 8 | 9 | -------------------------------------------------------------------------------- /demo/core/string/lchomp.md: -------------------------------------------------------------------------------- 1 | ## String#lchomp 2 | 3 | require 'facets/string/lchomp' 4 | 5 | s = "xxboo" 6 | r = s.lchomp("xx") 7 | r.assert == "boo" 8 | 9 | ## String#lchomp! 10 | 11 | s = "xxboo" 12 | s.lchomp!("xx") 13 | s.assert == "boo" 14 | 15 | -------------------------------------------------------------------------------- /demo/core/string/line_wrap.md: -------------------------------------------------------------------------------- 1 | ## String#line_wrap 2 | 3 | require 'facets/string/line_wrap' 4 | 5 | "abc123".line_wrap(3).assert == "abc\n123\n" 6 | "abcd123".line_wrap(4).assert == "abcd\n123\n" 7 | 8 | -------------------------------------------------------------------------------- /demo/core/string/lowercase.md: -------------------------------------------------------------------------------- 1 | ## String#lowercase 2 | 3 | require 'facets/string/lowercase' 4 | 5 | Downcase the first letter. 6 | 7 | s = 'Abc' 8 | s.lowercase.assert == 'abc' 9 | 10 | s = 'ABC' 11 | s.lowercase.assert == 'aBC' 12 | 13 | -------------------------------------------------------------------------------- /demo/core/string/methodize.md: -------------------------------------------------------------------------------- 1 | ## String#methodize 2 | 3 | require 'facets/string/methodize' 4 | 5 | module name 6 | 7 | a = "FooBase" 8 | r = "foo_base" 9 | a.methodize.assert == r 10 | 11 | path name 12 | 13 | a = "foo/base" 14 | r = "foo__base" 15 | a.methodize.assert == r 16 | 17 | name space 18 | 19 | a = "Foo::Base" 20 | r = "foo__base" 21 | a.methodize.assert == r 22 | 23 | -------------------------------------------------------------------------------- /demo/core/string/modulize.md: -------------------------------------------------------------------------------- 1 | ## String#modulize 2 | 3 | require 'facets/string/modulize' 4 | 5 | snakecase 6 | 7 | a = "foo_bar" 8 | r = "FooBar" 9 | a.modulize.assert == r 10 | 11 | path name 12 | 13 | a = "foo/bar" 14 | r = "Foo::Bar" 15 | a.modulize.assert == r 16 | 17 | on methodized string 18 | 19 | a = "foo__bar" 20 | r = "Foo::Bar" 21 | a.modulize.assert == r 22 | 23 | -------------------------------------------------------------------------------- /demo/core/string/mscan.md: -------------------------------------------------------------------------------- 1 | ## String#mscan 2 | 3 | require 'facets/string/mscan' 4 | 5 | r = 'abc,def,gh'.mscan(/[,]/) 6 | assert( r.all?{ |md| MatchData === md } ) 7 | r.to_a.length.assert == 2 8 | r[0][0].assert == ',' 9 | r[1][0].assert == ',' 10 | 11 | -------------------------------------------------------------------------------- /demo/core/string/natcmp.md: -------------------------------------------------------------------------------- 1 | ## String#natcmp 2 | 3 | require 'facets/string/natcmp' 4 | 5 | "my_prog_v1.1.0".natcmp( "my_prog_v1.2.0").assert == -1 6 | "my_prog_v1.2.0".natcmp("my_prog_v1.10.0").assert == -1 7 | "my_prog_v1.2.0".natcmp( "my_prog_v1.1.0").assert == 1 8 | "my_prog_v1.10.0".natcmp("my_prog_v1.2.0").assert == 1 9 | "my_prog_v1.0.0".natcmp( "my_prog_v1.0.0").assert == 0 10 | 11 | -------------------------------------------------------------------------------- /demo/core/string/nchar.md: -------------------------------------------------------------------------------- 1 | ## String#nchar 2 | 3 | require 'facets/string/nchar' 4 | 5 | "abcxyz".nchar(3).assert == "abc" 6 | "abcxyz".nchar(-3).assert == "xyz" 7 | "abcxyz".nchar(3, 'HI').assert == "HIxyz" 8 | "abcxyz".nchar(-3, 'HI').assert == "abcHI" 9 | 10 | -------------------------------------------------------------------------------- /demo/core/string/newlines.md: -------------------------------------------------------------------------------- 1 | ## String#newlines 2 | 3 | Since Ruby 1.9 defined #lines to keep the newline character, 4 | we have defined #newlines to leave them out. 5 | 6 | require 'facets/string/newlines' 7 | 8 | "a\nb\nc".newlines.to_a.assert == ["a","b","c"] 9 | 10 | -------------------------------------------------------------------------------- /demo/core/string/op_div.md: -------------------------------------------------------------------------------- 1 | ## String#op_div 2 | 3 | require 'facets/string/op_div' 4 | 5 | Treats +self+ and +path+ as representations of pathnames, joining thme together 6 | as a single path. 7 | 8 | ('merb' / 'string').assert == "merb/string" 9 | ('merb' / :symbol).assert == "merb/symbol" 10 | 11 | -------------------------------------------------------------------------------- /demo/core/string/op_sub.md: -------------------------------------------------------------------------------- 1 | ## String#- 2 | 3 | require 'facets/string/op_sub' 4 | 5 | s = "xxbooxxfoo" 6 | (s - "xx").assert == "boofoo" 7 | 8 | -------------------------------------------------------------------------------- /demo/core/string/pathize.md: -------------------------------------------------------------------------------- 1 | ## String#pathize 2 | 3 | require 'facets/string/pathize' 4 | 5 | module name 6 | 7 | a = "Foo::Base" 8 | x = "foo/base" 9 | a.pathize.assert == x 10 | 11 | path name 12 | 13 | a = "foo/base" 14 | x = "foo/base" 15 | a.pathize.assert == x 16 | 17 | name space 18 | 19 | a = "foo__base" 20 | x = "foo/base" 21 | a.pathize.assert == x 22 | 23 | -------------------------------------------------------------------------------- /demo/core/string/rewrite.md: -------------------------------------------------------------------------------- 1 | ## String#rewrite 2 | 3 | require 'facets/string/rewrite' 4 | 5 | s = "HELLO TOMMY!" 6 | rules = [[ /TOMMY/, 'MAN' ]] 7 | r = s.rewrite(rules) 8 | r.assert == "HELLO MAN!" 9 | 10 | -------------------------------------------------------------------------------- /demo/core/string/shatter.md: -------------------------------------------------------------------------------- 1 | ## String#shatter 2 | 3 | require 'facets/string/shatter' 4 | 5 | s = "Thisisa test.
" 6 | r = s.shatter( /<.*?>/ ) 7 | x = ["", "This", "", "is", "", "a test.", "
"] 8 | r.assert == x 9 | 10 | -------------------------------------------------------------------------------- /demo/core/string/snakecase.md: -------------------------------------------------------------------------------- 1 | ## String#snakecase 2 | 3 | require 'facets/string/snakecase' 4 | 5 | Underscore a string such that camelcase, dashes and spaces are 6 | replaced by underscores. This is the reverse of {#camelcase}, 7 | albeit not an exact inverse. 8 | 9 | 'my_name'.snakecase.assert == 'my_name' 10 | 11 | 'MyName'.snakecase.assert == 'my_name' 12 | 13 | 'URI'.snakecase.assert == 'uri' 14 | 15 | -------------------------------------------------------------------------------- /demo/core/string/store.md: -------------------------------------------------------------------------------- 1 | ## String#store 2 | 3 | require 'facets/string/store' 4 | 5 | Alias for []= 6 | 7 | a = "HELLO" 8 | a.store(1, "X") 9 | a.assert == "HXLLO" 10 | 11 | -------------------------------------------------------------------------------- /demo/core/string/subtract.md: -------------------------------------------------------------------------------- 1 | ## String#- 2 | 3 | require 'facets/string/subtract' 4 | 5 | ("foobar" - "oo").assert == "fbar" 6 | ("pizza pizza!" - "zz").assert == "pia pia!" 7 | ("letters" - /[a-z]+/).assert == "" 8 | 9 | -------------------------------------------------------------------------------- /demo/core/string/titlecase.md: -------------------------------------------------------------------------------- 1 | ## String#titlecase 2 | 3 | require 'facets/string/titlecase' 4 | 5 | r = "try this out".titlecase 6 | x = "Try This Out" 7 | r.assert == x 8 | 9 | -------------------------------------------------------------------------------- /demo/core/string/unfold.md: -------------------------------------------------------------------------------- 1 | ## String#unfold 2 | 3 | require 'facets/string/unfold' 4 | 5 | str = "This is a test of\nparagraph folding." 6 | res = str.unfold 7 | exp = "This is a test of paragraph folding." 8 | res.assert == exp 9 | 10 | -------------------------------------------------------------------------------- /demo/core/string/unquote.md: -------------------------------------------------------------------------------- 1 | ## String#unquote 2 | 3 | require 'facets/string/unquote' 4 | 5 | "'this'".unquote.assert == "this" 6 | 7 | -------------------------------------------------------------------------------- /demo/core/string/uppercase.md: -------------------------------------------------------------------------------- 1 | ## String#uppercase 2 | 3 | require 'facets/string/uppercase' 4 | 5 | Upcase the first letter. 6 | 7 | s = 'bob' 8 | s.uppercase.assert == 'Bob' 9 | 10 | s = 'boB' 11 | s.uppercase.assert == 'BoB' 12 | 13 | s = 'BoB' 14 | s.uppercase.assert == 'BoB' 15 | 16 | -------------------------------------------------------------------------------- /demo/core/string/variablize.md: -------------------------------------------------------------------------------- 1 | ## String#variablize 2 | 3 | require 'facets/string/variablize' 4 | 5 | s = "a" 6 | s.variablize.assert == "@a" 7 | 8 | -------------------------------------------------------------------------------- /demo/core/string/words.md: -------------------------------------------------------------------------------- 1 | ## String#words 2 | 3 | require 'facets/string/words' 4 | 5 | x = "a b c\nd e" 6 | x.words.assert == ['a','b','c','d','e'] 7 | 8 | x = "ab cd\nef" 9 | x.words.assert == ['ab','cd','ef'] 10 | 11 | x = "ab cd \n ef-gh" 12 | x.words.assert == ['ab','cd','ef-gh'] 13 | 14 | -------------------------------------------------------------------------------- /demo/core/string/xor.md: -------------------------------------------------------------------------------- 1 | ## String#^ 2 | 3 | require 'facets/string/xor' 4 | 5 | r = "try this out" ^ "puddingsnacks" 6 | x = "\004\a\035D\035\006\016\000N\016\026\037" 7 | r.assert == x 8 | 9 | -------------------------------------------------------------------------------- /lib/core/facets/array/after.rb: -------------------------------------------------------------------------------- 1 | require 'facets/array/before' 2 | -------------------------------------------------------------------------------- /lib/core/facets/array/average.rb: -------------------------------------------------------------------------------- 1 | class Array 2 | 3 | # Calculate the average of an array of numbers 4 | # 5 | # Examples 6 | # 7 | # [].average #=> nil 8 | # [1, 2, 3].average #=> 2 9 | # [3, 12, 57, 85, 15, 89, 33, 7, 22, 54].average #=> 37.7 10 | # 11 | def average 12 | return nil if empty? 13 | self.reduce(:+)/length.to_f 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /lib/core/facets/array/collapse.rb: -------------------------------------------------------------------------------- 1 | class Array 2 | 3 | # Simplify an array by flattening it then compacting it. 4 | # 5 | # Examples 6 | # 7 | # [1,[2,nil,[3]],nil,4].collapse #=> [1,2,3,4] 8 | # 9 | def collapse 10 | flatten.compact 11 | end 12 | 13 | def collapse! 14 | flatten!.compact! 15 | end 16 | 17 | end 18 | 19 | -------------------------------------------------------------------------------- /lib/core/facets/array/collisions.rb: -------------------------------------------------------------------------------- 1 | require 'facets/array/commonality' 2 | -------------------------------------------------------------------------------- /lib/core/facets/array/contains.rb: -------------------------------------------------------------------------------- 1 | class Array 2 | 3 | # Alias for #include?. 4 | alias_method :contains?, :include? 5 | 6 | end 7 | 8 | -------------------------------------------------------------------------------- /lib/core/facets/array/delete.rb: -------------------------------------------------------------------------------- 1 | # Here for backward compatability. To be deprecated. 2 | require 'facets/array/delete_unless' 3 | require 'facets/array/delete_values' 4 | 5 | -------------------------------------------------------------------------------- /lib/core/facets/array/delete_unless.rb: -------------------------------------------------------------------------------- 1 | class Array 2 | 3 | # Inverse of #delete_if. 4 | # 5 | # [1,2,3].delete_unless{ |x| x < 2 } 6 | # #=> [1] 7 | # 8 | # CREDIT: Daniel Schierbeck 9 | 10 | def delete_unless(&block) 11 | delete_if { |element| not block.call(element) } 12 | end 13 | 14 | end 15 | 16 | -------------------------------------------------------------------------------- /lib/core/facets/array/delete_values_at.rb: -------------------------------------------------------------------------------- 1 | require 'facets/array/delete_values' 2 | -------------------------------------------------------------------------------- /lib/core/facets/array/each_pair.rb: -------------------------------------------------------------------------------- 1 | class Array 2 | 3 | # Iterate over index and value. The intention of this 4 | # method is to provide polymorphism with Hash. 5 | # 6 | def each_pair #:yield: 7 | each_with_index {|e, i| yield(i,e) } 8 | end 9 | 10 | end 11 | 12 | -------------------------------------------------------------------------------- /lib/core/facets/array/each_value.rb: -------------------------------------------------------------------------------- 1 | class Array 2 | # Alias for #each. The intention of this method 3 | # is to provide polymorphism with Hash. 4 | alias :each_value :each 5 | end 6 | 7 | -------------------------------------------------------------------------------- /lib/core/facets/array/first.rb: -------------------------------------------------------------------------------- 1 | require 'facets/array/indexable' 2 | -------------------------------------------------------------------------------- /lib/core/facets/array/last.rb: -------------------------------------------------------------------------------- 1 | require 'facets/array/indexable' 2 | -------------------------------------------------------------------------------- /lib/core/facets/array/merge.rb: -------------------------------------------------------------------------------- 1 | class Array 2 | 3 | # In place #merge. 4 | # 5 | # a = [1,2] 6 | # a.merge! [2,3] 7 | # a #=> [1,2,3] 8 | # 9 | # CREDIT: Trans 10 | 11 | def merge!( other ) 12 | self.replace(self.merge(other)) 13 | end 14 | 15 | # Alias for |. 16 | # 17 | # [1,2].merge([2,3]) #=> [1,2,3] 18 | # 19 | alias_method :merge, :| 20 | 21 | end 22 | 23 | -------------------------------------------------------------------------------- /lib/core/facets/array/not_empty.rb: -------------------------------------------------------------------------------- 1 | class Array 2 | 3 | # Not empty? 4 | # 5 | # [].not_empty? #=> false 6 | # [1,2].not_empty? #=> true 7 | 8 | def not_empty? 9 | !empty? 10 | end 11 | 12 | end 13 | 14 | -------------------------------------------------------------------------------- /lib/core/facets/array/op_pow.rb: -------------------------------------------------------------------------------- 1 | class Array 2 | # Array#** is an alias for Array#product. 3 | # 4 | # NOTE: This method is not a common core extension and is not 5 | # loaded automatically when usingrequire 'facets'
.
6 | #
7 | # @uncommon
8 | # require 'facets/array/op_pow'
9 | #
10 | alias_method :**, :product
11 | end
12 |
13 |
--------------------------------------------------------------------------------
/lib/core/facets/array/peek.rb:
--------------------------------------------------------------------------------
1 | require 'facets/array/pull'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/array/poke.rb:
--------------------------------------------------------------------------------
1 | require 'facets/array/pull'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/array/store.rb:
--------------------------------------------------------------------------------
1 | class Array
2 |
3 | # Store a value at a given index. Store is an alias for #[]=.
4 | #
5 | # Example:
6 | #
7 | # a = []
8 | # a.store(1, "A")
9 | # a[1] #=> "A"
10 | #
11 | # Returns the stored object.
12 |
13 | alias_method :store, :[]=
14 |
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/lib/core/facets/array/thru.rb:
--------------------------------------------------------------------------------
1 | require 'facets/array/from'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/array/to_h.rb:
--------------------------------------------------------------------------------
1 | class Array
2 |
3 | # Convert an associative array to a Hash.
4 | #
5 | # Examples
6 | #
7 | # [[:a, 1], [:b, 2]].to_h
8 | # #=> {:a=>1, :b=>2}
9 | #
10 | # Returns [Hash].
11 | #
12 | def to_h
13 | h = {}
14 | each{ |(k,v)| h[k] = v }
15 | h
16 | end unless method_defined?(:to_h)
17 |
18 | end
19 |
20 |
--------------------------------------------------------------------------------
/lib/core/facets/binding/__callee__.rb:
--------------------------------------------------------------------------------
1 | require 'facets/binding/caller'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/binding/__method__.rb:
--------------------------------------------------------------------------------
1 | require 'facets/binding/caller'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/binding/call_stack.rb:
--------------------------------------------------------------------------------
1 | require 'facets/kernel/callstack'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/binding/callstack.rb:
--------------------------------------------------------------------------------
1 | require 'facets/kernel/callstack'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/binding/defined.rb:
--------------------------------------------------------------------------------
1 | class Binding
2 |
3 | # Returns the nature of something within the context of the binding.
4 | # Returns nil if that thing is not defined.
5 | def defined?(x)
6 | eval("defined? #{x}")
7 | end
8 |
9 | end
10 |
11 |
--------------------------------------------------------------------------------
/lib/core/facets/binding/op.rb:
--------------------------------------------------------------------------------
1 | # This file is here for backward compatibility only.
2 | # It can be deprecated eventually.
3 |
4 | require 'facets/binding/op_get'
5 |
--------------------------------------------------------------------------------
/lib/core/facets/binding/op_set.rb:
--------------------------------------------------------------------------------
1 | require 'facets/binding/op_get'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/binding/self.rb:
--------------------------------------------------------------------------------
1 | class Binding
2 |
3 | # This is already defined by Rubinius:
4 | # Kernel.eval('Rubinius::VariableScope.current.self', self)
5 | unless method_defined?(:self)
6 |
7 | # Returns self of the binding's context.
8 | def self
9 | eval('self')
10 | end
11 |
12 | end
13 |
14 | end
15 |
16 |
--------------------------------------------------------------------------------
/lib/core/facets/binding/with.rb:
--------------------------------------------------------------------------------
1 | class Binding
2 |
3 | # Returns a new binding with local varaibles set.
4 | #
5 | # CREDIT: Trans
6 |
7 | def with(_local_variables, &_yields)
8 | eval("lambda{ |#{_local_variables.keys.join(',')},&yields| binding }").call(*_local_variables.values, &_yields)
9 | end
10 |
11 | end
12 |
13 |
--------------------------------------------------------------------------------
/lib/core/facets/cattr.rb:
--------------------------------------------------------------------------------
1 | require 'facets/class/cattr'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/class.rb:
--------------------------------------------------------------------------------
1 | require_relative 'class/descendants.rb'
2 | #require_relative 'class/hierarchically' # uncommon
3 | require_relative 'class/methodize.rb'
4 | require_relative 'class/pathize.rb'
5 | #require_relative 'class/preallocate.rb' # uncommon
6 | #require_relative 'class/singleton.rb' # uncommon
7 | require_relative 'class/subclasses.rb'
8 | require_relative 'class/to_proc.rb'
9 |
10 |
--------------------------------------------------------------------------------
/lib/core/facets/class/cattr.rb:
--------------------------------------------------------------------------------
1 | require 'facets/module/cattr'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/class/hierarchically.rb:
--------------------------------------------------------------------------------
1 | module Kernel
2 |
3 | # Hierarchically apply a block, passing each ancestor to the block
4 | # starting at the root ancestor and working toward the current object.
5 | #
6 | def hierarchically(&block)
7 | ancestors.reverse_each do |m|
8 | block.call(m)
9 | end
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/lib/core/facets/class/methodize.rb:
--------------------------------------------------------------------------------
1 | require 'facets/string/methodize'
2 |
3 | class Class
4 |
5 | # Translate a class name to a suitable method name.
6 | #
7 | # module ::Example
8 | # class MethodizeExample
9 | # end
10 | # end
11 | #
12 | # Example::MethodizeExample.methodize #=> "example__methodize_example"
13 | #
14 | def methodize
15 | name.methodize
16 | end
17 |
18 | end
19 |
20 |
--------------------------------------------------------------------------------
/lib/core/facets/class/pathize.rb:
--------------------------------------------------------------------------------
1 | require 'facets/string/pathize'
2 |
3 | class Class
4 |
5 | # Converts a class name to a unix path.
6 | #
7 | # module ::Example
8 | # class PathizeExample
9 | # end
10 | # end
11 | #
12 | # Example::PathizeExample.pathize #=> "example/pathize_example"
13 | #
14 | def pathize
15 | name.pathize
16 | end
17 |
18 | end
19 |
20 |
--------------------------------------------------------------------------------
/lib/core/facets/class/singleton.rb:
--------------------------------------------------------------------------------
1 | require 'facets/class/singleton_class'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/class/singleton_class.rb:
--------------------------------------------------------------------------------
1 | class Class
2 |
3 | # Return true if a class is the singleton class of
4 | # an object.
5 | #
6 | # @uncommon
7 | # require 'facets/class/singleton_class'
8 | #
9 | def singleton_class?
10 | ! ancestors.include?( self ) rescue false
11 | end
12 |
13 | # @deprecated
14 | alias :singleton? :singleton_class?
15 |
16 | end
17 |
--------------------------------------------------------------------------------
/lib/core/facets/comparable.rb:
--------------------------------------------------------------------------------
1 | require_relative 'comparable/at_least.rb'
2 | require_relative 'comparable/at_most.rb'
3 | require_relative 'comparable/bound.rb'
4 | require_relative 'comparable/cap.rb'
5 | require_relative 'comparable/clip.rb'
6 | require_relative 'comparable/cmp.rb'
7 | require_relative 'comparable/op_get.rb'
8 |
9 |
--------------------------------------------------------------------------------
/lib/core/facets/comparable/at_least.rb:
--------------------------------------------------------------------------------
1 | require 'facets/comparable/cap'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/comparable/at_most.rb:
--------------------------------------------------------------------------------
1 | require 'facets/comparable/cap'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/comparable/bound.rb:
--------------------------------------------------------------------------------
1 | require 'facets/comparable/clip'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/dir.rb:
--------------------------------------------------------------------------------
1 | require_relative 'dir/ascend.rb'
2 | require_relative 'dir/descend.rb'
3 | require_relative 'dir/each_child.rb'
4 | require_relative 'dir/multiglob.rb'
5 | require_relative 'dir/parent.rb'
6 | require_relative 'dir/recurse.rb'
7 |
8 |
--------------------------------------------------------------------------------
/lib/core/facets/dir/descend.rb:
--------------------------------------------------------------------------------
1 | require 'facets/dir/ascend'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/dir/parent.rb:
--------------------------------------------------------------------------------
1 | class Dir
2 |
3 | # Is a path parental to another?
4 | #
5 | # Dir.parent?('parent', 'parent/child') #=> true
6 | #
7 | # TODO: Needs improvement.
8 | #
9 | # TODO: Instance version?
10 |
11 | def self.parent?(parent_path, child_path)
12 | %r|^#{Regexp.escape(parent_path)}| =~ child_path ? true : false
13 | end
14 |
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/lib/core/facets/enumerable/associate.rb:
--------------------------------------------------------------------------------
1 | require 'facets/enumerable/pair'
2 |
3 | module Enumerable
4 | # Alias for #pair.
5 | alias :associate :pair
6 | end
7 |
--------------------------------------------------------------------------------
/lib/core/facets/enumerable/collect_with_index.rb:
--------------------------------------------------------------------------------
1 | require 'facets/enumerable/map_with_index'
2 |
3 |
--------------------------------------------------------------------------------
/lib/core/facets/enumerable/exclude.rb:
--------------------------------------------------------------------------------
1 | module Enumerable
2 |
3 | unless method_defined?(:exclude?) # 1.9
4 |
5 | # The inverse of #include?.
6 | #
7 | # [:a, :b].exclude?(:c) #=> true
8 | # [:a, :b].exclude?(:a) #=> false
9 | #
10 | def exclude?(object)
11 | !include?(object)
12 | end
13 |
14 | end
15 |
16 | end
17 |
--------------------------------------------------------------------------------
/lib/core/facets/enumerable/expand.rb:
--------------------------------------------------------------------------------
1 | module Enumerable
2 |
3 | # Expand all elements of an Enumerable object.
4 | #
5 | # [0, 2..3, 5..7].expand #=> [0,[2, 3],[5,6,7]]
6 | #
7 | # CREDIT: Trans
8 | def expand
9 | map do |x|
10 | (Enumerable === x ? x.expand : x)
11 | end
12 | end
13 |
14 | end
15 |
16 |
--------------------------------------------------------------------------------
/lib/core/facets/enumerable/map_detect.rb:
--------------------------------------------------------------------------------
1 | require 'facets/enumerable/find_yield'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/enumerable/map_to.rb:
--------------------------------------------------------------------------------
1 | module Enumerable
2 |
3 | # Map each element into another class via class constructor.
4 | #
5 | # @param [#new] to_class
6 | # Generally a class, but any object that repsonds to #new.
7 | #
8 | def map_to(to_class)
9 | map{ |e| to_class.new(e) }
10 | end
11 |
12 | end
13 |
14 |
--------------------------------------------------------------------------------
/lib/core/facets/enumerable/uniq_by.rb:
--------------------------------------------------------------------------------
1 | module Enumerable
2 |
3 | # Like #uniq, but determines uniqueness based on a given block.
4 | #
5 | # (-5..5).to_a.uniq_by {|i| i*i }
6 | # #=> [-5, -4, -3, -2, -1, 0]
7 | #
8 | def uniq_by #:yield:
9 | h = {}; inject([]) {|a,x| h[yield(x)] ||= a << x}
10 | end
11 |
12 | end
13 |
14 |
--------------------------------------------------------------------------------
/lib/core/facets/enumerable/zip_map.rb:
--------------------------------------------------------------------------------
1 | require 'facets/enumerable/map_with'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/exception.rb:
--------------------------------------------------------------------------------
1 | require_relative 'exception/detail.rb'
2 | require_relative 'exception/raised.rb'
3 | require_relative 'exception/suppress.rb'
4 |
5 |
--------------------------------------------------------------------------------
/lib/core/facets/exception/raised.rb:
--------------------------------------------------------------------------------
1 | class Exception
2 |
3 | # Does a block raise an a given +exception+.
4 | #
5 | def self.raised? #:yeild:
6 | begin
7 | yield
8 | false
9 | rescue self
10 | true
11 | end
12 | end
13 |
14 | end
15 |
--------------------------------------------------------------------------------
/lib/core/facets/exception/set_message.rb:
--------------------------------------------------------------------------------
1 | class Exception
2 |
3 | # See exception message.
4 | #
5 | def set_message(string)
6 | @mesg = string.to_s
7 | end
8 |
9 | end
10 |
11 |
--------------------------------------------------------------------------------
/lib/core/facets/file/append.rb:
--------------------------------------------------------------------------------
1 | class File
2 |
3 | # Append to a file.
4 | #
5 | # CREDIT: George Moschovitis
6 |
7 | def self.append(file, str)
8 | File.open(file, 'ab') { |f|
9 | f << str
10 | }
11 | end
12 |
13 | end
14 |
15 |
--------------------------------------------------------------------------------
/lib/core/facets/file/atomic_id.rb:
--------------------------------------------------------------------------------
1 | class File
2 |
3 | #
4 | def self.atomic_id
5 | @atomic_id ||= 0
6 | @atomic_id += 1
7 | end
8 |
9 | end
10 |
--------------------------------------------------------------------------------
/lib/core/facets/file/null.rb:
--------------------------------------------------------------------------------
1 | class File
2 |
3 | # Platform dependent null device.
4 | #
5 | # CREDIT: Daniel Burger
6 |
7 | def self.null
8 | case RUBY_PLATFORM
9 | when /mswin/i
10 | 'NUL'
11 | when /amiga/i
12 | 'NIL:'
13 | when /openvms/i
14 | 'NL:'
15 | else
16 | '/dev/null'
17 | end
18 | end
19 |
20 | end
21 |
22 |
--------------------------------------------------------------------------------
/lib/core/facets/file/read_binary.rb:
--------------------------------------------------------------------------------
1 | class File
2 |
3 | # Read in a file as binary data.
4 | #
5 | # Assuming we had a binary file 'binary.dat'.
6 | #
7 | # File.read_binary('binary.dat')
8 | #
9 | # CREDIT: George Moschovitis
10 |
11 | def self.read_binary(fname)
12 | open(fname, 'rb') do |f|
13 | return f.read
14 | end
15 | end
16 |
17 | end
18 |
19 |
--------------------------------------------------------------------------------
/lib/core/facets/file/split_root.rb:
--------------------------------------------------------------------------------
1 | class File
2 |
3 | # Return the head of path from the rest of the path.
4 | #
5 | # File.split_root('etc/xdg/gtk') #=> ['etc', 'xdg/gtk']
6 | #
7 | def self.split_root(path)
8 | path_re = Regexp.new('[' + Regexp.escape(File::Separator + %q{\/}) + ']')
9 | path.split(path_re, 2)
10 | end
11 |
12 | end
13 |
14 |
--------------------------------------------------------------------------------
/lib/core/facets/filetest.rb:
--------------------------------------------------------------------------------
1 | require_relative 'filetest/absolute.rb'
2 | require_relative 'filetest/contains.rb'
3 | require_relative 'filetest/relative.rb'
4 | require_relative 'filetest/root.rb'
5 | require_relative 'filetest/safe.rb'
6 | require_relative 'filetest/separator_pattern.rb'
7 |
8 |
--------------------------------------------------------------------------------
/lib/core/facets/filetest/absolute.rb:
--------------------------------------------------------------------------------
1 | require 'facets/filetest/relative'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/filetest/contains.rb:
--------------------------------------------------------------------------------
1 | module FileTest
2 |
3 | module_function
4 |
5 | # Does the +parent+ contain the +child+?
6 | def contains?(child, parent=Dir.pwd)
7 | parent = File.expand_path(parent)
8 | child = File.expand_path(child)
9 | child.sub(parent,'') != child
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/lib/core/facets/filetest/root.rb:
--------------------------------------------------------------------------------
1 | module FileTest
2 |
3 | module_function
4 |
5 | # Is the specified directory the root directory?
6 | #
7 | # CREDIT: Jeffrey Schwab
8 |
9 | def root?(dir=nil)
10 | pth = File.expand_path(dir||Dir.pwd)
11 | return true if pth == '/'
12 | return true if pth =~ /^(\w:)?\/$/
13 | false
14 | end
15 |
16 | end
17 |
18 |
--------------------------------------------------------------------------------
/lib/core/facets/float.rb:
--------------------------------------------------------------------------------
1 | require_relative 'float/round_to.rb'
2 |
3 |
--------------------------------------------------------------------------------
/lib/core/facets/float/round_to.rb:
--------------------------------------------------------------------------------
1 | require 'facets/numeric/round_to'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/hash/at.rb:
--------------------------------------------------------------------------------
1 | class Hash
2 |
3 | # Alias for fetch for greater polymorphism with Array.
4 | #
5 | alias_method :at, :[]
6 |
7 | end
8 |
9 |
--------------------------------------------------------------------------------
/lib/core/facets/hash/count.rb:
--------------------------------------------------------------------------------
1 | class Hash
2 |
3 | # Like Enumerable#count, but can count hash values.
4 | #
5 | # {:A=>1, :B=>1}.count(1) #=> 2
6 | #
7 | def count(*value)
8 | if value.empty?
9 | super()
10 | else
11 | values.count(*value)
12 | end
13 | end
14 |
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/lib/core/facets/hash/delete.rb:
--------------------------------------------------------------------------------
1 | # TODO: should we deprecate hash/delete?
2 | require 'facets/hash/delete_at'
3 | require 'facets/hash/delete_values'
4 | require 'facets/hash/delete_unless'
5 |
--------------------------------------------------------------------------------
/lib/core/facets/hash/delete_at.rb:
--------------------------------------------------------------------------------
1 | class Hash
2 |
3 | # Polymorphic with Array#delete_at.
4 | alias_method :delete_at, :delete
5 |
6 | end
7 |
8 |
--------------------------------------------------------------------------------
/lib/core/facets/hash/delete_unless.rb:
--------------------------------------------------------------------------------
1 | class Hash
2 |
3 | # Inverse of #delete_if.
4 | #
5 | # h = { :a => 1, :b => 2, :c => 3 }
6 | # r = h.delete_unless{|k,v| v == 1}
7 | # r #=> { :a => 1 }
8 | # h #=> { :a => 1 }
9 | #
10 | # CREDIT: Daniel Schierbeck
11 |
12 | def delete_unless #:yield:
13 | delete_if{ |key, value| ! yield(key, value) }
14 | end
15 |
16 | end
17 |
18 |
--------------------------------------------------------------------------------
/lib/core/facets/hash/diff.rb:
--------------------------------------------------------------------------------
1 | class Hash
2 |
3 | # Difference comparison of two hashes.
4 | #
5 | # h1 = {:a=>1,:b=>2}
6 | # h2 = {:a=>1,:b=>3}
7 | #
8 | # h1.diff(h2) #=> {:b=>2}
9 | # h2.diff(h1) #=> {:b=>3}
10 | #
11 | def diff(hash)
12 | h1 = self.dup.delete_if{ |k,v| hash[k] == v }
13 | h2 = hash.dup.delete_if{ |k,v| has_key?(k) }
14 | h1.merge(h2)
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/lib/core/facets/hash/each_with_key.rb:
--------------------------------------------------------------------------------
1 | class Hash
2 |
3 | # Each with key is like each_pair but reverses the order
4 | # the parameters to [value,key] instead of [key,value].
5 | #
6 | # CREDIT: Trans
7 |
8 | def each_with_key( &yld )
9 | each_pair{ |k,v| yld.call(v,k) }
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/lib/core/facets/hash/insert.rb:
--------------------------------------------------------------------------------
1 | class Hash
2 |
3 | # As with #store but only if the key isn't
4 | # already in the hash.
5 | #
6 | # TODO: Would #store? be a better name?
7 | #
8 | # CREDIT: Trans
9 |
10 | def insert(name, value)
11 | if key?(name)
12 | false
13 | else
14 | store(name,value)
15 | true
16 | end
17 | end
18 |
19 | end
20 |
--------------------------------------------------------------------------------
/lib/core/facets/hash/mash.rb:
--------------------------------------------------------------------------------
1 | require 'facets/hash/graph'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/hash/new_with.rb:
--------------------------------------------------------------------------------
1 | class Hash
2 |
3 | # Instantiate a new hash with a default
4 | # value determined by the block.
5 | #
6 | # Hash.new_with{ [] }
7 | #
8 | # CREDIT: Pit Capitan
9 |
10 | def self.new_with #:yield:
11 | new { |h, k| h[k] = yield }
12 | end
13 |
14 | end
15 |
16 |
--------------------------------------------------------------------------------
/lib/core/facets/hash/only_keys.rb:
--------------------------------------------------------------------------------
1 | require 'facets/hash/keys'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/hash/op.rb:
--------------------------------------------------------------------------------
1 | require 'facets/hash/op_and'
2 | require 'facets/hash/op_or'
3 | require 'facets/hash/op_add'
4 | require 'facets/hash/op_sub'
5 | require 'facets/hash/op_mul'
6 | require 'facets/hash/op_push'
7 |
8 |
--------------------------------------------------------------------------------
/lib/core/facets/hash/op_add.rb:
--------------------------------------------------------------------------------
1 | class Hash
2 |
3 | # Operator for #merge.
4 | #
5 | # CREDIT: Trans
6 |
7 | def +(other)
8 | merge(other)
9 | end
10 |
11 | end
12 |
13 |
--------------------------------------------------------------------------------
/lib/core/facets/hash/op_mul.rb:
--------------------------------------------------------------------------------
1 | class Hash
2 |
3 | # Like merge operator '+' but merges in reverse order.
4 | #
5 | # h1 = {:a=>1}
6 | # h2 = {:a=>2, :b=>3}
7 | #
8 | # (h1 + h2) #=> { :a=>2, :b=>3 }
9 | # (h1 * h2) #=> { :a=>1, :b=>3 }
10 | #
11 | # CREDIT: Trans
12 |
13 | def *(other)
14 | other.merge(self)
15 | end
16 |
17 | end
18 |
19 |
--------------------------------------------------------------------------------
/lib/core/facets/hash/op_or.rb:
--------------------------------------------------------------------------------
1 | class Hash
2 |
3 | # Operator for #reverse_merge.
4 | #
5 | # CREDIT: Trans
6 |
7 | def |(other)
8 | other.merge(self)
9 | end
10 |
11 | end
12 |
13 |
--------------------------------------------------------------------------------
/lib/core/facets/hash/replace_each.rb:
--------------------------------------------------------------------------------
1 | class Hash
2 |
3 | # Same as #update_each, but deletes the key element first.
4 | #
5 | # CREDIT: Trans
6 |
7 | def replace_each # :yield:
8 | dup.each do |k,v|
9 | delete(k)
10 | update(yield(k,v))
11 | end
12 | self
13 | end
14 |
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/lib/core/facets/hash/stringify_keys.rb:
--------------------------------------------------------------------------------
1 | require 'facets/hash/symbolize_keys'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/hash/swap.rb:
--------------------------------------------------------------------------------
1 | class Hash
2 |
3 | # Swap the values of a pair of keys in place.
4 | #
5 | # {:a=>1,:b=>2}.swap!(:a,:b) #=> {:a=>2,:b=>1}
6 | #
7 | # CREDIT: Gavin Sinclair
8 |
9 | def swap!(key1, key2)
10 | tmp = self[key1]
11 | self[key1] = self[key2]
12 | self[key2] = tmp
13 | self
14 | end
15 |
16 | end
17 |
18 |
--------------------------------------------------------------------------------
/lib/core/facets/hash/to_options.rb:
--------------------------------------------------------------------------------
1 | require 'facets/hash/symbolize_keys'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/hash/update.rb:
--------------------------------------------------------------------------------
1 | # -- for backward compatibility. To be deprecated.
2 | require 'facets/hash/op_push'
3 | require 'facets/hash/update_each'
4 | require 'facets/hash/update_keys'
5 | require 'facets/hash/update_values'
6 |
7 |
--------------------------------------------------------------------------------
/lib/core/facets/integer.rb:
--------------------------------------------------------------------------------
1 | require_relative 'integer/bit.rb'
2 | require_relative 'integer/bitmask.rb'
3 | require_relative 'integer/factorial.rb'
4 | require_relative 'integer/multiple.rb'
5 | require_relative 'integer/of.rb'
6 | require_relative 'integer/ordinal.rb'
7 | #require_relative 'integer/roman.rb' # uncommon
8 |
9 |
--------------------------------------------------------------------------------
/lib/core/facets/integer/bit.rb:
--------------------------------------------------------------------------------
1 | require 'facets/integer/bitmask'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/integer/multiple.rb:
--------------------------------------------------------------------------------
1 | class Integer
2 |
3 | # Is +self+ a multiple of a given number?
4 | #
5 | # 7.multiple?(2) #=> false
6 | # 8.multiple?(2) #=> true
7 | #
8 | # CREDIT: Trans
9 |
10 | def multiple?(number)
11 | if number.zero?
12 | zero? ? true : false
13 | else
14 | self % number == 0
15 | end
16 | end
17 |
18 | end
19 |
20 |
--------------------------------------------------------------------------------
/lib/core/facets/integer/of.rb:
--------------------------------------------------------------------------------
1 | class Integer
2 |
3 | # Like #times but returns a collection of the yield results.
4 | #
5 | # a = 3.of { |i| "#{i+1}" }
6 | # a #=> [ "1", "2", "3" ]
7 | #
8 |
9 | def of(&block)
10 | Array.new(self, &block)
11 | end
12 |
13 | # Time warn aliases for #of.
14 | alias_method :times_collect, :of
15 | alias_method :times_map, :of
16 |
17 | end
18 |
19 |
--------------------------------------------------------------------------------
/lib/core/facets/integer/roman.rb:
--------------------------------------------------------------------------------
1 | require 'facets/roman'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/__class__.rb:
--------------------------------------------------------------------------------
1 | module Kernel
2 |
3 | # Defines core method __class__ as an alias of class.
4 | # This allows you to use #class as your own method, without
5 | # loosing the ability to determine the object's class.
6 |
7 | alias_method :__class__, :class
8 |
9 | end
10 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/__set__.rb:
--------------------------------------------------------------------------------
1 | require 'facets/kernel/__get__'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/assign_from.rb:
--------------------------------------------------------------------------------
1 | require 'facets/kernel/assign'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/call_stack.rb:
--------------------------------------------------------------------------------
1 | require 'facets/kernel/callstack'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/case.rb:
--------------------------------------------------------------------------------
1 | module Kernel
2 |
3 | def case?(*matchers)
4 | matchers.all?{ |m| m === self }
5 | end unless method_defined?(:case?)
6 |
7 | end
8 |
9 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/deep_copy.rb:
--------------------------------------------------------------------------------
1 | module Kernel
2 |
3 | # Anything that can be marshaled can be copied in totality.
4 | #
5 | # "ABC".deep_copy #=> "ABC"
6 | #
7 | # NOTE: Not sure why we wouldn't just call this #copy, but
8 | # the term +deep_copy+ seems to be the common practive.
9 | def deep_copy
10 | Marshal::load(Marshal::dump(self))
11 | end
12 |
13 | end
14 |
15 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/eigen.rb:
--------------------------------------------------------------------------------
1 | # Deprecated!
2 | require 'facets/kernel/meta'
3 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/enable_warnings.rb:
--------------------------------------------------------------------------------
1 | require 'facets/kernel/disable_warnings'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/extension.rb:
--------------------------------------------------------------------------------
1 | module Kernel
2 |
3 | # TODO: Must reduce the number of singleton method methods.
4 |
5 | # Don't say it!
6 | #
7 | def extension
8 | class << self; self; end
9 | end
10 |
11 | end
12 |
13 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/false.rb:
--------------------------------------------------------------------------------
1 | require 'facets/kernel/true'
2 |
3 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/here.rb:
--------------------------------------------------------------------------------
1 | module Kernel
2 |
3 | # A shorthand pronoun for binding().
4 | #
5 | # a = 3
6 | # eval("a", here) #=> 3
7 | #
8 | alias_method :here, :binding
9 |
10 | end
11 |
12 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/identical.rb:
--------------------------------------------------------------------------------
1 | module Kernel
2 | alias_method :identical?, :equal?
3 | end
4 |
5 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/in.rb:
--------------------------------------------------------------------------------
1 | module Kernel
2 |
3 | # Is self included in other?
4 | #
5 | # 5.in?(0..10) #=> true
6 | # 5.in?([0,1,2,3]) #=> false
7 | #
8 | def in?(other)
9 | other.include?(self)
10 | end
11 |
12 | end
13 |
14 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/instance_send.rb:
--------------------------------------------------------------------------------
1 | module Kernel
2 |
3 | # Private send.
4 | alias_method :instance_send, :__send__
5 |
6 | end
7 |
8 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/load_all.rb:
--------------------------------------------------------------------------------
1 | require 'facets/kernel/require_all'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/no.rb:
--------------------------------------------------------------------------------
1 | require 'facets/kernel/yes'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/not_nil.rb:
--------------------------------------------------------------------------------
1 | module Kernel
2 |
3 | # The opposite of #nil?.
4 | #
5 | # "hello".not_nil? # -> true
6 | # nil.not_nil? # -> false
7 | #
8 | # CREDIT: Gavin Sinclair
9 |
10 | def not_nil?
11 | ! nil?
12 | end
13 |
14 | # DEPRECATED: #not_nil? it enough.
15 | #alias_method :non_nil?, :not_nil?
16 |
17 | end
18 |
19 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/object_class.rb:
--------------------------------------------------------------------------------
1 | module Kernel
2 |
3 | # Defines object_classas an alias of class.
4 | # This is an alternative to __class__, akin to
5 | # #object_id.
6 |
7 | alias_method :object_class, :class
8 |
9 | end
10 |
11 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/presence.rb:
--------------------------------------------------------------------------------
1 | require 'facets/kernel/blank'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/present.rb:
--------------------------------------------------------------------------------
1 | require 'facets/kernel/blank'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/silence_warnings.rb:
--------------------------------------------------------------------------------
1 | require 'facets/kernel/disable_warnings'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/singleton_class.rb:
--------------------------------------------------------------------------------
1 | module Kernel
2 |
3 | # Easy access to an object's "special" class.
4 | #
5 | # NOTE: This is already defined in Ruby 1.9+.
6 | def singleton_class
7 | (class << self; self; end)
8 | end unless method_defined?(:singleton_class)
9 |
10 | end
11 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/super_method.rb:
--------------------------------------------------------------------------------
1 | module Kernel
2 |
3 | # Returns method of a parent class bound to self.
4 | def super_method(klass, meth)
5 | unless self.class.ancestors.include?(klass)
6 | raise ArgumentError, "Not an ancestor for super_method-- #{klass}"
7 | end
8 | klass.instance_method(meth).bind(self)
9 | end
10 |
11 | end
12 |
--------------------------------------------------------------------------------
/lib/core/facets/kernel/with.rb:
--------------------------------------------------------------------------------
1 | module Kernel
2 |
3 | # Like returning but exectues the block
4 | # via instance_eval.
5 | #
6 | # def foo
7 | # with values = [] do
8 | # self << 'bar'
9 | # self << 'baz'
10 | # end
11 | # end
12 | #
13 | # foo # => ['bar', 'baz']
14 | #
15 | def with(obj=self, &block)
16 | obj.instance_eval(&block)
17 | end
18 |
19 | end
20 |
21 |
--------------------------------------------------------------------------------
/lib/core/facets/load_path.rb:
--------------------------------------------------------------------------------
1 | require_relative 'load_path/search'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/load_path/search.rb:
--------------------------------------------------------------------------------
1 | class << $LOAD_PATH
2 |
3 | # Search load path for matching patterns.
4 | #
5 | def search(match)
6 | found = []
7 | uniq.map do |path|
8 | list = Dir.glob(File.join(File.expand_path(path), match))
9 | list = list.map{ |d| d.chomp('/') }
10 | found.concat(list)
11 | end
12 | found
13 | end
14 |
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/lib/core/facets/matchdata.rb:
--------------------------------------------------------------------------------
1 | require_relative 'matchdata/match.rb'
2 | require_relative 'matchdata/matchset.rb'
3 |
4 |
--------------------------------------------------------------------------------
/lib/core/facets/matchdata/match.rb:
--------------------------------------------------------------------------------
1 | class MatchData
2 |
3 | # Return the primary match string. This is equivalent to +md[0]+.
4 | #
5 | # md = /123/.match "123456"
6 | # md.match #=> "123"
7 | #
8 | # CREDIT: Martin DeMello
9 |
10 | def match(index=0)
11 | self[index]
12 | end
13 |
14 | end
15 |
16 |
--------------------------------------------------------------------------------
/lib/core/facets/matchdata/matchtree.rb:
--------------------------------------------------------------------------------
1 | # Matchdata#matchtree is defined in
2 | require 'facets/matchdata/matchset'
3 |
--------------------------------------------------------------------------------
/lib/core/facets/metaid.rb:
--------------------------------------------------------------------------------
1 | require 'facets/kernel/meta_alias'
2 | require 'facets/kernel/meta_class'
3 | require 'facets/kernel/meta_def'
4 | require 'facets/kernel/meta_eval'
5 |
6 | # in remberence of _why
7 | require 'facets/kernel/eigenclass'
8 |
--------------------------------------------------------------------------------
/lib/core/facets/method.rb:
--------------------------------------------------------------------------------
1 | require_relative 'method/composition.rb'
2 | #require_relative 'method/memoize' # uncommon
3 | require_relative 'method/op_mul.rb'
4 | require_relative 'method/op_pow.rb'
5 |
6 |
--------------------------------------------------------------------------------
/lib/core/facets/method/curry.rb:
--------------------------------------------------------------------------------
1 | require 'facets/proc'
2 |
3 | class Method
4 | # Curry a Method into a new Proc.
5 |
6 | def curry(*args)
7 | to_proc.curry(*args)
8 | end
9 | end
10 |
11 |
12 | # TODO: The question is as to whether to integrate this into Method::Composition,
13 | # or if Composition should be scuttled for just converting to Proc.
14 |
--------------------------------------------------------------------------------
/lib/core/facets/method/op_mul.rb:
--------------------------------------------------------------------------------
1 | require 'facets/method/composition'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/method/op_pow.rb:
--------------------------------------------------------------------------------
1 | require 'facets/method/composition'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/method/partial.rb:
--------------------------------------------------------------------------------
1 | require 'facets/proc/partial'
2 |
3 | class Method
4 | # Convert a method into a new partial Proc.
5 |
6 | def partial(*args)
7 | to_proc.partial(*args)
8 | end
9 | end
10 |
11 |
--------------------------------------------------------------------------------
/lib/core/facets/module/alias_class_method.rb:
--------------------------------------------------------------------------------
1 | class Module
2 |
3 | # Alias a class method.
4 | #
5 | def alias_class_method(name, target)
6 | class << self
7 | alias_method(name, target)
8 | end
9 | end
10 |
11 | end
12 |
--------------------------------------------------------------------------------
/lib/core/facets/module/ancestor.rb:
--------------------------------------------------------------------------------
1 | class Module
2 |
3 | # Is a given class or module an ancestor of
4 | # this class or module?
5 | #
6 | # class X ; end
7 | # class Y < X ; end
8 | #
9 | # X.ancestor?(Y)
10 | #
11 | def ancestor?( mod )
12 | ancestors.include?(mod)
13 | end
14 |
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/lib/core/facets/module/basename.rb:
--------------------------------------------------------------------------------
1 | require 'facets/module/lastname'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/module/can.rb:
--------------------------------------------------------------------------------
1 | class Module
2 |
3 | # An alias for #extend.
4 | #
5 | # module EgCan
6 | # def foo; "foo"; end
7 | # end
8 | #
9 | # class EgCanClass
10 | # can EgCan
11 | # end
12 | #
13 | # EgCanClass.foo #=> 'foo'
14 | #
15 | # BTW, why is Forwardable an -able? It's not a mixin!
16 |
17 | alias_method :can, :extend
18 |
19 | end
20 |
21 |
--------------------------------------------------------------------------------
/lib/core/facets/module/cattr.rb:
--------------------------------------------------------------------------------
1 | require 'facets/module/mattr'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/module/class.rb:
--------------------------------------------------------------------------------
1 | class Module
2 |
3 | # Alias for #===. This provides a verbal method
4 | # for inquery.
5 | #
6 | # s = "HELLO"
7 | # String.class?(s) #=> true
8 | #
9 | alias_method :class?, :===
10 |
11 | end
12 |
13 |
--------------------------------------------------------------------------------
/lib/core/facets/module/class_def.rb:
--------------------------------------------------------------------------------
1 | require 'facets/module/module_def'
2 |
3 |
--------------------------------------------------------------------------------
/lib/core/facets/module/class_method_defined.rb:
--------------------------------------------------------------------------------
1 | require 'facets/module/instance_method_defined'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/module/enclosures.rb:
--------------------------------------------------------------------------------
1 | require 'facets/module/enclosure'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/module/extend.rb:
--------------------------------------------------------------------------------
1 | require 'facets/kernel/extend'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/module/homename.rb:
--------------------------------------------------------------------------------
1 | require 'facets/module/home'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/module/housing.rb:
--------------------------------------------------------------------------------
1 | require 'facets/module/home'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/module/include_as.rb:
--------------------------------------------------------------------------------
1 | require 'facets/module/method_space'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/module/memoize.rb:
--------------------------------------------------------------------------------
1 | require 'facets/memoizable'
2 |
3 | class Module
4 |
5 | # This is here for backward compatibility.
6 | #
7 | # @uncommon
8 | # require 'facets/module/memoize'
9 | #
10 | def memoize(*args)
11 | include Memoizable
12 | Memoizable.instance_method(:memoize).bind(self).call(*args)
13 | #super(*args) # TODO: why is super not working here?
14 | end
15 |
16 | end
17 |
--------------------------------------------------------------------------------
/lib/core/facets/module/modname.rb:
--------------------------------------------------------------------------------
1 | require 'facets/module/homename'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/module/op_add.rb:
--------------------------------------------------------------------------------
1 | require 'facets/module/op'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/module/op_mul.rb:
--------------------------------------------------------------------------------
1 | require 'facets/module/op'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/module/op_sub.rb:
--------------------------------------------------------------------------------
1 | require 'facets/module/op'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/module/remove.rb:
--------------------------------------------------------------------------------
1 | require 'facets/module/nodef'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/module/singleton_method_defined.rb:
--------------------------------------------------------------------------------
1 | require 'facets/module/instance_method_defined'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/module/to_obj.rb:
--------------------------------------------------------------------------------
1 | class Module
2 |
3 | # Create an instance of Object and extend it with +self+.
4 | #
5 | # mod = Module.new do
6 | # def foo; "foo"; end
7 | # end
8 | #
9 | # obj = mod.to_obj
10 | #
11 | # obj.foo #=> "foo"
12 | #
13 | def to_obj
14 | o = Object.new
15 | o.extend self
16 | o
17 | end
18 |
19 | end
20 |
21 |
--------------------------------------------------------------------------------
/lib/core/facets/nilclass.rb:
--------------------------------------------------------------------------------
1 | require_relative 'nilclass/ergo.rb'
2 |
3 |
--------------------------------------------------------------------------------
/lib/core/facets/nilclass/ergo.rb:
--------------------------------------------------------------------------------
1 | require 'facets/kernel/ergo'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/numeric.rb:
--------------------------------------------------------------------------------
1 | require_relative 'numeric/approx.rb'
2 | require_relative 'numeric/distance.rb'
3 | require_relative 'numeric/length.rb'
4 | require_relative 'numeric/negative.rb'
5 | require_relative 'numeric/positive.rb'
6 | require_relative 'numeric/round_to.rb'
7 | require_relative 'numeric/spacing.rb'
8 |
9 |
--------------------------------------------------------------------------------
/lib/core/facets/numeric/close.rb:
--------------------------------------------------------------------------------
1 | require 'facets/numeric/approx'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/numeric/distance.rb:
--------------------------------------------------------------------------------
1 | class Numeric
2 |
3 | # Returns the distance between self an another value.
4 | # This is the same as #- but it provides an alternative
5 | # for common naming between variant classes.
6 | #
7 | # 4.distance(3) #=> 1
8 | #
9 | def distance(other)
10 | self - other
11 | end
12 |
13 | end
14 |
15 |
--------------------------------------------------------------------------------
/lib/core/facets/numeric/length.rb:
--------------------------------------------------------------------------------
1 | class Numeric
2 |
3 | # Returns +self+, useful for polymorphic cases.
4 | #
5 | def length
6 | self
7 | end
8 |
9 | end
10 |
11 |
--------------------------------------------------------------------------------
/lib/core/facets/numeric/negative.rb:
--------------------------------------------------------------------------------
1 | require 'facets/numeric/positive'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/numeric/positive.rb:
--------------------------------------------------------------------------------
1 | class Numeric
2 |
3 | # Is a number greater than zero.
4 | #
5 | def positive?
6 | self > 0
7 | end
8 |
9 | # Is a number less than zero.
10 | #
11 | def negative?
12 | self < 0
13 | end
14 |
15 | end
16 |
--------------------------------------------------------------------------------
/lib/core/facets/numeric/range.rb:
--------------------------------------------------------------------------------
1 | class Numeric
2 |
3 | # Create a range from the number plus-or-minus a given value.
4 | #
5 | # Return [Range]
6 | def range(value)
7 | Range.new(self - value, self + value)
8 | end
9 |
10 | alias :plus_or_minus :range
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/lib/core/facets/object.rb:
--------------------------------------------------------------------------------
1 | # TODO: Is there a good reason for these to be here instead of in Kernel module?
2 | require_relative 'object/clone.rb'
3 | require_relative 'object/dup.rb'
4 | require_relative 'object/itself.rb'
5 | require_relative 'object/object_state.rb'
6 | require_relative 'object/try_dup.rb'
7 |
8 |
--------------------------------------------------------------------------------
/lib/core/facets/object/clone.rb:
--------------------------------------------------------------------------------
1 | require 'facets/object/dup'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/object/itself.rb:
--------------------------------------------------------------------------------
1 | class Object
2 |
3 | # An identity method that provides access to an object's 'self'.
4 | #
5 | # Example
6 | #
7 | # [1,2,3,4,5,1,2,2,3].group_by(&:itself)
8 | # #=> {1=>[1, 1], 2=>[2, 2, 2], 3=>[3, 3], 4=>[4], 5=>[5]}
9 | #
10 | # CREDIT: Michael Kohl
11 |
12 | def itself
13 | self
14 | end
15 |
16 | end
17 |
--------------------------------------------------------------------------------
/lib/core/facets/object/try_dup.rb:
--------------------------------------------------------------------------------
1 | require 'facets/object/dup'
2 |
--------------------------------------------------------------------------------
/lib/core/facets/objectspace.rb:
--------------------------------------------------------------------------------
1 | require_relative 'objectspace/classes.rb'
2 | require_relative 'objectspace/op_fetch.rb'
3 |
4 |
--------------------------------------------------------------------------------
/lib/core/facets/objectspace/classes.rb:
--------------------------------------------------------------------------------
1 | module ObjectSpace
2 |
3 | # @return +a+x + +b+ = +c+
or +nil+
4 | # if no or an infinite number of solutions exist. If
5 | # c
is missing it is assumed to be 0.
6 | #
7 | # @author Josef Schugt
8 | def self.linsolve(a, b, c = 0.0)
9 | a == 0 ? nil : (c - b) / a
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/lib/standard/facets/math/log2.rb:
--------------------------------------------------------------------------------
1 | module Math
2 |
3 | INVERSE_LN_2 = 1.0 / ::Math.log(2.0)
4 |
5 | unless defined?(log2)
6 |
7 | # Logarithmus dualis of +x+.
8 | def self.log2(x)
9 | Math.log(x) * INVERSE_LN_2
10 | end
11 |
12 | end
13 |
14 | end
15 |
--------------------------------------------------------------------------------
/lib/standard/facets/math/max.rb:
--------------------------------------------------------------------------------
1 | require 'facets/math/min'
2 |
--------------------------------------------------------------------------------
/lib/standard/facets/math/mean.rb:
--------------------------------------------------------------------------------
1 | require 'facets/math/sum'
2 |
3 | module Math
4 |
5 | # Mean average.
6 | def self.mean(array, &blk)
7 | s = array.size
8 | return 0.0 if s == 0
9 | sum(array, &blk) / s
10 | end
11 |
12 | class << self
13 | alias_method :mean_average, :mean
14 | end
15 |
16 | end
17 |
--------------------------------------------------------------------------------
/lib/standard/facets/math/pow.rb:
--------------------------------------------------------------------------------
1 | module Math
2 |
3 | # `x` to the power `y`.
4 | def self.pow(x, y)
5 | x ** y
6 | end
7 |
8 | # `x` to the power `y`.
9 | def self.pwr(x, y)
10 | x ** y
11 | end
12 |
13 | end
14 |
--------------------------------------------------------------------------------
/lib/standard/facets/math/pstd.rb:
--------------------------------------------------------------------------------
1 | require 'facets/math/std'
2 |
--------------------------------------------------------------------------------
/lib/standard/facets/math/pvariance.rb:
--------------------------------------------------------------------------------
1 | require 'facets/math/variance'
2 |
--------------------------------------------------------------------------------
/lib/standard/facets/math/root.rb:
--------------------------------------------------------------------------------
1 | module Math
2 |
3 | # The `y` root of `x`.
4 | def self.root(x, y)
5 | x ** (1.0 / y)
6 | end
7 |
8 | end
9 |
--------------------------------------------------------------------------------
/lib/standard/facets/math/round.rb:
--------------------------------------------------------------------------------
1 | module Math
2 |
3 | # Round number to an integer.
4 | #
5 | def self.round(x)
6 | x.round
7 | end
8 |
9 | end
10 |
--------------------------------------------------------------------------------
/lib/standard/facets/math/sec.rb:
--------------------------------------------------------------------------------
1 | module Math
2 |
3 | # Secans of +x+.
4 | def self.sec(x)
5 | 1.0 / cos(x)
6 | end
7 |
8 | end
9 |
--------------------------------------------------------------------------------
/lib/standard/facets/math/sech.rb:
--------------------------------------------------------------------------------
1 | module Math
2 |
3 | # Secans hyperbolicus of +x+
4 | def self.sech(x)
5 | 1.0 / cosh(x)
6 | end
7 |
8 | end
9 |
--------------------------------------------------------------------------------
/lib/standard/facets/math/sinc.rb:
--------------------------------------------------------------------------------
1 | module Math
2 |
3 | # Sinc function of +x+.
4 | def self.sinc(x)
5 | (x == 0.0) ? 1.0 : sin(x) / x
6 | end
7 |
8 | end
9 |
--------------------------------------------------------------------------------
/lib/standard/facets/math/sqr.rb:
--------------------------------------------------------------------------------
1 | module Math
2 |
3 | # Square of number.
4 | def self.sqr(x)
5 | x * x
6 | end
7 |
8 | end
9 |
--------------------------------------------------------------------------------
/lib/standard/facets/math/stderr.rb:
--------------------------------------------------------------------------------
1 | require 'facets/math/std'
2 |
--------------------------------------------------------------------------------
/lib/standard/facets/math/sum.rb:
--------------------------------------------------------------------------------
1 | module Math
2 |
3 | # Returns sum. When a block is given, summation is taken over the
4 | # each result of block evaluation.
5 | #
6 | def self.sum(array) #:yield:
7 | sum = 0.0
8 | if block_given?
9 | array.each{|i| sum += yield(i)}
10 | else
11 | array.each{|i| sum += i}
12 | end
13 | sum
14 | end
15 |
16 | end
17 |
--------------------------------------------------------------------------------
/lib/standard/facets/math/summed_sqdevs.rb:
--------------------------------------------------------------------------------
1 | require 'facets/math/sum'
2 | require 'facets/math/mean'
3 |
4 | module Math
5 |
6 | # The sum of the squared deviations from the mean.
7 | #
8 | def self.summed_sqdevs(array)
9 | return 0 if array.size < 2
10 | m = mean(array)
11 | sum(array.map{ |x| (x - m) ** 2 })
12 | end
13 |
14 | end
15 |
--------------------------------------------------------------------------------
/lib/standard/facets/math/tau.rb:
--------------------------------------------------------------------------------
1 | module Math
2 | # See http://tauday.com/tau-manifesto
3 | TAU = 2 * PI
4 | end
5 |
6 |
--------------------------------------------------------------------------------
/lib/standard/facets/math/tgamma.rb:
--------------------------------------------------------------------------------
1 | require 'facets/math/lgamma'
2 |
3 | module Math
4 |
5 | # Exp of LGamma.
6 | def self.tgamma(x)
7 | exp(lngamma(x)) #exp(log(gamma(x).abs)
8 | end
9 |
10 | end
11 |
--------------------------------------------------------------------------------
/lib/standard/facets/ostruct/each.rb:
--------------------------------------------------------------------------------
1 | require 'ostruct'
2 |
3 | class OpenStruct
4 |
5 | # Iterate over key-value pairs.
6 | #
7 | def each(&blk)
8 | @table.each(&blk)
9 | end
10 |
11 | end
12 |
--------------------------------------------------------------------------------
/lib/standard/facets/ostruct/op_store.rb:
--------------------------------------------------------------------------------
1 | require 'facets/ostruct/op_fetch'
2 |
--------------------------------------------------------------------------------
/lib/standard/facets/ostruct/to_h.rb:
--------------------------------------------------------------------------------
1 | require 'ostruct'
2 |
3 | class OpenStruct
4 |
5 | #
6 | def to_h
7 | @table.dup
8 | end
9 |
10 | end
11 |
--------------------------------------------------------------------------------
/lib/standard/facets/pathname/chdir.rb:
--------------------------------------------------------------------------------
1 | class Pathname
2 |
3 | # Change current working directory of the process
4 | # to the given path
5 | #
6 | # See Dir.chdir
7 | #
8 | # CREDIT: Ryan Duryea
9 |
10 | def chdir(&block)
11 | Dir.chdir(self, &block)
12 | end
13 |
14 | end
15 |
16 |
--------------------------------------------------------------------------------
/lib/standard/facets/pathname/empty.rb:
--------------------------------------------------------------------------------
1 | class Pathname
2 |
3 | # Is a directory path empty?
4 | #
5 | # Returns [Boolean]
6 | def empty?
7 | Dir.glob(::File.join(to_s, '*')).empty?
8 | end
9 |
10 | end
11 |
--------------------------------------------------------------------------------
/lib/standard/facets/pathname/exists.rb:
--------------------------------------------------------------------------------
1 | class Pathname
2 |
3 | # Pluralized alias for `#exist?` method.
4 | alias :exists? :exist?
5 |
6 | end
7 |
--------------------------------------------------------------------------------
/lib/standard/facets/pathname/home.rb:
--------------------------------------------------------------------------------
1 | class Pathname
2 |
3 | # Home constant for building paths from root directory onward.
4 | #
5 | # TODO: Pathname#home needs to be more robust.
6 | #
7 | # Returns [Pathname]
8 | def self.home
9 | Pathname.new('~')
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/lib/standard/facets/pathname/null.rb:
--------------------------------------------------------------------------------
1 | class Pathname
2 |
3 | # Platform dependent null device.
4 | #
5 | # CREDIT: Daniel Burger
6 |
7 | def self.null
8 | case RUBY_PLATFORM
9 | when /mswin/i
10 | 'NUL'
11 | when /amiga/i
12 | 'NIL:'
13 | when /openvms/i
14 | 'NL:'
15 | else
16 | '/dev/null'
17 | end
18 | end
19 |
20 | end
21 |
--------------------------------------------------------------------------------
/lib/standard/facets/pathname/op_div.rb:
--------------------------------------------------------------------------------
1 | class Pathname
2 |
3 | # Start a path. Another alias for #new.
4 | #
5 | # Pathname / 'usr'
6 | #
7 | def self./(path)
8 | new(path)
9 | end
10 |
11 | # Try to get this into standard Pathname class.
12 | alias_method :/, :+
13 |
14 | end
15 |
16 |
--------------------------------------------------------------------------------
/lib/standard/facets/pathname/op_fetch.rb:
--------------------------------------------------------------------------------
1 | class Pathname
2 |
3 | # Alternate to Pathname#new.
4 | #
5 | # Pathname['/usr/share']
6 | #
7 | # Returns [Pathname]
8 |
9 | def self.[](path)
10 | new(path)
11 | end
12 |
13 | end
14 |
--------------------------------------------------------------------------------
/lib/standard/facets/pathname/outofdate.rb:
--------------------------------------------------------------------------------
1 | require 'facets/fileutils/outofdate'
2 |
3 | class Pathname
4 |
5 | # Is a path out of date relative a set of source files.
6 | #
7 | # Returns [Boolean]
8 |
9 | def outofdate?(*sources)
10 | ::FileUtils.outofdate?(to_s, sources.flatten)
11 | end
12 |
13 | end
14 |
--------------------------------------------------------------------------------
/lib/standard/facets/pathname/readline.rb:
--------------------------------------------------------------------------------
1 | class Pathname
2 | # Reads the first line of the file
3 | #
4 | # Captures the best practice from this post at stack overflow:
5 | # https://stackoverflow.com/questions/1490138/reading-the-first-line-of-a-file-in-ruby
6 | #
7 | # Credit: Ryan Duryea
8 | def readline(*args)
9 | open { |f| f.readline(*args) }
10 | end
11 | end
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lib/standard/facets/pathname/root.rb:
--------------------------------------------------------------------------------
1 | class Pathname
2 |
3 | # Root constant for building paths from root directory onward.
4 | #
5 | # Returns [Pathname]
6 | def self.root
7 | Pathname.new('/')
8 | end
9 |
10 | end
11 |
--------------------------------------------------------------------------------
/lib/standard/facets/pathname/rootname.rb:
--------------------------------------------------------------------------------
1 | require 'facets/file/rootname'
2 |
3 | class Pathname
4 |
5 | #
6 | def rootname
7 | self.class.new(File.rootname(to_s))
8 | end
9 |
10 | end
11 |
--------------------------------------------------------------------------------
/lib/standard/facets/pathname/safe.rb:
--------------------------------------------------------------------------------
1 | require 'facets/filetest/safe'
2 |
3 | class Pathname
4 |
5 | # Is a path reasonably safe?
6 | #
7 | # Do not mistake this for a perfect solution!
8 | #
9 | # Returns [Boolean]
10 |
11 | def safe?
12 | FileTest.safe?(to_s)
13 | end
14 |
15 | end
16 |
--------------------------------------------------------------------------------
/lib/standard/facets/pathname/split_root.rb:
--------------------------------------------------------------------------------
1 | class Pathname
2 |
3 | #
4 | def split_root
5 | head, tail = *::File.split_root(to_s)
6 | [self.class.new(head), self.class.new(tail)]
7 | end
8 |
9 | end
10 |
--------------------------------------------------------------------------------
/lib/standard/facets/pathname/to_str.rb:
--------------------------------------------------------------------------------
1 | class Pathname
2 |
3 | # Alias #to_s to #to_str when #to_str is not defined.
4 | #
5 | # Returns [String]
6 | alias_method(:to_str, :to_s) unless method_defined?(:to_str)
7 |
8 | end
9 |
--------------------------------------------------------------------------------
/lib/standard/facets/pathname/uptodate.rb:
--------------------------------------------------------------------------------
1 | class Pathname
2 |
3 | # Is a path up to date relative to a set of source files?
4 | #
5 | # Returns [Boolean]
6 |
7 | def uptodate?(*sources)
8 | ::FileUtils.uptodate?(to_s, sources.flatten)
9 | end
10 |
11 | end
12 |
--------------------------------------------------------------------------------
/lib/standard/facets/pathname/work.rb:
--------------------------------------------------------------------------------
1 | class Pathname
2 |
3 | # Work constant for building paths from root directory onward.
4 | #
5 | # Returns [Pathname]
6 | def self.work
7 | Pathname.new('.')
8 | end
9 |
10 | end
11 |
--------------------------------------------------------------------------------
/lib/standard/facets/uri/cgi_parse.rb:
--------------------------------------------------------------------------------
1 | require 'facets/uri/cgi_escape'
2 |
--------------------------------------------------------------------------------
/lib/standard/facets/uri/cgi_unescape.rb:
--------------------------------------------------------------------------------
1 | require 'facets/uri/cgi_escape'
2 |
--------------------------------------------------------------------------------
/lib/standard/facets/yaml.rb:
--------------------------------------------------------------------------------
1 | require 'yaml'
2 |
3 | require 'facets/yaml/file'
4 | require 'facets/yaml/read'
5 | require 'facets/yaml/kernel'
6 |
7 |
--------------------------------------------------------------------------------
/lib/standard/facets/yaml/read.rb:
--------------------------------------------------------------------------------
1 | module YAML
2 |
3 | # Alias for `YAML.load_file` and the same as:
4 | #
5 | # YAML.load(File.new(file))
6 | #
7 | def self.read(file)
8 | load(File.new(file))
9 | end
10 |
11 | end
12 |
13 |
--------------------------------------------------------------------------------
/test/core/array/test_contains.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/array/contains'
2 |
3 | test_case Array do
4 |
5 | method :contains? do
6 |
7 | test do
8 | [1,2,3,4].assert.contains?(2)
9 | [1,2,3,4].refute.contains?(9)
10 | end
11 |
12 | end
13 |
14 | end
15 |
--------------------------------------------------------------------------------
/test/core/array/test_delete_unless.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/array/delete_unless'
2 |
3 | test_case Array do
4 |
5 | method :delete_unless do
6 |
7 | test 'with an explicit block' do
8 | [1,2,3].delete_unless{ |x| x < 2 }.assert == [1]
9 | end
10 |
11 | test 'with an implicit block' do
12 | [1,2,3].delete_unless(&:even?).assert == [2]
13 | end
14 |
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/test/core/array/test_each_pair.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/array/each_pair'
2 |
3 | test_case Array do
4 |
5 | method :each_pair do
6 |
7 | test do
8 | result = {}
9 | a = [:a,:b,:c,:d]
10 | a.each_pair{|i,e| result[e] = i + 1}
11 | result.assert == {a: 1, b: 2, c: 3, d: 4}
12 | end
13 |
14 | end
15 |
16 | end
17 |
--------------------------------------------------------------------------------
/test/core/array/test_each_value.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/array/each_value'
2 |
3 | test_case Array do
4 |
5 | method :each_value do
6 |
7 | test do
8 | a = [ "a", "b", "c" ]
9 | out = ''
10 | a.each_value {|x| out += "#{x} -- " }
11 | out.assert == 'a -- b -- c -- '
12 | end
13 |
14 | end
15 |
16 | end
17 |
--------------------------------------------------------------------------------
/test/core/array/test_entropy.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/array/entropy'
2 |
3 | test_case Array do
4 |
5 | method :entropy do
6 |
7 | test do
8 | %w{ a b }.entropy.assert == 1.0
9 | end
10 |
11 | end
12 |
13 | method :ideal_entropy do
14 |
15 | test do
16 | %w{ a b }.ideal_entropy.assert == 1.0
17 | %w{ a a b b }.ideal_entropy.assert == 2.0
18 | end
19 |
20 | end
21 |
22 | end
23 |
24 |
--------------------------------------------------------------------------------
/test/core/array/test_first.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/array/indexable'
2 |
3 | test_case Array do
4 |
5 | method :first! do
6 |
7 | test "alias of shift" do
8 | a = [1,2,3]
9 | r = a.first!
10 | r.assert == 1
11 | a.assert == [2,3]
12 | end
13 |
14 | end
15 |
16 | end
17 |
18 |
--------------------------------------------------------------------------------
/test/core/array/test_last.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/array/indexable'
2 |
3 | test_case Array do
4 |
5 | method :last! do
6 |
7 | test "alias of pop" do
8 | a = [1,2,3]
9 | r = a.last!
10 | r.assert == 3
11 | a.assert == [1,2]
12 | end
13 |
14 | end
15 |
16 | end
17 |
18 |
--------------------------------------------------------------------------------
/test/core/array/test_missing.rb:
--------------------------------------------------------------------------------
1 | require 'facets/array/missing'
2 |
3 | test_case Array do
4 |
5 | method :missing do
6 | test { [1,3..3].missing.assert == [2] }
7 | test { [1..5,10..12].missing.assert == [6..9] }
8 | test { [100, 9..11, 14, 1..5, 16, 10..12, 17..17].missing.assert == [6..8, 13, 15, 18..99] }
9 | end
10 |
11 | end
12 |
13 |
--------------------------------------------------------------------------------
/test/core/array/test_mode.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/array/mode'
2 |
3 | test_case Array do
4 |
5 | method :mode do
6 |
7 | test do
8 | [1, 1, 2, 3].mode.assert == [1]
9 | end
10 |
11 | test do
12 | [1, 1, 2, 2, 3].mode.sort.assert == [1,2]
13 | end
14 |
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/test/core/array/test_not_empty.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/array/not_empty'
2 |
3 | test_case Array do
4 |
5 | method :not_empty? do
6 |
7 | test do
8 | [].refute.not_empty?
9 | end
10 |
11 | test do
12 | [1,2].assert.not_empty?
13 | end
14 |
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/test/core/array/test_only.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/array/only.rb'
2 |
3 | test_case Array do
4 |
5 | method :only do
6 |
7 | test do
8 | [5].only.assert == 5
9 | [nil].only.assert == nil
10 | expect(IndexError){ [].only }
11 | expect(IndexError){ [1,2,3].only }
12 | end
13 |
14 | end
15 |
16 | end
17 |
18 |
--------------------------------------------------------------------------------
/test/core/array/test_op_pow.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/array/op_pow'
2 |
3 | test_case Array do
4 |
5 | method :** do
6 |
7 | test do
8 | ([1,2] ** [3,4]).assert == [[1, 3], [1, 4], [2, 3], [2, 4]]
9 | end
10 |
11 | end
12 |
13 | end
14 |
--------------------------------------------------------------------------------
/test/core/array/test_poke.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/array/pull'
2 |
3 | test_case Array do
4 |
5 | method :poke do
6 |
7 | test do
8 | a = [1,2,3]
9 | a.poke(9)
10 | a.assert == [9,1,2,3]
11 | end
12 |
13 | test do
14 | a = [2,3]
15 | a.poke(1).assert == [1,2,3]
16 | a.poke(4).assert == [4,1,2,3]
17 | end
18 |
19 | end
20 |
21 | end
22 |
--------------------------------------------------------------------------------
/test/core/array/test_probability.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/array/probability'
2 |
3 | test_case Array do
4 |
5 | method :probability do
6 |
7 | test do
8 | %w{a b}.probability.assert == {'a'=>0.5, 'b'=>0.5}
9 | end
10 |
11 | test do
12 | %w{a a a b}.probability.assert == {'a'=>0.75, 'b'=>0.25}
13 | end
14 |
15 | end
16 |
17 | end
18 |
19 |
--------------------------------------------------------------------------------
/test/core/array/test_pull.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/array/pull'
2 |
3 | test_case Array do
4 |
5 | method :pull do
6 |
7 | test do
8 | a = [1,2,3]
9 | a.pull.assert == 1
10 | a.assert == [2,3]
11 | end
12 |
13 | end
14 |
15 | end
16 |
--------------------------------------------------------------------------------
/test/core/array/test_reject_values.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/array/reject_values'
2 |
3 | testcase Array do
4 |
5 | method :reject_values do
6 |
7 | test do
8 | a = [1,2,3,4,5]
9 | r = a.reject_values(2,4)
10 | r.assert == [1,3,5]
11 | a.assert = [1,2,3,4,5] # hasn't changed
12 | end
13 |
14 | end
15 |
16 | end
17 |
18 |
--------------------------------------------------------------------------------
/test/core/array/test_splice.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/array/splice'
2 |
3 | test_case Array do
4 |
5 | method :splice do
6 |
7 | test do
8 | a = [1,2,3]
9 | a.splice(1).assert == 2
10 | a.assert == [1,3]
11 | end
12 |
13 | test do
14 | a = [1,2,3]
15 | a.splice(1,4).assert == 4
16 | a.assert == [1,4,3]
17 | end
18 |
19 | end
20 |
21 | end
22 |
--------------------------------------------------------------------------------
/test/core/array/test_split.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/array/split'
2 |
3 | test_case Array do
4 |
5 | method :split do
6 |
7 | test do
8 | ['a','b','c'].split('b').assert == [['a'], ['c']]
9 | end
10 |
11 | test "empty" do
12 | [].split('a').assert == []
13 | end
14 |
15 | test "same" do
16 | ['a'].split('a').assert == []
17 | end
18 |
19 | end
20 |
21 | end
22 |
23 |
--------------------------------------------------------------------------------
/test/core/array/test_store.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/array/store'
2 |
3 | test_case Array do
4 |
5 | method :store do
6 |
7 | test do
8 | a = [1,2,3,4,5]
9 | a.store(0, :A)
10 | a.assert == [:A,2,3,4,5]
11 | end
12 |
13 | test do
14 | a = [1,2,3,4,5]
15 | a.store(-1, :Z)
16 | a.assert == [1,2,3,4,:Z]
17 | end
18 |
19 | end
20 |
21 | end
22 |
23 |
--------------------------------------------------------------------------------
/test/core/array/test_to_h.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/array/to_h'
2 |
3 | test_case Array do
4 |
5 | method :to_h do
6 |
7 | test do
8 | arr = [[:a, 1], [:b, 2]]
9 | arr.to_h.assert == {:a => 1, :b => 2}
10 | end
11 |
12 | end
13 |
14 | end
15 |
--------------------------------------------------------------------------------
/test/core/array/test_zip.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/array/zip'
2 |
3 | test_case Array do
4 |
5 | method :zip do
6 |
7 | test 'example' do
8 | Array.zip([1,2], [3,4]).assert == [[1,3],[2,4]]
9 | end
10 |
11 | end
12 |
13 | end
14 |
--------------------------------------------------------------------------------
/test/core/binding/test_defined.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/binding/defined'
2 |
3 | test_case Binding do
4 |
5 | a = 1
6 | b = 2
7 | x = "hello"
8 |
9 | bind = binding
10 |
11 | method :defined? do
12 | test do
13 | bind.assert.defined?("x")
14 | end
15 | end
16 |
17 | end
18 |
19 |
--------------------------------------------------------------------------------
/test/core/binding/test_op.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/binding/op'
2 |
3 | test_case Binding do
4 |
5 | a = 1
6 | b = 2
7 | x = "hello"
8 |
9 | bind = binding
10 |
11 | method :[] do
12 | test do
13 | bind["x"].assert == "hello"
14 | end
15 | end
16 |
17 | method :[]= do
18 | test do
19 | bind["x"] = "goodbye"
20 | bind["x"].assert == "goodbye"
21 | end
22 | end
23 |
24 | end
25 |
--------------------------------------------------------------------------------
/test/core/binding/test_self.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/binding/self'
2 |
3 | test_case Binding do
4 |
5 | bind = binding
6 | this = self
7 |
8 | method :self do
9 |
10 | test do
11 | bind.self == this
12 | end
13 |
14 | end
15 |
16 | end
17 |
--------------------------------------------------------------------------------
/test/core/class/test_descendents.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/class/descendants'
2 |
3 | test_case Class do
4 |
5 | method :descendants do
6 |
7 | a = Class.new
8 | b = Class.new(a)
9 | c = Class.new(b)
10 |
11 | test do
12 | a.descendants.assert.include?(b)
13 | a.descendants.assert.include?(c)
14 | end
15 |
16 | end
17 |
18 | end
19 |
20 |
--------------------------------------------------------------------------------
/test/core/class/test_subclasses.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/class/subclasses'
2 |
3 | test_case Class do
4 |
5 | method :subclasses do
6 |
7 | # class with a number of subclasses
8 | c = Class.new
9 | x = Class.new(c)
10 | y = Class.new(c)
11 | z = Class.new(c)
12 | zz = Class.new(z)
13 |
14 | test do
15 | c.subclasses == [x, y, z]
16 | end
17 |
18 | end
19 |
20 | end
21 |
22 |
--------------------------------------------------------------------------------
/test/core/class/test_to_proc.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/class/to_proc'
2 |
3 | test_case Class do
4 |
5 | method :to_proc do
6 |
7 | test do
8 | person = Struct.new(:name)
9 | people = ["joe"].map(&person)
10 | people[0].name.assert == "joe"
11 | end
12 |
13 | end
14 |
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/test/core/comparable/test_cmp.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/comparable/cmp'
2 |
3 | test_case Comparable do
4 |
5 | method :cmp do
6 |
7 | test 'on integers' do
8 | 3.cmp(4).assert == -1
9 | 3.cmp(3).assert == 0
10 | 3.cmp(2).assert == 1
11 | end
12 |
13 | end
14 |
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/test/core/dir/test_each_child.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/dir/each_child'
2 |
3 | test_case Dir do
4 |
5 | test_directory = 'test'
6 |
7 | method :each_child do
8 |
9 | test do
10 | c = []
11 | d = Dir.new(test_directory)
12 | d.each_child do |path|
13 | c << path
14 | end
15 | d.close
16 | (['core', 'standard'] - c).assert.empty?
17 | end
18 |
19 | end
20 |
21 | end
22 |
23 |
--------------------------------------------------------------------------------
/test/core/dir/test_parent.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/dir/parent'
2 |
3 | test_case Dir do
4 |
5 | class_method :parent? do
6 |
7 | test do
8 | Dir.assert.parent?("a/b/c", "a/b/c/d")
9 | end
10 |
11 | end
12 |
13 | end
14 |
15 |
--------------------------------------------------------------------------------
/test/core/enumerable/test_exclude.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/enumerable/exclude'
2 |
3 | test_case Enumerable do
4 |
5 | method :exclude? do
6 |
7 | test do
8 | a = [1,2,2,3]
9 | a.refute.exclude?(2)
10 | a.assert.exclude?(4)
11 | end
12 |
13 | end
14 |
15 | end
16 |
--------------------------------------------------------------------------------
/test/core/enumerable/test_expand.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/enumerable/expand'
2 |
3 | test_case Enumerable do
4 |
5 | method :expand do
6 |
7 | test do
8 | a = [1,2,2,[1,2]]
9 | r = a.expand
10 | r == [1,2,2,1,2]
11 | end
12 |
13 | end
14 |
15 | end
16 |
--------------------------------------------------------------------------------
/test/core/enumerable/test_frequency.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/enumerable/frequency'
2 |
3 | test_case Enumerable do
4 |
5 | method :frequency do
6 |
7 | test do
8 | %w{a b}.frequency.assert == {'a'=>1,'b'=>1}
9 | %w{a a b}.frequency.assert == {'a'=>2,'b'=>1}
10 | end
11 |
12 | end
13 |
14 | end
15 |
16 |
--------------------------------------------------------------------------------
/test/core/enumerable/test_mash.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/enumerable/mash'
2 |
3 | test_case Enumerable do
4 |
5 | method :mash do
6 |
7 | test "is an alias for #graph" do
8 | a = { :a => 1, :b => 2, :c => 3 }
9 | e = { :a => 2, :b => 3, :c => 4 }
10 | r = a.mash{ |k,v| {k => v+1} }
11 | r.assert == e
12 | end
13 |
14 | end
15 |
16 | end
17 |
18 |
--------------------------------------------------------------------------------
/test/core/enumerable/test_modulate.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/enumerable/modulate'
2 |
3 | test_case Enumerable do
4 |
5 | method :modulate do
6 |
7 | test do
8 | a = [2,4,6,8]
9 | r = a.modulate(2)
10 | x = [[2,6],[4,8]]
11 | r.assert == x
12 | end
13 |
14 | end
15 |
16 | end
17 |
18 |
--------------------------------------------------------------------------------
/test/core/enumerable/test_per.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/enumerable/per'
2 |
3 | test_case Enumerable do
4 |
5 | method :per do
6 |
7 | test "map" do
8 | e = [1,2,3].per.map
9 |
10 | (e + 3).assert == [4,5,6]
11 | (e - 1).assert == [0,1,2]
12 |
13 | e.to_s.assert == ['1','2','3']
14 | end
15 |
16 | end
17 |
18 | end
19 |
20 |
--------------------------------------------------------------------------------
/test/core/enumerable/test_visit.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/enumerable/visit'
2 |
3 | test_case Enumerable do
4 |
5 | method :visit do
6 |
7 | test do
8 | r = [1, 2, 8..9].visit{ |x| x.succ }
9 | r.assert == [2, 3, [9, 10]]
10 | end
11 |
12 | end
13 |
14 | end
15 |
--------------------------------------------------------------------------------
/test/core/enumerator/test_fx.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/enumerator/fx'
2 |
3 | test_case Enumerator do
4 |
5 | method :fx do
6 |
7 | test do
8 | e = [1,2,3].to_enum
9 | r = e.fx + 2
10 | r.assert == [3,4,5]
11 | end
12 |
13 | end
14 |
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/test/core/exception/test_detail.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/exception/detail'
2 |
3 | test_case Exception do
4 |
5 | method :detail do
6 |
7 | test "at least it runs" do
8 | err = ArgumentError.new("example error")
9 | err.detail
10 | end
11 |
12 | end
13 |
14 | end
15 |
16 |
--------------------------------------------------------------------------------
/test/core/exception/test_raised.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/exception/raised'
2 |
3 | test_case Exception do
4 |
5 | class_method :raised? do
6 |
7 | test do
8 | NameError.raised? do
9 | supercalafragalistic
10 | end
11 | end
12 |
13 | end
14 |
15 | end
16 |
--------------------------------------------------------------------------------
/test/core/exception/test_suppress.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/exception/suppress'
2 |
3 | test_case Exception do
4 |
5 | class_method :suppress do
6 |
7 | test do
8 | NameError.suppress do
9 | supercalafragalistic
10 | end
11 | end
12 |
13 | end
14 |
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/test/core/file/test_create.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/file/create'
2 |
3 | test_case File do
4 |
5 | class_method :create do
6 |
7 | test_file = 'tmp/rewrite.txt'
8 | test_data = 'This is a test!'
9 |
10 | test do
11 | File.create(test_file, test_data)
12 | File.read(test_file).assert == test_data
13 | end
14 |
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/test/core/file/test_null.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/file/null'
2 |
3 | test_case File do
4 |
5 | class_method :null do
6 |
7 | test do
8 | assert File.null
9 | end
10 |
11 | end
12 |
13 | end
14 |
15 |
--------------------------------------------------------------------------------
/test/core/file/test_read_list.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/file/read_list'
2 |
3 | test_case File do
4 |
5 | class_method :read_list do
6 |
7 | test_file = 'tmp/read_list.txt'
8 |
9 | test do
10 | File.open(test_file, 'w'){ |f| f << "line 1\nline 2\n#line 3" }
11 | File.read_list(test_file).assert == ['line 1', 'line 2']
12 | end
13 |
14 | end
15 |
16 | end
17 |
--------------------------------------------------------------------------------
/test/core/file/test_rootname.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/file/rootname'
2 |
3 | test_case File do
4 |
5 | class_method :rootname do
6 |
7 | test do
8 | File.rootname('test/core/file').assert == 'test'
9 | end
10 |
11 | end
12 |
13 | end
14 |
--------------------------------------------------------------------------------
/test/core/file/test_split_all.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/file/split_all'
2 |
3 | test_case File do
4 |
5 | class_method :split_all do
6 |
7 | test do
8 | fp = "test/core/file"
9 | File.split_all(fp).assert == ['test', 'core', 'file']
10 | end
11 |
12 | end
13 |
14 | end
15 |
--------------------------------------------------------------------------------
/test/core/file/test_write.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/file/write'
2 |
3 | test_case File do
4 |
5 | class_method :write do
6 |
7 | test_file = 'tmp/write.txt'
8 |
9 | test do
10 | data = "Test data\n"
11 |
12 | nbytes = File.write(test_file, data)
13 |
14 | out = File.read(test_file)
15 | out.assert == data
16 | out.size.assert == nbytes
17 | end
18 |
19 | end
20 |
21 | end
22 |
23 |
--------------------------------------------------------------------------------
/test/core/filetest/test_root.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/filetest/root'
2 |
3 | test_case FileTest do
4 |
5 | class_method :root? do
6 |
7 | test do
8 | assert FileTest.root?('/')
9 | end
10 |
11 | end
12 |
13 | end
14 |
15 |
--------------------------------------------------------------------------------
/test/core/hash/test_at.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/hash/at'
2 |
3 | test_case Hash do
4 |
5 | method :at do
6 |
7 | test do
8 | h = { :a=>1, :b=>2 }
9 | h.at(:a).assert == 1
10 | h.at(:b).assert == 2
11 | end
12 |
13 | end
14 |
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/test/core/hash/test_delete_at.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/hash/delete_at'
2 |
3 | test_case Hash do
4 |
5 | method :delete_at do
6 |
7 | test do
8 | a = { :a => 1, :b => 2, :c => 3 }
9 | x = { :b => 2, :c => 3 }
10 | v = a.delete_at(:a)
11 | v.assert == 1
12 | a.assert == x
13 | end
14 |
15 | end
16 |
17 | end
18 |
19 |
--------------------------------------------------------------------------------
/test/core/hash/test_delete_unless.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/hash/delete_unless'
2 |
3 | test_case Hash do
4 |
5 | method :delete_unless do
6 |
7 | test do
8 | a = { :a => 1, :b => 2, :c => 3 }
9 | x = { :a => 1 }
10 | r = a.delete_unless{|k,v| v == 1}
11 | r.assert == x
12 | a.assert == x
13 | end
14 |
15 | end
16 |
17 | end
18 |
19 |
--------------------------------------------------------------------------------
/test/core/hash/test_diff.rb:
--------------------------------------------------------------------------------
1 | covers "facets/hash/diff"
2 |
3 | test_case Hash do
4 |
5 | method :diff do
6 |
7 | test do
8 | h1 = {:a=>1,:b=>2}
9 | h2 = {:a=>1,:b=>3}
10 | h1.diff(h2).assert == {:b=>2}
11 | h2.diff(h1).assert == {:b=>3}
12 | end
13 |
14 | end
15 |
16 | end
17 |
--------------------------------------------------------------------------------
/test/core/hash/test_each_with_key.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/hash/each_with_key'
2 |
3 | test_case Hash do
4 |
5 | method :each_with_key do
6 |
7 | test do
8 | h1 = {:a=>1, :b=>2}
9 | h2 = {}
10 | h1.each_with_key { |v,k| h2[v] = k }
11 | h2.assert == {1=>:a, 2=>:b}
12 | end
13 |
14 | end
15 |
16 | end
17 |
--------------------------------------------------------------------------------
/test/core/hash/test_insert.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/hash/insert'
2 |
3 | test_case Hash do
4 |
5 | method :insert do
6 |
7 | test do
8 | h = {:a=>1, :b=>2}
9 |
10 | h.assert.insert(:c,3)
11 | h.assert == {:a=>1, :b=>2, :c=>3}
12 |
13 | h.refute.insert(:a,0)
14 | h.assert == {:a=>1, :b=>2, :c=>3}
15 | end
16 |
17 | end
18 |
19 | end
20 |
21 |
--------------------------------------------------------------------------------
/test/core/hash/test_inverse.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/hash/inverse'
2 |
3 | test_case Hash do
4 |
5 | method :inverse do
6 |
7 | test do
8 | h1 = { :a=>1, :b=>2, :c=>2 }
9 | h2 = h1.inverse
10 |
11 | h2[1].assert == :a
12 |
13 | h2[2].assert.include?(:b)
14 | h2[2].assert.include?(:c)
15 | end
16 |
17 | end
18 |
19 | end
20 |
21 |
--------------------------------------------------------------------------------
/test/core/hash/test_new_with.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/hash/new_with'
2 |
3 | test_case Hash do
4 |
5 | class_method :new_with do
6 |
7 | test do
8 | h = Hash.new_with{0}
9 |
10 | h[:ab].assert == 0
11 | h[100].assert == 0
12 | h["a"].assert == 0
13 | end
14 |
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/test/core/hash/test_op_add.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/hash/op_add'
2 |
3 | test_case Hash do
4 |
5 | method :+ do
6 |
7 | test do
8 | a = { :a => 1, :b => 2 }
9 | b = { :b => 3, :c => 4 }
10 | x = { :a => 1, :b => 3, :c => 4 }
11 | r = a + b
12 | r.assert == x
13 | end
14 |
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/test/core/hash/test_op_mul.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/hash/op_mul'
2 |
3 | test_case Hash do
4 |
5 | method :* do
6 |
7 | test do
8 | a = { :a => 1, :b => 2 }
9 | b = { :b => 3 }
10 | x = { :a => 1, :b => 2 }
11 | (a * b).assert == x
12 | end
13 |
14 | end
15 |
16 | end
17 |
18 |
--------------------------------------------------------------------------------
/test/core/hash/test_op_or.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/hash/op_or'
2 |
3 | test_case Hash do
4 |
5 | method :| do
6 |
7 | test do
8 | a = { :a => 1, :b => 2 }
9 | b = { :b => 3 }
10 | x = { :a => 1, :b => 2 }
11 | (a | b).assert == x
12 | end
13 |
14 | end
15 |
16 | end
17 |
18 |
--------------------------------------------------------------------------------
/test/core/hash/test_replace_each.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/hash/replace_each'
2 |
3 | test_case Hash do
4 |
5 | method :replace_each do
6 |
7 | test do
8 | a = { :a => 1, :b => 2, :c => 3 }
9 | x = { :a => 2, :b => 3, :c => 4 }
10 | a.replace_each{ |k,v| { k => v+1 } }
11 | a.assert == x
12 | end
13 |
14 | end
15 |
16 | end
17 |
18 |
--------------------------------------------------------------------------------
/test/core/hash/test_swap.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/hash/swap'
2 |
3 | test_case Hash do
4 |
5 | method :swap! do
6 |
7 | test do
8 | h = { :a=>1, :b=>2 }
9 | h.swap!(:a, :b).assert == { :a=>2, :b=>1 }
10 | end
11 |
12 | end
13 |
14 | end
15 |
16 |
--------------------------------------------------------------------------------
/test/core/hash/test_to_proc.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/hash/to_proc'
2 |
3 | test_case Hash do
4 |
5 | method :to_proc do
6 |
7 | test do
8 | c = Class.new do
9 | attr_accessor :a
10 | end
11 |
12 | h = {:a => 1}
13 | o = c.new
14 |
15 | h.to_proc.call(o)
16 |
17 | o.a.assert == 1
18 | end
19 |
20 | end
21 |
22 | end
23 |
24 |
--------------------------------------------------------------------------------
/test/core/hash/test_update_each.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/hash/update_each'
2 |
3 | test_case Hash do
4 |
5 | method :update_each do
6 |
7 | test do
8 | a = { :a => 1, :b => 2, :c => 3 }
9 | x = { :a => 2, :b => 3, :c => 4 }
10 | a.update_each{ |k,v| { k => v+1 } }
11 | a.assert == x
12 | end
13 |
14 | end
15 |
16 | end
17 |
--------------------------------------------------------------------------------
/test/core/hash/test_update_values.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/hash/update_values'
2 |
3 | test_case Hash do
4 |
5 | method :update_values do
6 |
7 | test do
8 | h = {1 => 'A', 2 => 'B'}
9 | h.update_values{ |v| v.downcase }
10 | h.assert == {1 => 'a', 2 => 'b'}
11 | end
12 |
13 | end
14 |
15 | end
16 |
--------------------------------------------------------------------------------
/test/core/hash/test_weave.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/hash/weave'
2 |
3 | test_case Hash do
4 |
5 | method :weave do
6 |
7 | test do
8 | b = { :a=>1, :b=>[1,2,3], :c=>{ :x=>'X' } }
9 | c = { :a=>2, :b=>[4,5,6], :c=>{ :x=>'A', :y => 'B' } }
10 | x = { :a=>2, :b=>[1,2,3,4,5,6], :c=>{ :x => 'A', :y => 'B' } }
11 | b.weave(c).assert == x
12 | end
13 |
14 | end
15 |
16 | end
17 |
18 |
19 |
--------------------------------------------------------------------------------
/test/core/hash/test_zip.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/hash/zip'
2 |
3 | test_case Hash do
4 |
5 | class_method :zip do
6 |
7 | test do
8 | a = [1,2,3]
9 | b = [4,5,6]
10 | Hash.zip(a,b).assert == {1=>4,2=>5,3=>6}
11 | end
12 |
13 | end
14 |
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/test/core/integer/test_multiple.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/integer/multiple'
2 |
3 | test_case Integer do
4 |
5 | method :multiple? do
6 |
7 | test do
8 | assert( ! 1.multiple?(2) )
9 | assert( 2.multiple?(2) )
10 | assert( ! 5.multiple?(3) )
11 | assert( 6.multiple?(3) )
12 | end
13 |
14 | end
15 |
16 | end
17 |
--------------------------------------------------------------------------------
/test/core/kernel/test_ask.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/kernel/ask'
2 |
3 | test_case Kernel do
4 |
5 | # requires user input
6 | method :ask do
7 | end
8 |
9 | end
10 |
--------------------------------------------------------------------------------
/test/core/kernel/test_callstack.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/kernel/callstack'
2 |
3 | test_case Kernel do
4 |
5 | method :call_stack do
6 |
7 | test do
8 | call_stack
9 | end
10 |
11 | end
12 |
13 | method :callstack do
14 |
15 | test do
16 | callstack
17 | end
18 |
19 | end
20 |
21 | end
22 |
--------------------------------------------------------------------------------
/test/core/kernel/test_class.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/kernel/__class__'
2 |
3 | test_case Kernel do
4 |
5 | method :__class__ do
6 |
7 | test do
8 | o = Object.new
9 | o.__class__.assert == o.class
10 | end
11 |
12 | end
13 |
14 | end
15 |
--------------------------------------------------------------------------------
/test/core/kernel/test_complete.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/kernel/complete'
2 |
3 | test_case Kernel do
4 |
5 | method :complete do
6 |
7 | test do
8 | a = []
9 | i = 0
10 | complete do
11 | i += 1
12 | i == 3 ? nil : a << i
13 | end
14 | a.assert == [1,2]
15 | end
16 |
17 | end
18 |
19 | end
20 |
--------------------------------------------------------------------------------
/test/core/kernel/test_d.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/kernel/d'
2 |
3 | test_case Kernel do
4 |
5 | # TODO: how to test #d silently? Need to redirect $stderr.
6 |
7 | method :d do
8 | end
9 |
10 | end
11 |
--------------------------------------------------------------------------------
/test/core/kernel/test_deep_copy.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/kernel/deep_copy'
2 |
3 | test_case Kernel do
4 |
5 | method :deep_copy do
6 |
7 | test do
8 | o = "This is a weak test."
9 | d = o.deep_copy
10 | d.assert == "This is a weak test."
11 | end
12 |
13 | end
14 |
15 | end
16 |
--------------------------------------------------------------------------------
/test/core/kernel/test_extension.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/kernel/extension'
2 |
3 | test_case Kernel do
4 |
5 | # DEPRECATE ?
6 | method :extension do
7 |
8 | test do
9 | c = Class.new
10 | o = c.new
11 | x = (class << o; self; end)
12 | o.extension.assert == x
13 | end
14 |
15 | end
16 |
17 | end
18 |
19 |
--------------------------------------------------------------------------------
/test/core/kernel/test_here.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/kernel/here'
2 |
3 | test_case Kernel do
4 |
5 | method :here do
6 |
7 | test do
8 | here.assert.is_a?(Binding)
9 | end
10 |
11 | end
12 |
13 | end
14 |
--------------------------------------------------------------------------------
/test/core/kernel/test_in.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/kernel/in'
2 |
3 | test_case Kernel do
4 |
5 | method :in? do
6 |
7 | test do
8 | 5.assert.in?(0..10)
9 | 5.assert.in?([1,2,3,4,5])
10 | end
11 |
12 | end
13 |
14 | end
15 |
--------------------------------------------------------------------------------
/test/core/kernel/test_instance_assign.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/kernel/instance_assign'
2 |
3 | test_case Kernel do
4 |
5 | method :instance_assign do
6 |
7 | test do
8 | ahash = { "z"=>0, "@a"=>1, "@b"=>2 } #, "@@a"=>3 }
9 | instance_assign(ahash)
10 | @z.assert == 0
11 | @a.assert == 1
12 | @b.assert == 2
13 | #@@a.assert == 3
14 | end
15 |
16 | end
17 |
18 | end
19 |
20 |
--------------------------------------------------------------------------------
/test/core/kernel/test_instance_class.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/kernel/instance_class'
2 |
3 | test_case Kernel do
4 |
5 | method :instance_class do
6 |
7 | test do
8 | o = Object.new
9 | o.instance_class.assert == (class << o; self; end)
10 | end
11 |
12 | end
13 |
14 | end
15 |
16 |
--------------------------------------------------------------------------------
/test/core/kernel/test_maybe.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/kernel/maybe'
2 |
3 | test_case Kernel do
4 |
5 | method :maybe do
6 |
7 | test do
8 | maybe
9 | end
10 |
11 | end
12 |
13 | end
14 |
--------------------------------------------------------------------------------
/test/core/kernel/test_meta_alias.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/kernel/meta_alias'
2 |
3 | test_case Kernel do
4 |
5 | method :meta_alias do
6 |
7 | test do
8 | c = Class.new do
9 | def self.y?; "y?" ; end
10 | end
11 | c.meta_alias "ynot?", "y?"
12 | c.ynot?.assert == "y?"
13 | end
14 |
15 | end
16 |
17 | end
18 |
19 |
--------------------------------------------------------------------------------
/test/core/kernel/test_meta_def.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/kernel/meta_def'
2 |
3 | test_case Kernel do
4 |
5 | method :meta_def do
6 |
7 | test do
8 | x = Class.new
9 | x.meta_def(:x){"x"}
10 | x.x.assert == "x"
11 | end
12 |
13 | end
14 |
15 | end
16 |
--------------------------------------------------------------------------------
/test/core/kernel/test_meta_eval.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/kernel/meta_eval'
2 |
3 | test_case Kernel do
4 |
5 | method :meta_eval do
6 |
7 | test do
8 | o = Object.new
9 | o.meta_eval do
10 | @y = "y"
11 | end
12 | o.instance_variable_get("@y").refute == "y"
13 | (class << o; self; end).instance_variable_get("@y").assert == "y"
14 | end
15 |
16 | end
17 |
18 | end
19 |
--------------------------------------------------------------------------------
/test/core/kernel/test_not_nil.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/kernel/not_nil'
2 |
3 | test_case Kernel do
4 |
5 | method :not_nil? do
6 |
7 | test do
8 | 5.assert.not_nil?
9 | end
10 |
11 | test do
12 | :x.assert.not_nil?
13 | end
14 |
15 | test do
16 | false.assert.not_nil?
17 | end
18 |
19 | test do
20 | nil.refute.not_nil?
21 | end
22 |
23 | end
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/test/core/kernel/test_object_class.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/kernel/object_class'
2 | covers 'facets/kernel/__class__'
3 |
4 | test_case Kernel do
5 |
6 | method :object_class do
7 |
8 | test do
9 | self.object_class.assert == self.class
10 | end
11 |
12 | end
13 |
14 | method :__class__ do
15 |
16 | test do
17 | self.__class__.assert == self.class
18 | end
19 |
20 | end
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/test/core/kernel/test_require_all.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/kernel/require_all'
2 |
3 | test_case Kernel do
4 |
5 | method :require_all do
6 | end
7 |
8 | method :load_all do
9 | end
10 |
11 | end
12 |
--------------------------------------------------------------------------------
/test/core/kernel/test_returning.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/kernel/returning'
2 |
3 | test_case Kernel do
4 |
5 | method :returning do
6 |
7 | test do
8 | foo = returning( values = [] ) do
9 | values << 'bar'
10 | values << 'baz'
11 | end
12 | foo.assert == ['bar', 'baz']
13 | end
14 |
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/test/core/kernel/test_singleton_class.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/kernel/singleton_class'
2 |
3 | test_case Kernel do
4 |
5 | method :singleton_class do
6 |
7 | test do
8 | x = Class.new
9 | m = (class << x; self; end)
10 | x.singleton_class.assert == m
11 | end
12 |
13 | end
14 |
15 | end
16 |
--------------------------------------------------------------------------------
/test/core/kernel/test_with.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/kernel/with'
2 |
3 | test_case Kernel do
4 |
5 | method :with do
6 |
7 | test do
8 | with values = [] do
9 | self << 'bar'
10 | self << 'baz'
11 | end
12 | values.assert == ['bar', 'baz']
13 | end
14 |
15 | end
16 |
17 | end
18 |
19 |
--------------------------------------------------------------------------------
/test/core/matchdata/test_match.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/matchdata/match'
2 |
3 | test_case MatchData do
4 |
5 | method :match do
6 |
7 | test do
8 | md = /X(a)(b)(c)X/.match("YXabcXY")
9 | md.match.assert == "XabcX"
10 | end
11 |
12 | end
13 |
14 | end
15 |
--------------------------------------------------------------------------------
/test/core/module/test_ancestor.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/module/ancestor'
2 |
3 | test_case Module do
4 |
5 | method :ancestor? do
6 |
7 | test do
8 | c1 = Class.new
9 | c2 = Class.new(c1)
10 | c2.assert.ancestor?(c1)
11 | end
12 |
13 | end
14 |
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/test/core/module/test_anonymous.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/module/anonymous'
2 |
3 | test_case Module do
4 |
5 | method :anonymous? do
6 |
7 | test do
8 | m = Module.new
9 | m.assert.anonymous?
10 | end
11 |
12 | test do
13 | Lemon.refute.anonymous?
14 | end
15 |
16 | end
17 |
18 | end
19 |
--------------------------------------------------------------------------------
/test/core/module/test_basename.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/module/basename'
2 |
3 | test_case Module do
4 |
5 | method :basename do
6 |
7 | test do
8 | Lemon::TestCase.basename.assert == "TestCase"
9 | end
10 |
11 | end
12 |
13 | end
14 |
15 |
--------------------------------------------------------------------------------
/test/core/module/test_can.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/module/can'
2 |
3 | test_case Module do
4 |
5 | method :can do
6 |
7 | test do
8 | m = Module.new do
9 | def x; "x"; end
10 | end
11 |
12 | c = Class.new do
13 | can m
14 | end
15 |
16 | c.x.assert == "x"
17 | end
18 |
19 | end
20 |
21 | end
22 |
23 |
--------------------------------------------------------------------------------
/test/core/module/test_instance_method.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/module/instance_method'
2 |
3 | test_case Module do
4 |
5 | method :instance_method! do
6 |
7 | test do
8 | c = Class.new do
9 | def x; "x"; end
10 | end
11 |
12 | x1 = c.instance_method!(:x)
13 | x2 = c.instance_method!(:x)
14 |
15 | x1.object_id.assert == x2.object_id
16 | end
17 |
18 | end
19 |
20 | end
21 |
--------------------------------------------------------------------------------
/test/core/module/test_modname.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/module/modname'
2 |
3 | test_case Module do
4 |
5 | method :modname do
6 |
7 | test do
8 | Lemon::TestCase.modname.assert == "Lemon"
9 | end
10 |
11 | end
12 |
13 | end
14 |
--------------------------------------------------------------------------------
/test/core/module/test_nodef.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/module/nodef'
2 |
3 | test_case Module do
4 |
5 | method :nodef do
6 |
7 | test do
8 | c = Class.new do
9 | def the_undefined_method ; 'not here' ; end
10 | nodef :the_undefined_method
11 | end
12 |
13 | c.new.refute.respond_to?(:the_undefined_method)
14 | end
15 |
16 | end
17 |
18 | end
19 |
20 |
--------------------------------------------------------------------------------
/test/core/module/test_pathize.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/module/pathize'
2 |
3 | test_case Module do
4 |
5 | method :pathize do
6 |
7 | test do
8 | Lemon.pathize.assert == 'lemon'
9 | end
10 |
11 | end
12 |
13 | end
14 |
15 | test_case Class do
16 |
17 | method :pathize do
18 |
19 | test do
20 | Lemon::TestCase.pathize.assert == 'lemon/test_case'
21 | end
22 |
23 | end
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/test/core/module/test_remove.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/module/remove'
2 |
3 | test_case Module do
4 |
5 | method :remove do
6 |
7 | test do
8 | c = Class.new do
9 | def the_removed_method ; 'not here' ; end
10 | remove :the_removed_method
11 | end
12 |
13 | c.new.refute.respond_to?(:the_removed_method)
14 | end
15 |
16 | end
17 |
18 | end
19 |
--------------------------------------------------------------------------------
/test/core/module/test_spacename.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/module/spacename'
2 |
3 | test_case Module do
4 |
5 | method :spacename do
6 |
7 | test do
8 | Lemon::TestCase.spacename.assert == 'Lemon'
9 | Lemon.spacename.assert == '' # should this be nil ?
10 | end
11 |
12 | end
13 |
14 | end
15 |
16 |
--------------------------------------------------------------------------------
/test/core/module/test_to_obj.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/module/to_obj'
2 |
3 | test_case Module do
4 |
5 | method :to_obj do
6 |
7 | test do
8 | m = Module.new do
9 | def x; "x"; end
10 | def y; "y"; end
11 | end
12 | o = m.to_obj
13 | o.x.assert == "x"
14 | o.y.assert == "y"
15 | end
16 |
17 | end
18 |
19 | end
20 |
21 |
--------------------------------------------------------------------------------
/test/core/numeric/test_distance.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/numeric/distance'
2 |
3 | test_case Numeric do
4 |
5 | method :distance do
6 |
7 | test do
8 | 10.distance(6).assert == 4
9 | 10.distance(8).assert == 2
10 | 7.distance(9).assert == -2
11 | end
12 |
13 | end
14 |
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/test/core/numeric/test_length.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/numeric/length'
2 |
3 | test_case Numeric do
4 |
5 | method :length do
6 |
7 | test do
8 | (0..10).each do |power|
9 | power.length.assert == power
10 | end
11 | end
12 |
13 | end
14 |
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/test/core/proc/test_bind_to.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/proc/bind_to'
2 |
3 | test_case Proc do
4 |
5 | method :bind_to do
6 |
7 | test do
8 | a = [1,2,3]
9 | p1 = Proc.new{ join(' ') }
10 | p2 = p1.bind_to(a)
11 | p2.call.assert == '1 2 3'
12 | end
13 |
14 | end
15 |
16 | end
17 |
18 |
--------------------------------------------------------------------------------
/test/core/proc/test_update.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/proc/update'
2 |
3 | test_case Proc do
4 |
5 | method :update do
6 |
7 | test do
8 | p1 = Proc.new{ 'here' }
9 | p1.update.assert == 'here'
10 | end
11 |
12 | end
13 |
14 | end
15 |
16 |
--------------------------------------------------------------------------------
/test/core/range/test_overlap.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/range/overlap'
2 |
3 | test_case Range do
4 |
5 | method :overlap? do
6 |
7 | test do
8 | assert( (4..5).overlap?(3..6) )
9 | assert(! (7..9).overlap?(3..6) )
10 | end
11 |
12 | end
13 |
14 | end
15 |
16 |
--------------------------------------------------------------------------------
/test/core/range/test_to_rng.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/range/to_rng'
2 |
3 | test_case Range do
4 |
5 | method :to_rng do
6 | test do
7 | a = (0..10)
8 | a.to_rng.assert == a
9 | end
10 | end
11 |
12 | method :to_range do
13 | test do
14 | a = (0..10)
15 | a.to_range.assert == a
16 | end
17 | end
18 |
19 | end
20 |
21 |
--------------------------------------------------------------------------------
/test/core/regexp/test_multiline.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/regexp/multiline'
2 |
3 | test_case Regexp do
4 |
5 | method :multiline? do
6 |
7 | test do
8 | re = /x/m
9 | re.assert.multiline?
10 | end
11 |
12 | test do
13 | re = /x/
14 | re.refute.multiline?
15 | end
16 |
17 | end
18 |
19 | end
20 |
--------------------------------------------------------------------------------
/test/core/regexp/test_op_add.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/regexp/op_add'
2 |
3 | test_case Regexp do
4 |
5 | method :+ do
6 |
7 | test do
8 | r = /a/ + /b/
9 | r.assert == /(?-mix:a)(?-mix:b)/
10 | end
11 |
12 | end
13 |
14 | end
15 |
16 |
--------------------------------------------------------------------------------
/test/core/regexp/test_op_or.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/regexp/op_or'
2 |
3 | test_case Regexp do
4 |
5 | method :| do
6 |
7 | test do
8 | re = /a/ | /b/
9 | re.assert =~ "a"
10 | re.assert =~ "b"
11 | end
12 |
13 | end
14 |
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/test/core/regexp/test_to_re.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/regexp/to_re'
2 |
3 | test_case Regexp do
4 |
5 | method :to_re do
6 |
7 | test do
8 | r = /0..10/
9 | r.to_re.assert == r.to_re
10 | end
11 |
12 | end
13 |
14 | method :to_regexp do
15 |
16 | test do
17 | r = /0..10/
18 | r.to_regexp.assert == r
19 | end
20 |
21 | end
22 |
23 | end
24 |
25 |
--------------------------------------------------------------------------------
/test/core/string/test_acronym.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/string/acronym'
2 |
3 | test_case String do
4 |
5 | method :acronym do
6 | test do
7 | 'abc'.acronym.assert == 'a'
8 | 'abc def'.acronym.assert == 'ad'
9 | 'abc def ghi'.acronym.assert == 'adg'
10 | end
11 | end
12 |
13 | end
14 |
15 |
--------------------------------------------------------------------------------
/test/core/string/test_cleanlines.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/string/cleanlines'
2 |
3 | test_case String do
4 |
5 | method :cleanlines do
6 | test do
7 | "a \n b \nc".cleanlines.to_a.assert == ["a","b","c"]
8 | end
9 | end
10 |
11 | end
12 |
13 |
--------------------------------------------------------------------------------
/test/core/string/test_cmp.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/string/cmp'
2 |
3 | test_case String do
4 |
5 | method :cmp do
6 |
7 | test 'on strings' do
8 | "abc".cmp("abc").assert == 0
9 | "abc".cmp("abcd").assert == -1
10 | "abcd".cmp("abc").assert == 1
11 | "abc".cmp("bcd").assert == -1
12 | "bcd".cmp("abc").assert == 1
13 | end
14 |
15 | end
16 |
17 | end
18 |
19 |
--------------------------------------------------------------------------------
/test/core/string/test_crypt.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/string/crypt'
2 |
3 | test_case String do
4 |
5 | method :crypt do
6 | test do
7 | "abc".crypt('ZZ').assert.start_with?('ZZ')
8 | end
9 |
10 | test do
11 | encrypted = "abc".crypt
12 | salt = encrypted[0..1]
13 | "abc".crypt(salt).assert == encrypted
14 | end
15 | end
16 | end
17 |
18 |
--------------------------------------------------------------------------------
/test/core/string/test_divide.rb:
--------------------------------------------------------------------------------
1 | covers 'facets/string/divide'
2 |
3 | test_case String do
4 |
5 | method :divide do
6 |
7 | test do
8 | s = "Thisisa test.
" 9 | d = s.divide( /<.*?>/ ) 10 | e = ["This", "is", "a test.", "
"] 11 | d.assert == e 12 | end 13 | 14 | end 15 | 16 | end 17 | 18 | -------------------------------------------------------------------------------- /test/core/string/test_each_word.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/each_word.rb' 2 | 3 | test_case String do 4 | 5 | method :each_word do 6 | 7 | test do 8 | a = [] 9 | i = "this is a test" 10 | i.each_word{ |w| a << w } 11 | a.assert == ['this', 'is', 'a', 'test'] 12 | end 13 | 14 | end 15 | 16 | end 17 | 18 | -------------------------------------------------------------------------------- /test/core/string/test_edit_distance.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/edit_distance' 2 | 3 | test_case String do 4 | 5 | method :edit_distance do 6 | 7 | test do 8 | d = "pretzel".edit_distance('pretzil') 9 | d.assert = 1 10 | end 11 | 12 | test do 13 | d = "zretzel".edit_distance('pretzil') 14 | d.assert = 2 15 | end 16 | 17 | end 18 | 19 | end 20 | 21 | -------------------------------------------------------------------------------- /test/core/string/test_file.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/file' 2 | 3 | test_case String do 4 | 5 | method :file do 6 | 7 | test do 8 | "home/trans".file.dirname.assert == "home" 9 | "home/trans".file.basename.assert == "trans" 10 | end 11 | 12 | end 13 | 14 | end 15 | 16 | -------------------------------------------------------------------------------- /test/core/string/test_interpolate.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/interpolate' 2 | 3 | test_case String do 4 | 5 | class_method :interpolate do 6 | 7 | test do 8 | a = 1 9 | String.interpolate{ 'this is #{a}' }.assert == 'this is 1' 10 | end 11 | 12 | end 13 | 14 | end 15 | 16 | 17 | -------------------------------------------------------------------------------- /test/core/string/test_lchomp.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/lchomp' 2 | 3 | test_case String do 4 | 5 | method :lchomp do 6 | 7 | test do 8 | s = "xxboo" 9 | r = s.lchomp("xx") 10 | r.assert == "boo" 11 | end 12 | 13 | end 14 | 15 | method :lchomp! do 16 | 17 | test do 18 | s = "xxboo" 19 | s.lchomp!("xx") 20 | s.assert == "boo" 21 | end 22 | 23 | end 24 | 25 | end 26 | -------------------------------------------------------------------------------- /test/core/string/test_line_wrap.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/line_wrap' 2 | 3 | test_case String do 4 | 5 | method :line_wrap do 6 | 7 | test do 8 | "abc123".line_wrap(3).assert == "abc\n123\n" 9 | "abcd123".line_wrap(4).assert == "abcd\n123\n" 10 | end 11 | 12 | end 13 | 14 | end 15 | 16 | -------------------------------------------------------------------------------- /test/core/string/test_lowercase.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/lowercase' 2 | 3 | test_case String do 4 | 5 | method :lowercase do 6 | 7 | test do 8 | "Bob".lowercase.assert == "bob" 9 | end 10 | 11 | test do 12 | "BOB".lowercase.assert == "bOB" 13 | end 14 | 15 | end 16 | 17 | end 18 | 19 | -------------------------------------------------------------------------------- /test/core/string/test_margin.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/margin' 2 | 3 | test_case String do 4 | 5 | # TODO: Need to expand margin tests 6 | method :margin do 7 | 8 | test do 9 | a = "xyz".margin(4) 10 | a[0..3].assert == ' ' 11 | end 12 | 13 | end 14 | 15 | end 16 | 17 | -------------------------------------------------------------------------------- /test/core/string/test_mscan.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/mscan' 2 | 3 | test_case String do 4 | 5 | method :mscan do 6 | 7 | test do 8 | r = 'abc,def,gh'.mscan(/[,]/) 9 | assert( r.all?{ |md| MatchData === md } ) 10 | r.to_a.length.assert == 2 11 | r[0][0].assert == ',' 12 | r[1][0].assert == ',' 13 | end 14 | 15 | end 16 | 17 | end 18 | 19 | -------------------------------------------------------------------------------- /test/core/string/test_nchar.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/nchar' 2 | 3 | test_case String do 4 | 5 | method :nchar do 6 | 7 | test do 8 | "abcxyz".nchar(3).assert == "abc" 9 | "abcxyz".nchar(-3).assert == "xyz" 10 | "abcxyz".nchar(3, 'HI').assert == "HIxyz" 11 | "abcxyz".nchar(-3, 'HI').assert == "abcHI" 12 | end 13 | 14 | end 15 | 16 | end 17 | 18 | -------------------------------------------------------------------------------- /test/core/string/test_newlines.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/newlines' 2 | 3 | test_case String do 4 | 5 | # Since Ruby 1.9 defined #lines to keep the newline character, 6 | # we have defined #newlines to leave them out. 7 | method :newlines do 8 | test do 9 | "a\nb\nc".newlines.to_a.assert == ["a","b","c"] 10 | end 11 | end 12 | 13 | end 14 | 15 | -------------------------------------------------------------------------------- /test/core/string/test_op_div.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/op_div' 2 | 3 | test_case String do 4 | 5 | method :/ do 6 | 7 | test do 8 | ('merb' / 'string').assert == "merb/string" 9 | ('merb' / :symbol).assert == "merb/symbol" 10 | end 11 | 12 | end 13 | 14 | end 15 | 16 | -------------------------------------------------------------------------------- /test/core/string/test_op_sub.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/op_sub' 2 | 3 | test_case String do 4 | 5 | method :"-" do 6 | 7 | test do 8 | s = "xxbooxxfoo" 9 | (s - "xx").assert == "boofoo" 10 | end 11 | 12 | end 13 | 14 | end 15 | 16 | -------------------------------------------------------------------------------- /test/core/string/test_rewrite.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/rewrite' 2 | 3 | test_case String do 4 | 5 | method :rewrite do 6 | 7 | test do 8 | s = "HELLO TOMMY!" 9 | rules = [[ /TOMMY/, 'MAN' ]] 10 | r = s.rewrite(rules) 11 | r.assert == "HELLO MAN!" 12 | end 13 | 14 | end 15 | 16 | end 17 | 18 | -------------------------------------------------------------------------------- /test/core/string/test_shatter.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/shatter' 2 | 3 | test_case String do 4 | 5 | method :shatter do 6 | 7 | test do 8 | s = "Thisisa test.
" 9 | r = s.shatter( /<.*?>/ ) 10 | x = ["", "This", "", "is", "", "a test.", "
"] 11 | r.assert == x 12 | end 13 | 14 | end 15 | 16 | end 17 | 18 | -------------------------------------------------------------------------------- /test/core/string/test_store.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/store' 2 | 3 | test_case String do 4 | 5 | method :store do 6 | 7 | test do 8 | a = "HELLO" 9 | a.store(1, "X") 10 | a.assert == "HXLLO" 11 | end 12 | 13 | end 14 | 15 | end 16 | 17 | -------------------------------------------------------------------------------- /test/core/string/test_subtract.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/subtract' 2 | 3 | test_case String do 4 | 5 | method :- do 6 | 7 | test do 8 | ("foobar" - "oo").assert == "fbar" 9 | ("pizza pizza!" - "zz").assert == "pia pia!" 10 | ("letters" - /[a-z]+/).assert == "" 11 | end 12 | 13 | end 14 | 15 | end 16 | 17 | -------------------------------------------------------------------------------- /test/core/string/test_titlecase.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/titlecase' 2 | 3 | test_case String do 4 | 5 | method :titlecase do 6 | 7 | test do 8 | r = "try this out".titlecase 9 | x = "Try This Out" 10 | r.assert == x 11 | end 12 | 13 | end 14 | 15 | end 16 | 17 | -------------------------------------------------------------------------------- /test/core/string/test_unfold.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/unfold' 2 | 3 | test_case String do 4 | 5 | method :unfold do 6 | 7 | test do 8 | str = "This is a test of\nparagraph folding." 9 | res = str.unfold 10 | exp = "This is a test of paragraph folding." 11 | res.assert == exp 12 | end 13 | 14 | end 15 | 16 | end 17 | 18 | -------------------------------------------------------------------------------- /test/core/string/test_unquote.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/unquote' 2 | 3 | test_case String do 4 | 5 | method :unquote do 6 | 7 | test do 8 | "'here'".unquote.assert == "here" 9 | end 10 | 11 | end 12 | 13 | end 14 | -------------------------------------------------------------------------------- /test/core/string/test_uppercase.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/uppercase' 2 | 3 | test_case String do 4 | 5 | method :uppercase do 6 | 7 | test do 8 | "bob".uppercase.assert == "Bob" 9 | end 10 | 11 | test do 12 | "boB".uppercase.assert == "BoB" 13 | end 14 | 15 | test do 16 | "BoB".uppercase.assert == "BoB" 17 | end 18 | 19 | end 20 | 21 | end 22 | 23 | -------------------------------------------------------------------------------- /test/core/string/test_variablize.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/variablize' 2 | 3 | test_case String do 4 | 5 | method :variablize do 6 | 7 | test do 8 | s = "a" 9 | s.variablize.assert == "@a" 10 | end 11 | 12 | end 13 | 14 | end 15 | 16 | -------------------------------------------------------------------------------- /test/core/string/test_xor.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/string/xor' 2 | 3 | test_case String do 4 | 5 | method :'^' do 6 | 7 | test do 8 | r = "try this out" ^ "puddingsnacks" 9 | x = "\004\a\035D\035\006\016\000N\016\026\037" 10 | r.assert == x 11 | end 12 | 13 | end 14 | 15 | end 16 | 17 | -------------------------------------------------------------------------------- /test/core/struct/test_replace.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/struct/replace' 2 | 3 | test_case Struct do 4 | method :replace do 5 | test do 6 | s = Struct.new(:name, :age) 7 | 8 | o = s.new('bob', 60) 9 | o.name.assert == 'bob' 10 | o.age.assert == 60 11 | 12 | o.replace(:name=>'tom', :age=>40) 13 | 14 | o.name.assert == 'tom' 15 | o.age.assert == 40 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /test/core/symbol/test_as_s.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/symbol/as_s' 2 | 3 | test_case Symbol do 4 | 5 | method :as_s do 6 | 7 | test do 8 | s = :foo.as_s.sub('f','g') 9 | s.assert == :goo 10 | end 11 | 12 | end 13 | 14 | end 15 | 16 | -------------------------------------------------------------------------------- /test/core/symbol/test_bang.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/symbol/bang' 2 | 3 | test_case Symbol do 4 | 5 | method :bang? do 6 | 7 | test do 8 | :a.refute.bang? 9 | :a?.refute.bang? 10 | :a!.assert.bang? 11 | end 12 | 13 | end 14 | 15 | end 16 | -------------------------------------------------------------------------------- /test/core/symbol/test_chomp.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/symbol/chomp' 2 | 3 | test_case Symbol do 4 | 5 | method :chomp do 6 | 7 | test do 8 | :ab.chomp(:b).assert == :a 9 | end 10 | 11 | end 12 | 13 | method :lchomp do 14 | 15 | test do 16 | :ab.lchomp(:a).assert == :b 17 | end 18 | 19 | end 20 | 21 | end 22 | 23 | -------------------------------------------------------------------------------- /test/core/symbol/test_not.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/symbol/not' 2 | 3 | test_case Symbol do 4 | 5 | method :~@ do 6 | test do 7 | ~:a.assert == :"~a" 8 | end 9 | end 10 | 11 | method :not? do 12 | test do 13 | a = :a 14 | n = ~a 15 | assert( n.not? ) 16 | end 17 | end 18 | 19 | end 20 | -------------------------------------------------------------------------------- /test/core/symbol/test_op_div.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/symbol/op_div' 2 | 3 | test_case Symbol do 4 | 5 | method :/ do 6 | 7 | test do 8 | (:merb / "string").assert == "merb/string" 9 | (:merb / :symbol).assert == "merb/symbol" 10 | end 11 | 12 | end 13 | 14 | end 15 | 16 | -------------------------------------------------------------------------------- /test/core/symbol/test_plain.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/symbol/plain' 2 | 3 | test_case Symbol do 4 | 5 | method :plain? do 6 | 7 | test do 8 | assert( :try.plain? ) 9 | end 10 | 11 | test do 12 | assert( ! :try=.plain? ) 13 | assert( ! :try?.plain? ) 14 | end 15 | 16 | end 17 | 18 | end 19 | 20 | -------------------------------------------------------------------------------- /test/core/symbol/test_query.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/symbol/query' 2 | 3 | test_case Symbol do 4 | 5 | method :query? do 6 | 7 | test do 8 | assert( :try?.query? ) 9 | end 10 | 11 | test do 12 | assert( ! :try.query? ) 13 | assert( ! :try=.query? ) 14 | end 15 | 16 | end 17 | 18 | end 19 | 20 | -------------------------------------------------------------------------------- /test/core/symbol/test_setter.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/symbol/setter' 2 | 3 | test_case Symbol do 4 | 5 | method :setter? do 6 | test do 7 | assert( :try=.setter? ) 8 | end 9 | 10 | test do 11 | assert( ! :try.setter? ) 12 | assert( ! :try?.setter? ) 13 | end 14 | end 15 | 16 | end 17 | 18 | -------------------------------------------------------------------------------- /test/core/symbol/test_succ.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/symbol/succ' 2 | 3 | test_case Symbol do 4 | 5 | method :succ do 6 | 7 | test do 8 | :a.succ.assert == :b 9 | :aaa.succ.assert == :aab 10 | :"1".succ.assert == :"2" 11 | end 12 | 13 | end 14 | 15 | end 16 | 17 | -------------------------------------------------------------------------------- /test/core/symbol/test_variablize.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/symbol/variablize' 2 | 3 | test_case Symbol do 4 | 5 | method :variablize do 6 | 7 | test do 8 | :a.variablize.assert == "@a".to_sym 9 | end 10 | 11 | end 12 | 13 | end 14 | 15 | -------------------------------------------------------------------------------- /test/core/time/test_change.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/time/change' 2 | 3 | test_case Time do 4 | 5 | method :change do 6 | 7 | test do 8 | t = Time.local(2006,04,20,15,37) 9 | n = Time.now 10 | n = n.change(:month=>4, :day=>20, :hour=>15, :min=>37, :year=>2006) 11 | n.assert == t 12 | end 13 | 14 | end 15 | 16 | end 17 | 18 | -------------------------------------------------------------------------------- /test/core/time/test_elapse.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/time/elapse' 2 | 3 | test_case Time do 4 | 5 | class_method :elapse do 6 | 7 | test do 8 | t = Time.elapse { sleep 1 } 9 | assert( (t > 0.9) && (t < 2.1 )) 10 | end 11 | 12 | end 13 | 14 | end 15 | 16 | -------------------------------------------------------------------------------- /test/core/time/test_to_time.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/time/to_time' 2 | 3 | test_case Time do 4 | 5 | method :to_time do 6 | 7 | test do 8 | t = Time.now 9 | t.to_time.assert.is_a?(Time) 10 | end 11 | 12 | end 13 | 14 | end 15 | 16 | -------------------------------------------------------------------------------- /test/standard/math/test_abs.rb: -------------------------------------------------------------------------------- 1 | require 'facets/math/abs' 2 | 3 | test_case Math do 4 | 5 | class_method :abs do 6 | test do 7 | Math.abs(-3.1).assert == 3.1 8 | Math.abs( 0.0).assert == 0.0 9 | Math.abs( 3.1).assert == 3.1 10 | end 11 | end 12 | 13 | end 14 | -------------------------------------------------------------------------------- /test/standard/math/test_cot.rb: -------------------------------------------------------------------------------- 1 | require 'facets/math/cot' 2 | require 'facets/numeric/range' # used to test within a precision 3 | 4 | test_case Math do 5 | 6 | class_method :cot do 7 | test do 8 | Math.cot(1.0).range(1.0e-6).assert === 1.0 / Math.tan(1.0) 9 | Math.cot(2.0).range(1.0e-6).assert === 1.0 / Math.tan(2.0) 10 | end 11 | end 12 | 13 | end 14 | -------------------------------------------------------------------------------- /test/standard/math/test_coth.rb: -------------------------------------------------------------------------------- 1 | require 'facets/math/coth' 2 | require 'facets/numeric/range' # used to test within a precision 3 | 4 | test_case Math do 5 | 6 | class_method :coth do 7 | test do 8 | Math.coth(1.0).range(1.0e-6).assert === 1.0 / Math.tanh(1.0) 9 | Math.coth(2.0).range(1.0e-6).assert === 1.0 / Math.tanh(2.0) 10 | end 11 | end 12 | 13 | end 14 | -------------------------------------------------------------------------------- /test/standard/math/test_exp10.rb: -------------------------------------------------------------------------------- 1 | require 'facets/math/exp10' 2 | require 'facets/numeric/range' # used to test within a precision 3 | 4 | test_case Math do 5 | 6 | class_method :exp10 do 7 | test do 8 | Math.exp10(0.0).range(1.0e-6).assert === 1.0 9 | Math.exp10(0.5).range(1.0e-6).assert === Math.sqrt(10.0) 10 | Math.exp10(1.0).range(1.0e-6).assert === 10.0 11 | end 12 | end 13 | 14 | end 15 | -------------------------------------------------------------------------------- /test/standard/math/test_exp2.rb: -------------------------------------------------------------------------------- 1 | require 'facets/math/exp2' 2 | require 'facets/numeric/range' # used to test within a precision 3 | 4 | test_case Math do 5 | 6 | class_method :exp2 do 7 | test do 8 | Math.exp2(0.0).range(1.0e-6).assert === 1.0 9 | Math.exp2(0.5).range(1.0e-6).assert === Math.sqrt(2.0) 10 | Math.exp2(1.0).range(1.0e-6).assert === 2.0 11 | end 12 | end 13 | 14 | end 15 | -------------------------------------------------------------------------------- /test/standard/math/test_factorial.rb: -------------------------------------------------------------------------------- 1 | require 'facets/math/factorial' 2 | 3 | test_case Math do 4 | 5 | class_method :factorial do 6 | fac = 1 7 | 1.upto(100) do |i| 8 | fac *= i 9 | Math.factorial(i).assert == fac 10 | end 11 | end 12 | 13 | end 14 | -------------------------------------------------------------------------------- /test/standard/math/test_lcm.rb: -------------------------------------------------------------------------------- 1 | require 'facets/math/lcm' 2 | 3 | test_case Math do 4 | 5 | class_method :lcm do 6 | test do 7 | Math.lcm( 77, 221).assert == 17017 8 | Math.lcm(143, 187).assert == 2431 9 | Math.lcm( 91, 119).assert == 1547 10 | end 11 | end 12 | 13 | end 14 | -------------------------------------------------------------------------------- /test/standard/math/test_median.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/math/median' 2 | 3 | test_case Math do 4 | 5 | class_method :median do 6 | test "fractional" do 7 | r = Math.median [1, 2, 3, 3, 6, 11, 20, 20] 8 | r.assert == 4.5 9 | end 10 | 11 | test "whole value" do 12 | r = Math.median [1, 2, 4, 6, 8] 13 | r.assert == 4 14 | end 15 | end 16 | 17 | end 18 | -------------------------------------------------------------------------------- /test/standard/math/test_percentile.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/math/percentile' 2 | 3 | test_case Math do 4 | 5 | class_method :percentile do 6 | test do 7 | a = [1,1,2,2,3,3,3,4] 8 | r = Math.percentile(a,75) 9 | r.assert == 3.0 10 | end 11 | end 12 | 13 | end 14 | -------------------------------------------------------------------------------- /test/standard/math/test_sinc.rb: -------------------------------------------------------------------------------- 1 | require 'facets/math/sinc' 2 | 3 | test_case Math do 4 | 5 | class_method :sinc do 6 | test do 7 | Math.sinc( 0.0).assert == 1.0 8 | Math.sinc( 1.0).assert == Math.sin(1.0) 9 | Math.sinc(-1.0).assert == Math.sin(1.0) 10 | Math.sinc( 2.0).assert == 0.5 * Math.sin(2.0) 11 | Math.sinc(-2.0).assert == 0.5 * Math.sin(2.0) 12 | end 13 | end 14 | 15 | end 16 | -------------------------------------------------------------------------------- /test/standard/pathname/test_chdir.rb: -------------------------------------------------------------------------------- 1 | covers 'facets/pathname/chdir' 2 | 3 | test_case Pathname do 4 | 5 | method :chdir do 6 | 7 | test do 8 | Pathname.pwd.basename.to_s.assert != 'tmp' 9 | Pathname.new('tmp').chdir do 10 | Pathname.pwd.basename.to_s.assert == 'tmp' 11 | end 12 | end 13 | 14 | end 15 | end 16 | 17 | -------------------------------------------------------------------------------- /test/standard/test_math.rb: -------------------------------------------------------------------------------- 1 | # test the math require 2 | require 'facets/math' 3 | 4 | -------------------------------------------------------------------------------- /work/OLD_COMPARE/facets/string/align_left.rb: -------------------------------------------------------------------------------- 1 | # stub 2 | require 'facets/string/align_center' 3 | -------------------------------------------------------------------------------- /work/OLD_COMPARE/facets/string/align_right.rb: -------------------------------------------------------------------------------- 1 | # stub 2 | require 'facets/string/align_center' 3 | -------------------------------------------------------------------------------- /work/OLD_COMPARE/facets/string/at.rb: -------------------------------------------------------------------------------- 1 | 2 | class String 3 | 4 | # Alias for slice which increases polymorphism 5 | # with Array. 6 | alias_method :at, :slice 7 | 8 | end 9 | -------------------------------------------------------------------------------- /work/OLD_COMPARE/facets/string/ends_with.rb: -------------------------------------------------------------------------------- 1 | # stub 2 | require 'facets/string/starts_with' 3 | -------------------------------------------------------------------------------- /work/OLD_COMPARE/facets/string/ordinal.rb: -------------------------------------------------------------------------------- 1 | require 'facets/integer/ordinal' 2 | 3 | class String 4 | def ordinal 5 | self.to_i.ordinal 6 | end 7 | end 8 | 9 | 10 | # _____ _ 11 | # |_ _|__ ___| |_ 12 | # | |/ _ \/ __| __| 13 | # | | __/\__ \ |_ 14 | # |_|\___||___/\__| 15 | # 16 | # TODO 17 | -------------------------------------------------------------------------------- /work/OLD_COMPARE/facets/string/plural.rb: -------------------------------------------------------------------------------- 1 | # stub 2 | require 'facets/string/singular' 3 | -------------------------------------------------------------------------------- /work/OLD_COMPARE/facets/string/pull.rb: -------------------------------------------------------------------------------- 1 | class String 2 | # Same as #shift. 3 | def pull 4 | return '' if size == 0 5 | self[0] = '' 6 | self 7 | end 8 | end 9 | 10 | 11 | # _____ _ 12 | # |_ _|__ ___| |_ 13 | # | |/ _ \/ __| __| 14 | # | | __/\__ \ |_ 15 | # |_|\___||___/\__| 16 | # 17 | # TODO 18 | -------------------------------------------------------------------------------- /work/OLD_COMPARE/facets/string/shell_escape.rb: -------------------------------------------------------------------------------- 1 | 2 | class String 3 | 4 | # Escape special characters used in most 5 | # unix shells to use it, eg. with system(). 6 | 7 | def shell_escape 8 | self.gsub(/([\\\t\| &`<>)('"])/) { |s| '\\' << s } 9 | end 10 | 11 | end 12 | -------------------------------------------------------------------------------- /work/OLD_COMPARE/facets/string/tab.rb: -------------------------------------------------------------------------------- 1 | # stub 2 | require 'facets/string/indent' 3 | -------------------------------------------------------------------------------- /work/OLD_COMPARE/facets/string/tabto.rb: -------------------------------------------------------------------------------- 1 | # stub 2 | require 'facets/string/indent' 3 | -------------------------------------------------------------------------------- /work/OLD_COMPARE/facets/string/to_rx.rb: -------------------------------------------------------------------------------- 1 | # stub 2 | require 'facets/string/to_re' 3 | -------------------------------------------------------------------------------- /work/OLD_COMPARE/facets/string/uppercase.rb: -------------------------------------------------------------------------------- 1 | # stub 2 | require 'facets/string/upcase' 3 | -------------------------------------------------------------------------------- /work/bench/general/bench_methods.rb: -------------------------------------------------------------------------------- 1 | 2 | class ManyMethods 3 | 4 | puts "Generating methods..." 5 | 6 | (0..100000).each do |i| 7 | define_method( "_#{i}" ) { puts "Called method #{i}." } 8 | end 9 | 10 | end 11 | 12 | mm = ManyMethods.new 13 | 14 | n1 = Time.now 15 | mm._50000 16 | n2 = Time.now 17 | puts "Time to call a single method among 100000: #{(n2 - n1).to_f} seconds." 18 | -------------------------------------------------------------------------------- /work/bench/general/comment_loading/comments_none.rb: -------------------------------------------------------------------------------- 1 | a = 1 2 | -------------------------------------------------------------------------------- /work/consider/core/enumerator.rb: -------------------------------------------------------------------------------- 1 | 2 | require 'enumerator' 3 | 4 | # This could be used instead of Enumerator#x. It's more 5 | # concise, but is it safe? 6 | 7 | class Enumerable::Enumerator 8 | def method_missing(sym,*args,&blk) 9 | each{ |x| x.send(sym,*args,&blk) } 10 | end 11 | end 12 | 13 | -------------------------------------------------------------------------------- /work/consider/core/module/aliased_methods.rb: -------------------------------------------------------------------------------- 1 | class Module 2 | 3 | # 4 | def instance_method_aliases(opts={}) 5 | list = instance_methods.group_by{|m| instance_method(m)}.map(&:last) 6 | 7 | if opts[:only] 8 | list.keep_if{|symbols| symbols.length > 1} 9 | end 10 | end 11 | 12 | end 13 | -------------------------------------------------------------------------------- /work/consider/core/module/bool_accessor.rb: -------------------------------------------------------------------------------- 1 | class Module 2 | 3 | def bool_accessor(*attrs) 4 | attrs.each do |attr| 5 | attr_writer(attr) 6 | bool_reader(attr) 7 | end 8 | end 9 | 10 | def bool_reader(*attrs) 11 | attrs.each do |attr| 12 | attr_reader attr 13 | define_method("#{attr}?") do 14 | !!send(attr) 15 | end 16 | end 17 | end 18 | 19 | end 20 | -------------------------------------------------------------------------------- /work/consider/core/module/instance_class_method.rb: -------------------------------------------------------------------------------- 1 | class Module 2 | 3 | def instance_class_method(*method_names) 4 | method_names.each do |method_name| 5 | define_method(method_name) do 6 | self.class.send(method_name) 7 | end 8 | end 9 | end 10 | 11 | end 12 | -------------------------------------------------------------------------------- /work/consider/core/module/subfield_accessors.rb: -------------------------------------------------------------------------------- 1 | class Module 2 | 3 | def subfield_accessors(field, subfields) 4 | subfields.each do |subfield, index| 5 | define_method(subfield) do 6 | self.send(field)[index] 7 | end 8 | 9 | define_method("#{subfield}=") do |value| 10 | self.send(field)[index] = value 11 | end 12 | end 13 | end 14 | 15 | end 16 | -------------------------------------------------------------------------------- /work/consider/core/object/class_def.rb: -------------------------------------------------------------------------------- 1 | class Object 2 | 3 | # Defines an instance method within a class. 4 | def class_def name, &blk 5 | class_eval { define_method name, &blk } 6 | end 7 | 8 | end 9 | 10 | -------------------------------------------------------------------------------- /work/consider/standard/math/algebra.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rubyworks/facets/12326d4767bd109bdf5f9fa3582797bd88c36d30/work/consider/standard/math/algebra.rb -------------------------------------------------------------------------------- /work/consider/standard/math/finance.rb: -------------------------------------------------------------------------------- 1 | module Math #:nodoc: 2 | 3 | # TODO 4 | module Finance 5 | 6 | end 7 | 8 | include Finance 9 | extend Finance 10 | end 11 | 12 | -------------------------------------------------------------------------------- /work/reference/tmatrix.rb: -------------------------------------------------------------------------------- 1 | require 'matrix.rb' 2 | 3 | class StickMatrix < Matrix 4 | end 5 | 6 | sm = StickMatrix[[0,1,0]] 7 | cl = sm.clone 8 | p cl.class 9 | 10 | -------------------------------------------------------------------------------- /work/rejected/hash/op_div.rb: -------------------------------------------------------------------------------- 1 | class Hash 2 | 3 | # Use division operator as a fetch notation. 4 | # 5 | # h = {:a=>1} 6 | # h/:a #=> 1 7 | 8 | alias_method :/, :[] 9 | 10 | end 11 | 12 | -------------------------------------------------------------------------------- /work/rejected/module/module_method.rb: -------------------------------------------------------------------------------- 1 | class Module 2 | 3 | # Like module_function but makes the instance method 4 | # public rather than private. 5 | # 6 | # NOTE: This does not work as a sectional modifier. 7 | 8 | def module_method(*meth) 9 | module_function(*meth) 10 | public(*meth) 11 | end 12 | 13 | end 14 | 15 | -------------------------------------------------------------------------------- /work/rejected/test_continuation.rb: -------------------------------------------------------------------------------- 1 | require 'facets/continuation' 2 | require 'test/unit' 3 | 4 | if defined?(Continuation) 5 | 6 | class TC_Continuation < Test::Unit::TestCase 7 | 8 | def test_create 9 | assert_nothing_raised { c, r = Continuation.create } 10 | end 11 | 12 | end 13 | 14 | end 15 | 16 | -------------------------------------------------------------------------------- /work/sandbox/safe-study/safe_extension.rb: -------------------------------------------------------------------------------- 1 | require 'facets/module/module_require' 2 | 3 | module StringExtensions 4 | end 5 | 6 | printer = "hello world" 7 | 8 | StringExtensions::String = class << printer; self; end 9 | 10 | module StringExtensions 11 | module_require '~/ruby/facets/trunk/lib/core/ext/facets/string/titlecase.rb' 12 | end 13 | 14 | #printer.extend StringExtensions 15 | 16 | puts printer.titlecase 17 | 18 | -------------------------------------------------------------------------------- /work/sandbox/safe-study/safe_study.rb: -------------------------------------------------------------------------------- 1 | 2 | class X 3 | def yo=x; @yo=x; end 4 | end 5 | 6 | class Y 7 | def yo!; puts @yo; end 8 | end 9 | 10 | x = X.new 11 | 12 | class << x; Y.instance_methods.each {|m| define_method m, Y.instance_method(m)}; end 13 | 14 | x.yo = "Hello World" 15 | x.yo! 16 | 17 | -------------------------------------------------------------------------------- /work/site/posts/tomslib.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rubyworks/facets/12326d4767bd109bdf5f9fa3582797bd88c36d30/work/site/posts/tomslib.rb -------------------------------------------------------------------------------- /work/trash/site-jekyll/.htaccess: -------------------------------------------------------------------------------- 1 | DirectoryIndex index.html 2 | -------------------------------------------------------------------------------- /work/trash/site-jekyll/.rsync-filter: -------------------------------------------------------------------------------- 1 | - .svn 2 | P usage 3 | P statcvs 4 | P statsvn 5 | P robot.txt 6 | P robots.txt 7 | P wiki 8 | -------------------------------------------------------------------------------- /work/trash/site-jekyll/.till: -------------------------------------------------------------------------------- 1 | sh "jekyll . ../../doc/" 2 | -------------------------------------------------------------------------------- /work/trash/site-jekyll/_config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | source : . 3 | destination : output-sample 4 | markdown : rdiscount 5 | pygments : true 6 | url : http://rubyworks.github.com/facets 7 | -------------------------------------------------------------------------------- /work/trash/site-jekyll/assets/scripts/hover.js: -------------------------------------------------------------------------------- 1 | 2 | function hover(thisElem, imgName) { 3 | ro = document.getElementById('hover'); 4 | ro.posX = thisElem.posX; 5 | ro.posY = thisElem.posY; 6 | alert(thisElem.posX); 7 | roi = document.getElementById('hover_img'); 8 | roi.src = imgName; 9 | } 10 | 11 | function unhover() { 12 | ro = document.getElementById('hover'); 13 | ro.style.left = "-200px" 14 | } 15 | -------------------------------------------------------------------------------- /work/trash/site/.htaccess: -------------------------------------------------------------------------------- 1 | DirectoryIndex index.xml 2 | -------------------------------------------------------------------------------- /work/trash/site/.rsync-filter: -------------------------------------------------------------------------------- 1 | - .svn 2 | - apiwiki 3 | - sitemap.yaml 4 | - scrap 5 | P wiki 6 | P robot.txt 7 | P statcvs 8 | P statsvn 9 | P usage 10 | 11 | -------------------------------------------------------------------------------- /work/trash/site/js/hover.js: -------------------------------------------------------------------------------- 1 | 2 | function hover(thisElem, imgName) { 3 | ro = document.getElementById('hover'); 4 | ro.posX = thisElem.posX; 5 | ro.posY = thisElem.posY; 6 | alert(thisElem.posX); 7 | roi = document.getElementById('hover_img'); 8 | roi.src = imgName; 9 | } 10 | 11 | function unhover() { 12 | ro = document.getElementById('hover'); 13 | ro.style.left = "-200px" 14 | } 15 | --------------------------------------------------------------------------------