stringex 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +76 -0
- data/Rakefile +250 -0
- data/init.rb +1 -0
- data/lib/lucky_sneaks/acts_as_url.rb +88 -0
- data/lib/lucky_sneaks/string_extensions.rb +177 -0
- data/lib/lucky_sneaks/unidecoder.rb +61 -0
- data/lib/lucky_sneaks/unidecoder_data/x00.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x01.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x02.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x03.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x04.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x05.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x06.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x07.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x09.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x0a.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x0b.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x0c.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x0d.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x0e.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x0f.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x10.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x11.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x12.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x13.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x14.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x15.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x16.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x17.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x18.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x1e.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x1f.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x20.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x21.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x22.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x23.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x24.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x25.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x26.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x27.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x28.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x2e.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x2f.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x30.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x31.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x32.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x33.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x4d.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/x4e.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x4f.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x50.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x51.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x52.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x53.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x54.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x55.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x56.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x57.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x58.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x59.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x5a.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x5b.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x5c.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x5d.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x5e.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x5f.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x60.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x61.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x62.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x63.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x64.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x65.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x66.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x67.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x68.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x69.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x6a.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x6b.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x6c.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x6d.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x6e.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x6f.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x70.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x71.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x72.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x73.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x74.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x75.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x76.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x77.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x78.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x79.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x7a.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x7b.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x7c.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x7d.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x7e.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x7f.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x80.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x81.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x82.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x83.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x84.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x85.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x86.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x87.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x88.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x89.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x8a.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x8b.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x8c.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x8d.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x8e.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x8f.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x90.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x91.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x92.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x93.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x94.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x95.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x96.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x97.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x98.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x99.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x9a.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x9b.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x9c.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x9d.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x9e.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/x9f.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/xa0.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xa1.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xa2.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xa3.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xa4.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/xac.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xad.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xae.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xaf.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xb0.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xb1.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xb2.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xb3.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xb4.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xb5.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xb6.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xb7.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xb8.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xb9.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xba.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xbb.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xbc.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xbd.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xbe.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xbf.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xc0.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xc1.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xc2.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xc3.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xc4.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xc5.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xc6.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xc7.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xc8.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xc9.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xca.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xcb.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xcc.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xcd.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xce.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xcf.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xd0.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xd1.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xd2.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xd3.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xd4.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xd5.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xd6.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xd7.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/xf9.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xfa.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/xfb.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xfc.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xfd.yml +256 -0
- data/lib/lucky_sneaks/unidecoder_data/xfe.yml +257 -0
- data/lib/lucky_sneaks/unidecoder_data/xff.yml +257 -0
- data/lib/stringex.rb +9 -0
- data/stringex.gemspec +229 -0
- data/test/acts_as_url_test.rb +183 -0
- data/test/string_extensions_test.rb +142 -0
- data/test/unidecoder_test.rb +90 -0
- metadata +250 -0
data/lib/stringex.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'lucky_sneaks/string_extensions'
|
2
|
+
require 'lucky_sneaks/unidecoder'
|
3
|
+
|
4
|
+
String.send :include, LuckySneaks::StringExtensions
|
5
|
+
|
6
|
+
if defined?(ActiveRecord)
|
7
|
+
require 'lucky_sneaks/acts_as_url'
|
8
|
+
ActiveRecord::Base.send :include, LuckySneaks::ActsAsUrl
|
9
|
+
end
|
data/stringex.gemspec
ADDED
@@ -0,0 +1,229 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{stringex}
|
5
|
+
s.version = "1.0.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Russell Norris"]
|
9
|
+
s.date = %q{2009-07-20}
|
10
|
+
s.description = %q{Some [hopefully] useful extensions to Ruby’s String class. Stringex is made up of three libraries: ActsAsUrl [permalink solution with better character translation], Unidecoder [Unicode to Ascii transliteration], and StringExtensions [miscellaneous helper methods for the String class].}
|
11
|
+
s.email = %q{rsl@luckysneaks.com}
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"MIT-LICENSE",
|
14
|
+
"README.rdoc"
|
15
|
+
]
|
16
|
+
s.files = [
|
17
|
+
"MIT-LICENSE",
|
18
|
+
"README.rdoc",
|
19
|
+
"Rakefile",
|
20
|
+
"init.rb",
|
21
|
+
"lib/lucky_sneaks/acts_as_url.rb",
|
22
|
+
"lib/lucky_sneaks/string_extensions.rb",
|
23
|
+
"lib/lucky_sneaks/unidecoder.rb",
|
24
|
+
"lib/lucky_sneaks/unidecoder_data/x00.yml",
|
25
|
+
"lib/lucky_sneaks/unidecoder_data/x01.yml",
|
26
|
+
"lib/lucky_sneaks/unidecoder_data/x02.yml",
|
27
|
+
"lib/lucky_sneaks/unidecoder_data/x03.yml",
|
28
|
+
"lib/lucky_sneaks/unidecoder_data/x04.yml",
|
29
|
+
"lib/lucky_sneaks/unidecoder_data/x05.yml",
|
30
|
+
"lib/lucky_sneaks/unidecoder_data/x06.yml",
|
31
|
+
"lib/lucky_sneaks/unidecoder_data/x07.yml",
|
32
|
+
"lib/lucky_sneaks/unidecoder_data/x09.yml",
|
33
|
+
"lib/lucky_sneaks/unidecoder_data/x0a.yml",
|
34
|
+
"lib/lucky_sneaks/unidecoder_data/x0b.yml",
|
35
|
+
"lib/lucky_sneaks/unidecoder_data/x0c.yml",
|
36
|
+
"lib/lucky_sneaks/unidecoder_data/x0d.yml",
|
37
|
+
"lib/lucky_sneaks/unidecoder_data/x0e.yml",
|
38
|
+
"lib/lucky_sneaks/unidecoder_data/x0f.yml",
|
39
|
+
"lib/lucky_sneaks/unidecoder_data/x10.yml",
|
40
|
+
"lib/lucky_sneaks/unidecoder_data/x11.yml",
|
41
|
+
"lib/lucky_sneaks/unidecoder_data/x12.yml",
|
42
|
+
"lib/lucky_sneaks/unidecoder_data/x13.yml",
|
43
|
+
"lib/lucky_sneaks/unidecoder_data/x14.yml",
|
44
|
+
"lib/lucky_sneaks/unidecoder_data/x15.yml",
|
45
|
+
"lib/lucky_sneaks/unidecoder_data/x16.yml",
|
46
|
+
"lib/lucky_sneaks/unidecoder_data/x17.yml",
|
47
|
+
"lib/lucky_sneaks/unidecoder_data/x18.yml",
|
48
|
+
"lib/lucky_sneaks/unidecoder_data/x1e.yml",
|
49
|
+
"lib/lucky_sneaks/unidecoder_data/x1f.yml",
|
50
|
+
"lib/lucky_sneaks/unidecoder_data/x20.yml",
|
51
|
+
"lib/lucky_sneaks/unidecoder_data/x21.yml",
|
52
|
+
"lib/lucky_sneaks/unidecoder_data/x22.yml",
|
53
|
+
"lib/lucky_sneaks/unidecoder_data/x23.yml",
|
54
|
+
"lib/lucky_sneaks/unidecoder_data/x24.yml",
|
55
|
+
"lib/lucky_sneaks/unidecoder_data/x25.yml",
|
56
|
+
"lib/lucky_sneaks/unidecoder_data/x26.yml",
|
57
|
+
"lib/lucky_sneaks/unidecoder_data/x27.yml",
|
58
|
+
"lib/lucky_sneaks/unidecoder_data/x28.yml",
|
59
|
+
"lib/lucky_sneaks/unidecoder_data/x2e.yml",
|
60
|
+
"lib/lucky_sneaks/unidecoder_data/x2f.yml",
|
61
|
+
"lib/lucky_sneaks/unidecoder_data/x30.yml",
|
62
|
+
"lib/lucky_sneaks/unidecoder_data/x31.yml",
|
63
|
+
"lib/lucky_sneaks/unidecoder_data/x32.yml",
|
64
|
+
"lib/lucky_sneaks/unidecoder_data/x33.yml",
|
65
|
+
"lib/lucky_sneaks/unidecoder_data/x4d.yml",
|
66
|
+
"lib/lucky_sneaks/unidecoder_data/x4e.yml",
|
67
|
+
"lib/lucky_sneaks/unidecoder_data/x4f.yml",
|
68
|
+
"lib/lucky_sneaks/unidecoder_data/x50.yml",
|
69
|
+
"lib/lucky_sneaks/unidecoder_data/x51.yml",
|
70
|
+
"lib/lucky_sneaks/unidecoder_data/x52.yml",
|
71
|
+
"lib/lucky_sneaks/unidecoder_data/x53.yml",
|
72
|
+
"lib/lucky_sneaks/unidecoder_data/x54.yml",
|
73
|
+
"lib/lucky_sneaks/unidecoder_data/x55.yml",
|
74
|
+
"lib/lucky_sneaks/unidecoder_data/x56.yml",
|
75
|
+
"lib/lucky_sneaks/unidecoder_data/x57.yml",
|
76
|
+
"lib/lucky_sneaks/unidecoder_data/x58.yml",
|
77
|
+
"lib/lucky_sneaks/unidecoder_data/x59.yml",
|
78
|
+
"lib/lucky_sneaks/unidecoder_data/x5a.yml",
|
79
|
+
"lib/lucky_sneaks/unidecoder_data/x5b.yml",
|
80
|
+
"lib/lucky_sneaks/unidecoder_data/x5c.yml",
|
81
|
+
"lib/lucky_sneaks/unidecoder_data/x5d.yml",
|
82
|
+
"lib/lucky_sneaks/unidecoder_data/x5e.yml",
|
83
|
+
"lib/lucky_sneaks/unidecoder_data/x5f.yml",
|
84
|
+
"lib/lucky_sneaks/unidecoder_data/x60.yml",
|
85
|
+
"lib/lucky_sneaks/unidecoder_data/x61.yml",
|
86
|
+
"lib/lucky_sneaks/unidecoder_data/x62.yml",
|
87
|
+
"lib/lucky_sneaks/unidecoder_data/x63.yml",
|
88
|
+
"lib/lucky_sneaks/unidecoder_data/x64.yml",
|
89
|
+
"lib/lucky_sneaks/unidecoder_data/x65.yml",
|
90
|
+
"lib/lucky_sneaks/unidecoder_data/x66.yml",
|
91
|
+
"lib/lucky_sneaks/unidecoder_data/x67.yml",
|
92
|
+
"lib/lucky_sneaks/unidecoder_data/x68.yml",
|
93
|
+
"lib/lucky_sneaks/unidecoder_data/x69.yml",
|
94
|
+
"lib/lucky_sneaks/unidecoder_data/x6a.yml",
|
95
|
+
"lib/lucky_sneaks/unidecoder_data/x6b.yml",
|
96
|
+
"lib/lucky_sneaks/unidecoder_data/x6c.yml",
|
97
|
+
"lib/lucky_sneaks/unidecoder_data/x6d.yml",
|
98
|
+
"lib/lucky_sneaks/unidecoder_data/x6e.yml",
|
99
|
+
"lib/lucky_sneaks/unidecoder_data/x6f.yml",
|
100
|
+
"lib/lucky_sneaks/unidecoder_data/x70.yml",
|
101
|
+
"lib/lucky_sneaks/unidecoder_data/x71.yml",
|
102
|
+
"lib/lucky_sneaks/unidecoder_data/x72.yml",
|
103
|
+
"lib/lucky_sneaks/unidecoder_data/x73.yml",
|
104
|
+
"lib/lucky_sneaks/unidecoder_data/x74.yml",
|
105
|
+
"lib/lucky_sneaks/unidecoder_data/x75.yml",
|
106
|
+
"lib/lucky_sneaks/unidecoder_data/x76.yml",
|
107
|
+
"lib/lucky_sneaks/unidecoder_data/x77.yml",
|
108
|
+
"lib/lucky_sneaks/unidecoder_data/x78.yml",
|
109
|
+
"lib/lucky_sneaks/unidecoder_data/x79.yml",
|
110
|
+
"lib/lucky_sneaks/unidecoder_data/x7a.yml",
|
111
|
+
"lib/lucky_sneaks/unidecoder_data/x7b.yml",
|
112
|
+
"lib/lucky_sneaks/unidecoder_data/x7c.yml",
|
113
|
+
"lib/lucky_sneaks/unidecoder_data/x7d.yml",
|
114
|
+
"lib/lucky_sneaks/unidecoder_data/x7e.yml",
|
115
|
+
"lib/lucky_sneaks/unidecoder_data/x7f.yml",
|
116
|
+
"lib/lucky_sneaks/unidecoder_data/x80.yml",
|
117
|
+
"lib/lucky_sneaks/unidecoder_data/x81.yml",
|
118
|
+
"lib/lucky_sneaks/unidecoder_data/x82.yml",
|
119
|
+
"lib/lucky_sneaks/unidecoder_data/x83.yml",
|
120
|
+
"lib/lucky_sneaks/unidecoder_data/x84.yml",
|
121
|
+
"lib/lucky_sneaks/unidecoder_data/x85.yml",
|
122
|
+
"lib/lucky_sneaks/unidecoder_data/x86.yml",
|
123
|
+
"lib/lucky_sneaks/unidecoder_data/x87.yml",
|
124
|
+
"lib/lucky_sneaks/unidecoder_data/x88.yml",
|
125
|
+
"lib/lucky_sneaks/unidecoder_data/x89.yml",
|
126
|
+
"lib/lucky_sneaks/unidecoder_data/x8a.yml",
|
127
|
+
"lib/lucky_sneaks/unidecoder_data/x8b.yml",
|
128
|
+
"lib/lucky_sneaks/unidecoder_data/x8c.yml",
|
129
|
+
"lib/lucky_sneaks/unidecoder_data/x8d.yml",
|
130
|
+
"lib/lucky_sneaks/unidecoder_data/x8e.yml",
|
131
|
+
"lib/lucky_sneaks/unidecoder_data/x8f.yml",
|
132
|
+
"lib/lucky_sneaks/unidecoder_data/x90.yml",
|
133
|
+
"lib/lucky_sneaks/unidecoder_data/x91.yml",
|
134
|
+
"lib/lucky_sneaks/unidecoder_data/x92.yml",
|
135
|
+
"lib/lucky_sneaks/unidecoder_data/x93.yml",
|
136
|
+
"lib/lucky_sneaks/unidecoder_data/x94.yml",
|
137
|
+
"lib/lucky_sneaks/unidecoder_data/x95.yml",
|
138
|
+
"lib/lucky_sneaks/unidecoder_data/x96.yml",
|
139
|
+
"lib/lucky_sneaks/unidecoder_data/x97.yml",
|
140
|
+
"lib/lucky_sneaks/unidecoder_data/x98.yml",
|
141
|
+
"lib/lucky_sneaks/unidecoder_data/x99.yml",
|
142
|
+
"lib/lucky_sneaks/unidecoder_data/x9a.yml",
|
143
|
+
"lib/lucky_sneaks/unidecoder_data/x9b.yml",
|
144
|
+
"lib/lucky_sneaks/unidecoder_data/x9c.yml",
|
145
|
+
"lib/lucky_sneaks/unidecoder_data/x9d.yml",
|
146
|
+
"lib/lucky_sneaks/unidecoder_data/x9e.yml",
|
147
|
+
"lib/lucky_sneaks/unidecoder_data/x9f.yml",
|
148
|
+
"lib/lucky_sneaks/unidecoder_data/xa0.yml",
|
149
|
+
"lib/lucky_sneaks/unidecoder_data/xa1.yml",
|
150
|
+
"lib/lucky_sneaks/unidecoder_data/xa2.yml",
|
151
|
+
"lib/lucky_sneaks/unidecoder_data/xa3.yml",
|
152
|
+
"lib/lucky_sneaks/unidecoder_data/xa4.yml",
|
153
|
+
"lib/lucky_sneaks/unidecoder_data/xac.yml",
|
154
|
+
"lib/lucky_sneaks/unidecoder_data/xad.yml",
|
155
|
+
"lib/lucky_sneaks/unidecoder_data/xae.yml",
|
156
|
+
"lib/lucky_sneaks/unidecoder_data/xaf.yml",
|
157
|
+
"lib/lucky_sneaks/unidecoder_data/xb0.yml",
|
158
|
+
"lib/lucky_sneaks/unidecoder_data/xb1.yml",
|
159
|
+
"lib/lucky_sneaks/unidecoder_data/xb2.yml",
|
160
|
+
"lib/lucky_sneaks/unidecoder_data/xb3.yml",
|
161
|
+
"lib/lucky_sneaks/unidecoder_data/xb4.yml",
|
162
|
+
"lib/lucky_sneaks/unidecoder_data/xb5.yml",
|
163
|
+
"lib/lucky_sneaks/unidecoder_data/xb6.yml",
|
164
|
+
"lib/lucky_sneaks/unidecoder_data/xb7.yml",
|
165
|
+
"lib/lucky_sneaks/unidecoder_data/xb8.yml",
|
166
|
+
"lib/lucky_sneaks/unidecoder_data/xb9.yml",
|
167
|
+
"lib/lucky_sneaks/unidecoder_data/xba.yml",
|
168
|
+
"lib/lucky_sneaks/unidecoder_data/xbb.yml",
|
169
|
+
"lib/lucky_sneaks/unidecoder_data/xbc.yml",
|
170
|
+
"lib/lucky_sneaks/unidecoder_data/xbd.yml",
|
171
|
+
"lib/lucky_sneaks/unidecoder_data/xbe.yml",
|
172
|
+
"lib/lucky_sneaks/unidecoder_data/xbf.yml",
|
173
|
+
"lib/lucky_sneaks/unidecoder_data/xc0.yml",
|
174
|
+
"lib/lucky_sneaks/unidecoder_data/xc1.yml",
|
175
|
+
"lib/lucky_sneaks/unidecoder_data/xc2.yml",
|
176
|
+
"lib/lucky_sneaks/unidecoder_data/xc3.yml",
|
177
|
+
"lib/lucky_sneaks/unidecoder_data/xc4.yml",
|
178
|
+
"lib/lucky_sneaks/unidecoder_data/xc5.yml",
|
179
|
+
"lib/lucky_sneaks/unidecoder_data/xc6.yml",
|
180
|
+
"lib/lucky_sneaks/unidecoder_data/xc7.yml",
|
181
|
+
"lib/lucky_sneaks/unidecoder_data/xc8.yml",
|
182
|
+
"lib/lucky_sneaks/unidecoder_data/xc9.yml",
|
183
|
+
"lib/lucky_sneaks/unidecoder_data/xca.yml",
|
184
|
+
"lib/lucky_sneaks/unidecoder_data/xcb.yml",
|
185
|
+
"lib/lucky_sneaks/unidecoder_data/xcc.yml",
|
186
|
+
"lib/lucky_sneaks/unidecoder_data/xcd.yml",
|
187
|
+
"lib/lucky_sneaks/unidecoder_data/xce.yml",
|
188
|
+
"lib/lucky_sneaks/unidecoder_data/xcf.yml",
|
189
|
+
"lib/lucky_sneaks/unidecoder_data/xd0.yml",
|
190
|
+
"lib/lucky_sneaks/unidecoder_data/xd1.yml",
|
191
|
+
"lib/lucky_sneaks/unidecoder_data/xd2.yml",
|
192
|
+
"lib/lucky_sneaks/unidecoder_data/xd3.yml",
|
193
|
+
"lib/lucky_sneaks/unidecoder_data/xd4.yml",
|
194
|
+
"lib/lucky_sneaks/unidecoder_data/xd5.yml",
|
195
|
+
"lib/lucky_sneaks/unidecoder_data/xd6.yml",
|
196
|
+
"lib/lucky_sneaks/unidecoder_data/xd7.yml",
|
197
|
+
"lib/lucky_sneaks/unidecoder_data/xf9.yml",
|
198
|
+
"lib/lucky_sneaks/unidecoder_data/xfa.yml",
|
199
|
+
"lib/lucky_sneaks/unidecoder_data/xfb.yml",
|
200
|
+
"lib/lucky_sneaks/unidecoder_data/xfc.yml",
|
201
|
+
"lib/lucky_sneaks/unidecoder_data/xfd.yml",
|
202
|
+
"lib/lucky_sneaks/unidecoder_data/xfe.yml",
|
203
|
+
"lib/lucky_sneaks/unidecoder_data/xff.yml",
|
204
|
+
"lib/stringex.rb",
|
205
|
+
"stringex.gemspec"
|
206
|
+
]
|
207
|
+
s.has_rdoc = true
|
208
|
+
s.homepage = %q{http://github.com/rsl/stringex}
|
209
|
+
s.rdoc_options = ["--main", "README.rdoc", "--charset", "utf-8", "--line-numbers"]
|
210
|
+
s.require_paths = ["lib"]
|
211
|
+
s.rubyforge_project = %q{stringex}
|
212
|
+
s.rubygems_version = %q{1.3.2}
|
213
|
+
s.summary = %q{Some [hopefully] useful extensions to Ruby’s String class}
|
214
|
+
s.test_files = [
|
215
|
+
"test/acts_as_url_test.rb",
|
216
|
+
"test/string_extensions_test.rb",
|
217
|
+
"test/unidecoder_test.rb"
|
218
|
+
]
|
219
|
+
|
220
|
+
if s.respond_to? :specification_version then
|
221
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
222
|
+
s.specification_version = 3
|
223
|
+
|
224
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
225
|
+
else
|
226
|
+
end
|
227
|
+
else
|
228
|
+
end
|
229
|
+
end
|
@@ -0,0 +1,183 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
begin
|
4
|
+
require File.dirname(__FILE__) + '/../../../config/environment'
|
5
|
+
rescue LoadError
|
6
|
+
require 'rubygems'
|
7
|
+
gem 'activerecord'
|
8
|
+
require 'active_record'
|
9
|
+
|
10
|
+
RAILS_ROOT = File.dirname(__FILE__)
|
11
|
+
$: << File.join(File.dirname(__FILE__), '../lib')
|
12
|
+
end
|
13
|
+
|
14
|
+
require File.join(File.dirname(__FILE__), '../init')
|
15
|
+
|
16
|
+
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => "acts_as_url.sqlite3")
|
17
|
+
|
18
|
+
ActiveRecord::Migration.verbose = false
|
19
|
+
ActiveRecord::Schema.define(:version => 1) do
|
20
|
+
create_table :documents, :force => true do |t|
|
21
|
+
t.string :title, :url, :other
|
22
|
+
end
|
23
|
+
|
24
|
+
create_table :updateuments, :force => true do |t|
|
25
|
+
t.string :title, :url, :other
|
26
|
+
end
|
27
|
+
|
28
|
+
create_table :mocuments, :force => true do |t|
|
29
|
+
t.string :title, :url, :other
|
30
|
+
end
|
31
|
+
|
32
|
+
create_table :permuments, :force => true do |t|
|
33
|
+
t.string :title, :permalink, :other
|
34
|
+
end
|
35
|
+
|
36
|
+
create_table :procuments, :force => true do |t|
|
37
|
+
t.string :title, :url, :other
|
38
|
+
end
|
39
|
+
|
40
|
+
create_table :blankuments, :force => true do |t|
|
41
|
+
t.string :title, :url, :other
|
42
|
+
end
|
43
|
+
end
|
44
|
+
ActiveRecord::Migration.verbose = true
|
45
|
+
|
46
|
+
class Document < ActiveRecord::Base
|
47
|
+
acts_as_url :title
|
48
|
+
end
|
49
|
+
|
50
|
+
class Updateument < ActiveRecord::Base
|
51
|
+
acts_as_url :title, :sync_url => true
|
52
|
+
end
|
53
|
+
|
54
|
+
class Mocument < ActiveRecord::Base
|
55
|
+
acts_as_url :title, :scope => :other, :sync_url => true
|
56
|
+
end
|
57
|
+
|
58
|
+
class Permument < ActiveRecord::Base
|
59
|
+
acts_as_url :title, :url_attribute => :permalink
|
60
|
+
end
|
61
|
+
|
62
|
+
class Procument < ActiveRecord::Base
|
63
|
+
acts_as_url :non_attribute_method
|
64
|
+
|
65
|
+
def non_attribute_method
|
66
|
+
"#{title} got massaged"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
class Blankument < ActiveRecord::Base
|
71
|
+
acts_as_url :title, :only_when_blank => true
|
72
|
+
end
|
73
|
+
|
74
|
+
class ActsAsUrlTest < Test::Unit::TestCase
|
75
|
+
def test_should_create_url
|
76
|
+
@doc = Document.create(:title => "Let's Make a Test Title, <em>Okay</em>?")
|
77
|
+
assert_equal "lets-make-a-test-title-okay", @doc.url
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_should_create_unique_url
|
81
|
+
@doc = Document.create!(:title => "Unique")
|
82
|
+
@other_doc = Document.create!(:title => "Unique")
|
83
|
+
assert_equal "unique-1", @other_doc.url
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_should_not_succ_on_repeated_saves
|
87
|
+
@doc = Document.new(:title => "Continuous or Constant")
|
88
|
+
5.times do
|
89
|
+
@doc.save!
|
90
|
+
assert_equal "continuous-or-constant", @doc.url
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_should_create_unique_url_and_not_clobber_if_another_exists
|
95
|
+
@doc = Updateument.create!(:title => "Unique")
|
96
|
+
@other_doc = Updateument.create!(:title => "Unique")
|
97
|
+
@doc.update_attributes :other => "foo"
|
98
|
+
|
99
|
+
@doc2 = Document.create!(:title => "twonique")
|
100
|
+
@other_doc2 = Document.create!(:title => "twonique")
|
101
|
+
@doc2.update_attributes(:other => "foo")
|
102
|
+
|
103
|
+
assert_equal "unique", @doc.url
|
104
|
+
assert_equal "foo", @doc.other
|
105
|
+
assert_equal "unique-1", @other_doc.url
|
106
|
+
|
107
|
+
assert_equal "twonique", @doc2.url
|
108
|
+
assert_equal "foo", @doc2.other
|
109
|
+
assert_equal "twonique-1", @other_doc2.url
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_should_scope_uniqueness
|
113
|
+
@moc = Mocument.create!(:title => "Mocumentary", :other => "I dunno why but I don't care if I'm unique")
|
114
|
+
@other_moc = Mocument.create!(:title => "Mocumentary")
|
115
|
+
assert_equal @moc.url, @other_moc.url
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_should_still_create_unique_if_in_same_scope
|
119
|
+
@moc = Mocument.create!(:title => "Mocumentary", :other => "Suddenly, I care if I'm unique")
|
120
|
+
@other_moc = Mocument.create!(:title => "Mocumentary", :other => "Suddenly, I care if I'm unique")
|
121
|
+
assert_not_equal @moc.url, @other_moc.url
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_should_use_alternate_field_name
|
125
|
+
@perm = Permument.create!(:title => "Anything at This Point")
|
126
|
+
assert_equal "anything-at-this-point", @perm.permalink
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_should_not_update_url_by_default
|
130
|
+
@doc = Document.create!(:title => "Stable as Stone")
|
131
|
+
@original_url = @doc.url
|
132
|
+
@doc.update_attributes :title => "New Unstable Madness"
|
133
|
+
assert_equal @original_url, @doc.url
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_should_update_url_if_asked
|
137
|
+
@moc = Mocument.create!(:title => "Original")
|
138
|
+
@original_url = @moc.url
|
139
|
+
@moc.update_attributes :title => "New and Improved"
|
140
|
+
assert_not_equal @original_url, @moc.url
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_should_update_url_only_when_blank_if_asked
|
144
|
+
@original_url = 'the-url-of-concrete'
|
145
|
+
@blank = Blankument.create!(:title => "Stable as Stone", :url => @original_url)
|
146
|
+
assert_equal @original_url, @blank.url
|
147
|
+
@blank = Blankument.create!(:title => "Stable as Stone")
|
148
|
+
assert_equal 'stable-as-stone', @blank.url
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_should_mass_initialize_urls
|
152
|
+
@doc_1 = Document.create!(:title => "Initial")
|
153
|
+
@doc_2 = Document.create!(:title => "Subsequent")
|
154
|
+
@doc_1.update_attribute :url, nil
|
155
|
+
@doc_2.update_attribute :url, nil
|
156
|
+
assert_nil @doc_1.url
|
157
|
+
assert_nil @doc_2.url
|
158
|
+
Document.initialize_urls
|
159
|
+
@doc_1.reload
|
160
|
+
@doc_2.reload
|
161
|
+
assert_equal "initial", @doc_1.url
|
162
|
+
assert_equal "subsequent", @doc_2.url
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_should_mass_initialize_urls_with_custom_url_attribute
|
166
|
+
@doc_1 = Permument.create!(:title => "Initial")
|
167
|
+
@doc_2 = Permument.create!(:title => "Subsequent")
|
168
|
+
@doc_1.update_attribute :permalink, nil
|
169
|
+
@doc_2.update_attribute :permalink, nil
|
170
|
+
assert_nil @doc_1.permalink
|
171
|
+
assert_nil @doc_2.permalink
|
172
|
+
Permument.initialize_urls
|
173
|
+
@doc_1.reload
|
174
|
+
@doc_2.reload
|
175
|
+
assert_equal "initial", @doc_1.permalink
|
176
|
+
assert_equal "subsequent", @doc_2.permalink
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_should_utilize_block_if_given
|
180
|
+
@doc = Procument.create!(:title => "Title String")
|
181
|
+
assert_equal "title-string-got-massaged", @doc.url
|
182
|
+
end
|
183
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
|
3
|
+
$: << File.join(File.dirname(__FILE__), '../lib')
|
4
|
+
require File.join(File.dirname(__FILE__), "../init")
|
5
|
+
|
6
|
+
class StringExtensionsTest < Test::Unit::TestCase
|
7
|
+
def test_to_html
|
8
|
+
require "rubygems"
|
9
|
+
require "RedCloth"
|
10
|
+
{
|
11
|
+
"h1. A Solution" => "<h1>A Solution</h1>",
|
12
|
+
"I hated wrapping textilize around a string.\n\nIt always felt dirty." =>
|
13
|
+
"<p>I hated wrapping textilize around a string.</p>\n<p>It always felt dirty.</p>",
|
14
|
+
"I think _this_ is awesome" => "<p>I think <em>this</em> is awesome</p>",
|
15
|
+
"Um... _*really*_, man" => "<p>Um… <em><strong>really</strong></em>, man</p>"
|
16
|
+
}.each do |plain, html|
|
17
|
+
assert_equal html, plain.to_html
|
18
|
+
end
|
19
|
+
rescue LoadError
|
20
|
+
puts "\n>> Could not load RedCloth. String#to_html was not tested.\n>> Please gem install RedCloth if you'd like to use this functionality."
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_to_html_lite
|
24
|
+
require "rubygems"
|
25
|
+
require "RedCloth"
|
26
|
+
{
|
27
|
+
"I have no pee on me" => "I have no pee on me",
|
28
|
+
"But I _do_ get Textile!" => "But I <em>do</em> get Textile!"
|
29
|
+
}.each do |plain, html|
|
30
|
+
assert_equal html, plain.to_html(:lite)
|
31
|
+
end
|
32
|
+
rescue LoadError
|
33
|
+
puts "\n>> Could not load RedCloth. String#to_html (with :lite argument) was not tested.\n>> Please gem install RedCloth if you'd like to use this functionality."
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_to_url
|
37
|
+
{
|
38
|
+
"<p>This has 100% too much <em>formatting</em></p>" =>
|
39
|
+
"this-has-100-percent-too-much-formatting",
|
40
|
+
"Tea & crumpets & <strong>crêpes</strong> for me!" =>
|
41
|
+
"tea-and-crumpets-and-crepes-for-me",
|
42
|
+
"The Suspense... Is... Killing Me" =>
|
43
|
+
"the-suspense-dot-dot-dot-is-dot-dot-dot-killing-me",
|
44
|
+
"How to use attr_accessible and attr_protected" =>
|
45
|
+
"how-to-use-attr-accessible-and-attr-protected",
|
46
|
+
"I'm just making sure there's nothing wrong with things!" =>
|
47
|
+
"im-just-making-sure-theres-nothing-wrong-with-things"
|
48
|
+
}.each do |html, plain|
|
49
|
+
assert_equal plain, html.to_url
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_remove_formatting
|
54
|
+
{
|
55
|
+
"<p>This has 100% too much <em>formatting</em></p>" =>
|
56
|
+
"This has 100 percent too much formatting",
|
57
|
+
"Tea & crumpets & <strong>crêpes</strong> for me!" =>
|
58
|
+
"Tea and crumpets and crepes for me"
|
59
|
+
}.each do |html, plain|
|
60
|
+
assert_equal plain, html.remove_formatting
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_strip_html_tags
|
65
|
+
{
|
66
|
+
"<h1><em>This</em> is good but <strong>that</strong> is better</h1>" =>
|
67
|
+
"This is good but that is better",
|
68
|
+
"<p>This is invalid XHTML but valid HTML, right?" =>
|
69
|
+
"This is invalid XHTML but valid HTML, right?",
|
70
|
+
"<p class='foo'>Everything goes!</p>" => "Everything goes!",
|
71
|
+
"<ol>This is completely invalid and just plain wrong</p>" =>
|
72
|
+
"This is completely invalid and just plain wrong"
|
73
|
+
}.each do |html, plain|
|
74
|
+
assert_equal plain, html.strip_html_tags
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_convert_accented_entities
|
79
|
+
{
|
80
|
+
"å" => "a",
|
81
|
+
"è" => "e",
|
82
|
+
"î" => "i",
|
83
|
+
"Ø" => "O",
|
84
|
+
"ü" => "u",
|
85
|
+
"Ñ" => "N",
|
86
|
+
"ç" => "c"
|
87
|
+
}.each do |entitied, plain|
|
88
|
+
assert_equal plain, entitied.convert_accented_entities
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_convert_misc_entities
|
93
|
+
{
|
94
|
+
"America™" => "America(tm)",
|
95
|
+
"Tea & Sympathy" => "Tea and Sympathy",
|
96
|
+
"To be continued…" => "To be continued...",
|
97
|
+
"Foo Bar" => "Foo Bar",
|
98
|
+
"100£" => "100 pound",
|
99
|
+
"½ a dollar" => "half a dollar",
|
100
|
+
"35°" => "35 degrees"
|
101
|
+
}.each do |entitied, plain|
|
102
|
+
assert_equal plain, entitied.convert_misc_entities
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_convert_misc_characters
|
107
|
+
{
|
108
|
+
"Foo & bar make foobar" => "Foo and bar make foobar",
|
109
|
+
"Breakdown #9" => "Breakdown number 9",
|
110
|
+
"foo@bar.com" => "foo at bar dot com",
|
111
|
+
"100% of yr love" => "100 percent of yr love",
|
112
|
+
"Kisses are $3.25 each" => "Kisses are 3 dollars 25 cents each",
|
113
|
+
"That CD is £3.25 plus tax" => "That CD is 3 pounds 25 pence plus tax",
|
114
|
+
"This CD is ¥1000 instead" => "This CD is 1000 yen instead"
|
115
|
+
}.each do |misc, plain|
|
116
|
+
assert_equal plain, misc.convert_misc_characters
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_replace_whitespace
|
121
|
+
{
|
122
|
+
"this has too much space" => "this has too much space",
|
123
|
+
"\t\tThis is merely formatted with superfluous whitespace\n" =>
|
124
|
+
" This is merely formatted with superfluous whitespace "
|
125
|
+
}.each do |whitespaced, plain|
|
126
|
+
assert_equal plain, whitespaced.replace_whitespace
|
127
|
+
end
|
128
|
+
|
129
|
+
assert_equal "now-with-more-hyphens", "now with more hyphens".replace_whitespace("-")
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_collapse
|
133
|
+
{
|
134
|
+
"too much space" => "too much space",
|
135
|
+
" at the beginning" => "at the beginning"
|
136
|
+
}.each do |uncollapsed, plain|
|
137
|
+
assert_equal plain, uncollapsed.collapse
|
138
|
+
end
|
139
|
+
|
140
|
+
assert_equal "now-with-hyphens", "----now---------with-hyphens--------".collapse("-")
|
141
|
+
end
|
142
|
+
end
|