Converting /to slash. #50

Merged
merged 1 commit into from Jul 12, 2012
Jump to file or symbol
Failed to load files and symbols.
+12 −10
Diff settings

Always

Just for now

@@ -40,7 +40,7 @@ def to_url(options = {})
end
def limit(lim = nil)
- lim.nil? ? self : self[0...lim]
+ lim.nil? ? self : self[0...lim]
end
# Performs multiple text manipulations. Essentially a shortcut for typing them all. View source
@@ -173,7 +173,7 @@ def convert_misc_characters(options = {})
dummy.gsub!(found, replaced)
end
# Back to normal rules
- misc_characters =
+ misc_characters =
{
/\s*&\s*/ => "and",
/\s*#/ => "number",
@@ -188,7 +188,7 @@ def convert_misc_characters(options = {})
/\s*\+\s*/ => "plus",
/\s\s*/ => "degrees"
}
- misc_characters[/\s*(\\|\/)\s*/] = 'slash' unless options[:allow_slash]
+ misc_characters[/\s*(\\|\/|/)\s*/] = 'slash' unless options[:allow_slash]
misc_characters.each do |found, replaced|
replaced = " #{replaced} " unless replaced =~ /\\1/
dummy.gsub!(found, replaced)
@@ -57,18 +57,20 @@ def test_to_url
"one-fourth-pound-with-cheese",
"Will's Ferrel" =>
"wills-ferrel",
- "Капитал" =>
+ "Капитал" =>
"kapital",
- "Ελλάδα" =>
+ "Ελλάδα" =>
"ellada",
- "中文" =>
+ "中文" =>
"zhong-wen",
- "Paul Cézanne" =>
+ "Paul Cézanne" =>
"paul-cezanne",
- "21'17ʼ51" =>
+ "21'17ʼ51" =>
"21-17-51",
- "ITCZ 1 (21°17ʼ51.78”N / 89°35ʼ28.18”O / 26-04-08 / 09:00 am)" =>
- "itcz-1-21-degrees-17-51-dot-78-n-slash-89-degrees-35-28-dot-18-o-slash-26-04-08-slash-09-00-am"
+ "ITCZ 1 (21°17ʼ51.78”N / 89°35ʼ28.18”O / 26-04-08 / 09:00 am)" =>
+ "itcz-1-21-degrees-17-51-dot-78-n-slash-89-degrees-35-28-dot-18-o-slash-26-04-08-slash-09-00-am",
+ "" =>
+ "slash"
}.each do |html, plain|
assert_equal plain, html.to_url
end