EventChart 2022.6.8 → 2022.6.11
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 +4 -4
- data/bin/eventchart +4 -2
- data/lib/eventchart.js.rb +77 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4574fee43536c87d3040a9514e015b60e2fda32a13e98c2d0e411843ea0201a4
|
4
|
+
data.tar.gz: b54bfa809efa1d61dc61d34c520e885819b0aaed1b70a73f112294d2047513e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4ec543984274d2fddc9c3535d52765a5e751207575444ee2e93485617923ed5c867c71cfa31a5ba5fd71aafe414fe24331c7f91589dafcb65a36af008ba7308
|
7
|
+
data.tar.gz: 324bd8616312d604e199155ce7a653aa3705c342fefaa51e3a658a21584108d90a93b1fd54b3ee6909e6a5e5970c08759dac60cadb13cf6b5e6d529675f8011b
|
data/bin/eventchart
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require '
|
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 =
|
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
@@ -9,8 +9,23 @@ require 'em/timers'
|
|
9
9
|
class EventChart
|
10
10
|
def initialize
|
11
11
|
@events=[] # Event list
|
12
|
+
@lastTimerTime=Time.now
|
13
|
+
|
12
14
|
end
|
13
15
|
|
16
|
+
# Schedule a timer to wirte evnetys.
|
17
|
+
def scheduleWriteEventTimer
|
18
|
+
time=Time.now
|
19
|
+
|
20
|
+
if (time-@lastTimerTime)>1 # 1 timer 1 second at most
|
21
|
+
@timer&.cancel # Cancel existing timer.
|
22
|
+
|
23
|
+
@timer = EventMachine::Timer.new(10) { writeEvents }
|
24
|
+
|
25
|
+
@lastTimerTime= time
|
26
|
+
end #if (time-@lastTimerTime)>1 # 1 timer 1 second at most
|
27
|
+
end
|
28
|
+
|
14
29
|
# 解压
|
15
30
|
def reportEvent(eventType, event)
|
16
31
|
event['eventType']=eventType
|
@@ -19,9 +34,8 @@ class EventChart
|
|
19
34
|
|
20
35
|
#EventMachine.add_timer(10) { writeEvents }
|
21
36
|
|
22
|
-
|
23
|
-
|
24
|
-
@timer = EventMachine::Timer.new(10) { writeEvents }
|
37
|
+
scheduleWriteEventTimer # Schedule a timer to wirte evnetys.
|
38
|
+
|
25
39
|
end # def exuz(rootPath)
|
26
40
|
|
27
41
|
def writeEvents
|
@@ -33,4 +47,64 @@ class EventChart
|
|
33
47
|
extremeZipOutputFile.syswrite(compressed) # 写入文件
|
34
48
|
extremeZipOutputFile.close # 关闭文件
|
35
49
|
end
|
50
|
+
|
51
|
+
# 解压
|
52
|
+
def exuz(rootPath)
|
53
|
+
result = true # 解压结果
|
54
|
+
|
55
|
+
currentBlockFile = File.new(rootPath, 'rb') # 打开文件
|
56
|
+
|
57
|
+
@wholeFileContent = currentBlockFile.read # 读取全部内容
|
58
|
+
|
59
|
+
currentBlockFile.close # 关闭文件
|
60
|
+
|
61
|
+
wholeCborByteArray = @wholeFileContent # 从第5个到末尾
|
62
|
+
|
63
|
+
begin # 可能出错。
|
64
|
+
options = {:tolerant => true}
|
65
|
+
|
66
|
+
wholeCbor = CBOR.decode(wholeCborByteArray, options) # 解码
|
67
|
+
|
68
|
+
#puts wholeCbor
|
69
|
+
|
70
|
+
x=1..wholeCbor.length
|
71
|
+
y=wholeCbor.map { |event| event["optimisticScore"] }
|
72
|
+
y1=wholeCbor.map { |event| event["speciesScore"] }
|
73
|
+
|
74
|
+
#puts x
|
75
|
+
#puts y
|
76
|
+
|
77
|
+
xString=""
|
78
|
+
|
79
|
+
x.each { |value| xString=xString+"#{value}," }
|
80
|
+
|
81
|
+
xString="[#{xString}]"
|
82
|
+
|
83
|
+
#puts xString
|
84
|
+
|
85
|
+
yString=""
|
86
|
+
y.each { |value| yString=yString+"#{value}," }
|
87
|
+
|
88
|
+
yString="[#{yString}]"
|
89
|
+
|
90
|
+
#puts yString
|
91
|
+
|
92
|
+
yString1=""
|
93
|
+
y1.each { |value| yString1=yString1+"#{value}," }
|
94
|
+
|
95
|
+
yString1="[#{yString1}]"
|
96
|
+
|
97
|
+
#puts yString1
|
98
|
+
|
99
|
+
|
100
|
+
result =true # 解压成功
|
101
|
+
rescue EOFError => e # 文件内容提前到末尾。一般是压缩包文件未传输完全 。
|
102
|
+
#puts "Error: the exz file may be incomplete." # 报告错误。文件可能不完整。
|
103
|
+
|
104
|
+
result = false # 失败
|
105
|
+
end #begin # 可能出错。
|
106
|
+
|
107
|
+
wholeCbor
|
108
|
+
end # def exuz(rootPath)
|
109
|
+
|
36
110
|
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
|
+
version: 2022.6.11
|
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-
|
11
|
+
date: 2022-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cod
|