tefil 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,65 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require "helper"
5
+ #require "test/unit"
6
+ #require "pkg/klass.rb"
7
+ require "stringio"
8
+
9
+ class Tefil::ColumnAnalyzer
10
+ public :process_stream, :projection_ary, :get_ranges
11
+ end
12
+
13
+ class TC_ColumnAnalyzer < Test::Unit::TestCase
14
+
15
+ TEXT = [
16
+ '0123 45 6789',
17
+ 'abcd ef ghij',
18
+ 'a e g ',
19
+ 'a cd f gh j',
20
+ 'abcd ',
21
+ ' hij',
22
+ ]
23
+
24
+ def setup
25
+ @c00 = Tefil::ColumnAnalyzer.new
26
+ end
27
+
28
+ def test_projection_ary
29
+ results = @c00.projection_ary(TEXT)
30
+ corrects = [true, true, true, true, false,
31
+ true, true, false,
32
+ true, true, true, true]
33
+ assert_equal(corrects, results)
34
+ end
35
+
36
+ def test_get_ranges
37
+ results = @c00.get_ranges([true, true, true, true, false,
38
+ true, true, false,
39
+ true, true, true, true]
40
+ )
41
+ corrects = [ 0..3, 5..6, 8..11 ]
42
+ assert_equal(corrects, results)
43
+
44
+ end
45
+
46
+
47
+ def test_process_stream
48
+
49
+ c01 = Tefil::ColumnAnalyzer.new(['0=abcd'])
50
+ in_io = StringIO.new
51
+ in_io.puts '0123 45 6789'
52
+ in_io.puts 'abcd ef ghij'
53
+ in_io.puts 'a e g '
54
+ in_io.puts 'a cd f gh j'
55
+ in_io.puts 'abcd '
56
+ in_io.puts ' hij'
57
+ in_io.rewind
58
+ out_io = StringIO.new
59
+ c01.process_stream(in_io, out_io)
60
+ out_io.rewind
61
+ #pp out_io.readlines
62
+ #assert_equal
63
+ end
64
+ end
65
+
@@ -13,6 +13,8 @@ end
13
13
  class TC_ColumnFormer < Test::Unit::TestCase
14
14
  def setup
15
15
  @cf00 = Tefil::ColumnFormer.new
16
+ @cf01 = Tefil::ColumnFormer.new({:just => :right})
17
+ @cf02 = Tefil::ColumnFormer.new({:separator => ','})
16
18
  end
17
19
 
18
20
  def test_print_size
@@ -29,19 +31,25 @@ class TC_ColumnFormer < Test::Unit::TestCase
29
31
  ]
30
32
  @cf00.form(matrix, io)
31
33
  io.rewind
32
- assert_equal(" a ab\nabc a\n", io.read)
34
+ assert_equal("a ab\nabc a\n", io.read)
33
35
 
34
36
  io = StringIO.new
35
- @cf00.form(matrix, io, ",")
37
+ @cf00.form(matrix, io, 2)
36
38
  io.rewind
37
- assert_equal(" a,ab\nabc, a\n", io.read)
39
+ assert_equal(" a ab\n abc a\n", io.read)
40
+
38
41
 
39
42
  io = StringIO.new
40
- @cf00.form(matrix, io, " ", true )
43
+ @cf01.form(matrix, io)
41
44
  io.rewind
42
- assert_equal("a ab\nabc a\n", io.read)
45
+ assert_equal(" a ab\nabc a\n", io.read)
43
46
  io.rewind
44
47
 
48
+ io = StringIO.new
49
+ @cf02.form(matrix, io)
50
+ io.rewind
51
+ assert_equal("a ,ab\nabc,a\n", io.read)
52
+
45
53
  #####
46
54
  io = StringIO.new
47
55
  matrix = [
@@ -50,7 +58,10 @@ class TC_ColumnFormer < Test::Unit::TestCase
50
58
  ]
51
59
  @cf00.form(matrix, io)
52
60
  io.rewind
53
- assert_equal(" abc def\nあいう えおか\n", io.read)
61
+ assert_equal("abc def\nあいう えおか\n", io.read)
62
+
63
+ ####
64
+
54
65
  end
55
66
  end
56
67
 
@@ -24,13 +24,13 @@ class TC_FswikiToMd < Test::Unit::TestCase
24
24
  #["abc __underline__ def" , ],
25
25
  #['"" quotation' , ],
26
26
  ["* item" , "* item" ],
27
- ["** item" , " * item" ],
28
- ["*** item" , " * item" ],
29
- ["**** item" , " * item" ],
30
- ["+ enum" , "0. enum" ],
31
- ["++ enum" , " 0. enum" ],
32
- ["+++ enum" , " 0. enum" ],
33
- ["++++ enum" , " 0. enum" ],
27
+ ["** item" , " * item" ],
28
+ ["*** item" , " * item" ],
29
+ ["**** item" , " * item" ],
30
+ ["+ enum" , "1. enum" ],
31
+ ["++ enum" , " 1. enum" ],
32
+ ["+++ enum" , " 1. enum" ],
33
+ ["++++ enum" , " 1. enum" ],
34
34
  #["*http://www.yahoo.co.jp/" , ],
35
35
  ["[Google|http://www.google.co.jp/]" , "[Google](http://www.google.co.jp/)" ],
36
36
  [" formatted text" , " formatted text" ],
@@ -0,0 +1,38 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require "helper"
5
+ require "stringio"
6
+
7
+ #class Tefil::IndentConverter
8
+ # public :process_stream
9
+ #end
10
+
11
+ class TC_Statistics < Test::Unit::TestCase
12
+ def setup
13
+ @s00 = Tefil::Statistics.new()
14
+ end
15
+
16
+ def test_process_stream
17
+ # stdin -> stdout
18
+ $stdin = StringIO.new
19
+ $stdin.puts "1.0"
20
+ $stdin.puts "2.0"
21
+ $stdin.puts "3.0"
22
+ $stdin.rewind
23
+ #str = capture_stdout{}
24
+ result = capture_stdout{ @s00.filter([])}
25
+ correct =
26
+ "sample: 3\n" +
27
+ "highest: 3.0\n" +
28
+ "lowest: 1.0\n" +
29
+ "sum: 6.0\n" +
30
+ "average: 2.0\n" +
31
+ "variance: 0.6666666666666666\n" +
32
+ "standard_deviation: 0.816496580927726\n"
33
+ assert_equal(correct, result)
34
+ end
35
+ end
36
+
37
+
38
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tefil
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ippei94da
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-31 00:00:00.000000000 Z
11
+ date: 2017-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-unit
@@ -113,6 +113,7 @@ description: "This gem provides a framework of text filter.\n Tefil eneable t
113
113
  email: ippei94da@gmail.com
114
114
  executables:
115
115
  - calc
116
+ - columnanalyze
116
117
  - columnform
117
118
  - eachsentence
118
119
  - fswiki2md
@@ -121,6 +122,7 @@ executables:
121
122
  - linesub
122
123
  - md2fswiki
123
124
  - percentpack
125
+ - statistics
124
126
  - zshescape
125
127
  extensions: []
126
128
  extra_rdoc_files:
@@ -135,6 +137,7 @@ files:
135
137
  - Rakefile
136
138
  - VERSION
137
139
  - bin/calc
140
+ - bin/columnanalyze
138
141
  - bin/columnform
139
142
  - bin/eachsentence
140
143
  - bin/fswiki2md
@@ -143,8 +146,14 @@ files:
143
146
  - bin/linesub
144
147
  - bin/md2fswiki
145
148
  - bin/percentpack
149
+ - bin/statistics
146
150
  - bin/zshescape
147
151
  - doc/memo.txt
152
+ - example/calc/run.zsh
153
+ - example/columnanalyze/ps.out
154
+ - example/columnanalyze/qstat.out
155
+ - example/columnanalyze/run.zsh
156
+ - example/columnformer/indent.txt
148
157
  - example/columnformer/sample.txt
149
158
  - example/eachsentence/sample.txt
150
159
  - example/indentconv/sample0.txt
@@ -156,6 +165,7 @@ files:
156
165
  - example/zshescape/sample.txt
157
166
  - lib/tefil.rb
158
167
  - lib/tefil/calculator.rb
168
+ - lib/tefil/columnanalyzer.rb
159
169
  - lib/tefil/columnformer.rb
160
170
  - lib/tefil/eachsentence.rb
161
171
  - lib/tefil/fswikitomd.rb
@@ -164,13 +174,16 @@ files:
164
174
  - lib/tefil/linesubstituter.rb
165
175
  - lib/tefil/mdtofswiki.rb
166
176
  - lib/tefil/percentpacker.rb
177
+ - lib/tefil/statistics.rb
167
178
  - lib/tefil/textfilterbase.rb
168
179
  - lib/tefil/zshescaper.rb
169
180
  - tefil.gemspec
170
181
  - test/calc/sample.dat
171
182
  - test/formcolumn_space
172
183
  - test/helper.rb
184
+ - test/qstat.out
173
185
  - test/test_calculator.rb
186
+ - test/test_columnanalyzer.rb
174
187
  - test/test_columnformer.rb
175
188
  - test/test_eachsentence.rb
176
189
  - test/test_fswikitomd.rb
@@ -179,6 +192,7 @@ files:
179
192
  - test/test_linesubstituter.rb
180
193
  - test/test_mdtofswiki.rb
181
194
  - test/test_percentpacker.rb
195
+ - test/test_statistics.rb
182
196
  - test/test_textfilterbase.rb
183
197
  - test/test_zshescaper.rb
184
198
  homepage: http://github.com/ippei94da/tefil