shunkuntype 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa980481aa57d8bae72450249ad33e6fe82b62ba
4
- data.tar.gz: 03142adad7500cec3252942be94bc084efc7120e
3
+ metadata.gz: c5361ad1a9894115d0773dbb8b2929cbe047c7e8
4
+ data.tar.gz: 421c83828a3cf7c36cb63197d00bb1f3a600aed2
5
5
  SHA512:
6
- metadata.gz: de1e1914b42d69b735da36af6e0fa6e55322483aa15717c1d5d15ca4bbe7173e7eb1d2e18adfdf325372b64c524a940e0766294ee7f48244e3aad8421379e914
7
- data.tar.gz: 3369e8e93244e3780ce67ac56d3deb375bcb28bcb46f6eb68fb10a1959d81790a87b37c420f1d720debb1aff0531507c1b958b17ef8f451d9c2dca79421d9a80
6
+ metadata.gz: 70b5626b63c53f1feb97044f9e56514a86ba38e4470b22f55a171127a29082d2a9ec3b8870862b7b05179dd40c238ae8acc4fb4304b29c9bf3b18dd1b65c717f
7
+ data.tar.gz: c93345719cf1b43c51904298eec89b7efbb381115b2044104ef25793e0904cf71400191e94b9d97ca44de82d755fbf94dedcb93cca72b93172a9ee7b9f9fd119
@@ -0,0 +1,52 @@
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
@@ -2,7 +2,7 @@ require 'fileutils'
2
2
  require 'tmpdir'
3
3
 
4
4
  module Shunkuntype
5
- VERSION = "1.0.4"
5
+ VERSION = "1.0.5"
6
6
  data_dir = File.join(ENV['HOME'], '.shunkuntype')
7
7
  # SPEED_FILE="./shunkuntype_speed_data.txt"
8
8
  SPEED_FILE=File.join(data_dir,"speed_data.txt")
data/lib/shunkuntype.rb CHANGED
@@ -7,6 +7,7 @@ require "shunkuntype/plot"
7
7
  require "shunkuntype/mk_summary"
8
8
  require "shunkuntype/plot_data"
9
9
  require "shunkuntype/db"
10
+ require "shunkuntype/merge"
10
11
  require 'systemu'
11
12
 
12
13
  module Shunkuntype
@@ -58,15 +59,37 @@ module Shunkuntype
58
59
  end
59
60
 
60
61
  def report_submit
62
+ p 'report submission'
63
+ data_dir = File.join(ENV['HOME'], '.shunkuntype')
64
+ FileUtils.cd(data_dir)
61
65
  server_info=File.readlines(Shunkuntype::SERVER_FILE)
62
- p server_directory=server_info[0].chomp
63
- p user_name=server_info[0].split('@')[0]
64
- system "scp #{Shunkuntype::TRAIN_FILE} #{server_directory}/#{user_name}_training_data.txt"
65
- system "scp #{Shunkuntype::SPEED_FILE} #{server_directory}/#{user_name}_speed_data.txt"
66
+ p @server_directory=server_info[0].chomp
67
+ p @user_name=server_info[0].split('@')[0]
68
+
69
+ ['training_data.txt','speed_data.txt'].each{|ext|
70
+ file_merge(ext)
71
+ }
72
+ end
73
+
74
+ def file_merge(ext_name)
75
+ file_name=ext_name
76
+ file_current = File.readlines(file_name)
77
+ tmp_file = File.open("./tmp_data.txt",'w')
78
+ sta, out, stderror = systemu "scp #{@server_directory}/#{@user_name}_#{ext_name} ."
79
+ if stderror.split(":")[2] != " No such file or directory\n" then
80
+ file_server = File.readlines("#{@user_name}_#{ext_name}")
81
+ tmp_file.print data_merge(file_current,file_server)
82
+ else
83
+ p " No such file or directory in server.\n"
84
+ tmp_file.print file_current.join
85
+ end
86
+ tmp_file.close
87
+ system "cat tmp_data.txt"
88
+ system "scp tmp_data.txt #{@server_directory}/#{@user_name}_#{ext_name}"
66
89
  end
67
90
 
68
91
  def data_viewing(file)
69
- # opts for MkPlots could be described in file
92
+ # opts for MkPlots could be described in file
70
93
  # Not coded yet at all!!!
71
94
  if file==nil then
72
95
  opts = {}
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.4
4
+ version: 1.0.5
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-09-22 00:00:00.000000000 Z
11
+ date: 2016-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: systemu
@@ -189,9 +189,9 @@ files:
189
189
  - lib/data/trans2.rb
190
190
  - lib/data/word.list
191
191
  - lib/shunkuntype.rb
192
- - lib/shunkuntype/#version.rb#
193
192
  - lib/shunkuntype/db.rb
194
193
  - lib/shunkuntype/finished_check.rb
194
+ - lib/shunkuntype/merge.rb
195
195
  - lib/shunkuntype/mk_summary.rb
196
196
  - lib/shunkuntype/options.rb
197
197
  - lib/shunkuntype/plot.rb
@@ -1,12 +0,0 @@
1
- require 'fileutils'
2
- require 'tmpdir'
3
-
4
- module Shunkuntype
5
- VERSION = "1.0.3"
6
- data_dir = File.join(ENV['HOME'], '.shunkuntype')
7
- # SPEED_FILE="./shunkuntype_speed_data.txt"
8
- SPEED_FILE=File.join(data_dir,"speed_data.txt")
9
- # TRAIN_FILE="./shunkuntype_training_data.txt"
10
- TRAIN_FILE=File.join(data_dir,"training_data.txt")
11
- SERVER_FILE=File.join(data_dir,"server_data.txt")
12
- end