Permalink
Browse files

+ Extract Base class for character substituters

  • Loading branch information...
1 parent 61b8711 commit 77acc31582fc3ed1cbeccb4e6938527b9b415675 @floere committed Dec 6, 2012
View
21 server/lib/picky/character_substituters/base.rb
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+
+module Picky
+
+ module CharacterSubstituters
+
+ class Base
+
+ def initialize
+ @chars = ActiveSupport::Multibyte.proxy_class
+ end
+
+ def to_s
+ self.class.name
+ end
+
+ end
+
+ end
+
+end
View
10 server/lib/picky/character_substituters/polish.rb
@@ -4,11 +4,7 @@ module Picky
module CharacterSubstituters
- class Polish
-
- def initialize
- @chars = ActiveSupport::Multibyte.proxy_class
- end
+ class Polish < Base
def substitute text
trans = @chars.new(text).normalize :kd
@@ -21,10 +17,6 @@ def substitute text
}.pack 'U*'
end
- def to_s
- self.class.name
- end
-
end
end
View
10 server/lib/picky/character_substituters/west_european.rb
@@ -10,11 +10,7 @@ module CharacterSubstituters
# ä, ö, ü => ae, oe, ue.
# (and more, see specs)
#
- class WestEuropean
-
- def initialize
- @chars = ActiveSupport::Multibyte.proxy_class
- end
+ class WestEuropean < Base
# Substitutes occurrences of certain characters
# (like Umlauts) with ASCII representations of them.
@@ -45,10 +41,6 @@ def substitute text
}.pack 'U*'
end
- def to_s
- self.class.name
- end
-
end
end
View
1 server/lib/picky/loader.rb
@@ -268,6 +268,7 @@ def load_user_interface
load_relative 'tokenizer/regexp_wrapper'
load_relative 'tokenizer'
# load_relative 'rack/harakiri' # Needs to be explicitly loaded/required.
+ load_relative 'character_substituters/base'
load_relative 'character_substituters/west_european'
load_relative 'character_substituters/polish'
load_relative 'splitters/automatic'

0 comments on commit 77acc31

Please sign in to comment.