shunkuntype 1.0.1 → 1.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5b7c4b3091c6dbc4547472c1b7bc263a1ee45638
4
- data.tar.gz: a16097d397f661555f86b75a3673f7be9141f842
3
+ metadata.gz: 73ac5960873c2ccd96d886d20a7ec3f6ca2e6ec2
4
+ data.tar.gz: c149a6d1c2af462e5d7261aab6e7e589e6c98105
5
5
  SHA512:
6
- metadata.gz: 62210a0160399201b785326dbfddac41cff7107f3df3e34ff20fb2f8de9926ab813eed37a485ff6072293ea560bdd5153019d60f028be2bf0613d36fad480eca
7
- data.tar.gz: 7df32fa38b700dce3aeccbeaec7d6868c9b256a3548a8fdbc57d56c377f3e49e86d851e72d4f2f994a0f51b0057d91ab2fc8e4413f3eed3ad146dc5675d7d155
6
+ metadata.gz: 28fd40092698ed5557e7c1f549864f22d2e3d81bf60cef22b8ec012e870d038b79a2b4db739ed07b70f0766f235f78b7f8337d862228a60ce2181e96a4f3f0ff
7
+ data.tar.gz: 0e178b3638d1c448603769e90294112b179953dbfaf7213fd2bc901542597507042e81d8ba7bc5e6b1b53a75d5e979cef3ade79083a841afef1263b63cb988cc
data/README.md CHANGED
@@ -23,7 +23,6 @@ Or install it yourself as:
23
23
  ```ruby
24
24
  Usage: shunkuntype [options]
25
25
  -v, --version show program Version.
26
- -i, --init Initialize data files
27
26
  -c, --check Check speed
28
27
  -d, --drill [VAL] one minute Drill [VAL]
29
28
  -h, --history view training History
data/Rakefile CHANGED
@@ -16,3 +16,11 @@ Rake::TestTask.new(:test) do |test|
16
16
  test.test_files = FileList['test/**/*_test.rb']
17
17
  test.verbose = true
18
18
  end
19
+
20
+ desc "setenv for release from Kwansei gakuin."
21
+ task :setenv do
22
+ p command='setenv HTTP_PROXY http://proxy.ksc.kwansei.ac.jp:8080'
23
+ system command
24
+ p command='setenv HTTPS_PROXY http://proxy.ksc.kwansei.ac.jp:8080'
25
+ system command
26
+ end
data/config.ru CHANGED
@@ -1,3 +1,3 @@
1
1
  require 'application'
2
2
 
3
- run Todo::Application
3
+ run Shunkuntype::Application
data/lib/shunkuntype.rb CHANGED
@@ -2,7 +2,6 @@ require 'optparse'
2
2
  require "shunkuntype/version"
3
3
  require "shunkuntype/speed"
4
4
  require "shunkuntype/training"
5
- require "shunkuntype/init"
6
5
  require "shunkuntype/finished_check"
7
6
  require "shunkuntype/plot"
8
7
  require "shunkuntype/mk_summary"
@@ -23,7 +22,7 @@ module Shunkuntype
23
22
  end
24
23
 
25
24
  def execute
26
- DB.prepare
25
+ DataFiles.prepare
27
26
 
28
27
  @argv << '--help' if @argv.size==0
29
28
  command_parser = OptionParser.new do |opt|
@@ -31,7 +30,6 @@ module Shunkuntype
31
30
  opt.version = Shunkuntype::VERSION
32
31
  puts opt.ver
33
32
  }
34
- opt.on('-i', '--init','Initialize data files') {|v| InitDataFiles.new }
35
33
  opt.on('-c', '--check','Check speed') {|v| SpeedCheck.new }
36
34
  opt.on('-d', '--drill [VAL]','one minute Drill [VAL]', Integer) {|v| Training.new(v) }
37
35
  opt.on('-h', '--history','view training History') {|v| FinishCheck.new }
@@ -54,30 +52,33 @@ module Shunkuntype
54
52
  def data_viewing(form)
55
53
  server_info=File.readlines(Shunkuntype::SERVER_FILE)
56
54
  p server_directory=server_info[0].chomp
57
- system "scp -r #{server_directory} ."
58
- # write data to file
59
- table = MkSummary.new
60
- MkPlots.new
61
- p form ||= :html
62
- case form
55
+ Dir.mktmpdir('shunkun'){|tmp_dir|
56
+ FileUtils.mkdir_p(File.join(tmp_dir,'mem_data'))
57
+ system "scp -r #{server_directory}/* #{tmp_dir}/mem_data"
58
+ # write data to file
59
+ table = MkSummary.new(tmp_dir)
60
+ MkPlots.new(tmp_dir)
61
+ p form ||= :html
62
+ case form
63
63
  when :html then
64
- File.open('tmp.html','a'){|f|
65
- f.write("<html>\n")
66
- f.write(table.mk_html_table())
67
- f.write("<p><img src=\"./work.png\" /></p>")
68
- f.write("<p><img src=\"./speed.png\" /></p>")
69
- f.write("</html>\n")
70
- }
64
+ File.open('./tmp.html','a'){|f|
65
+ f.write("<html>\n")
66
+ f.write(table.mk_html_table())
67
+ f.write("<p><img src=\"./work.png\" /></p>")
68
+ f.write("<p><img src=\"./speed.png\" /></p>")
69
+ f.write("</html>\n")
70
+ }
71
71
  when :hiki then
72
- File.open('tmp.hiki','a'){|f|
73
- f.write(table.mk_hiki_table())
74
- f.write('||{{attach_view(work.png)}}')
75
- f.write('||{{attach_view(speed.png)}}')
76
- f.write("\n")
77
- }
72
+ File.open('./tmp.hiki','a'){|f|
73
+ f.write(table.mk_hiki_table())
74
+ f.write('||{{attach_view(work.png)}}')
75
+ f.write('||{{attach_view(speed.png)}}')
76
+ f.write("\n")
77
+ }
78
78
  else
79
- exit
80
- end
79
+
80
+ end
81
+ }
81
82
  end
82
83
  end
83
84
  end
@@ -1,25 +1,49 @@
1
1
  #encoding: utf-8
2
2
 
3
3
  require 'fileutils'
4
+ #require 'init'
4
5
 
5
- module DB
6
+ module DataFiles
6
7
 
7
8
  def self.prepare
8
9
  data_path = File.join(ENV['HOME'], '.shunkuntype','training_data.txt')
9
10
 
10
- create_file_if_not_exists data_path
11
+ create_file_if_not_exists(data_path)
11
12
  end
12
13
 
13
14
  def self.create_file_if_not_exists(path)
14
- create_file_path path
15
+ create_file_path(path)
15
16
 
16
17
  return if File::exists?(path)
18
+ create_data_files
17
19
  end
18
20
 
19
21
  def self.create_file_path(path)
20
22
  FileUtils.mkdir_p File.dirname(path)
21
23
  end
22
24
 
23
- private_class_method :create_file_if_not_exists, :create_file_path
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
24
48
  end
25
49
 
@@ -9,7 +9,7 @@ class FinishCheck
9
9
  ['lo. 30,31,32,33,34', 30,31,32,33,34],
10
10
  ['aqz 35,36,37,38,39', 35,36,37,38,39],
11
11
  [';p 40,41,42,43,44,45',40,41,42,43,44,45],
12
- ['consol 46,47,48,49,50', 46,47,48,49,50]]
12
+ ['consol 46,47,48,49,50', 46,47,48,49,50]
13
13
  ]]
14
14
  def initialize
15
15
  finish = [[],[]]
@@ -1,6 +1,7 @@
1
1
  class MkSummary
2
- def initialize
3
- files = Dir::entries("./mem_data")
2
+ def initialize(tmp_dir)
3
+ $mem_dir=File.join(tmp_dir,"mem_data")
4
+ files = Dir::entries($mem_dir)
4
5
  member = mk_member(files)
5
6
  @scores = take_scores(files,member)
6
7
  end
@@ -22,14 +23,14 @@ class MkSummary
22
23
  p name
23
24
  speed_file="#{name}_speed_data.txt"
24
25
  if files.include?(speed_file)
25
- file = File.readlines("mem_data/#{speed_file}")
26
+ file = File.readlines(File.join($mem_dir,speed_file))
26
27
  init= (file[0]!=nil ? file[0].split(",")[2].to_f : 0.0 )
27
28
  cur = (file[-1]!=nil ? file[-1].split(",")[2].to_f : 0.0 )
28
29
  scores[name]=[init,cur]
29
30
  end
30
31
  training_file="#{name}_training_data.txt"
31
32
  if files.include?(training_file)
32
- file = File.readlines("mem_data/#{training_file}")
33
+ file = File.readlines(File.join($mem_dir,training_file))
33
34
  work_time = file.inject(0){|sum,line|
34
35
  sec=line.split(',')[3].to_i
35
36
  sec= (sec!=0)? sec : 60
@@ -1,23 +1,19 @@
1
1
  require 'time'
2
+ require 'tempfile'
2
3
 
3
4
  class PlotPersonalData
4
-
5
5
  def initialize
6
6
  plot_data = read_data()
7
7
  make_data_file(plot_data)
8
8
 
9
9
  text=["Typing speed [words/min]","Work minutes [min]"]
10
- 2.times{|i|
11
- opts = {:title=>"Elapsed time vs #{text[i]}",
12
- :plot=>"plot \"./tmp.data\" using 1:#{i+2} w st\n",
13
- :xlabel=>"Elapsed time[hrs]",:ylabel=>text[i],:xtics=>"0 2"}
14
- listplot(opts)
15
- }
16
-
17
- opts = {:title=>"Elapsed time vs Finished steps",
18
- :xlabel=>"Elapsed time[hrs]",:ylabel=>"Finished steps",:xtics=>"0 2",
19
- :plot=>"plot \"./tmp.data\" u 1:4 w st ti \"basic drills\", \\
20
- \"./tmp.data\" u 1:5 w st ti \"Gerard Strong drills\""}
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"}
21
17
  listplot(opts)
22
18
  end
23
19
 
@@ -25,7 +21,6 @@ class PlotPersonalData
25
21
  today=Time.now.to_s
26
22
  plot_data=[]
27
23
  d_total_min=0
28
- d_step=[[0],[0]]
29
24
  File.open(Shunkuntype::TRAIN_FILE,'r'){|file|
30
25
  while line=file.gets do
31
26
  tmp=line.chomp.split(',')
@@ -35,8 +30,7 @@ class PlotPersonalData
35
30
  d_total_min += tmp[3].to_f/60.0 # total_second
36
31
  name = tmp[1]
37
32
  step = name.scan(/\d+/)[0].to_i # extract step from file name
38
- name.include?('GerardStrong_data') ? d_step[1] << step : d_step[0] << step
39
- plot_data << [d_day,d_speed,d_total_min,d_step[0][-1],d_step[1][-1]]
33
+ plot_data << [d_day,d_speed,d_total_min]
40
34
  end
41
35
  }
42
36
  return plot_data
@@ -48,7 +42,9 @@ class PlotPersonalData
48
42
  idata.each{|ele| cont << sprintf("%7.2f ",ele)}
49
43
  cont << "\n"
50
44
  }
51
- File.open("./tmp.data",'w'){|io| io.print(cont)}
45
+ $temp=Tempfile.new(["tmp",".data"])
46
+ $temp.puts(cont)
47
+ $temp.close # must! before another use
52
48
  end
53
49
 
54
50
  def listplot(opts)
@@ -60,8 +56,11 @@ class PlotPersonalData
60
56
  cont << "set ylabel \"#{opts[:ylabel]}\"\n" if opts.has_key?(:ylabel)
61
57
  cont << "set xtics #{opts[:xtics]} \n" if opts.has_key?(:xtics)
62
58
  cont << "#{opts[:plot]} \n"
63
- File.open("./tmp.txt",'w'){|io| io.print(cont)}
64
- system "gnuplot ./tmp.txt"
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
65
64
  end
66
65
 
67
66
  end
@@ -1,15 +1,29 @@
1
+ # -*- coding: utf-8 -*-
1
2
  require 'time'
3
+ require 'fileutils'
2
4
  require "gnuplot"
3
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
+ #
4
17
  class PlotData
5
18
  attr_accessor :data, :title
6
- # def initialize()
19
+
7
20
  def initialize(file_name="",x_col=nil,y_col=nil,title="")
8
21
  @data=[]
9
22
  read_general_data(file_name,x_col,y_col) if ""!=file_name
10
23
  @title=title if ""!=title
11
24
  end
12
25
 
26
+ # @!group data read
13
27
  def add_general_data(file, x_col, y_col)
14
28
  read_general_data(file, x_col, y_col)
15
29
  end
@@ -22,7 +36,10 @@ class PlotData
22
36
  end
23
37
  }
24
38
  end
39
+ # @!endgroup
25
40
 
41
+ #gnuplot libraryに沿った形のdataを出力.
42
+ # 列データを行データに
26
43
  def to_gnuplot()
27
44
  x,y=[],[]
28
45
  @data.each{|ele|
@@ -32,6 +49,7 @@ class PlotData
32
49
  return [x,y]
33
50
  end
34
51
 
52
+ # x_func,y_funcに変換関数をyieldで入れる
35
53
  def mk_plot_data(x_func,y_func)
36
54
  tmp_data=[]
37
55
  @data.each{|ele|
@@ -42,6 +60,7 @@ class PlotData
42
60
  @data = tmp_data
43
61
  end
44
62
 
63
+ #y軸の値の積分を取る
45
64
  def sum_data
46
65
  tmp_data=[]
47
66
  y_data=0
@@ -49,6 +68,7 @@ class PlotData
49
68
  @data = tmp_data
50
69
  end
51
70
 
71
+ #x軸の値によってsortをかける.
52
72
  def sort
53
73
  @data.sort!{|x,y| x[0] <=> y[0]}
54
74
  end
@@ -56,12 +76,14 @@ end
56
76
 
57
77
  class MkPlots
58
78
 
59
- def initialize
60
- @source_dir='mem_data'
79
+ def initialize(tmp_dir)
80
+ @source_dir=File.join(tmp_dir,'mem_data')
61
81
  @mem_names=[]
62
82
  mk_mem_names()
63
83
  work_all()
84
+ FileUtils.mv('res.png', './work.png')
64
85
  speed_all()
86
+ FileUtils.mv('res.png', './speed.png')
65
87
  end
66
88
 
67
89
  def work_all
@@ -69,8 +91,6 @@ class MkPlots
69
91
  text="Work minutes [min]"
70
92
  plot(all_data,text)
71
93
  plot(all_data,text,opts={:png=>true})
72
- # system 'cp res.png ~/Sites/nishitani0/Internal/data/cache/attach/ShunkunTyper2015/work.png'
73
- system 'mv res.png work.png'
74
94
  end
75
95
 
76
96
  def speed_all
@@ -79,16 +99,14 @@ class MkPlots
79
99
  text="Typing speed [sec/20 words]"
80
100
  plot(all_data,text)
81
101
  plot(all_data,text,opts={:png=>true})
82
- system 'mv res.png speed.png'
83
102
  end
84
103
 
85
104
  def speed_view(name)
86
105
  p name1 = "#{@source_dir}/#{name}_speed_data.txt"
87
106
  data0 = PlotData.new(name1, 0, 2, name)
88
- # start=Time.parse(data0.data[0][0])
89
107
  start=Time.parse(Time.now.to_s)
90
108
  x_func = proc{|x| ((Time.parse(x)-start)/3600/24) }
91
- y_func = proc{|x| x }
109
+ y_func = proc{|y| y }
92
110
  data0.mk_plot_data(x_func,y_func)
93
111
  return data0
94
112
  end
@@ -108,7 +126,7 @@ class MkPlots
108
126
  data0.add_general_data(name1, 0, 2)
109
127
  start=Time.parse(Time.now.to_s)
110
128
  x_func = proc{|x| ((Time.parse(x)-start)/3600/24) }
111
- y_func = proc{|x| x.to_f/60.0 }
129
+ y_func = proc{|y| y.to_f/60.0 }
112
130
  data0.mk_plot_data(x_func,y_func)
113
131
  data0.sort
114
132
  data0.sum_data
@@ -1,10 +1,12 @@
1
1
  require 'fileutils'
2
+ require 'tmpdir'
3
+
2
4
  module Shunkuntype
3
- VERSION = "1.0.1"
4
- data_path = File.join(ENV['HOME'], '.shunkuntype')
5
+ VERSION = "1.0.2"
6
+ data_dir = File.join(ENV['HOME'], '.shunkuntype')
5
7
  # SPEED_FILE="./shunkuntype_speed_data.txt"
6
- SPEED_FILE=File.join(data_path,"speed_data.txt")
8
+ SPEED_FILE=File.join(data_dir,"speed_data.txt")
7
9
  # TRAIN_FILE="./shunkuntype_training_data.txt"
8
- TRAIN_FILE=File.join(data_path,"training_data.txt")
9
- SERVER_FILE=File.join(data_path,"server_data.txt")
10
+ TRAIN_FILE=File.join(data_dir,"training_data.txt")
11
+ SERVER_FILE=File.join(data_dir,"server_data.txt")
10
12
  end
data/tmp.data ADDED
@@ -0,0 +1,72 @@
1
+ -114.75 68.00 1.00
2
+ -114.75 55.00 2.00
3
+ -114.75 52.00 3.00
4
+ -114.75 42.00 4.00
5
+ -114.75 48.00 5.00
6
+ -114.74 57.00 6.00
7
+ -114.74 52.00 7.00
8
+ -114.74 50.00 8.00
9
+ -114.74 55.00 9.00
10
+ -114.74 55.00 10.00
11
+ -113.94 39.00 11.00
12
+ -113.93 48.00 12.00
13
+ -112.77 51.00 13.00
14
+ -111.91 58.51 16.35
15
+ -111.91 57.00 17.35
16
+ -111.89 43.54 20.27
17
+ -111.77 59.00 21.27
18
+ -107.75 49.68 24.37
19
+ -107.72 56.00 25.37
20
+ -104.91 36.67 25.67
21
+ -104.90 39.00 26.67
22
+ -104.90 69.00 27.67
23
+ -104.76 12.00 27.75
24
+ -104.76 24.00 27.83
25
+ -104.76 52.06 30.10
26
+ -104.76 55.00 31.10
27
+ -103.08 57.00 32.10
28
+ -103.08 53.00 33.10
29
+ -103.08 47.14 33.57
30
+ -103.07 60.00 34.57
31
+ -103.07 60.00 34.82
32
+ -102.81 37.50 35.08
33
+ -102.80 60.00 35.33
34
+ -102.80 64.00 35.58
35
+ -102.80 38.95 36.53
36
+ -102.79 45.84 38.02
37
+ -102.79 60.00 38.27
38
+ -102.79 64.00 38.52
39
+ -102.79 36.00 39.27
40
+ -102.78 0.00 39.32
41
+ -102.78 20.00 39.87
42
+ -102.78 56.00 40.12
43
+ -102.77 24.00 40.37
44
+ -102.68 60.00 40.62
45
+ -102.68 40.00 41.67
46
+ -102.67 48.00 41.92
47
+ -102.67 16.00 42.17
48
+ -102.67 32.00 42.42
49
+ -102.67 60.00 42.67
50
+ -102.67 45.00 43.20
51
+ -102.66 37.06 43.77
52
+ -102.66 64.00 44.02
53
+ -102.66 56.00 44.27
54
+ -102.66 56.00 44.52
55
+ -102.66 45.88 45.65
56
+ -102.66 20.00 45.70
57
+ -102.66 20.00 45.95
58
+ -102.10 56.00 46.20
59
+ -99.96 43.00 49.20
60
+ -52.05 69.00 50.20
61
+ -51.99 33.00 50.53
62
+ -51.07 54.00 50.87
63
+ -51.06 51.00 51.20
64
+ -51.06 54.00 51.53
65
+ -50.99 57.00 52.53
66
+ -50.84 48.00 53.53
67
+ -50.83 55.00 54.53
68
+ -50.83 48.00 55.53
69
+ -50.83 49.00 56.53
70
+ -50.83 54.00 57.53
71
+ -42.07 39.00 58.53
72
+ -0.98 44.00 59.53
data/tmp.txt ADDED
@@ -0,0 +1,6 @@
1
+ set title "Elapsed time vs Work minutes [min]"
2
+ set xlabel "Elapsed time[hrs]"
3
+ set ylabel "Work minutes [min]"
4
+ set xtics 0 2
5
+ plot "./tmp.data" using 1:3 w st
6
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shunkuntype
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shigeto R. Nishitani
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-09 00:00:00.000000000 Z
11
+ date: 2016-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: systemu
@@ -171,11 +171,8 @@ files:
171
171
  - lib/data/trans2.rb
172
172
  - lib/data/word.list
173
173
  - lib/shunkuntype.rb
174
- - lib/shunkuntype/#db.rb#
175
- - lib/shunkuntype/#version.rb#
176
174
  - lib/shunkuntype/db.rb
177
175
  - lib/shunkuntype/finished_check.rb
178
- - lib/shunkuntype/init.rb
179
176
  - lib/shunkuntype/mk_summary.rb
180
177
  - lib/shunkuntype/options.rb
181
178
  - lib/shunkuntype/plot.rb
@@ -184,6 +181,8 @@ files:
184
181
  - lib/shunkuntype/training.rb
185
182
  - lib/shunkuntype/version.rb
186
183
  - shunkuntype.gemspec
184
+ - tmp.data
185
+ - tmp.txt
187
186
  - tmp1/always_restart.txt
188
187
  homepage: https://github.com/daddygongon/shunkuntype
189
188
  licenses:
@@ -1,25 +0,0 @@
1
- #encoding: utf-8
2
-
3
- require 'fileutils'
4
-
5
- module DB
6
-
7
- def self.prepare
8
- data_path = File.join(ENV['HOME'], '.shunkuntype','training_data.txt')
9
-
10
- create_file_if_not_exists data_path
11
- end
12
-
13
- def self.create_file_if_not_exists(path)
14
- create_file_path path
15
-
16
- return if File::exists?(path)
17
- end
18
-
19
- def self.create_file_path(path)
20
- FileUtils.mkdir_p File.dirname(path)
21
- end
22
-
23
- private_class_method :create_file_if_not_exists, :create_file_path
24
- end
25
-
@@ -1,8 +0,0 @@
1
- require 'fileutils'
2
- module Shunkuntype
3
- VERSION = "1.0.1"
4
- data_path = File.join(ENV['HOME'], '.shunkuntype')
5
- SPEED_FILE=File.join(data_path,"speed_data.txt")
6
- TRAIN_FILE=File.join(data_path,"training_data.txt")
7
- SERVER_FILE=File.join(data_path,"server_data.txt")
8
- end
@@ -1,24 +0,0 @@
1
- class InitDataFiles
2
- def initialize
3
- if File::exist?("./speed_data.txt") then
4
- system "mv ./speed_data.txt #{Shunkuntype::SPEED_FILE}"
5
- print "moving ./speed_data.txt #{Shunkuntype::SPEED_FILE}.\n"
6
- end
7
- if File::exist?("./training_data.txt") then
8
- system "mv ./training_data.txt #{Shunkuntype::TRAIN_FILE}"
9
- print "moving ./training_data.txt #{Shunkuntype::TRAIN_FILE}.\n"
10
- end
11
- if File::exist?(Shunkuntype::SPEED_FILE) then
12
- print "#{Shunkuntype::SPEED_FILE} exits.\n"
13
- else
14
- File::open(Shunkuntype::SPEED_FILE,'a')
15
- print "make #{Shunkuntype::SPEED_FILE}.\n"
16
- end
17
- if File::exist?(Shunkuntype::TRAIN_FILE) then
18
- print "#{Shunkuntype::TRAIN_FILE} exits.\n"
19
- else
20
- File::open(Shunkuntype::TRAIN_FILE,'a')
21
- print "make #{Shunkuntype::TRAIN_FILE}.\n"
22
- end
23
- end
24
- end