facets 2.6.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.rdoc +331 -35
- data/MANIFEST +685 -826
- data/{doc/guide/notes.rd → NOTES} +0 -0
- data/README.rdoc +73 -25
- data/Rakefile +245 -2
- data/TODO +5 -0
- data/demo/hook.rd +47 -0
- data/demo/scenario_require.rd +9 -0
- data/doc/README.more +24 -6
- data/doc/manual/about.rb +47 -0
- data/doc/manual/annotations.rdoc +60 -0
- data/doc/manual/associations.rdoc +55 -0
- data/doc/manual/blockups.rdoc +101 -0
- data/doc/manual/capsule.rdoc +34 -0
- data/doc/manual/command.rdoc +177 -0
- data/doc/manual/core.rdoc +37 -0
- data/doc/manual/faq.rdoc +32 -0
- data/doc/manual/typecast.html +112 -0
- data/lib/core/facets.rb +359 -11
- data/lib/core/facets/array/combination.rb +3 -3
- data/lib/core/facets/array/index.rb +4 -1
- data/lib/core/facets/array/permutation.rb +2 -2
- data/lib/core/facets/array/product.rb +1 -1
- data/lib/core/facets/binding/eval.rb +1 -1
- data/lib/core/facets/denumerable.rb +76 -0
- data/lib/core/facets/duplicable.rb +34 -0
- data/lib/core/facets/enumerable/count.rb +10 -4
- data/lib/core/facets/enumerable/defer.rb +77 -0
- data/lib/core/facets/enumerable/each_by.rb +1 -1
- data/lib/core/facets/enumerable/every.rb +35 -0
- data/lib/{more/facets/elementwise.rb → core/facets/enumerable/ewise.rb} +0 -0
- data/lib/core/facets/enumerable/filter.rb +25 -0
- data/lib/core/facets/enumerable/group_by.rb +1 -1
- data/lib/core/facets/enumerable/none.rb +3 -2
- data/lib/core/facets/enumerable/one.rb +3 -2
- data/lib/core/facets/enumerable/per.rb +61 -0
- data/lib/core/facets/exception/raised.rb +14 -0
- data/lib/core/facets/integer/odd.rb +5 -1
- data/lib/core/facets/kernel/__dir__.rb +13 -3
- data/lib/core/facets/kernel/__here__.rb +14 -0
- data/lib/core/facets/kernel/__method__.rb +9 -3
- data/lib/core/facets/kernel/ask.rb +1 -0
- data/lib/core/facets/kernel/equate.rb +13 -0
- data/lib/core/facets/kernel/extension.rb +9 -0
- data/lib/core/facets/kernel/identical.rb +4 -0
- data/lib/core/facets/kernel/instance_exec.rb +2 -1
- data/lib/core/facets/kernel/method.rb +49 -0
- data/lib/core/facets/kernel/object_send.rb +2 -2
- data/lib/core/facets/kernel/{state.rb → object_state.rb} +23 -12
- data/lib/core/facets/kernel/require_all.rb +6 -1
- data/lib/core/facets/kernel/require_local.rb +8 -1
- data/lib/core/facets/kernel/require_relative.rb +52 -0
- data/lib/core/facets/kernel/source_location.rb +13 -0
- data/lib/core/facets/kernel/tap.rb +13 -6
- data/lib/core/facets/module/attr_setter.rb +57 -0
- data/lib/core/facets/module/instance_method.rb +24 -0
- data/lib/core/facets/module/module_load.rb +60 -44
- data/lib/core/facets/module/module_require.rb +1 -0
- data/lib/core/facets/nilclass/to_f.rb +1 -1
- data/lib/core/facets/objectspace/op_fetch.rb +3 -0
- data/lib/core/facets/proc/curry.rb +4 -3
- data/lib/core/facets/string/bytes.rb +10 -4
- data/lib/core/facets/string/camelcase.rb +6 -5
- data/lib/core/facets/string/chars.rb +5 -1
- data/lib/core/facets/string/each_char.rb +1 -1
- data/lib/core/facets/string/each_word.rb +1 -1
- data/lib/core/facets/string/lines.rb +11 -4
- data/lib/core/facets/string/start_with.rb +9 -2
- data/lib/core/facets/string/unfold.rb +27 -0
- data/lib/core/facets/symbol/succ.rb +3 -3
- data/lib/core/facets/symbol/thrown.rb +20 -0
- data/lib/core/facets/symbol/to_proc.rb +3 -2
- data/lib/core/facets/time/to_time.rb +1 -1
- data/lib/core/facets/to_hash.rb +41 -100
- data/lib/core/facets/unboundmethod/name.rb +20 -23
- data/lib/more/facets/ansicode.rb +1 -10
- data/lib/more/facets/autoarray.rb +3 -31
- data/lib/more/facets/basicobject.rb +73 -0
- data/lib/more/facets/blankslate.rb +2 -66
- data/lib/{lore → more}/facets/cgi.rb +0 -0
- data/lib/more/facets/class_extend.rb +1 -0
- data/lib/{lore → more}/facets/continuation.rb +0 -0
- data/lib/{lore → more}/facets/date.rb +3 -3
- data/lib/more/facets/enumargs.rb +192 -0
- data/lib/more/facets/enumerablepass.rb +2 -216
- data/lib/more/facets/enumerator.rb +62 -0
- data/lib/more/facets/{equatable.rb → equitable.rb} +11 -11
- data/lib/more/facets/expirable.rb +13 -41
- data/lib/{lore → more}/facets/fileutils.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/head.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/safe_ln.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/slice.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/tail.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/wc.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/whereis.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/which.rb +0 -0
- data/lib/{lore → more}/facets/getoptlong.rb +0 -0
- data/lib/more/facets/hook.rb +2 -29
- data/lib/more/facets/inheritor.rb +2 -2
- data/lib/more/facets/instance_eval.rb +50 -0
- data/lib/more/facets/instance_function.rb +78 -0
- data/lib/more/facets/main.rb +20 -15
- data/lib/more/facets/memoize.rb +1 -113
- data/lib/more/facets/module/attr.rb +83 -0
- data/lib/more/facets/module/attr_tester.rb +44 -0
- data/lib/more/facets/module/attr_toggler.rb +59 -0
- data/lib/more/facets/module/attr_validator.rb +34 -0
- data/lib/more/facets/{class_extension.rb → module/class_extend.rb} +21 -13
- data/lib/more/facets/once.rb +59 -0
- data/lib/more/facets/openmodule.rb +1 -0
- data/lib/more/facets/orderedhash.rb +1 -33
- data/lib/{lore → more}/facets/ostruct.rb +0 -0
- data/lib/more/facets/ostructable.rb +1 -4
- data/lib/more/facets/partial.rb +18 -16
- data/lib/{lore → more}/facets/pathname.rb +0 -0
- data/lib/more/facets/preinitialize.rb +157 -0
- data/lib/{lore → more}/facets/rbconfig.rb +0 -0
- data/lib/more/facets/recorder.rb +1 -2
- data/lib/{lore → more}/facets/set.rb +0 -0
- data/lib/{lore → more}/facets/shellwords.rb +0 -0
- data/lib/{lore → more}/facets/uri.rb +0 -0
- data/lib/{lore → more}/facets/yaml.rb +0 -0
- data/lib/{lore → more}/facets/zlib.rb +0 -0
- data/meta/loadpath +0 -1
- data/meta/sitemap +4 -0
- data/meta/version +1 -1
- data/test/core/enumerable/test_count.rb +1 -1
- data/test/{more/test_filter.rb → core/enumerable/test_defer.rb} +24 -22
- data/test/{more/test_elementor.rb → core/enumerable/test_every.rb} +2 -15
- data/test/core/enumerable/test_ewise.rb +23 -0
- data/test/core/enumerable/test_per.rb +18 -0
- data/test/core/enumerable/test_take.rb +13 -0
- data/test/core/kernel/test_deepcopy.rb +1 -1
- data/test/{more/test_1stclassmethod.rb → core/kernel/test_method.rb} +2 -7
- data/test/core/kernel/test_tap.rb +1 -1
- data/test/core/proc/test_curry.rb +11 -0
- data/test/core/string/test_bytes.rb +1 -1
- data/test/core/string/test_camelcase.rb +23 -6
- data/test/core/string/test_lines.rb +1 -1
- data/test/core/string/test_unfold.rb +14 -0
- data/test/{more → core}/test_blank.rb +0 -0
- data/test/{more → core}/test_boolean.rb +0 -0
- data/test/{more → core}/test_functor.rb +0 -0
- data/test/{lore → more}/test_basicobject.rb +0 -0
- data/test/more/{test_class_extension.rb → test_class_extend.rb} +6 -6
- data/test/{lore → more}/test_continuation.rb +0 -0
- data/test/{lore → more}/test_date.rb +0 -0
- data/test/more/{test_enumerablepass.rb → test_enumargs.rb} +2 -4
- data/test/more/{test_equatable.rb → test_equitable.rb} +2 -2
- data/test/more/{test_instantise.rb → test_instance_function.rb} +3 -2
- data/test/more/test_memoize.rb +1 -1
- data/test/{lore → more}/test_ostruct.rb +0 -0
- metadata +865 -1016
- data/RELEASE +0 -38
- data/doc/README.lore +0 -51
- data/doc/log/basic_stats/index.html +0 -39
- data/doc/log/changelog.html +0 -648
- data/doc/log/changelog.txt +0 -217
- data/doc/log/stats/index.html +0 -39
- data/doc/log/testlog.txt +0 -278
- data/doc/notes/CHANGES +0 -2529
- data/doc/rdoc/lore/classes/Array.html +0 -176
- data/doc/rdoc/lore/classes/CGI.html +0 -191
- data/doc/rdoc/lore/classes/Config.html +0 -135
- data/doc/rdoc/lore/classes/Continuation.html +0 -113
- data/doc/rdoc/lore/classes/Date.html +0 -631
- data/doc/rdoc/lore/classes/DateTime.html +0 -583
- data/doc/rdoc/lore/classes/Enumerable.html +0 -89
- data/doc/rdoc/lore/classes/Enumerable/Enumerator.html +0 -147
- data/doc/rdoc/lore/classes/File.html +0 -128
- data/doc/rdoc/lore/classes/FileUtils.html +0 -434
- data/doc/rdoc/lore/classes/GetoptLong.html +0 -118
- data/doc/rdoc/lore/classes/GetoptLong/DSL.html +0 -208
- data/doc/rdoc/lore/classes/Kernel.html +0 -135
- data/doc/rdoc/lore/classes/Logger.html +0 -229
- data/doc/rdoc/lore/classes/Logger/Ansicolor.html +0 -277
- data/doc/rdoc/lore/classes/Logger/LogDevice.html +0 -121
- data/doc/rdoc/lore/classes/NilClass.html +0 -119
- data/doc/rdoc/lore/classes/OpenStruct.html +0 -432
- data/doc/rdoc/lore/classes/Pathname.html +0 -353
- data/doc/rdoc/lore/classes/Set.html +0 -117
- data/doc/rdoc/lore/classes/Shellwords.html +0 -111
- data/doc/rdoc/lore/classes/String.html +0 -140
- data/doc/rdoc/lore/classes/Time.html +0 -154
- data/doc/rdoc/lore/classes/URI.html +0 -454
- data/doc/rdoc/lore/classes/URI/Hash.html +0 -105
- data/doc/rdoc/lore/classes/URI/Kernel.html +0 -122
- data/doc/rdoc/lore/classes/Zlib.html +0 -188
- data/doc/rdoc/lore/created.rid +0 -1
- data/doc/rdoc/lore/files/README.html +0 -286
- data/doc/rdoc/lore/files/doc/README_lore.html +0 -155
- data/doc/rdoc/lore/files/lib/lore/facets/basicobject_rb.html +0 -118
- data/doc/rdoc/lore/files/lib/lore/facets/cgi_rb.html +0 -111
- data/doc/rdoc/lore/files/lib/lore/facets/continuation_rb.html +0 -147
- data/doc/rdoc/lore/files/lib/lore/facets/date_rb.html +0 -97
- data/doc/rdoc/lore/files/lib/lore/facets/enumerator_rb.html +0 -111
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/head_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/safe_ln_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/slice_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/tail_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/wc_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/whereis_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/which_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils_rb.html +0 -131
- data/doc/rdoc/lore/files/lib/lore/facets/getoptlong_rb.html +0 -135
- data/doc/rdoc/lore/files/lib/lore/facets/logger_rb.html +0 -142
- data/doc/rdoc/lore/files/lib/lore/facets/ostruct_rb.html +0 -135
- data/doc/rdoc/lore/files/lib/lore/facets/pathname_rb.html +0 -145
- data/doc/rdoc/lore/files/lib/lore/facets/rbconfig_rb.html +0 -124
- data/doc/rdoc/lore/files/lib/lore/facets/set_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/shellwords_rb.html +0 -124
- data/doc/rdoc/lore/files/lib/lore/facets/uri_rb.html +0 -125
- data/doc/rdoc/lore/files/lib/lore/facets/yaml_rb.html +0 -146
- data/doc/rdoc/lore/files/lib/lore/facets/zlib_rb.html +0 -97
- data/doc/rdoc/lore/fr_class_index.html +0 -73
- data/doc/rdoc/lore/fr_file_index.html +0 -71
- data/doc/rdoc/lore/fr_method_index.html +0 -177
- data/doc/rdoc/lore/index.html +0 -26
- data/doc/rdoc/lore/rdoc-style.css +0 -177
- data/doc/release-notes/RELEASE-2.0.5 +0 -8
- data/doc/release-notes/RELEASE-2.1.0 +0 -9
- data/doc/release-notes/RELEASE-2.1.1 +0 -5
- data/doc/release-notes/RELEASE-2.1.2 +0 -6
- data/doc/release-notes/RELEASE-2.1.3 +0 -5
- data/doc/release-notes/RELEASE-2.2.0 +0 -14
- data/doc/release-notes/RELEASE-2.2.1 +0 -4
- data/doc/release-notes/RELEASE-2.3.0 +0 -6
- data/doc/release-notes/RELEASE-2.4.0 +0 -70
- data/doc/release-notes/RELEASE-2.4.1 +0 -8
- data/doc/release-notes/RELEASE-2.4.2 +0 -4
- data/doc/release-notes/RELEASE-2.4.3 +0 -78
- data/doc/release-notes/RELEASE-2.4.4 +0 -38
- data/doc/release-notes/RELEASE-2.4.5 +0 -37
- data/doc/release-notes/RELEASE-2.5.0 +0 -83
- data/lib/core/facets/kernel/instance.rb +0 -19
- data/lib/lore/facets/basicobject.rb +0 -14
- data/lib/lore/facets/enumerator.rb +0 -67
- data/lib/lore/facets/logger.rb +0 -291
- data/lib/more/facets/1stclassmethod.rb +0 -140
- data/lib/more/facets/advisable.rb +0 -162
- data/lib/more/facets/association.rb +0 -210
- data/lib/more/facets/attr.rb +0 -209
- data/lib/more/facets/basex.rb +0 -37
- data/lib/more/facets/bbcode.rb +0 -397
- data/lib/more/facets/bicrypt.rb +0 -265
- data/lib/more/facets/binreadable.rb +0 -221
- data/lib/more/facets/censor.rb +0 -97
- data/lib/more/facets/classmethods.rb +0 -199
- data/lib/more/facets/consoleutils.rb +0 -99
- data/lib/more/facets/crypt.rb +0 -166
- data/lib/more/facets/dependency.rb +0 -151
- data/lib/more/facets/downloader.rb +0 -281
- data/lib/more/facets/duplicable.rb +0 -43
- data/lib/more/facets/elementor.rb +0 -133
- data/lib/more/facets/filter.rb +0 -121
- data/lib/more/facets/heap.rb +0 -22
- data/lib/more/facets/infinity.rb +0 -193
- data/lib/more/facets/ini.rb +0 -264
- data/lib/more/facets/instantise.rb +0 -1
- data/lib/more/facets/instantize.rb +0 -95
- data/lib/more/facets/interval.rb +0 -282
- data/lib/more/facets/iteration.rb +0 -65
- data/lib/more/facets/linkedlist.rb +0 -222
- data/lib/more/facets/lrucache.rb +0 -157
- data/lib/more/facets/matcher.rb +0 -140
- data/lib/more/facets/memoizer.rb +0 -74
- data/lib/more/facets/minitar.rb +0 -1063
- data/lib/more/facets/nackclass.rb +0 -41
- data/lib/more/facets/net/smtp_tls.rb +0 -131
- data/lib/more/facets/nilstatus.rb +0 -48
- data/lib/more/facets/overload.rb +0 -94
- data/lib/more/facets/paramix.rb +0 -202
- data/lib/more/facets/pool.rb +0 -91
- data/lib/more/facets/pqueue.rb +0 -449
- data/lib/more/facets/pry.rb +0 -32
- data/lib/more/facets/reflection.rb +0 -145
- data/lib/more/facets/semaphore.rb +0 -92
- data/lib/more/facets/settings.rb +0 -248
- data/lib/more/facets/snapshot.rb +0 -209
- data/lib/more/facets/sparse_array.rb +0 -809
- data/lib/more/facets/string/mask.rb +0 -278
- data/lib/more/facets/string/obfuscate.rb +0 -65
- data/lib/more/facets/string/stylize.rb +0 -169
- data/lib/more/facets/string/words.rb +0 -167
- data/lib/more/facets/syncarray.rb +0 -114
- data/lib/more/facets/synchash.rb +0 -157
- data/lib/more/facets/typecast.rb +0 -261
- data/lib/more/facets/uninheritable.rb +0 -50
- data/lib/more/facets/xmlhash.rb +0 -112
- data/lib/more/facets/xoxo.rb +0 -259
- data/lib/more/facets/ziputils.rb +0 -490
- data/task/conflicts +0 -63
- data/task/coverage.rake +0 -37
- data/task/methods +0 -49
- data/task/rdoc.rake +0 -17
- data/task/setup.rake +0 -38
- data/task/test.rake +0 -145
- data/test/more/test_advisable.rb +0 -71
- data/test/more/test_association.rb +0 -38
- data/test/more/test_bbcode.rb +0 -21
- data/test/more/test_binreadable.rb +0 -50
- data/test/more/test_buildable.rb +0 -73
- data/test/more/test_classmethods.rb +0 -56
- data/test/more/test_crypt.rb +0 -32
- data/test/more/test_dependency.rb +0 -69
- data/test/more/test_elementwise.rb +0 -25
- data/test/more/test_infinity.rb +0 -40
- data/test/more/test_interval.rb +0 -151
- data/test/more/test_linkedlist.rb +0 -41
- data/test/more/test_lrucache.rb +0 -14
- data/test/more/test_overload.rb +0 -160
- data/test/more/test_paramix.rb +0 -170
- data/test/more/test_prototype.rb +0 -35
- data/test/more/test_snapshot.rb +0 -21
- data/test/more/test_sparsearray.rb +0 -279
- data/test/more/test_syncarray.rb +0 -15
- data/test/more/test_synchash.rb +0 -16
- data/test/more/test_typecast.rb +0 -54
- data/test/more/test_uninheritable.rb +0 -31
- data/test/more/test_xoxo.rb +0 -274
- data/test/test_facets.rb +0 -9
data/test/more/test_syncarray.rb
DELETED
data/test/more/test_synchash.rb
DELETED
data/test/more/test_typecast.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'facets/typecast.rb'
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
class TC_TypeCast < Test::Unit::TestCase
|
5
|
-
|
6
|
-
class TestClass
|
7
|
-
attr_accessor :my_var
|
8
|
-
def initialize(my_var); @my_var = my_var; end
|
9
|
-
|
10
|
-
def to_string(options={})
|
11
|
-
@my_var
|
12
|
-
end
|
13
|
-
|
14
|
-
class << self
|
15
|
-
def from_string(string, options={})
|
16
|
-
self.new( string )
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
def setup
|
23
|
-
@test_string = "this is a test"
|
24
|
-
@test_class = TestClass.new(@test_string)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_to_string
|
28
|
-
assert_equal( '1234', 1234.cast_to(String) )
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_custom_to_string
|
32
|
-
assert_equal( @test_string, @test_class.cast_to(String) )
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_custom_from_string
|
36
|
-
assert_equal( @test_class.my_var, @test_string.cast_to(TestClass).my_var )
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_string_to_class
|
40
|
-
assert_equal( Test::Unit::TestCase, "Test::Unit::TestCase".cast_to(Class) )
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_string_to_time
|
44
|
-
assert_equal( "Mon Oct 10 00:00:00 2005", "2005-10-10".cast_to(Time).localtime.strftime("%a %b %d %H:%M:%S %Y") )
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_no_converter
|
48
|
-
"sfddsf".cast_to( ::Regexp )
|
49
|
-
assert(1+1==3, 'should not get here')
|
50
|
-
rescue TypeCastException => ex
|
51
|
-
assert_equal(TypeCastException, ex.class)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# Test facets/uninheritable.rb
|
2
|
-
|
3
|
-
require 'facets/uninheritable.rb'
|
4
|
-
require 'test/unit'
|
5
|
-
|
6
|
-
class TC_Uninheritable < Test::Unit::TestCase
|
7
|
-
|
8
|
-
class Cannot
|
9
|
-
extend Uninheritable
|
10
|
-
end
|
11
|
-
|
12
|
-
class Can
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_module
|
16
|
-
assert_nothing_raised {
|
17
|
-
self.instance_eval <<-EOS
|
18
|
-
class A < Can; end
|
19
|
-
EOS
|
20
|
-
}
|
21
|
-
assert_raises(TypeError, "Class Cannot cannot be subclassed.") do
|
22
|
-
self.instance_eval <<-EOS
|
23
|
-
class B < Cannot; end
|
24
|
-
EOS
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
|
data/test/more/test_xoxo.rb
DELETED
@@ -1,274 +0,0 @@
|
|
1
|
-
# Test lib/more/add/facets/xoxo.rb
|
2
|
-
|
3
|
-
require 'facets/xoxo.rb'
|
4
|
-
require 'test/unit'
|
5
|
-
|
6
|
-
class TCXOXO < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def test_simple_list
|
9
|
-
l = ['1', '2', '3']
|
10
|
-
html = XOXO.dump(l)
|
11
|
-
assert_equal '<ol class="xoxo"><li>1</li><li>2</li><li>3</li></ol>', html
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_nested_list
|
15
|
-
l = ['1', ['2', '3']]
|
16
|
-
assert_equal '<ol class="xoxo"><li>1</li><li><ol><li>2</li><li>3</li></ol></li></ol>', XOXO.dump(l)
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_hash
|
20
|
-
h = {'test' => '1', 'name' => 'Kevin'}
|
21
|
-
# Changed since Ruby sorts the hash differently.
|
22
|
-
assert_equal '<ol class="xoxo"><li><dl><dt>name</dt><dd>Kevin</dd><dt>test</dt><dd>1</dd></dl></li></ol>', XOXO.dump(h)
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_single_item
|
26
|
-
l = 'test'
|
27
|
-
assert_equal '<ol class="xoxo"><li>test</li></ol>', XOXO.dump(l)
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_wrap_differs
|
31
|
-
l = 'test'
|
32
|
-
html = XOXO.dump(l)
|
33
|
-
html_wrap = XOXO.dump(l, :html_wrap => true)
|
34
|
-
assert_not_equal html, html_wrap
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_wrap_single_item
|
38
|
-
l = 'test'
|
39
|
-
html = XOXO.dump(l, :html_wrap => true)
|
40
|
-
assert_equal <<EOF.strip, html
|
41
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN
|
42
|
-
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
43
|
-
<html xmlns="http://www.w3.org/1999/xhtml"><head profile=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><ol class="xoxo"><li>test</li></ol></body></html>
|
44
|
-
EOF
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_wrap_item_with_css
|
48
|
-
l = 'test'
|
49
|
-
html = XOXO.dump(l, :html_wrap => true, :css => 'reaptest.css')
|
50
|
-
assert_equal <<EOF.strip, html
|
51
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN
|
52
|
-
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
53
|
-
<html xmlns="http://www.w3.org/1999/xhtml"><head profile=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style type="text/css" >@import "reaptest.css";</style></head><body><ol class="xoxo"><li>test</li></ol></body></html>
|
54
|
-
EOF
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_hash_roundtrip
|
58
|
-
h = {'test' => '1', 'name' => 'Kevin'}
|
59
|
-
assert_equal h, XOXO.load(XOXO.dump(h))
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_hash_with_url_roundtrip
|
63
|
-
h = {'url' => 'http://example.com', 'name' => 'Kevin'}
|
64
|
-
assert_equal h, XOXO.load(XOXO.dump(h))
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_nested_hash_roundtrip
|
68
|
-
h = {'test' => '1', 'inner' => {'name' => 'Kevin'}}
|
69
|
-
assert_equal h, XOXO.load(XOXO.dump(h))
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_nested_hash_with_url_roundtrip
|
73
|
-
h = {'url' => 'http://example.com', 'inner' => {
|
74
|
-
'url' => 'http://slashdot.org', 'name' => 'Kevin'}}
|
75
|
-
assert_equal h, XOXO.load(XOXO.dump(h))
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_list_round_trip
|
79
|
-
l = ['3', '2', '1']
|
80
|
-
assert_equal l, XOXO.load(XOXO.dump(l))
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_list_of_hashes_round_trip
|
84
|
-
l = ['3', {'a' => '2'}, {'b' => '1', 'c' => '4'}]
|
85
|
-
assert_equal l, XOXO.load(XOXO.dump(l))
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_list_of_lists_round_trip
|
89
|
-
l = ['3', ['a', '2'], ['b', ['1', ['c', '4']]]]
|
90
|
-
assert_equal l, XOXO.load(XOXO.dump(l))
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_hashes_of_lists_roundtrip
|
94
|
-
h = {
|
95
|
-
'test' => ['1', '2'],
|
96
|
-
'name' => 'Kevin',
|
97
|
-
'nestlist' => ['a', ['b', 'c']],
|
98
|
-
'nestdict' => {'e' => '6', 'f' => '7'}
|
99
|
-
}
|
100
|
-
assert_equal h, XOXO.load(XOXO.dump(h))
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_xoxo_junk_in_containers
|
104
|
-
h = XOXO.load '<ol>bad<li><dl>worse<dt>good</dt><dd>buy</dd> now</dl></li></ol>'
|
105
|
-
assert_equal({'good' => 'buy'}, h)
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_xoxo_junk_in_elements
|
109
|
-
l = XOXO.load '<ol><li>bad<dl><dt>good</dt><dd>buy</dd></dl>worse</li><li>bag<ol><li>OK</li></ol>fish</li></ol>'
|
110
|
-
assert_equal([{'good' => 'buy'}, ['OK']], l)
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_xoxo_with_spaces_and_newlines
|
114
|
-
xoxo_sample = <<EOF.strip
|
115
|
-
<ol class='xoxo'>
|
116
|
-
<li>
|
117
|
-
<dl>
|
118
|
-
<dt>text</dt>
|
119
|
-
<dd>item 1</dd>
|
120
|
-
<dt>description</dt>
|
121
|
-
<dd> This item represents the main point we're trying to make.</dd>
|
122
|
-
<dt>url</dt>
|
123
|
-
<dd>http://example.com/more.xoxo</dd>
|
124
|
-
<dt>title</dt>
|
125
|
-
<dd>title of item 1</dd>
|
126
|
-
<dt>type</dt>
|
127
|
-
<dd>text/xml</dd>
|
128
|
-
<dt>rel</dt>
|
129
|
-
<dd>help</dd>
|
130
|
-
</dl>
|
131
|
-
</li>
|
132
|
-
</ol>
|
133
|
-
EOF
|
134
|
-
h = XOXO.load xoxo_sample
|
135
|
-
h2 = {
|
136
|
-
'text' => 'item 1',
|
137
|
-
'description' => " This item represents the main point we're trying to make.",
|
138
|
-
'url' => 'http://example.com/more.xoxo',
|
139
|
-
'title' => 'title of item 1',
|
140
|
-
'type' => 'text/xml',
|
141
|
-
'rel' => 'help'
|
142
|
-
}
|
143
|
-
assert_equal h2, XOXO.load(xoxo_sample)
|
144
|
-
end
|
145
|
-
|
146
|
-
def test_special_attribute_decoding
|
147
|
-
xoxo_sample = <<EOF.strip
|
148
|
-
<ol class='xoxo'>
|
149
|
-
<li>
|
150
|
-
<dl>
|
151
|
-
<dt>text</dt>
|
152
|
-
<dd>item 1</dd>
|
153
|
-
<dt>url</dt>
|
154
|
-
<dd>http://example.com/more.xoxo</dd>
|
155
|
-
<dt>title</dt>
|
156
|
-
<dd>title of item 1</dd>
|
157
|
-
<dt>type</dt>
|
158
|
-
<dd>text/xml</dd>
|
159
|
-
<dt>rel</dt>
|
160
|
-
<dd>help</dd>
|
161
|
-
</dl>
|
162
|
-
</li>
|
163
|
-
</ol>
|
164
|
-
EOF
|
165
|
-
smart_xoxo_sample = <<EOF.strip
|
166
|
-
<ol class='xoxo'>
|
167
|
-
<li><a href="http://example.com/more.xoxo"
|
168
|
-
title="title of item 1"
|
169
|
-
type="text/xml"
|
170
|
-
rel="help">item 1</a>
|
171
|
-
<!-- note how the "text" property is simply the contents of the <a> element -->
|
172
|
-
</li>
|
173
|
-
</ol>
|
174
|
-
EOF
|
175
|
-
assert_equal XOXO.load(xoxo_sample), XOXO.load(smart_xoxo_sample)
|
176
|
-
end
|
177
|
-
|
178
|
-
def test_special_attribute_and_dl_decoding
|
179
|
-
xoxo_sample = <<EOF.strip
|
180
|
-
<ol class="xoxo">
|
181
|
-
<li>
|
182
|
-
<dl>
|
183
|
-
<dt>text</dt>
|
184
|
-
<dd>item 1</dd>
|
185
|
-
<dt>description</dt>
|
186
|
-
<dd> This item represents the main point we're trying to make.</dd>
|
187
|
-
<dt>url</dt>
|
188
|
-
<dd>http://example.com/more.xoxo</dd>
|
189
|
-
<dt>title</dt>
|
190
|
-
<dd>title of item 1</dd>
|
191
|
-
<dt>type</dt>
|
192
|
-
<dd>text/xml</dd>
|
193
|
-
<dt>rel</dt>
|
194
|
-
<dd>help</dd>
|
195
|
-
</dl>
|
196
|
-
</li>
|
197
|
-
</ol>
|
198
|
-
EOF
|
199
|
-
smart_xoxo_sample = <<EOF.strip
|
200
|
-
<ol class="xoxo">
|
201
|
-
<li><a href="http://example.com/more.xoxo"
|
202
|
-
title="title of item 1"
|
203
|
-
type="text/xml"
|
204
|
-
rel="help">item 1</a>
|
205
|
-
<!-- note how the "text" property is simply the contents of the <a> element -->
|
206
|
-
<dl>
|
207
|
-
<dt>description</dt>
|
208
|
-
<dd> This item represents the main point we're trying to make.</dd>
|
209
|
-
</dl>
|
210
|
-
</li>
|
211
|
-
</ol>
|
212
|
-
EOF
|
213
|
-
assert_equal XOXO.load(xoxo_sample), XOXO.load(smart_xoxo_sample)
|
214
|
-
end
|
215
|
-
|
216
|
-
def test_special_attribute_encode
|
217
|
-
h = {
|
218
|
-
'url' => 'http://example.com/more.xoxo',
|
219
|
-
'title' => 'sample url',
|
220
|
-
'type' => "text/xml",
|
221
|
-
'rel' => 'help',
|
222
|
-
'text' => 'an example'
|
223
|
-
}
|
224
|
-
assert_equal '<ol class="xoxo"><li><a href="http://example.com/more.xoxo" title="sample url" rel="help" type="text/xml" >an example</a></li></ol>', XOXO.dump(h)
|
225
|
-
end
|
226
|
-
|
227
|
-
def test_special_attribute_roundtrip_full
|
228
|
-
h = {
|
229
|
-
'url' => 'http://example.com/more.xoxo',
|
230
|
-
'title' => 'sample url',
|
231
|
-
'type' => "text/xml",
|
232
|
-
'rel' => 'help',
|
233
|
-
'text' => 'an example'
|
234
|
-
}
|
235
|
-
assert_equal h, XOXO.load(XOXO.dump(h))
|
236
|
-
end
|
237
|
-
|
238
|
-
def test_special_attribute_roundtrip_no_text
|
239
|
-
h = {
|
240
|
-
'url' => 'http://example.com/more.xoxo',
|
241
|
-
'title' => 'sample url',
|
242
|
-
'type' => "text/xml",
|
243
|
-
'rel' => 'help'
|
244
|
-
}
|
245
|
-
assert_equal h, XOXO.load(XOXO.dump(h))
|
246
|
-
end
|
247
|
-
|
248
|
-
def test_special_attribute_roundtrip_no_text_or_title
|
249
|
-
h = {'url' => 'http://example.com/more.xoxo'}
|
250
|
-
assert_equal h, XOXO.load(XOXO.dump(h))
|
251
|
-
end
|
252
|
-
|
253
|
-
def test_attention_roundtrip
|
254
|
-
kmattn = <<EOF.strip
|
255
|
-
<ol class="xoxo"><li><a href="http://www.boingboing.net/" title="Boing Boing Blog" >Boing Boing Blog</a><dl><dt>alturls</dt><dd><ol><li><a href="http://boingboing.net/rss.xml" >xmlurl</a></li></ol></dd><dt>description</dt><dd>Boing Boing Blog</dd></dl></li><li><a href="http://www.financialcryptography.com/" title="Financial Cryptography" >Financial Cryptography</a><dl><dt>alturls</dt><dd><ol><li><a href="http://www.financialcryptography.com/mt/index.rdf" >xmlurl</a></li></ol></dd><dt>description</dt><dd>Financial Cryptography</dd></dl></li><li><a href="http://hublog.hubmed.org/" title="HubLog" >HubLog</a><dl><dt>alturls</dt><dd><ol><li><a href="http://hublog.hubmed.org/index.xml" >xmlurl</a></li><li><a href="http://hublog.hubmed.org/foaf.rdf" >foafurl</a></li></ol></dd><dt>description</dt><dd>HubLog</dd></dl></li></ol>
|
256
|
-
EOF
|
257
|
-
assert_equal kmattn, XOXO.dump(XOXO.load(kmattn))
|
258
|
-
assert_equal XOXO.load(kmattn), XOXO.load(XOXO.dump(XOXO.load(kmattn)))
|
259
|
-
assert_equal XOXO.dump(XOXO.load(kmattn)),
|
260
|
-
XOXO.dump(XOXO.load(XOXO.dump(XOXO.load(kmattn))))
|
261
|
-
end
|
262
|
-
|
263
|
-
def test_unicode_roundtrip
|
264
|
-
unicode = "Tantek \xc3\x87elik and a snowman \xe2\x98\x83"
|
265
|
-
assert_equal unicode, XOXO.load(XOXO.dump(unicode))
|
266
|
-
end
|
267
|
-
|
268
|
-
# TBD: Implement proper encodings.
|
269
|
-
#
|
270
|
-
# def test_utf8_roundtrip
|
271
|
-
# end
|
272
|
-
# def test_windows1252_roundtrip
|
273
|
-
# end
|
274
|
-
end
|