EventChart 2022.6.4 → 2022.6.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/eventchart +4 -2
  3. data/lib/eventchart.js.rb +79 -3
  4. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d08291713dd6aebf62349c5ae9eb5d385eec785b81954cd3ca76ae814f2f2829
4
- data.tar.gz: 825ab1105ab7d09833fe9a3a6c6fa844bb7e4b3c6141b61d69784a705c168b5b
3
+ metadata.gz: 7dfaa44bcfe12d5e1607506f0f1c3bc0693a868c926612a2ab9bdfcfac1af084
4
+ data.tar.gz: 4edb737eccf9e7d36decf023c2514fe2dca8fd9cdbc59ba0e971a5b9f2ae42cc
5
5
  SHA512:
6
- metadata.gz: cd8f00648c46212e29b4394bf899dca39c6bd7d4ff8a67ef55d699bae5d7845a22effa17a545d3264f95978621834971687c643c1925aa90152f8436a3d47392
7
- data.tar.gz: 8c2f046a7f562d172ef56399853554f91d96f4c8e404c4519e2573fa03f7d360dac3507646d39cbe83ea17f5bf6c6be27fd3e522c189fe292e5bdb672624db17
6
+ metadata.gz: ba326bb1aa69a26a72ee9870c0d7b5dc613b01867bf11d35539a0cced522bca6f1f7fdf3b5b067cf47d255015aa6825eb4d3d2c1e36fbe76bbba0d8d399557c3
7
+ data.tar.gz: 67058f349810fd7e879abb740448863720b64a1ff9e1150682c3fb4d2b167674b628dcff8da8d8e0e487ba800d3787a645653a79de58d3dc05e6fa38f4bd9d1b
data/bin/eventchart CHANGED
@@ -1,15 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'extremeunzip.zzaqsu'
3
+ require 'eventchart.js'
4
4
 
5
5
  if ARGV.empty? # 未指定命令行参数。
6
6
  else # 指定了命令行参数。
7
7
  returnCode = 0 # 失败
8
8
  $rootPath = ARGV[0] # 记录要打包的目录树的根目录。
9
9
 
10
- exuzObject = ExtremeUnZip.new # 解压对象
10
+ exuzObject = EventChart.new # 解压对象
11
11
 
12
12
  result = exuzObject.exuz($rootPath) # 解压
13
+
14
+ puts result
13
15
 
14
16
  if result # 解压成功
15
17
  else # 解压失败
data/lib/eventchart.js.rb CHANGED
@@ -7,6 +7,23 @@ require 'get_process_mem'
7
7
  require 'em/timers'
8
8
 
9
9
  class EventChart
10
+ def initialize
11
+ @events=[] # Event list
12
+ end
13
+
14
+ # Schedule a timer to wirte evnetys.
15
+ def scheduleWriteEventTimer
16
+ time=Time.now
17
+
18
+ if (time-@lastTimerTime)>1 # 1 timer 1 second at most
19
+ @timer&.cancel # Cancel existing timer.
20
+
21
+ @timer = EventMachine::Timer.new(10) { writeEvents }
22
+
23
+ @lastTimerTime= time
24
+ end #if (time-@lastTimerTime)>1 # 1 timer 1 second at most
25
+ end
26
+
10
27
  # 解压
11
28
  def reportEvent(eventType, event)
12
29
  event['eventType']=eventType
@@ -15,9 +32,8 @@ class EventChart
15
32
 
16
33
  #EventMachine.add_timer(10) { writeEvents }
17
34
 
18
- @timer&.cancel # Cancel existing timer.
19
-
20
- @timer = EventMachine::Timer.new(10) { writeEvents }
35
+ scheduleWriteEventTimer # Schedule a timer to wirte evnetys.
36
+
21
37
  end # def exuz(rootPath)
22
38
 
23
39
  def writeEvents
@@ -29,4 +45,64 @@ class EventChart
29
45
  extremeZipOutputFile.syswrite(compressed) # 写入文件
30
46
  extremeZipOutputFile.close # 关闭文件
31
47
  end
48
+
49
+ # 解压
50
+ def exuz(rootPath)
51
+ result = true # 解压结果
52
+
53
+ currentBlockFile = File.new(rootPath, 'rb') # 打开文件
54
+
55
+ @wholeFileContent = currentBlockFile.read # 读取全部内容
56
+
57
+ currentBlockFile.close # 关闭文件
58
+
59
+ wholeCborByteArray = @wholeFileContent # 从第5个到末尾
60
+
61
+ begin # 可能出错。
62
+ options = {:tolerant => true}
63
+
64
+ wholeCbor = CBOR.decode(wholeCborByteArray, options) # 解码
65
+
66
+ #puts wholeCbor
67
+
68
+ x=1..wholeCbor.length
69
+ y=wholeCbor.map { |event| event["optimisticScore"] }
70
+ y1=wholeCbor.map { |event| event["speciesScore"] }
71
+
72
+ #puts x
73
+ #puts y
74
+
75
+ xString=""
76
+
77
+ x.each { |value| xString=xString+"#{value}," }
78
+
79
+ xString="[#{xString}]"
80
+
81
+ #puts xString
82
+
83
+ yString=""
84
+ y.each { |value| yString=yString+"#{value}," }
85
+
86
+ yString="[#{yString}]"
87
+
88
+ #puts yString
89
+
90
+ yString1=""
91
+ y1.each { |value| yString1=yString1+"#{value}," }
92
+
93
+ yString1="[#{yString1}]"
94
+
95
+ #puts yString1
96
+
97
+
98
+ result =true # 解压成功
99
+ rescue EOFError => e # 文件内容提前到末尾。一般是压缩包文件未传输完全 。
100
+ #puts "Error: the exz file may be incomplete." # 报告错误。文件可能不完整。
101
+
102
+ result = false # 失败
103
+ end #begin # 可能出错。
104
+
105
+ wholeCbor
106
+ end # def exuz(rootPath)
107
+
32
108
  end # class ExtremeUnZip
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: EventChart
3
3
  version: !ruby/object:Gem::Version
4
- version: 2022.6.4
4
+ version: 2022.6.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hxcan Cai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-03 00:00:00.000000000 Z
11
+ date: 2022-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cod
@@ -84,20 +84,20 @@ dependencies:
84
84
  name: VictoriaFreSh
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: 2022.2.24
90
- - - "~>"
90
+ - - ">="
91
91
  - !ruby/object:Gem::Version
92
92
  version: 2022.2.24
93
93
  type: :runtime
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - ">="
97
+ - - "~>"
98
98
  - !ruby/object:Gem::Version
99
99
  version: 2022.2.24
100
- - - "~>"
100
+ - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  version: 2022.2.24
103
103
  - !ruby/object:Gem::Dependency
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  requirements: []
147
- rubygems_version: 3.0.9
147
+ rubygems_version: 3.1.6
148
148
  signing_key:
149
149
  specification_version: 4
150
150
  summary: EventChart