Hoodow-stringex 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -42,7 +42,12 @@ module LuckySneaks
42
42
  # Performs multiple text manipulations. Essentially a shortcut for typing them all. View source
43
43
  # below to see which methods are run.
44
44
  def remove_formatting
45
- strip_html_tags.convert_accented_entities.convert_misc_entities.convert_misc_characters.to_ascii.collapse
45
+ strip_html_tags.
46
+ convert_german_umlauts.
47
+ convert_accented_entities.
48
+ convert_misc_entities.
49
+ convert_misc_characters.
50
+ to_ascii.collapse
46
51
  end
47
52
 
48
53
  # Removes HTML tags from text. This code is simplified from Tobias Luettke's regular expression
@@ -70,6 +75,20 @@ module LuckySneaks
70
75
  gsub(/&([A-Za-z])(grave|acute|circ|tilde|uml|ring|cedil|slash);/, '\1')
71
76
  end
72
77
 
78
+ # Converts German Umlauts to their transliteration according to German conventions.
79
+ def convert_german_umlauts
80
+ map = {
81
+ "Ä" => "ae",
82
+ "Ö" => "oe",
83
+ "Ü" => "ue",
84
+ "ä" => "ae",
85
+ "ö" => "oe",
86
+ "ü" => "ue",
87
+ "ß" => "ss"
88
+ }
89
+ gsub(/#{map.keys.join('|')}/) { |match| map[match] }
90
+ end
91
+
73
92
  # Converts HTML entities (taken from common Textile/RedCloth formattings) into plain text formats.
74
93
  #
75
94
  # Note: This isn't an attempt at complete conversion of HTML entities, just those most likely
data/stringex.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{stringex}
5
- s.version = "1.0.0"
5
+ s.version = "1.0.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Russell Norris"]
@@ -44,7 +44,9 @@ class StringExtensionsTest < Test::Unit::TestCase
44
44
  "How to use attr_accessible and attr_protected" =>
45
45
  "how-to-use-attr-accessible-and-attr-protected",
46
46
  "I'm just making sure there's nothing wrong with things!" =>
47
- "im-just-making-sure-theres-nothing-wrong-with-things"
47
+ "im-just-making-sure-theres-nothing-wrong-with-things",
48
+ "Umlaute hätten wir außerdem gern deutsch übersetzt." =>
49
+ "umlaute-haetten-wir-ausserdem-gern-deutsch-uebersetzt"
48
50
  }.each do |html, plain|
49
51
  assert_equal plain, html.to_url
50
52
  end
@@ -89,6 +91,20 @@ class StringExtensionsTest < Test::Unit::TestCase
89
91
  end
90
92
  end
91
93
 
94
+ def test_convert_german_umlauts
95
+ {
96
+ "Ä" => "ae",
97
+ "Ö" => "oe",
98
+ "Ü" => "ue",
99
+ "ä" => "ae",
100
+ "ö" => "oe",
101
+ "ü" => "ue",
102
+ "ß" => "ss"
103
+ }.each do |entitied, plain|
104
+ assert_equal plain, entitied.convert_german_umlauts
105
+ end
106
+ end
107
+
92
108
  def test_convert_misc_entities
93
109
  {
94
110
  "America&#8482;" => "America(tm)",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Hoodow-stringex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Russell Norris