facets 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +6 -0
- data/NOTES +14 -1
- data/Rakefile +26 -0
- data/demo/bench/general/bench_calls.rb +74 -0
- data/demo/bench/general/bench_includes.rb +25 -0
- data/demo/bench/general/bench_methods.rb +17 -0
- data/demo/bench/general/bench_pathname.rb +24 -0
- data/demo/bench/general/bench_range.rb +64 -0
- data/demo/bench/general/bench_return.rb +56 -0
- data/demo/bench/general/bench_yeild.rb +75 -0
- data/lib/{more → class}/facets/association.rb +0 -0
- data/lib/{more → class}/facets/autoarray.rb +0 -0
- data/lib/{more → class}/facets/basicobject.rb +0 -0
- data/lib/{more → class}/facets/buildingblock.rb +0 -44
- data/lib/{more → class}/facets/cachedelegator.rb +3 -0
- data/lib/{more → class}/facets/coroutine.rb +0 -56
- data/lib/{more → class}/facets/dictionary.rb +0 -0
- data/lib/{more → class}/facets/downloader.rb +0 -0
- data/lib/{more → class}/facets/filelist.rb +0 -0
- data/lib/{more → class}/facets/fileshell.rb +0 -0
- data/lib/{more → class}/facets/hashbuilder.rb +0 -0
- data/lib/{more → class}/facets/heap.rb +0 -0
- data/lib/{more → class}/facets/infinity.rb +0 -46
- data/lib/{more → class}/facets/interval.rb +0 -0
- data/lib/{more → class}/facets/ioredirect.rb +0 -0
- data/lib/{more → class}/facets/linkedlist.rb +0 -42
- data/lib/{more → class}/facets/lrucache.rb +0 -23
- data/lib/{more → class}/facets/minitar.rb +0 -0
- data/lib/{more → class}/facets/nackclass.rb +0 -0
- data/lib/{more → class}/facets/nullclass.rb +0 -0
- data/lib/{more → class}/facets/opencascade.rb +0 -70
- data/lib/{more → class}/facets/opencollection.rb +0 -0
- data/lib/class/facets/openhash.rb +41 -0
- data/lib/{more → class}/facets/openobject.rb +0 -121
- data/lib/{more → class}/facets/orderedhash.rb +0 -0
- data/lib/{more → class}/facets/pathlist.rb +0 -0
- data/lib/{more → class}/facets/pool.rb +0 -0
- data/lib/{more → class}/facets/pqueue.rb +0 -0
- data/lib/{more → class}/facets/progressbar.rb +0 -0
- data/lib/{more → class}/facets/recorder.rb +0 -40
- data/lib/{more → class}/facets/reference.rb +0 -0
- data/lib/{more → class}/facets/rwdelegator.rb +0 -0
- data/lib/{more → class}/facets/semaphore.rb +0 -0
- data/lib/{more → class}/facets/syncarray.rb +0 -24
- data/lib/{more → class}/facets/synchash.rb +1 -25
- data/lib/{more → class}/facets/timer.rb +0 -62
- data/lib/{more → class}/facets/tuple.rb +0 -60
- data/lib/{more → class}/facets/version.rb +0 -0
- data/lib/core/facets/dir/multiglob.rb +20 -5
- data/lib/core/facets/enumerable/cartesian.rb +2 -2
- data/lib/core/facets/enumerable/combination.rb +9 -1
- data/lib/core/facets/kernel/object.rb +1 -1
- data/lib/{more → mixin}/facets/binreadable.rb +0 -62
- data/lib/{more → mixin}/facets/buildable.rb +0 -48
- data/lib/mixin/facets/cloneable.rb +90 -0
- data/lib/{more → mixin}/facets/enumerablepass.rb +0 -81
- data/lib/{more → mixin}/facets/expirable.rb +0 -0
- data/lib/{more → mixin}/facets/fileable.rb +0 -0
- data/lib/{more → mixin}/facets/instantiable.rb +0 -30
- data/lib/{more → mixin}/facets/multiton.rb +0 -0
- data/lib/{more → mixin}/facets/registerable.rb +0 -0
- data/lib/mixin/facets/tasksystem.rb +350 -0
- data/lib/{more → mixin}/facets/uninheritable.rb +1 -39
- data/lib/{more → mixin}/facets/validation.rb +0 -0
- data/lib/more/facets/arguments.rb +0 -66
- data/lib/more/facets/attributes.rb +0 -35
- data/lib/more/facets/bbcode.rb +1 -31
- data/lib/more/facets/bytes.rb +0 -80
- data/lib/more/facets/class_extension.rb +0 -66
- data/lib/more/facets/classmethods.rb +0 -64
- data/lib/more/facets/compare_on.rb +0 -52
- data/lib/more/facets/curry.rb +0 -29
- data/lib/more/facets/cut.rb +0 -27
- data/lib/more/facets/date.rb +0 -54
- data/lib/more/facets/dependency.rb +0 -70
- data/lib/more/facets/elementor.rb +0 -67
- data/lib/more/facets/getoptlong.rb +0 -30
- data/lib/more/facets/{hash_keyize.rb → hash/keyize.rb} +0 -0
- data/lib/more/facets/inheritor.rb +0 -150
- data/lib/more/facets/instantise.rb +0 -41
- data/lib/more/facets/let.rb +0 -20
- data/lib/more/facets/memoize.rb +0 -45
- data/lib/more/facets/multipliers.rb +0 -110
- data/lib/more/facets/ostruct.rb +0 -124
- data/lib/more/facets/random.rb +0 -153
- data/lib/more/facets/rbconfig.rb +55 -0
- data/lib/more/facets/set.rb +27 -0
- data/lib/more/facets/snapshot.rb +0 -30
- data/lib/more/facets/stylize.rb +0 -147
- data/lib/more/facets/times.rb +0 -98
- data/lib/more/facets/tracepoint.rb +194 -0
- data/lib/more/facets/typecast.rb +0 -63
- data/lib/more/facets/ziputils.rb +7 -0
- data/log/Changelog-0.txt +239 -0
- data/log/Changelog-1.txt +450 -0
- data/log/Changelog.txt +841 -0
- data/log/Fixme.txt +18 -0
- data/log/Testlog.txt +188 -0
- data/log/Todo.txt +326 -0
- data/meta/MANIFEST +1 -1
- data/meta/VERSION +1 -0
- data/meta/authors +48 -0
- data/meta/description +8 -0
- data/meta/project.yaml +11 -5
- data/task/install +4 -2
- data/task/rdoc +5 -0
- data/task/test +40 -0
- data/test/{unit → class}/test_association.rb +0 -0
- data/test/{unit → class}/test_autoarray.rb +0 -0
- data/test/{unit → class}/test_basicobject.rb +0 -0
- data/test/{unit → class}/test_buildingblock.rb +1 -0
- data/test/{unit → class}/test_coroutine.rb +0 -0
- data/test/{unit → class}/test_dictionary.rb +0 -0
- data/test/{unit → class}/test_infinity.rb +0 -0
- data/test/{unit → class}/test_interval.rb +0 -0
- data/test/{unit → class}/test_linkedlist.rb +1 -1
- data/test/{unit → class}/test_lrucache.rb +3 -0
- data/test/{unit → class}/test_opencascade.rb +0 -0
- data/test/{unit → class}/test_openobject.rb +0 -0
- data/test/{unit → class}/test_recorder.rb +0 -1
- data/test/{unit → class}/test_syncarray.rb +2 -4
- data/test/{unit → class}/test_synchash.rb +2 -4
- data/test/{unit → class}/test_timer.rb +0 -1
- data/test/{unit → class}/test_tuple.rb +0 -0
- data/test/{unit → core}/array/test_delete.rb +0 -0
- data/test/{unit → core}/array/test_indexable.rb +0 -0
- data/test/{unit → core}/array/test_merge.rb +0 -0
- data/test/{unit → core}/array/test_only.rb +0 -0
- data/test/{unit → core}/array/test_pad.rb +0 -0
- data/test/{unit → core}/array/test_rotate.rb +0 -0
- data/test/{unit → core}/array/test_select.rb +0 -0
- data/test/{unit → core}/array/test_stackable.rb +0 -0
- data/test/{unit/binding/test_cflow.rb → core/binding/test_caller.rb} +2 -2
- data/test/{unit → core}/binding/test_defined.rb +0 -0
- data/test/{unit → core}/binding/test_eval.rb +0 -0
- data/test/{unit → core}/binding/test_here.rb +0 -0
- data/test/{unit → core}/binding/test_self.rb +0 -0
- data/test/{unit → core}/binding/test_vars.rb +0 -0
- data/test/{unit → core}/class/test_descendents.rb +0 -0
- data/test/{unit → core}/class/test_initializer.rb +0 -0
- data/test/{unit → core}/class/test_remove_descendents.rb +0 -0
- data/test/{unit → core}/comparable/test_bound.rb +0 -0
- data/test/{unit → core}/comparable/test_cmp.rb +0 -0
- data/test/{unit → core}/dir/test_parent.rb +0 -0
- data/test/{unit → core}/dir/test_recurse.rb +0 -0
- data/test/{unit → core}/dir/test_traverse.rb +0 -0
- data/test/{unit → core}/enumerable/test_cartesian.rb +0 -0
- data/test/{unit → core}/enumerable/test_collect.rb +0 -0
- data/test/{unit → core}/enumerable/test_combination.rb +0 -0
- data/test/{unit → core}/enumerable/test_count.rb +0 -0
- data/test/{unit → core}/enumerable/test_each.rb +0 -0
- data/test/{unit → core}/enumerable/test_mash.rb +0 -0
- data/test/{unit → core}/enumerable/test_permutation.rb +0 -0
- data/test/{unit → core}/enumerable/test_probability.rb +0 -0
- data/test/{unit → core}/enumerable/test_split.rb +0 -0
- data/test/{unit → core}/exception/test_detail.rb +0 -0
- data/test/{unit → core}/file/test_null.rb +0 -0
- data/test/{unit → core}/file/test_read.rb +0 -0
- data/test/{unit → core}/file/test_sanitize.rb +0 -0
- data/test/{unit → core}/file/test_split_all.rb +0 -0
- data/test/{unit → core}/file/test_write.rb +0 -0
- data/test/{unit → core}/filetest/test_root.rb +0 -0
- data/test/{unit → core}/hash/test_alias.rb +0 -0
- data/test/{unit → core}/hash/test_at.rb +0 -0
- data/test/{unit → core}/hash/test_autonew.rb +0 -0
- data/test/core/hash/test_collate.rb +33 -0
- data/test/{unit → core}/hash/test_delete.rb +0 -0
- data/test/{unit → core}/hash/test_each_with_key.rb +0 -0
- data/test/{unit → core}/hash/test_has_keys.rb +0 -0
- data/test/{unit → core}/hash/test_insert.rb +0 -0
- data/test/{unit → core}/hash/test_inverse.rb +0 -0
- data/test/{unit → core}/hash/test_op.rb +0 -0
- data/test/{unit → core}/hash/test_rekey.rb +0 -0
- data/test/{unit → core}/hash/test_reverse_merge.rb +0 -0
- data/test/{unit → core}/hash/test_select.rb +0 -0
- data/test/{unit → core}/hash/test_swap.rb +0 -0
- data/test/{unit → core}/hash/test_traverse.rb +0 -0
- data/test/{unit → core}/hash/test_update.rb +0 -0
- data/test/{unit → core}/hash/test_weave.rb +0 -0
- data/test/{unit → core}/hash/test_zipnew.rb +0 -0
- data/test/{unit → core}/integer/test_bitmask.rb +0 -0
- data/test/{unit → core}/integer/test_factorial.rb +0 -0
- data/test/{unit → core}/integer/test_multiple.rb +0 -0
- data/test/{unit → core}/integer/test_of.rb +0 -0
- data/test/{unit → core}/kernel/test_callstack.rb +0 -0
- data/test/{unit → core}/kernel/test_constant.rb +0 -0
- data/test/{unit → core}/kernel/test_deepcopy.rb +0 -0
- data/test/{unit → core}/kernel/test_instance.rb +0 -0
- data/test/{unit → core}/kernel/test_metaid.rb +0 -0
- data/test/{unit → core}/kernel/test_object.rb +1 -1
- data/test/{unit → core}/kernel/test_populate.rb +0 -0
- data/test/{unit → core}/kernel/test_report.rb +0 -0
- data/test/{unit → core}/kernel/test_returning.rb +0 -0
- data/test/{unit → core}/kernel/test_silence.rb +0 -0
- data/test/{unit → core}/kernel/test_super.rb +0 -0
- data/test/{unit → core}/kernel/test_tap.rb +0 -0
- data/test/{unit → core}/kernel/test_val.rb +0 -0
- data/test/{unit → core}/kernel/test_withattr.rb +0 -0
- data/test/{unit → core}/matchdata/test_match.rb +0 -0
- data/test/{unit → core}/matchdata/test_matchset.rb +0 -0
- data/test/{unit → core}/module/test_abstract.rb +0 -0
- data/test/{unit → core}/module/test_alias.rb +0 -0
- data/test/{unit → core}/module/test_cattr.rb +0 -0
- data/test/{unit → core}/module/test_clone.rb +0 -0
- data/test/{unit → core}/module/test_include.rb +0 -0
- data/test/{unit → core}/module/test_modify.rb +0 -0
- data/test/{unit → core}/module/test_name.rb +0 -0
- data/test/{unit → core}/module/test_traits.rb +0 -0
- data/test/{unit → core}/numeric/test_round.rb +0 -0
- data/test/{unit → core}/proc/test_bind.rb +0 -0
- data/test/{unit → core}/proc/test_compose.rb +0 -0
- data/test/{unit → core}/range/test_combine.rb +0 -0
- data/test/{unit → core}/range/test_overlap.rb +0 -0
- data/test/{unit → core}/regexp/test_arity.rb +0 -0
- data/test/{unit → core}/string/test_align.rb +0 -0
- data/test/{unit → core}/string/test_blank.rb +0 -0
- data/test/{unit → core}/string/test_bracket.rb +0 -0
- data/test/{unit → core}/string/test_case.rb +0 -0
- data/test/{unit → core}/string/test_crypt.rb +0 -0
- data/test/{unit → core}/string/test_filter.rb +0 -0
- data/test/{unit → core}/string/test_indexable.rb +0 -0
- data/test/{unit → core}/string/test_interpolate.rb +0 -0
- data/test/{unit → core}/string/test_natcmp.rb +0 -0
- data/test/{unit → core}/string/test_nchar.rb +0 -0
- data/test/{unit → core}/string/test_op.rb +0 -0
- data/test/{unit → core}/string/test_partitions.rb +0 -0
- data/test/{unit → core}/string/test_range.rb +0 -0
- data/test/{unit → core}/string/test_regesc.rb +0 -0
- data/test/{unit → core}/string/test_scan.rb +0 -0
- data/test/{unit → core}/string/test_stackable.rb +0 -0
- data/test/{unit → core}/string/test_tabs.rb +0 -0
- data/test/{unit → core}/string/test_wrap.rb +0 -0
- data/test/{unit → core}/symbol/test_chomp.rb +0 -0
- data/test/{unit → core}/symbol/test_generate.rb +0 -0
- data/test/{unit → core}/symbol/test_not.rb +0 -0
- data/test/{unit → core}/symbol/test_shadow.rb +0 -0
- data/test/{unit → core}/symbol/test_succ.rb +0 -0
- data/test/{unit → core}/symbol/test_to_proc.rb +0 -0
- data/test/{unit → core}/test_1stclassmethod.rb +0 -0
- data/test/{unit → core}/test_boolean.rb +0 -0
- data/test/{unit → core}/test_conversion.rb +0 -0
- data/test/{unit → core}/test_functor.rb +0 -0
- data/test/{unit → core}/time/test_change.rb +0 -0
- data/test/{unit → core}/time/test_elapse.rb +0 -0
- data/test/{unit → core}/time/test_stamp.rb +0 -0
- data/test/{unit → mixin}/test_binreadable.rb +0 -0
- data/test/{unit → mixin}/test_buildable.rb +1 -0
- data/test/mixin/test_cloneable.rb +41 -0
- data/test/{unit → mixin}/test_enumerablepass.rb +0 -0
- data/test/{unit → mixin}/test_instantiable.rb +2 -1
- data/test/{unit → mixin}/test_multiton.rb +0 -0
- data/test/{unit → mixin}/test_uninheritable.rb +1 -2
- data/test/{unit → more/hash}/test_keyize.rb +1 -1
- data/test/{unit → more}/test_advice.rb +0 -0
- data/test/{unit → more}/test_annotations.rb +0 -0
- data/test/{unit → more}/test_ansicode.rb +0 -0
- data/test/{unit → more}/test_aop.rb +0 -0
- data/test/{unit → more}/test_arguments.rb +1 -0
- data/test/{unit → more}/test_attributes.rb +2 -2
- data/test/{unit → more}/test_bbcode.rb +1 -0
- data/test/{unit → more}/test_bytes.rb +1 -0
- data/test/{unit → more}/test_class_extension.rb +2 -1
- data/test/{unit → more}/test_classmethods.rb +2 -1
- data/test/{unit → more}/test_compare_on.rb +0 -1
- data/test/{unit → more}/test_continuation.rb +0 -0
- data/test/{unit → more}/test_crypt.rb +0 -0
- data/test/{unit → more}/test_curry.rb +1 -0
- data/test/{unit → more}/test_cut.rb +2 -1
- data/test/{unit → more}/test_date.rb +1 -1
- data/test/{unit → more}/test_dependency.rb +2 -2
- data/test/{unit → more}/test_elementor.rb +1 -1
- data/test/{unit → more}/test_getoptlong.rb +1 -0
- data/test/{unit → more}/test_inheritor.rb +1 -1
- data/test/{unit → more}/test_instantise.rb +2 -1
- data/test/{unit → more}/test_interface.rb +0 -0
- data/test/{unit → more}/test_let.rb +0 -1
- data/test/{unit → more}/test_memoize.rb +2 -3
- data/test/{unit → more}/test_multipliers.rb +1 -1
- data/test/{unit → more}/test_namespace.rb +0 -0
- data/test/{unit → more}/test_ostruct.rb +0 -0
- data/test/{unit → more}/test_overload.rb +0 -0
- data/test/{unit → more}/test_paramix.rb +0 -0
- data/test/{unit → more}/test_prototype.rb +0 -0
- data/test/more/test_random.rb +146 -0
- data/test/{unit → more}/test_snapshot.rb +0 -3
- data/test/{unit → more}/test_stylize.rb +1 -2
- data/test/{unit → more}/test_thread.rb +0 -0
- data/test/{unit → more}/test_times.rb +2 -2
- data/test/{unit → more}/test_typecast.rb +0 -3
- metadata +1117 -1098
- data/lib/more/facets/cloneable.rb +0 -75
- data/log/changelog.txt +0 -0
- data/meta/facets.roll +0 -4
- data/meta/google_ad.html +0 -15
- data/meta/icli.yaml +0 -17
- data/task/changes +0 -29
- data/task/clean +0 -17
- data/task/clobber/package +0 -10
- data/task/log +0 -17
- data/task/prepare +0 -7
- data/task/publish +0 -43
- data/task/release +0 -10
- data/task/stamp +0 -33
- data/task/stats +0 -138
- data/task/test/cross +0 -309
- data/task/test/each +0 -42
- data/task/test/load +0 -30
- data/task/test/pairs +0 -50
- data/task/test/solo +0 -294
- data/task/test/syntax +0 -31
- data/task/test/whole +0 -34
- data/test/unit/hash/test_collate.rb +0 -31
- data/test/unit/test_random.rb +0 -149
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# TITLE:
|
|
2
|
+
#
|
|
3
|
+
# Ruby Configuration
|
|
4
|
+
#
|
|
5
|
+
# SUMMARY:
|
|
6
|
+
#
|
|
7
|
+
# An extended rendition of the Ruby's standard Config module.
|
|
8
|
+
#
|
|
9
|
+
# COPYRIGHT:
|
|
10
|
+
#
|
|
11
|
+
# Copyright (c) 2006 Thomas Sawyer
|
|
12
|
+
#
|
|
13
|
+
# LICENSE:
|
|
14
|
+
#
|
|
15
|
+
# Ruby License
|
|
16
|
+
#
|
|
17
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
|
18
|
+
# software under the same terms as Ruby.
|
|
19
|
+
#
|
|
20
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
21
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
22
|
+
# FOR A PARTICULAR PURPOSE.
|
|
23
|
+
#
|
|
24
|
+
# AUTHORS:
|
|
25
|
+
#
|
|
26
|
+
# - Thomas Sawyer
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
require 'rbconfig'
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# = Config
|
|
33
|
+
#
|
|
34
|
+
module Config
|
|
35
|
+
|
|
36
|
+
def self.inspect
|
|
37
|
+
CONFIG.inspect
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# In case rubygems has already defined it.
|
|
41
|
+
unless self.respond_to?(:datadir)
|
|
42
|
+
# Return the path to the data directory associated with the
|
|
43
|
+
# given library/package name. Normally this is just
|
|
44
|
+
#
|
|
45
|
+
# "#{Config::CONFIG['datadir']}/#{name}"
|
|
46
|
+
#
|
|
47
|
+
# but may be modified by tools like RubyGems to handle
|
|
48
|
+
# versioned data directories.
|
|
49
|
+
|
|
50
|
+
def self.datadir(package_name)
|
|
51
|
+
File.join(CONFIG['datadir'], package_name)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'set'
|
|
2
|
+
|
|
3
|
+
class Set
|
|
4
|
+
def power_set
|
|
5
|
+
if empty?
|
|
6
|
+
Set[ self ]
|
|
7
|
+
else
|
|
8
|
+
any_value = [to_a.first]
|
|
9
|
+
subsubs = (self - any_value).power_set
|
|
10
|
+
subsubs + subsubs.map{ |subset| subset + any_value }
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class Array
|
|
16
|
+
def power_set
|
|
17
|
+
if empty?
|
|
18
|
+
[self]
|
|
19
|
+
else
|
|
20
|
+
subset = dup
|
|
21
|
+
value = [ subset.pop ]
|
|
22
|
+
subsubs = subset.power_set
|
|
23
|
+
subsubs.concat( subsubs.map{ |subset| subset + value } )
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
data/lib/more/facets/snapshot.rb
CHANGED
|
@@ -181,33 +181,3 @@ class Struct
|
|
|
181
181
|
end
|
|
182
182
|
end
|
|
183
183
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
# _____ _
|
|
187
|
-
# |_ _|__ ___| |_
|
|
188
|
-
# | |/ _ \/ __| __|
|
|
189
|
-
# | | __/\__ \ |_
|
|
190
|
-
# |_|\___||___/\__|
|
|
191
|
-
#
|
|
192
|
-
|
|
193
|
-
=begin testing
|
|
194
|
-
|
|
195
|
-
require 'test/unit'
|
|
196
|
-
|
|
197
|
-
class TestSnapshot < Test::Unit::TestCase
|
|
198
|
-
|
|
199
|
-
def setup
|
|
200
|
-
customer = Struct.new(:name, :address, :zip)
|
|
201
|
-
joe = customer.new( "Joe Pitare", "1115 Lila Ln.", 47634 )
|
|
202
|
-
@joe_snap = joe.take_snapshot
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
def test_storage
|
|
206
|
-
assert_equal( "Joe Pitare", @joe_snap[:name] )
|
|
207
|
-
assert_equal( "1115 Lila Ln.", @joe_snap[:address] )
|
|
208
|
-
assert_equal( 47634, @joe_snap[:zip] )
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
=end
|
data/lib/more/facets/stylize.rb
CHANGED
|
@@ -211,150 +211,3 @@ class Integer
|
|
|
211
211
|
include Style
|
|
212
212
|
end
|
|
213
213
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
# _____ _
|
|
217
|
-
# |_ _|__ ___| |_
|
|
218
|
-
# | |/ _ \/ __| __|
|
|
219
|
-
# | | __/\__ \ |_
|
|
220
|
-
# |_|\___||___/\__|
|
|
221
|
-
#
|
|
222
|
-
=begin test
|
|
223
|
-
|
|
224
|
-
require 'test/unit'
|
|
225
|
-
|
|
226
|
-
class TestInflect < Test::Unit::TestCase
|
|
227
|
-
|
|
228
|
-
def test_basename_01
|
|
229
|
-
assert_equal( "Unit", "Test::Unit".basename )
|
|
230
|
-
end
|
|
231
|
-
|
|
232
|
-
def test_basename_02
|
|
233
|
-
a = "Down::Bottom"
|
|
234
|
-
assert_raises( ArgumentError ) { a.basename(1) }
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
def test_basename_03
|
|
238
|
-
a = "Down::Bottom"
|
|
239
|
-
assert_equal( "Bottom", a.basename )
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
def test_basename_04
|
|
243
|
-
b = "Further::Down::Bottom"
|
|
244
|
-
assert_equal( "Bottom", b.basename )
|
|
245
|
-
end
|
|
246
|
-
|
|
247
|
-
def test_camelize
|
|
248
|
-
assert_equal( 'ThisIsIt', 'this_is_it'.camelize )
|
|
249
|
-
end
|
|
250
|
-
|
|
251
|
-
def test_camelcase
|
|
252
|
-
assert_equal( "abcXyz", "abc_xyz".camelcase )
|
|
253
|
-
assert_equal( "abcXyz", "abc xyz".camelcase )
|
|
254
|
-
assert_equal( "abcXyz", "abc xyz".camelcase )
|
|
255
|
-
assert_equal( "abcXyz", "abc\txyz".camelcase )
|
|
256
|
-
assert_equal( "abcXyz", "abc\nxyz".camelcase )
|
|
257
|
-
assert_equal( "abcXyz", "abc____xyz".camelcase )
|
|
258
|
-
end
|
|
259
|
-
|
|
260
|
-
def test_camelcase_true
|
|
261
|
-
assert_equal( "AbcXyz", "abc_xyz".camelcase(true) )
|
|
262
|
-
assert_equal( "AbcXyz", "abc xyz".camelcase(true) )
|
|
263
|
-
assert_equal( "AbcXyz", "abc xyz".camelcase(true) )
|
|
264
|
-
assert_equal( "AbcXyz", "abc\txyz".camelcase(true) )
|
|
265
|
-
assert_equal( "AbcXyz", "abc\nxyz".camelcase(true) )
|
|
266
|
-
end
|
|
267
|
-
|
|
268
|
-
def test_humanize
|
|
269
|
-
assert_equal( 'This is it', 'this_is_it'.humanize )
|
|
270
|
-
end
|
|
271
|
-
|
|
272
|
-
def test_title
|
|
273
|
-
r = "try this out".title
|
|
274
|
-
x = "Try This Out"
|
|
275
|
-
assert_equal(x,r)
|
|
276
|
-
end
|
|
277
|
-
|
|
278
|
-
def test_demodulize_01
|
|
279
|
-
a = "Down::Bottom"
|
|
280
|
-
assert_raises( ArgumentError ) { a.demodulize(1) }
|
|
281
|
-
end
|
|
282
|
-
|
|
283
|
-
def test_demodulize_02
|
|
284
|
-
a = "Down::Bottom"
|
|
285
|
-
assert_equal( "Bottom", a.demodulize )
|
|
286
|
-
end
|
|
287
|
-
|
|
288
|
-
def test_demodulize_03
|
|
289
|
-
b = "Further::Down::Bottom"
|
|
290
|
-
assert_equal( "Bottom", b.demodulize )
|
|
291
|
-
end
|
|
292
|
-
|
|
293
|
-
def test_demodulize_01
|
|
294
|
-
a = "Down::Bottom"
|
|
295
|
-
assert_raises( ArgumentError ) { a.demodulize(1) }
|
|
296
|
-
end
|
|
297
|
-
|
|
298
|
-
def test_demodulize_02
|
|
299
|
-
a = "Down::Bottom"
|
|
300
|
-
assert_equal( "Bottom", a.demodulize )
|
|
301
|
-
end
|
|
302
|
-
|
|
303
|
-
def test_demodulize_03
|
|
304
|
-
b = "Further::Down::Bottom"
|
|
305
|
-
assert_equal( "Bottom", b.demodulize )
|
|
306
|
-
end
|
|
307
|
-
|
|
308
|
-
def test_methodize
|
|
309
|
-
assert_equal( 'hello_world', 'HelloWorld'.methodize )
|
|
310
|
-
assert_equal( '__unix_path', '/unix_path'.methodize )
|
|
311
|
-
end
|
|
312
|
-
|
|
313
|
-
def test_modulize
|
|
314
|
-
assert_equal( 'MyModule::MyClass', 'my_module__my_class'.modulize )
|
|
315
|
-
assert_equal( '::MyModule::MyClass', '__my_module__my_class'.modulize )
|
|
316
|
-
assert_equal( 'MyModule::MyClass', 'my_module/my_class'.modulize )
|
|
317
|
-
assert_equal( '::MyModule::MyClass', '/my_module/my_class'.modulize )
|
|
318
|
-
end
|
|
319
|
-
|
|
320
|
-
def test_pathize
|
|
321
|
-
assert_equal( 'my_module/my_class', 'MyModule::MyClass'.pathize )
|
|
322
|
-
assert_equal( 'u_r_i', 'URI'.pathize )
|
|
323
|
-
assert_equal( '/my_class', '::MyClass'.pathize )
|
|
324
|
-
assert_equal( '/my_module/my_class/', '/my_module/my_class/'.pathize )
|
|
325
|
-
end
|
|
326
|
-
|
|
327
|
-
end
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
class TestClassInflect < Test::Unit::TestCase
|
|
331
|
-
|
|
332
|
-
def test_method_name
|
|
333
|
-
assert_equal( Test::Unit::TestCase.methodize, 'test__unit__test_case' )
|
|
334
|
-
end
|
|
335
|
-
|
|
336
|
-
def test_method_name
|
|
337
|
-
assert_equal( Test::Unit::TestCase.pathize, '/test/unit/test_case' )
|
|
338
|
-
end
|
|
339
|
-
|
|
340
|
-
end
|
|
341
|
-
|
|
342
|
-
class TestIntegerInflect < Test::Unit::TestCase
|
|
343
|
-
|
|
344
|
-
def test_ordinalize
|
|
345
|
-
assert_equal( '1st', '1'.ordinalize )
|
|
346
|
-
assert_equal( '2nd', '2'.ordinalize )
|
|
347
|
-
assert_equal( '3rd', '3'.ordinalize )
|
|
348
|
-
assert_equal( '4th', '4'.ordinalize )
|
|
349
|
-
end
|
|
350
|
-
|
|
351
|
-
def test_ordinal
|
|
352
|
-
assert_equal( '1st', 1.ordinal )
|
|
353
|
-
assert_equal( '2nd', 2.ordinal )
|
|
354
|
-
assert_equal( '3rd', 3.ordinal )
|
|
355
|
-
assert_equal( '4th', 4.ordinal )
|
|
356
|
-
end
|
|
357
|
-
|
|
358
|
-
end
|
|
359
|
-
|
|
360
|
-
=end
|
data/lib/more/facets/times.rb
CHANGED
|
@@ -344,101 +344,3 @@ class Time
|
|
|
344
344
|
end
|
|
345
345
|
end
|
|
346
346
|
|
|
347
|
-
|
|
348
|
-
# _____ _
|
|
349
|
-
# |_ _|__ ___| |_
|
|
350
|
-
# | |/ _ \/ __| __|
|
|
351
|
-
# | | __/\__ \ |_
|
|
352
|
-
# |_|\___||___/\__|
|
|
353
|
-
#
|
|
354
|
-
|
|
355
|
-
=begin testing
|
|
356
|
-
|
|
357
|
-
require 'test/unit'
|
|
358
|
-
#require 'mega/multiplier'
|
|
359
|
-
|
|
360
|
-
class NumericTest < Test::Unit::TestCase
|
|
361
|
-
|
|
362
|
-
#def test_micro_seconds
|
|
363
|
-
# assert_equal( 0.000001, 1.microsecond )
|
|
364
|
-
#end
|
|
365
|
-
|
|
366
|
-
#def test_milli_seconds
|
|
367
|
-
# assert_equal( 0.001, 1.millisecond )
|
|
368
|
-
#end
|
|
369
|
-
|
|
370
|
-
def test_seconds
|
|
371
|
-
assert_equal( 60**0, 1.seconds )
|
|
372
|
-
end
|
|
373
|
-
|
|
374
|
-
def test_minutes
|
|
375
|
-
assert_equal( 60**1, 1.minutes )
|
|
376
|
-
end
|
|
377
|
-
|
|
378
|
-
def test_hours
|
|
379
|
-
assert_equal( 60**2, 1.hours )
|
|
380
|
-
end
|
|
381
|
-
|
|
382
|
-
def test_days
|
|
383
|
-
assert_equal( 24*(60**2), 1.days )
|
|
384
|
-
end
|
|
385
|
-
|
|
386
|
-
def test_weeks
|
|
387
|
-
assert_equal( 7*24*(60**2), 1.weeks )
|
|
388
|
-
end
|
|
389
|
-
|
|
390
|
-
def test_fortnights
|
|
391
|
-
assert_equal( 14*24*(60**2), 1.fortnights )
|
|
392
|
-
end
|
|
393
|
-
|
|
394
|
-
def test_months
|
|
395
|
-
assert_equal( 30*24*(60**2), 1.months )
|
|
396
|
-
end
|
|
397
|
-
|
|
398
|
-
def test_years
|
|
399
|
-
assert_equal( 365*24*(60**2), 1.years )
|
|
400
|
-
end
|
|
401
|
-
|
|
402
|
-
def test_before
|
|
403
|
-
t = Time.now
|
|
404
|
-
assert_equal( t - 1.day, 1.day.before(t) )
|
|
405
|
-
end
|
|
406
|
-
|
|
407
|
-
def test_after
|
|
408
|
-
t = Time.now
|
|
409
|
-
assert_equal( t + 1.day, 1.day.after(t) )
|
|
410
|
-
end
|
|
411
|
-
|
|
412
|
-
end
|
|
413
|
-
|
|
414
|
-
class WeekdaysTest < Test::Unit::TestCase
|
|
415
|
-
|
|
416
|
-
MONDAY = Time.at(1165250000)
|
|
417
|
-
THURSDAY = Time.at(1165500000)
|
|
418
|
-
FRIDAY = Time.at(1165606025)
|
|
419
|
-
|
|
420
|
-
def test_weekday_after_monday
|
|
421
|
-
assert_equal 2, 1.weekday.since(MONDAY).wday
|
|
422
|
-
end
|
|
423
|
-
|
|
424
|
-
def test_weekday_after_friday
|
|
425
|
-
assert_equal 1, 1.weekday.after(FRIDAY).wday
|
|
426
|
-
end
|
|
427
|
-
|
|
428
|
-
def test_weekdays_before_friday
|
|
429
|
-
assert_equal 2, 3.weekdays.before(FRIDAY).wday
|
|
430
|
-
end
|
|
431
|
-
|
|
432
|
-
#def test_weekday_before_today
|
|
433
|
-
# Time.expects(:now).returns(THURSDAY)
|
|
434
|
-
# assert_equal 3, 1.weekday.ago.wday
|
|
435
|
-
#end
|
|
436
|
-
|
|
437
|
-
#def test_weekdays_after_today
|
|
438
|
-
# Time.expects(:now).returns(MONDAY)
|
|
439
|
-
# assert_equal 3, 2.weekday.from_now.wday
|
|
440
|
-
#end
|
|
441
|
-
|
|
442
|
-
end
|
|
443
|
-
|
|
444
|
-
=end
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# TITLE:
|
|
2
|
+
#
|
|
3
|
+
# TracePoint
|
|
4
|
+
#
|
|
5
|
+
# SUMMARY:
|
|
6
|
+
#
|
|
7
|
+
# A TracePoint is a Binding with the addition event information.
|
|
8
|
+
# And it's a better way to use set_trace_func.
|
|
9
|
+
#
|
|
10
|
+
# COPYRIGHT:
|
|
11
|
+
#
|
|
12
|
+
# Copyright (c) 2005 Thomas Sawyer
|
|
13
|
+
#
|
|
14
|
+
# LICENSE:
|
|
15
|
+
#
|
|
16
|
+
# Ruby License
|
|
17
|
+
#
|
|
18
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
|
19
|
+
# software under the same terms as Ruby.
|
|
20
|
+
#
|
|
21
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
22
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
23
|
+
# FOR A PARTICULAR PURPOSE.
|
|
24
|
+
#
|
|
25
|
+
# AUTHORS:
|
|
26
|
+
#
|
|
27
|
+
# - Thomas Sawyer
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
require 'facets/binding'
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# = CodePoint
|
|
34
|
+
#
|
|
35
|
+
# This is the same as a Binding. Not really needed, but I like consistency :)
|
|
36
|
+
|
|
37
|
+
CodePoint = Binding
|
|
38
|
+
|
|
39
|
+
# = TracePoint
|
|
40
|
+
#
|
|
41
|
+
# A TracePoint is a Binding with the addition of event information.
|
|
42
|
+
# Among other things, it functions very well as the join-point for
|
|
43
|
+
# Event-based AOP.
|
|
44
|
+
#
|
|
45
|
+
# == Usage
|
|
46
|
+
#
|
|
47
|
+
# TracePoint.trace { |tp|
|
|
48
|
+
# puts "#{tp.self.class}\t#{tp.called}\t#{tp.event}\t#{tp.return?}\t#{tp.back == tp.bind}"
|
|
49
|
+
# }
|
|
50
|
+
#
|
|
51
|
+
# 1 + 1
|
|
52
|
+
#
|
|
53
|
+
# produces
|
|
54
|
+
#
|
|
55
|
+
# Class trace return true false
|
|
56
|
+
# Object line false false
|
|
57
|
+
# Fixnum + c-call false false
|
|
58
|
+
# Fixnum + c-return false false
|
|
59
|
+
#
|
|
60
|
+
# == Notes
|
|
61
|
+
#
|
|
62
|
+
# You can't subclass Binding, so we delegate (which is better anyway).
|
|
63
|
+
|
|
64
|
+
class TracePoint #< Codepoint
|
|
65
|
+
|
|
66
|
+
# -- class ---------------------
|
|
67
|
+
class << self
|
|
68
|
+
|
|
69
|
+
@@active = false
|
|
70
|
+
|
|
71
|
+
def active ; @@active ; end
|
|
72
|
+
|
|
73
|
+
def active=(x)
|
|
74
|
+
@@active = x ? true : false
|
|
75
|
+
unless @@active
|
|
76
|
+
set_trace_func nil
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Trace execution using a TracePoint.
|
|
81
|
+
def trace # :yield:
|
|
82
|
+
if active
|
|
83
|
+
bb_stack = []
|
|
84
|
+
set_trace_func proc{ |e, f, l, m, b, k|
|
|
85
|
+
#(p e, f, l, m, b, k, @@bb_stack; puts "---") if $DEBUG
|
|
86
|
+
if ['call','c-call','class'].include?(e)
|
|
87
|
+
bb_stack << b
|
|
88
|
+
elsif ['return','c-return','end'].include?(e)
|
|
89
|
+
bb = bb_stack.pop
|
|
90
|
+
end
|
|
91
|
+
b = bb if ! b # this sucks!
|
|
92
|
+
tp = TracePoint.new(e,m,b,bb)
|
|
93
|
+
yield(tp)
|
|
94
|
+
}
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
end #class
|
|
99
|
+
|
|
100
|
+
# -- instance -------------------
|
|
101
|
+
|
|
102
|
+
attr_accessor :event, :binding, :back_binding
|
|
103
|
+
|
|
104
|
+
# Until Ruby has a built-in way to get the name of the calling method
|
|
105
|
+
# that information must be passed into the TracePoint.
|
|
106
|
+
def initialize( event, method, bind, back_binding=bind )
|
|
107
|
+
@event = event
|
|
108
|
+
@method = method
|
|
109
|
+
@binding = bind
|
|
110
|
+
@back_binding = back_binding
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# shorthand for binding
|
|
114
|
+
def bind ; @binding ; end
|
|
115
|
+
|
|
116
|
+
# shorthand for back_binding
|
|
117
|
+
def back ; @back_binding ; end
|
|
118
|
+
|
|
119
|
+
# Delegates "self" to the binding which
|
|
120
|
+
# in turn delegates the binding object.
|
|
121
|
+
def self ; @binding.self ; end
|
|
122
|
+
|
|
123
|
+
# Returns the name of the event's method.
|
|
124
|
+
# This could delegate to the binding if Ruby had
|
|
125
|
+
# an internal way to retrieve the current method name.
|
|
126
|
+
def callee ; @method ; end
|
|
127
|
+
#def method ; @method ; end # TODO Conflict with Kernel#method?
|
|
128
|
+
alias_method( :called, :callee ) # TODO deprecate
|
|
129
|
+
alias_method( :method_name, :called ) # TODO deprecate
|
|
130
|
+
|
|
131
|
+
# delegate to binding
|
|
132
|
+
#def method_missing(meth, *args, &blk)
|
|
133
|
+
# @binding.send(meth, *args, &blk)
|
|
134
|
+
#end
|
|
135
|
+
|
|
136
|
+
### methods for working with events
|
|
137
|
+
|
|
138
|
+
EVENT_MAP = {
|
|
139
|
+
:all => ['call', 'c-call', 'return', 'c-return', 'line', 'class', 'end', 'raise'],
|
|
140
|
+
:before => ['call', 'c-call'],
|
|
141
|
+
:after => ['return', 'c-return'],
|
|
142
|
+
:call => ['call'],
|
|
143
|
+
:return => ['return'],
|
|
144
|
+
:ccall => ['c-call'],
|
|
145
|
+
:creturn => ['c-return'],
|
|
146
|
+
:line => ['line'],
|
|
147
|
+
:class => ['class'],
|
|
148
|
+
:end => ['end'],
|
|
149
|
+
:raise => ['raise']
|
|
150
|
+
}
|
|
151
|
+
def event_map(e) ; EVENT_MAP[e] ; end
|
|
152
|
+
|
|
153
|
+
# Is the trace point defined or undefined?
|
|
154
|
+
def event? ; !! @event ; end
|
|
155
|
+
def eventless? ; ! @event ; end
|
|
156
|
+
|
|
157
|
+
# For use in case conditions
|
|
158
|
+
def ===(e)
|
|
159
|
+
EVENT_MAP[e].include?(@event)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Creates an <event>? method for each of the above event mappings.
|
|
163
|
+
EVENT_MAP.each_pair { |m,v|
|
|
164
|
+
define_method( "#{m}?" ){ v.include?(@event) }
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
# _____ _
|
|
172
|
+
# |_ _|__ ___| |_
|
|
173
|
+
# | |/ _ \/ __| __|
|
|
174
|
+
# | | __/\__ \ |_
|
|
175
|
+
# |_|\___||___/\__|
|
|
176
|
+
#
|
|
177
|
+
|
|
178
|
+
# TODO
|
|
179
|
+
|
|
180
|
+
=begin #test
|
|
181
|
+
|
|
182
|
+
# Note: TracePoint will probably prove tricky to test, since
|
|
183
|
+
# manipulating set_trace_func tends to wreak havoc on errors,
|
|
184
|
+
# the call stack, and so on.
|
|
185
|
+
|
|
186
|
+
TracePoint.active = true
|
|
187
|
+
|
|
188
|
+
TracePoint.trace { |tp|
|
|
189
|
+
puts "#{tp.self.class}\t#{tp.called}\t#{tp.event}\t#{tp.return?}\t#{tp.back == tp.bind}"
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
1 + 1
|
|
193
|
+
|
|
194
|
+
=end
|