shunkuntype 1.0.15 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +10 -2
  3. data/.hyper_card/docs/.Shunkuntype.hiki.swp +0 -0
  4. data/.hyper_card/history/test_cli_bdd.md +849 -0
  5. data/.hyper_card/history/test_cli_bdd_251114.md +883 -0
  6. data/.hyper_card/history/tidy.md +226 -0
  7. data/.hyper_card/history/tidy_251114.md +248 -0
  8. data/Gemfile.lock +36 -0
  9. data/Rakefile +6 -35
  10. data/exe/shunkuntype +1 -1
  11. data/lib/shunkuntype/db.rb +7 -14
  12. data/lib/shunkuntype/finished_check.rb +1 -2
  13. data/lib/shunkuntype/speed.rb +38 -29
  14. data/lib/shunkuntype/training.rb +23 -25
  15. data/lib/shunkuntype/version.rb +2 -7
  16. data/lib/shunkuntype.rb +35 -111
  17. data/shunkuntype/speed_data.txt +6 -0
  18. data/shunkuntype/training_data.txt +36 -0
  19. data/shunkuntype.gemspec +5 -6
  20. metadata +50 -59
  21. data/.rspec +0 -2
  22. data/.ruby-version +0 -1
  23. data/.yardopts +0 -3
  24. data/Rakefile.rb +0 -1
  25. data/lib/shunkuntype/#db.rb# +0 -49
  26. data/lib/shunkuntype/#mk_summary.rb# +0 -77
  27. data/lib/shunkuntype/merge.rb +0 -52
  28. data/lib/shunkuntype/mk_summary.rb +0 -77
  29. data/lib/shunkuntype/options.rb +0 -24
  30. data/lib/shunkuntype/plot.rb +0 -66
  31. data/lib/shunkuntype/plot_data.rb +0 -200
  32. data/shunkuntype_bob/.gitignore +0 -1
  33. data/shunkuntype_bob/Rakefile +0 -252
  34. data/shunkuntype_bob/hiki_help.yml +0 -53
  35. data/shunkuntype_bob/report.hiki +0 -173
  36. data/shunkuntype_bob/shunkuntype_bob.hiki +0 -36
  37. /data/{docs → .hyper_card/docs}/Shunkuntype.hiki +0 -0
  38. /data/{docs → .hyper_card/docs}/Shunkuntype_Coding.hiki +0 -0
  39. /data/{docs → .hyper_card/docs}/Shunkuntype_Coding_PlotData.hiki +0 -0
  40. /data/{docs → .hyper_card/docs}/Shunkuntype_Coding_gnuplot.hiki +0 -0
  41. /data/{docs → .hyper_card/docs}/Shunkuntype_GroupHearing_20160128.pdf +0 -0
  42. /data/{docs → .hyper_card/docs}/Shunkuntype_gemizing.hiki +0 -0
  43. /data/{docs → .hyper_card/docs}/Shunkuntype_manual.hiki +0 -0
  44. /data/{docs → .hyper_card/docs}/Shunkuntype_report.hiki +0 -0
  45. /data/{docs → .hyper_card/docs}/TouchTypespeedResult.png +0 -0
  46. /data/{docs → .hyper_card/docs}/TouchTypetrainingResult.png +0 -0
  47. /data/{docs → .hyper_card/docs}/TouchTypewhole_workResult.png +0 -0
  48. /data/{docs → .hyper_card/docs}/donkey_and_fujimoto.png +0 -0
  49. /data/{docs → .hyper_card/docs}/readme_en.hiki +0 -0
  50. /data/{docs → .hyper_card/docs}/readme_ja.hiki +0 -0
  51. /data/{docs → .hyper_card/docs}/res.png +0 -0
  52. /data/{docs → .hyper_card/docs}/shunkun_report.pdf +0 -0
  53. /data/{docs → .hyper_card/docs}/speed.png +0 -0
  54. /data/{docs → .hyper_card/docs}/work.png +0 -0
@@ -1,49 +0,0 @@
1
- #encoding: utf-8
2
-
3
- require 'fileutils'
4
- #require 'init'
5
-
6
- module DataFiles
7
-
8
- def self.prepare
9
- data_path = File.join(ENV['HOME'], '.shunkuntype','training_data.txt')
10
-
11
- create_file_if_not_exists(data_path)
12
- end
13
-
14
- def self.create_file_if_not_exists(path)
15
- create_file_path(path)
16
-
17
- return if File::exists?(path)
18
- create_data_files
19
- end
20
-
21
- def self.create_file_path(path)
22
- FileUtils.mkdir_p File.dirname(path)
23
- end
24
-
25
- def self.create_data_files
26
- if File::exist?("./speed_data.txt") then
27
- system "mv ./speed_data.txt #{Shunkuntype::SPEED_FILE}"
28
- print "moving ./speed_data.txt #{Shunkuntype::SPEED_FILE}.\n"
29
- end
30
- if File::exist?("./training_data.txt") then
31
- system "mv ./training_data.txt #{Shunkuntype::TRAIN_FILE}"
32
- print "moving ./training_data.txt #{Shunkuntype::TRAIN_FILE}.\n"
33
- end
34
- if File::exist?(Shunkuntype::SPEED_FILE) then
35
- print "#{Shunkuntype::SPEED_FILE} exits.\n"
36
- else
37
- File::open(Shunkuntype::SPEED_FILE,'a')
38
- print "make #{Shunkuntype::SPEED_FILE}\n"
39
- end
40
- if File::exist?(Shunkuntype::TRAIN_FILE) then
41
- print "#{Shunkuntype::TRAIN_FILE} exits.\n"
42
- else
43
- File::open(Shunkuntype::TRAIN_FILE,'a')
44
- print "make #{Shunkuntype::TRAIN_FILE}\n"
45
- end
46
- end
47
- private_class_method :create_file_if_not_exists, :create_file_path, :create_data_files
48
- end
49
-
@@ -1,77 +0,0 @@
1
- class MkSummary
2
- def initialize(tmp_dir)
3
- $mem_dir=File.join(tmp_dir,"mem_data")
4
- files = Dir::entries($mem_dir)
5
- member = mk_member(files)
6
- @scores = take_scores(files,member)
7
- end
8
-
9
- def mk_member(files)
10
- member = []
11
- files.each{|file|
12
- if file.include?('training') then
13
- name=file.split('_')[0]
14
- member << name
15
- end
16
- }
17
- return member
18
- end
19
-
20
- def take_scores(files,member)
21
- scores = {}
22
- member.each{|name|
23
- p name
24
- speed_file="#{name}_speed_data.txt"
25
- if files.include?(speed_file)
26
- p speed_file
27
- file = File.readlines(File.join($mem_dir,speed_file))
28
- init= (file[0]!=nil ? file[0].split(",")[2].to_f : 0.0 )
29
- cur = (file[-1]!=nil ? file[-1].split(",")[2].to_f : 0.0 )
30
- scores[name]=[init,cur]
31
- end
32
- training_file="#{name}_training_data.txt"
33
- if files.include?(training_file)
34
- p training_file
35
- file = File.readlines(File.join($mem_dir,training_file))
36
- work_time = file.inject(0){|sum,line|
37
- sec=line.split(',')[3].to_i
38
- sec= (sec!=0)? sec : 60
39
- sum + sec
40
- }
41
- step = (file[-1]!=nil ? file[-1].match(/STEP-(\d*)/)[1].to_i : 0 )
42
- scores[name] << work_time/60 << step
43
- end
44
- }
45
- return scores
46
- end
47
-
48
- def mk_html_table()
49
- cont = ""
50
- title = "Shunkun typer"
51
- cont << "<table border=\"1\">\n<caption>#{title}<caption>\n"
52
- cont << "<tr><th></th><th colspan=2>speed[sec]</th><th colspan=2>training</th></tr>\n"
53
- cont << "<tr><th></th><th>init</th><th>current</th><th>total time[min]</th><th>step</th></tr>\n"
54
- @scores.each_pair{|key,score|
55
- cont << "<tr><th>#{key}</th>"
56
- score.each{|val| cont << sprintf("<td>%5.2f</td>",val)}
57
- cont << "</tr>\n"
58
- }
59
- cont << "</table>\n"
60
- return cont
61
- end
62
-
63
- def mk_hiki_table()
64
- t= Time.now
65
- cont = "!!Shunkun typer #{t.localtime}\n"
66
- cont << "|| ||>speed[sec]||>training\n"
67
- cont << "||||init||current||total time[min]||step\n"
68
- @scores.each_pair{|key,score|
69
- cont << "||#{key}"
70
- score.each{|val| cont << sprintf("||%5.2f",val)}
71
- cont << "\n"
72
- }
73
- cont << "\n"
74
- return cont
75
- end
76
- end
77
-
@@ -1,52 +0,0 @@
1
- require 'time'
2
-
3
- def data_merge(file_current, file_server)
4
- all_data=[]
5
- i,j=0,0
6
- while (file_current.length > i) and (file_server.length > j) do
7
- line_current,line_server = file_current[i], file_server[j]
8
- break if line_current=="\n" or line_server=="\n"
9
- time_current=Time.parse(line_current.split(',')[0])
10
- time_server=Time.parse(line_server.split(',')[0])
11
- if time_current == time_server then
12
- all_data << line_current
13
- i += 1
14
- j += 1
15
- elsif time_current < time_server then
16
- all_data << line_current
17
- i += 1
18
- else
19
- all_data << line_server
20
- j += 1
21
- end
22
- end
23
- while (file_current.length > i)
24
- all_data << file_current[i]
25
- i += 1
26
- end
27
- while (file_server.length > j)
28
- all_data << file_server[j]
29
- j += 1
30
- end
31
- all_data.delete("\n")
32
- return all_data.join
33
- end
34
-
35
- if $0 == __FILE__ then
36
- file_current = <<'EOS'
37
- 2016-09-23 13:41:36 +0900,STEP-1.txt,60,60
38
- 2016-09-23 13:48:45 +0900,STEP-2.txt,5,60
39
- 2016-09-28 11:41:56 +0900,STEP-2.txt,0,60
40
- 2016-09-28 11:51:46 +0900,STEP-15.txt,29,60
41
- 2016-09-28 12:47:48 +0900,STEP-3.txt,48,60
42
- 2016-09-28 12:50:12 +0900,STEP-1.txt,60,60
43
-
44
- EOS
45
- file_server = <<'EOS'
46
- 2016-09-23 13:41:36 +0900,STEP-1.txt,60,60
47
- 2016-09-23 13:48:45 +0900,STEP-2.txt,5,60
48
- 2016-09-28 12:48:57 +0900,STEP-4.txt,50,60
49
-
50
- EOS
51
- print data_merge(file_current.lines, file_server.lines)
52
- end
@@ -1,77 +0,0 @@
1
- class MkSummary
2
- def initialize(tmp_dir)
3
- $mem_dir=File.join(tmp_dir,"mem_data")
4
- files = Dir::entries($mem_dir)
5
- member = mk_member(files)
6
- @scores = take_scores(files,member)
7
- end
8
-
9
- def mk_member(files)
10
- member = []
11
- files.each{|file|
12
- if file.include?('training') then
13
- name=file.split('_')[0]
14
- member << name
15
- end
16
- }
17
- return member
18
- end
19
-
20
- def take_scores(files,member)
21
- scores = {}
22
- member.each{|name|
23
- p name
24
- speed_file="#{name}_speed_data.txt"
25
- if files.include?(speed_file)
26
- p speed_file
27
- file = File.readlines(File.join($mem_dir,speed_file))
28
- init= (file[0]!=nil ? file[0].split(",")[2].to_f : 0.0 )
29
- cur = (file[-1]!=nil ? file[-1].split(",")[2].to_f : 0.0 )
30
- scores[name]=[init,cur]
31
- end
32
- training_file="#{name}_training_data.txt"
33
- if files.include?(training_file)
34
- p training_file
35
- file = File.readlines(File.join($mem_dir,training_file))
36
- work_time = file.inject(0){|sum,line|
37
- sec=line.split(',')[3].to_i
38
- sec= (sec!=0)? sec : 60
39
- sum + sec
40
- }
41
- step = (file[-1]!=nil ? file[-1].match(/STEP-(\d*)/)[1].to_i : 0 )
42
- scores[name] << work_time/60 << step
43
- end
44
- }
45
- return scores
46
- end
47
-
48
- def mk_html_table()
49
- cont = ""
50
- title = "Shunkun typer"
51
- cont << "<table border=\"1\">\n<caption>#{title}<caption>\n"
52
- cont << "<tr><th></th><th colspan=2>speed[sec]</th><th colspan=2>training</th></tr>\n"
53
- cont << "<tr><th></th><th>init</th><th>current</th><th>total time[min]</th><th>step</th></tr>\n"
54
- @scores.each_pair{|key,score|
55
- cont << "<tr><th>#{key}</th>"
56
- score.each{|val| cont << sprintf("<td>%5.2f</td>",val)}
57
- cont << "</tr>\n"
58
- }
59
- cont << "</table>\n"
60
- return cont
61
- end
62
-
63
- def mk_hiki_table()
64
- t= Time.now
65
- cont = "!!Shunkun typer #{t.localtime}\n"
66
- cont << "|| ||>speed[sec]||>training\n"
67
- cont << "||||init||current||total time[min]||step\n"
68
- @scores.each_pair{|key,score|
69
- cont << "||#{key}"
70
- score.each{|val| cont << sprintf("||%5.2f",val)}
71
- cont << "\n"
72
- }
73
- cont << "\n"
74
- return cont
75
- end
76
- end
77
-
@@ -1,24 +0,0 @@
1
- #coding: utf-8
2
-
3
- require 'optparse'
4
-
5
- module Shunkuntype
6
- class Command
7
- module Options
8
-
9
- def self.parse!(argv)
10
- options = {}
11
- command_parser = OptionParser.new do |opt|
12
- opt.on_head('-v', '--version','Show program version') do |v|
13
- puts options.ver
14
- opt.version = Shunkuntype::VERSION
15
- exit
16
- end
17
- end
18
-
19
- command_parser.parse!(argv)
20
- end
21
-
22
- end
23
- end
24
- end
@@ -1,66 +0,0 @@
1
- require 'time'
2
- require 'tempfile'
3
-
4
- class PlotPersonalData
5
- def initialize
6
- plot_data = read_data()
7
- make_data_file(plot_data)
8
-
9
- text=["Typing speed [words/min]","Work minutes [min]"]
10
- opts = {:title=>"Elapsed time vs #{text[0]}",
11
- :plot=>"plot \"#{$temp.path}\" using 1:2 w st\n",
12
- :xlabel=>"Elapsed time[hrs]",:ylabel=>text[0],:xtics=>"0 2"}
13
- listplot(opts)
14
- opts = {:title=>"Elapsed time vs #{text[1]}",
15
- :plot=>"plot \"#{$temp.path}\" using 1:3 w st\n",
16
- :xlabel=>"Elapsed time[hrs]",:ylabel=>text[1],:xtics=>"0 2"}
17
- listplot(opts)
18
- end
19
-
20
- def read_data
21
- today=Time.now.to_s
22
- plot_data=[]
23
- d_total_min=0
24
- File.open(Shunkuntype::TRAIN_FILE,'r'){|file|
25
- while line=file.gets do
26
- tmp=line.chomp.split(',')
27
- d_day = ((Time.parse(tmp[0])-Time.parse(today))/3600/24) #hours
28
- tmp << "60" if tmp.size ==3 # for backward consist. to "d,f,w"+",t"
29
- d_speed = tmp[2].to_f/tmp[3].to_f*60
30
- d_total_min += tmp[3].to_f/60.0 # total_second
31
- name = tmp[1]
32
- step = name.scan(/\d+/)[0].to_i # extract step from file name
33
- plot_data << [d_day,d_speed,d_total_min]
34
- end
35
- }
36
- return plot_data
37
- end
38
-
39
- def make_data_file(outdata)
40
- cont=""
41
- outdata.each {|idata|
42
- idata.each{|ele| cont << sprintf("%7.2f ",ele)}
43
- cont << "\n"
44
- }
45
- $temp=Tempfile.new(["tmp",".data"])
46
- $temp.puts(cont)
47
- $temp.close # must! before another use
48
- end
49
-
50
- def listplot(opts)
51
- cont = ""
52
- cont << "set xrange \[#{opts[:x]}\]\n" if opts.has_key?(:x)
53
- cont << "set yrange \[#{opts[:y]}\]\n" if opts.has_key?(:y)
54
- cont << "set title \"#{opts[:title]}\"\n" if opts.has_key?(:title)
55
- cont << "set xlabel \"#{opts[:xlabel]}\"\n" if opts.has_key?(:xlabel)
56
- cont << "set ylabel \"#{opts[:ylabel]}\"\n" if opts.has_key?(:ylabel)
57
- cont << "set xtics #{opts[:xtics]} \n" if opts.has_key?(:xtics)
58
- cont << "#{opts[:plot]} \n"
59
- temp2= Tempfile.new(["tmp",".txt"])
60
- temp2.print(cont)
61
- temp2.close # must! before another use
62
- p command ="gnuplot #{temp2.path}"
63
- system command
64
- end
65
-
66
- end
@@ -1,200 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'time'
3
- require 'fileutils'
4
- require "gnuplot"
5
-
6
- # = gnuplotが扱えるデータフォーマットへの変換
7
- # ==Usage
8
- # data0 = PlotData.new(name0,0,3,name)
9
- # data0.add_general_data(name1, 0, 2)
10
- # start=Time.parse(Time.now.to_s)
11
- # x_func = proc{|x| ((Time.parse(x)-start)/3600/24) }
12
- # y_func = proc{|y| y.to_f/60.0 }
13
- # data0.mk_plot_data(x_func,y_func)
14
- # data0.sort
15
- # data0.sum_data
16
- #
17
- class PlotData
18
- attr_accessor :data, :title
19
-
20
- def initialize(file_name="",x_col=nil,y_col=nil,title="")
21
- @data=[]
22
- read_general_data(file_name,x_col,y_col) if ""!=file_name
23
- @title=title if ""!=title
24
- end
25
-
26
- # @!group data read
27
- def add_general_data(file, x_col, y_col)
28
- read_general_data(file, x_col, y_col)
29
- end
30
-
31
- def read_general_data(file, x_col, y_col)
32
- begin
33
- File.open(file,'r'){|file|
34
- while line=file.gets do
35
- tmp=line.chomp.split(',')
36
- @data << [tmp[x_col],tmp[y_col]]
37
- end
38
- }
39
- rescue => e
40
- p e
41
- end
42
- end
43
- # @!endgroup
44
-
45
- #gnuplot libraryに沿った形のdataを出力.
46
- # 列データを行データに
47
- def to_gnuplot()
48
- x,y=[],[]
49
- @data.each{|ele|
50
- x << ele[0]
51
- y << ele[1]
52
- }
53
- return [x,y]
54
- end
55
-
56
- # x_func,y_funcに変換関数をyieldで入れる
57
- def mk_plot_data(x_func,y_func)
58
- tmp_data=[]
59
- @data.each{|ele|
60
- x_data = x_func.call(ele[0])
61
- y_data = y_func.call(ele[1])
62
- tmp_data << [x_data,y_data]
63
- }
64
- @data = tmp_data
65
- end
66
-
67
- #y軸の値の積分を取る
68
- def sum_data
69
- tmp_data=[]
70
- y_data=0
71
- @data.each{|ele| tmp_data << [ele[0], y_data+=ele[1]]}
72
- @data = tmp_data
73
- end
74
-
75
- #x軸の値によってsortをかける.
76
- def sort
77
- @data.sort!{|x,y| x[0] <=> y[0]}
78
- end
79
- end
80
-
81
- class MkPlots
82
-
83
- def initialize(tmp_dir,opts={})
84
- @source_dir=File.join(tmp_dir,'mem_data')
85
- @mem_names=[]
86
- @opts = opts
87
- mk_mem_names()
88
- work_all()
89
- speed_all()
90
- end
91
-
92
- def work_all
93
- all_data= @mem_names.inject([]){|all,name|
94
- all << work_view(name)
95
- }
96
- text="Work minutes [min]"
97
- plot(all_data,text)
98
- end
99
-
100
- def speed_all
101
- mk_mem_names
102
- all_data= @mem_names.inject([]){|all,name| all << speed_view(name) }
103
- text="Typing speed [sec/20 words]"
104
-
105
- plot(all_data,text)
106
- end
107
-
108
- def speed_view(name)
109
- name1 = "#{@source_dir}/#{name}_speed_data.txt"
110
- data0 = PlotData.new(name1, 0, 2, name)
111
- start=Time.parse(Time.now.to_s)
112
- x_func = proc{|x| ((Time.parse(x)-start)/3600/24) }
113
- y_func = proc{|y| y }
114
- data0.mk_plot_data(x_func,y_func)
115
- return data0
116
- end
117
-
118
- def mk_mem_names
119
- names = Dir.entries(@source_dir)
120
- names.each{|name|
121
- title = name.split('_')[0]
122
- @mem_names << title if (!@mem_names.include?(title) and title.match(/\w/))
123
- }
124
- end
125
-
126
- def work_view(name)
127
- p name0 = "#{@source_dir}/#{name}_training_data.txt"
128
- p name1 = "#{@source_dir}/#{name}_speed_data.txt"
129
- data0 = PlotData.new(name0,0,3,name)
130
- data0.add_general_data(name1, 0, 2)
131
- start=Time.parse(Time.now.to_s)
132
- x_func = proc{|x| ((Time.parse(x)-start)/3600/24) }
133
- y_func = proc{|y| y.to_f/60.0 }
134
- data0.mk_plot_data(x_func,y_func)
135
- data0.sort
136
- data0.sum_data
137
- return data0
138
- end
139
-
140
- def plot(data,text0,opts={})
141
- Gnuplot.open do |gp|
142
- Gnuplot::Plot.new( gp ) do |plot|
143
- plot.title "Elapsed time vs #{text0}"
144
- plot.ylabel text0
145
- plot.xlabel "Elapsed time[days]"
146
- plot.xtics "7"
147
- plot.xrange "[-49:1]"
148
- if true==opts.has_key?(:png) then
149
- plot.term "pngcairo enhanced size 480,360"
150
- plot.output "res.png"
151
- end
152
-
153
- plot.data = []
154
- data.each{|ele|
155
- plot.data << Gnuplot::DataSet.new( ele.to_gnuplot ) do |ds|
156
- ds.with = "line"
157
- if ""==ele.title then
158
- ds.notitle
159
- else
160
- ds.title=ele.title
161
- end
162
- end
163
- }
164
- end
165
- end
166
- end
167
- end
168
-
169
- if __FILE__ == $0 then
170
- data0 = PlotData.new()
171
- data0.read_general_data(ARGV[0], 0, 3)
172
- data0.add_general_data(ARGV[1], 0, 2)
173
-
174
- start=Time.parse(data0.data[0][0])
175
- x_func = proc{|x| ((Time.parse(x)-start)/3600/24) }
176
- y_func = proc{|x| x.to_f/60.0 }
177
- data0.mk_plot_data(x_func,y_func)
178
- data0.sort
179
- data0.sum_data
180
-
181
- text="Work minutes [min]"
182
- Gnuplot.open do |gp|
183
- Gnuplot::Plot.new( gp ) do |plot|
184
- plot.title "Elapsed time vs #{text}"
185
- plot.ylabel text
186
- plot.xlabel "Elapsed time[days]"
187
- plot.xtics "0 2"
188
- x,y = data0.to_gnuplot
189
-
190
- plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
191
- ds.with = "line"
192
- ds.notitle
193
- end
194
- end
195
- end
196
-
197
- end
198
-
199
-
200
-
@@ -1 +0,0 @@
1
- .hikirc