textutils 0.6.5 → 0.6.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,6 +41,49 @@ 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
+
44
87
  class LineReader
45
88
 
46
89
  include LogUtils::Logging
@@ -55,8 +98,13 @@ class LineReader
55
98
 
56
99
  def each_line
57
100
  @data.each_line do |line|
58
-
59
- if line =~ /^\s*#/
101
+
102
+ # comments allow:
103
+ # 1) ##### (shell/ruby style)
104
+ # 2) -- comment here (haskel/?? style)
105
+ # 3) % comment here (tex/latex style)
106
+
107
+ if line =~ /^\s*#/ || line =~ /^\s*--/ || line =~ /^\s*%/
60
108
  # skip komments and do NOT copy to result (keep comments secret!)
61
109
  logger.debug 'skipping comment line'
62
110
  next
@@ -68,7 +116,14 @@ class LineReader
68
116
  next
69
117
  end
70
118
 
71
- # remove leading and trailing whitespace
119
+ # pass 1) remove possible trailing eol comment
120
+ ## e.g -> nyc, New York # Sample EOL Comment Here (with or without commas,,,,)
121
+ ## becomes -> nyc, New York
122
+
123
+ line = line.sub( /\s+#.+$/, '' )
124
+
125
+ # pass 2) remove leading and trailing whitespace
126
+
72
127
  line = line.strip
73
128
 
74
129
  yield( line )
@@ -1,6 +1,6 @@
1
1
 
2
2
  module TextUtils
3
3
 
4
- VERSION = '0.6.5'
4
+ VERSION = '0.6.6'
5
5
 
6
6
  end # module TextUtils
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.6.5
4
+ version: 0.6.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-24 00:00:00.000000000Z
12
+ date: 2013-06-25 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: logutils
16
- requirement: &18184884 !ruby/object:Gem::Requirement
16
+ requirement: &16771836 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0.5'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *18184884
24
+ version_requirements: *16771836
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &18183684 !ruby/object:Gem::Requirement
27
+ requirement: &16771092 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '4.0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *18183684
35
+ version_requirements: *16771092
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: hoe
38
- requirement: &18183096 !ruby/object:Gem::Requirement
38
+ requirement: &16770396 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '3.6'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *18183096
46
+ version_requirements: *16770396
47
47
  description: textutils - Text Filters, Helpers, Readers and More
48
48
  email: webslideshow@googlegroups.com
49
49
  executables: []