string_normalizr 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest ADDED
@@ -0,0 +1,8 @@
1
+ README.rdoc
2
+ Rakefile
3
+ init.rb
4
+ lib/string_normalizr.rb
5
+ nbproject/private/rake-d.txt
6
+ string_normalizr.gemspec
7
+ test/string_normalizr_test.rb
8
+ Manifest
data/README.rdoc ADDED
@@ -0,0 +1,27 @@
1
+ == String Normalizr
2
+ === Simplifying the non-ASCII world
3
+
4
+ This gem adds String#normalize to easily retrieve a normalized representation
5
+ of your String instance.
6
+
7
+
8
+ === Installation
9
+ $ gem install carpodaster-string_normalizr --source http://gems.github.com
10
+
11
+ Or use it as a plugin with your Rails app:
12
+
13
+ $ ruby script/plugin install git://github.com/carpodaster/string_normalizr.git
14
+
15
+ === Usage
16
+ "hellö world".normalize
17
+
18
+ === Caveats
19
+ * Tests seem to have difficulties with multibyte characters right now.
20
+
21
+ === .plan
22
+ * Add option-hash to customize the normalization
23
+
24
+
25
+ ---
26
+
27
+ Copyright (c) 2010 Carsten Zimmermann, released under a BSD-type license
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ require "rubygems"
2
+ require "rake"
3
+ require "echoe"
4
+
5
+ task :default => [:test, :rebuild]
6
+
7
+ Rake::TestTask.new("test") do |t|
8
+ t.test_files = FileList['test/*_test.rb']
9
+ t.verbose = false
10
+ end
11
+
12
+ Echoe.new('string_normalizr', '0.1') do |p|
13
+ p.description = "Let String instances be conviently normalized"
14
+ p.url = "http://github.com/carpodaster/string_normalizr"
15
+ p.author = "Carsten Zimmermann"
16
+ p.email = "carp@hacksocke.de"
17
+ p.ignore_pattern = ["tmp/*", "script/*", "nbproject/*"]
18
+ p.development_dependencies = []
19
+ end
20
+
21
+
22
+ task :rebuild => [:manifest, :build_gemspec, :gem] do
23
+ end
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'string_normalizr'
@@ -0,0 +1,20 @@
1
+ module AegisNet
2
+ module StringNormalizr
3
+
4
+ def self.included(base)
5
+ base.send(:include, InstanceMethods)
6
+ end
7
+
8
+
9
+ module InstanceMethods
10
+ def normalize
11
+ self.strip.gsub('ä', 'ae').gsub('ö', 'oe').gsub('ü', 'ue').gsub('Ä', 'Ae').gsub('Ö', 'Oe').gsub('Ü', 'Ue').gsub("ß", "ss")
12
+ end
13
+ end
14
+
15
+ end
16
+ end
17
+
18
+ class String
19
+ include AegisNet::StringNormalizr
20
+ end
File without changes
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{string_normalizr}
5
+ s.version = "0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Carsten Zimmermann"]
9
+ s.date = %q{2010-09-17}
10
+ s.description = %q{Let String instances be conviently normalized}
11
+ s.email = %q{carp@hacksocke.de}
12
+ s.extra_rdoc_files = ["README.rdoc", "lib/string_normalizr.rb"]
13
+ s.files = ["README.rdoc", "Rakefile", "init.rb", "lib/string_normalizr.rb", "nbproject/private/rake-d.txt", "string_normalizr.gemspec", "test/string_normalizr_test.rb", "Manifest"]
14
+ s.homepage = %q{http://github.com/carpodaster/string_normalizr}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "String_normalizr", "--main", "README.rdoc"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{string_normalizr}
18
+ s.rubygems_version = %q{1.3.7}
19
+ s.summary = %q{Let String instances be conviently normalized}
20
+ s.test_files = ["test/string_normalizr_test.rb"]
21
+
22
+ if s.respond_to? :specification_version then
23
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
+ s.specification_version = 3
25
+
26
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
+ else
28
+ end
29
+ else
30
+ end
31
+ end
@@ -0,0 +1,22 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + "/../lib/string_normalizr"
3
+
4
+ class StringNormalizrTest < Test::Unit::TestCase
5
+
6
+ def test_string_integration
7
+ assert "some string".respond_to?(:normalize)
8
+ end
9
+
10
+ def test_whitespaces
11
+ assert_equal "foo", " foo \n \t".normalize
12
+ end
13
+
14
+ def test_german_umlauts
15
+ assert_equal "foeOebaerueghbAerUegh", "föÖbärüghbÄrÜgh"
16
+ end
17
+
18
+ def test_sz
19
+ assert_equal "Strasse", "Straße"
20
+ end
21
+
22
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: string_normalizr
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ version: "0.1"
10
+ platform: ruby
11
+ authors:
12
+ - Carsten Zimmermann
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-09-17 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Let String instances be conviently normalized
22
+ email: carp@hacksocke.de
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - README.rdoc
29
+ - lib/string_normalizr.rb
30
+ files:
31
+ - README.rdoc
32
+ - Rakefile
33
+ - init.rb
34
+ - lib/string_normalizr.rb
35
+ - nbproject/private/rake-d.txt
36
+ - string_normalizr.gemspec
37
+ - test/string_normalizr_test.rb
38
+ - Manifest
39
+ has_rdoc: true
40
+ homepage: http://github.com/carpodaster/string_normalizr
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options:
45
+ - --line-numbers
46
+ - --inline-source
47
+ - --title
48
+ - String_normalizr
49
+ - --main
50
+ - README.rdoc
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 11
68
+ segments:
69
+ - 1
70
+ - 2
71
+ version: "1.2"
72
+ requirements: []
73
+
74
+ rubyforge_project: string_normalizr
75
+ rubygems_version: 1.3.7
76
+ signing_key:
77
+ specification_version: 3
78
+ summary: Let String instances be conviently normalized
79
+ test_files:
80
+ - test/string_normalizr_test.rb