textutils 0.8.7 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
File without changes
data/Manifest.txt CHANGED
@@ -1,4 +1,4 @@
1
- History.md
1
+ HISTORY.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
@@ -21,8 +21,11 @@ lib/textutils/patterns.rb
21
21
  lib/textutils/reader/code_reader.rb
22
22
  lib/textutils/reader/fixture_reader.rb
23
23
  lib/textutils/reader/hash_reader.rb
24
+ lib/textutils/reader/hash_reader_v2.rb
24
25
  lib/textutils/reader/line_reader.rb
26
+ lib/textutils/reader/line_reader_v2.rb
25
27
  lib/textutils/reader/values_reader.rb
28
+ lib/textutils/reader/values_reader_v2.rb
26
29
  lib/textutils/sanitizier.rb
27
30
  lib/textutils/title.rb
28
31
  lib/textutils/utils.rb
data/Rakefile CHANGED
@@ -15,10 +15,13 @@ Hoe.spec 'textutils' do
15
15
 
16
16
  # switch extension to .markdown for gihub formatting
17
17
  self.readme_file = 'README.md'
18
- self.history_file = 'History.md'
18
+ self.history_file = 'HISTORY.md'
19
19
 
20
20
  self.extra_deps = [
21
- ['logutils', '~> 0.5'] # e.g. >= 0.5 <= 1.0
21
+ ['props'],
22
+ ['logutils', '~> 0.5'], # e.g. >= 0.5 <= 1.0
23
+ ### 3rd party gems
24
+ ['activesupport']
22
25
  ]
23
26
 
24
27
  self.licenses = ['Public Domain']
@@ -26,6 +29,5 @@ Hoe.spec 'textutils' do
26
29
  self.spec_extras = {
27
30
  :required_ruby_version => '>= 1.9.2'
28
31
  }
29
-
30
32
 
31
- end
33
+ end
data/lib/textutils.rb CHANGED
@@ -12,6 +12,11 @@ require 'erb'
12
12
 
13
13
  # 3rd party gems / libs
14
14
 
15
+ # fix: remove version from activerecord in deps
16
+ require 'active_support/all' # String.starts_with?, Object.blank?, etc.
17
+
18
+ require 'props'
19
+ require 'props/db' ## for Prop model --> move create_from fixtures to textutils!!
15
20
  require 'logutils'
16
21
 
17
22
  # our own code
@@ -39,8 +44,11 @@ require 'textutils/helper/value_helper'
39
44
  require 'textutils/utils'
40
45
  require 'textutils/reader/code_reader'
41
46
  require 'textutils/reader/hash_reader'
47
+ require 'textutils/reader/hash_reader_v2'
42
48
  require 'textutils/reader/line_reader'
49
+ require 'textutils/reader/line_reader_v2'
43
50
  require 'textutils/reader/values_reader'
51
+ require 'textutils/reader/values_reader_v2'
44
52
  require 'textutils/reader/fixture_reader'
45
53
 
46
54
  require 'textutils/classifier'
@@ -106,6 +106,7 @@ module TextUtils
106
106
  ['ğ', 'g' ], # e.g. Qarabağ
107
107
  ['ì', 'i' ], # e.g. Potosì
108
108
  ['í', 'i' ], # e.g. Ústí
109
+ ['ï', 'i' ], # e.g. El Djazaïr
109
110
  ['ł', 'l' ], # e.g. Wisła, Wrocław
110
111
  ['ñ', 'n' ], # e.g. Porteño
111
112
  ['ň', 'n' ], # e.g. Plzeň, Třeboň
@@ -114,6 +115,7 @@ module TextUtils
114
115
  ['ó', 'o' ], # e.g. Colón, Łódź, Kraków
115
116
  ['õ', 'o' ], # e.g. Nõmme
116
117
  ['ô', 'o' ], # e.g. Amazônia (pt)
118
+ ['ō', 'o' ], # e.g. Tōkyō
117
119
  ['ø', 'o' ], # e.g. Fuglafjørdur, København
118
120
  ['ř', 'r' ], # e.g. Třeboň
119
121
  ['ș', 's' ], # e.g. Chișinău, București
@@ -199,27 +201,34 @@ module TextUtils
199
201
  alternatives = [
200
202
  ['-', '(-| )'], ## e.g. Blau-Weiß Linz
201
203
  ['æ', '(æ|ae)'], ## e.g.
204
+ ['ä', '(ä|ae)'], ## e.g.
205
+ ['Ö', '(Ö|Oe)'], ## e.g. Österreich
206
+ ['ö', '(ö|oe)'], ## e.g. Mönchengladbach
207
+ ['ß', '(ß|ss)'], ## e.g. Blau-Weiß Linz
208
+ ['ü', '(ü|ue)'], ## e.g.
209
+
202
210
  ['á', '(á|a)'], ## e.g. Bogotá, Sársfield
203
211
  ['ã', '(ã|a)'], ## e.g São Paulo
204
- ['ä', '(ä|ae)'], ## e.g.
205
212
  ['ç', '(ç|c)'], ## e.g. Fenerbahçe
206
213
  ['é', '(é|e)'], ## e.g. Vélez
207
214
  ['ê', '(ê|e)'], ## e.g. Grêmio
215
+ ['ï', '(ï|i)' ], ## e.g. El Djazaïr
208
216
  ['ñ', '(ñ|n)'], ## e.g. Porteño
209
217
  ['ň', '(ň|n)'], ## e.g. Plzeň
210
- ['Ö', '(Ö|Oe)'], ## e.g. Österreich
211
- ['ö', '(ö|oe)'], ## e.g. Mönchengladbach
212
218
  ['ó', '(ó|o)'], ## e.g. Colón
219
+ ['ō', '(ō|o)'], # # e.g. Tōkyō
213
220
  ['ș', '(ș|s)'], ## e.g. Bucarești
214
- ['ß', '(ß|ss)'], ## e.g. Blau-Weiß Linz
215
- ['ü', '(ü|ue)'], ## e.g.
216
221
  ['ú', '(ú|u)'] ## e.g. Fútbol
217
222
  ]
218
-
223
+
219
224
  ### fix/todo: check for dot+space e.g. . and make dot optional
220
- ## e.g. U. de. G. or U de G or U.de.G ??
225
+ ##
226
+ # e.g. make dot (.) optional plus allow alternative optional space e.g.
227
+ # -- for U.S.A. => allow USA or U S A
228
+ #
229
+ ## e.g. U. de G. or U de G or U.de G. ??
221
230
  ## collect some more (real-world) examples first!!!!!
222
-
231
+
223
232
  alternatives.each do |alt|
224
233
  title = title.gsub( alt[0], alt[1] )
225
234
  end
@@ -1,71 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
-
4
3
  # fix: move into TextUtils namespace/module!!
5
4
 
6
5
 
7
- ## todo/fix: find a better name than HashReaderV2 (HashReaderPlus?) ??
8
-
9
- class HashReaderV2
10
- include LogUtils::Logging
11
-
12
- def initialize( name, include_path )
13
- @name = name
14
- @include_path = include_path
15
-
16
- # map name to name_real_path
17
- # name might include !/ for virtual path (gets cut off)
18
- # e.g. at-austria!/w-wien/beers becomse w-wien/beers
19
-
20
- pos = @name.index( '!/')
21
- if pos.nil?
22
- @name_real_path = @name # not found; real path is the same as name
23
- else
24
- # cut off everything until !/ e.g.
25
- # at-austria!/w-wien/beers becomes
26
- # w-wien/beers
27
- @name_real_path = @name[ (pos+2)..-1 ]
28
- end
29
- end
30
-
31
- attr_reader :name
32
- attr_reader :name_real_path
33
- attr_reader :include_path
34
-
35
- def each
36
- path = "#{include_path}/#{name_real_path}.yml"
37
- reader = HashReader.new( path )
38
-
39
- logger.info "parsing data '#{name}' (#{path})..."
40
-
41
- reader.each do |key, value|
42
- yield( key, value )
43
- end
44
-
45
- ## fix: move Prop table to props gem - why? why not??
46
- WorldDb::Models::Prop.create_from_fixture!( name, path )
47
- end
48
-
49
-
50
- def each_typed
51
- path = "#{include_path}/#{name_real_path}.yml"
52
- reader = HashReader.new( path )
53
-
54
- logger.info "parsing data '#{name}' (#{path})..."
55
-
56
- reader.each_typed do |key, value|
57
- yield( key, value )
58
- end
59
-
60
- ## fix: move Prop table to props gem - why? why not??
61
- WorldDb::Models::Prop.create_from_fixture!( name, path )
62
- end
63
-
64
-
65
- end # class HashReaderV2
66
-
67
-
68
-
69
6
  class HashReader
70
7
 
71
8
  include LogUtils::Logging
@@ -0,0 +1,61 @@
1
+ # encoding: utf-8
2
+
3
+ # fix: move into TextUtils namespace/module!!
4
+
5
+ ## todo/fix: find a better name than HashReaderV2 (HashReaderPlus?) ??
6
+
7
+ class HashReaderV2
8
+ include LogUtils::Logging
9
+
10
+ def initialize( name, include_path )
11
+ @name = name
12
+ @include_path = include_path
13
+
14
+ # map name to name_real_path
15
+ # name might include !/ for virtual path (gets cut off)
16
+ # e.g. at-austria!/w-wien/beers becomse w-wien/beers
17
+
18
+ pos = @name.index( '!/')
19
+ if pos.nil?
20
+ @name_real_path = @name # not found; real path is the same as name
21
+ else
22
+ # cut off everything until !/ e.g.
23
+ # at-austria!/w-wien/beers becomes
24
+ # w-wien/beers
25
+ @name_real_path = @name[ (pos+2)..-1 ]
26
+ end
27
+ end
28
+
29
+ attr_reader :name
30
+ attr_reader :name_real_path
31
+ attr_reader :include_path
32
+
33
+ def each
34
+ path = "#{include_path}/#{name_real_path}.yml"
35
+ reader = HashReader.new( path )
36
+
37
+ logger.info "parsing data '#{name}' (#{path})..."
38
+
39
+ reader.each do |key, value|
40
+ yield( key, value )
41
+ end
42
+
43
+ ConfDb::Model::Prop.create_from_fixture!( name, path )
44
+ end
45
+
46
+
47
+ def each_typed
48
+ path = "#{include_path}/#{name_real_path}.yml"
49
+ reader = HashReader.new( path )
50
+
51
+ logger.info "parsing data '#{name}' (#{path})..."
52
+
53
+ reader.each_typed do |key, value|
54
+ yield( key, value )
55
+ end
56
+
57
+ ConfDb::Model::Prop.create_from_fixture!( name, path )
58
+ end
59
+
60
+
61
+ end # class HashReaderV2
@@ -41,49 +41,6 @@ class StringLineReader
41
41
  end
42
42
 
43
43
 
44
- class LineReaderV2
45
- include LogUtils::Logging
46
-
47
- def initialize( name, include_path )
48
- @name = name
49
- @include_path = include_path
50
-
51
- # map name to name_real_path
52
- # name might include !/ for virtual path (gets cut off)
53
- # e.g. at-austria!/w-wien/beers becomse w-wien/beers
54
-
55
- pos = @name.index( '!/')
56
- if pos.nil?
57
- @name_real_path = @name # not found; real path is the same as name
58
- else
59
- # cut off everything until !/ e.g.
60
- # at-austria!/w-wien/beers becomes
61
- # w-wien/beers
62
- @name_real_path = @name[ (pos+2)..-1 ]
63
- end
64
- end
65
-
66
- attr_reader :name
67
- attr_reader :name_real_path
68
- attr_reader :include_path
69
-
70
- def each_line
71
- path = "#{include_path}/#{name_real_path}.txt"
72
- reader = LineReader.new( path )
73
-
74
- logger.info "parsing data '#{name}' (#{path})..."
75
-
76
- reader.each_line do |line|
77
- yield( line )
78
- end
79
-
80
- ## fix: move Prop table to props gem - why? why not??
81
- WorldDb::Models::Prop.create_from_fixture!( name, path )
82
- end
83
-
84
- end # class LineReaderV2
85
-
86
-
87
44
  class LineReader
88
45
 
89
46
  include LogUtils::Logging
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+
3
+
4
+ # fix: move into TextUtils namespace/module!!
5
+
6
+
7
+ class LineReaderV2
8
+ include LogUtils::Logging
9
+
10
+ def initialize( name, include_path )
11
+ @name = name
12
+ @include_path = include_path
13
+
14
+ # map name to name_real_path
15
+ # name might include !/ for virtual path (gets cut off)
16
+ # e.g. at-austria!/w-wien/beers becomse w-wien/beers
17
+
18
+ pos = @name.index( '!/')
19
+ if pos.nil?
20
+ @name_real_path = @name # not found; real path is the same as name
21
+ else
22
+ # cut off everything until !/ e.g.
23
+ # at-austria!/w-wien/beers becomes
24
+ # w-wien/beers
25
+ @name_real_path = @name[ (pos+2)..-1 ]
26
+ end
27
+ end
28
+
29
+ attr_reader :name
30
+ attr_reader :name_real_path
31
+ attr_reader :include_path
32
+
33
+ def each_line
34
+ path = "#{include_path}/#{name_real_path}.txt"
35
+ reader = LineReader.new( path )
36
+
37
+ logger.info "parsing data '#{name}' (#{path})..."
38
+
39
+ reader.each_line do |line|
40
+ yield( line )
41
+ end
42
+
43
+ ConfDb::Model::Prop.create_from_fixture!( name, path )
44
+ end
45
+
46
+ end # class LineReaderV2
47
+
@@ -2,53 +2,6 @@
2
2
 
3
3
  # fix: move into TextUtils namespace/module!!
4
4
 
5
- ## todo/fix: find a better name than HashReaderV2 (HashReaderPlus?) ??
6
-
7
- class ValuesReaderV2
8
- include LogUtils::Logging
9
-
10
- def initialize( name, include_path, more_attribs={} )
11
- @name = name
12
- @include_path = include_path
13
- @more_attribs = more_attribs
14
-
15
- # map name to name_real_path
16
- # name might include !/ for virtual path (gets cut off)
17
- # e.g. at-austria!/w-wien/beers becomse w-wien/beers
18
-
19
- pos = @name.index( '!/')
20
- if pos.nil?
21
- @name_real_path = @name # not found; real path is the same as name
22
- else
23
- # cut off everything until !/ e.g.
24
- # at-austria!/w-wien/beers becomes
25
- # w-wien/beers
26
- @name_real_path = @name[ (pos+2)..-1 ]
27
- end
28
- end
29
-
30
- attr_reader :name
31
- attr_reader :name_real_path
32
- attr_reader :include_path
33
- attr_reader :more_attribs
34
-
35
- def each_line
36
- path = "#{include_path}/#{name_real_path}.txt"
37
- reader = ValuesReader.new( path, more_attribs )
38
-
39
- logger.info "parsing data '#{name}' (#{path})..."
40
-
41
- reader.each_line do |attribs, values|
42
- yield( attribs, values )
43
- end
44
-
45
- ## fix: move Prop table to props gem - why? why not??
46
- WorldDb::Model::Prop.create_from_fixture!( name, path )
47
- end
48
-
49
- end # class ValuesReaderV2
50
-
51
-
52
5
 
53
6
  class ValuesReader
54
7
 
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ # fix: move into TextUtils namespace/module!!
4
+
5
+ ## todo/fix: find a better name than HashReaderV2 (HashReaderPlus?) ??
6
+
7
+ class ValuesReaderV2
8
+ include LogUtils::Logging
9
+
10
+ def initialize( name, include_path, more_attribs={} )
11
+ @name = name
12
+ @include_path = include_path
13
+ @more_attribs = more_attribs
14
+
15
+ # map name to name_real_path
16
+ # name might include !/ for virtual path (gets cut off)
17
+ # e.g. at-austria!/w-wien/beers becomse w-wien/beers
18
+
19
+ pos = @name.index( '!/')
20
+ if pos.nil?
21
+ @name_real_path = @name # not found; real path is the same as name
22
+ else
23
+ # cut off everything until !/ e.g.
24
+ # at-austria!/w-wien/beers becomes
25
+ # w-wien/beers
26
+ @name_real_path = @name[ (pos+2)..-1 ]
27
+ end
28
+ end
29
+
30
+ attr_reader :name
31
+ attr_reader :name_real_path
32
+ attr_reader :include_path
33
+ attr_reader :more_attribs
34
+
35
+ def each_line
36
+ path = "#{include_path}/#{name_real_path}.txt"
37
+ reader = ValuesReader.new( path, more_attribs )
38
+
39
+ logger.info "parsing data '#{name}' (#{path})..."
40
+
41
+ reader.each_line do |attribs, values|
42
+ yield( attribs, values )
43
+ end
44
+
45
+ ConfDb::Model::Prop.create_from_fixture!( name, path )
46
+ end
47
+
48
+ end # class ValuesReaderV2
49
+
@@ -1,6 +1,6 @@
1
1
 
2
2
  module TextUtils
3
3
 
4
- VERSION = '0.8.7'
4
+ VERSION = '0.9.0'
5
5
 
6
6
  end # module TextUtils
data/test/helper.rb CHANGED
@@ -10,7 +10,7 @@ require 'minitest/autorun'
10
10
 
11
11
  ## make sure activesupport gets included/required
12
12
  # note: just activesupport or active_support will NOT work
13
- require 'active_support/all'
13
+ # require 'active_support/all' # -- now included in textutils itself
14
14
 
15
15
  ## our own code
16
16
 
@@ -36,7 +36,9 @@ class TestTitleHelper < MiniTest::Unit::TestCase
36
36
  [ 'Minerva 8:60', 'minerva860' ],
37
37
  [ 'Hop Crisis!', 'hopcrisis' ],
38
38
  [ '$Alianz$ Arena', 'alianzarena' ],
39
- [ 'Arena Amazônia', 'arenaamazonia' ]
39
+ [ 'Arena Amazônia', 'arenaamazonia' ],
40
+ [ 'Tōkyō [Tokyo]', 'tokyo' ],
41
+ [ 'El Djazaïr [Algiers]', 'eldjazair' ]
40
42
  ]
41
43
 
42
44
  txt_io.each do |txt|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: textutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.7
4
+ version: 0.9.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-02 00:00:00.000000000 Z
12
+ date: 2014-03-24 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: props
16
+ requirement: &76193510 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *76193510
14
25
  - !ruby/object:Gem::Dependency
15
26
  name: logutils
16
- requirement: &78669010 !ruby/object:Gem::Requirement
27
+ requirement: &76193110 !ruby/object:Gem::Requirement
17
28
  none: false
18
29
  requirements:
19
30
  - - ~>
@@ -21,10 +32,21 @@ dependencies:
21
32
  version: '0.5'
22
33
  type: :runtime
23
34
  prerelease: false
24
- version_requirements: *78669010
35
+ version_requirements: *76193110
36
+ - !ruby/object:Gem::Dependency
37
+ name: activesupport
38
+ requirement: &76192860 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *76192860
25
47
  - !ruby/object:Gem::Dependency
26
48
  name: rdoc
27
- requirement: &78668430 !ruby/object:Gem::Requirement
49
+ requirement: &76192430 !ruby/object:Gem::Requirement
28
50
  none: false
29
51
  requirements:
30
52
  - - ~>
@@ -32,10 +54,10 @@ dependencies:
32
54
  version: '3.10'
33
55
  type: :development
34
56
  prerelease: false
35
- version_requirements: *78668430
57
+ version_requirements: *76192430
36
58
  - !ruby/object:Gem::Dependency
37
59
  name: hoe
38
- requirement: &78667530 !ruby/object:Gem::Requirement
60
+ requirement: &76191590 !ruby/object:Gem::Requirement
39
61
  none: false
40
62
  requirements:
41
63
  - - ~>
@@ -43,7 +65,7 @@ dependencies:
43
65
  version: '3.3'
44
66
  type: :development
45
67
  prerelease: false
46
- version_requirements: *78667530
68
+ version_requirements: *76191590
47
69
  description: textutils - Text Filters, Helpers, Readers and More
48
70
  email: ruby-talk@ruby-lang.org
49
71
  executables: []
@@ -51,7 +73,7 @@ extensions: []
51
73
  extra_rdoc_files:
52
74
  - Manifest.txt
53
75
  files:
54
- - History.md
76
+ - HISTORY.md
55
77
  - Manifest.txt
56
78
  - README.md
57
79
  - Rakefile
@@ -74,8 +96,11 @@ files:
74
96
  - lib/textutils/reader/code_reader.rb
75
97
  - lib/textutils/reader/fixture_reader.rb
76
98
  - lib/textutils/reader/hash_reader.rb
99
+ - lib/textutils/reader/hash_reader_v2.rb
77
100
  - lib/textutils/reader/line_reader.rb
101
+ - lib/textutils/reader/line_reader_v2.rb
78
102
  - lib/textutils/reader/values_reader.rb
103
+ - lib/textutils/reader/values_reader_v2.rb
79
104
  - lib/textutils/sanitizier.rb
80
105
  - lib/textutils/title.rb
81
106
  - lib/textutils/utils.rb