evt-telemetry 0.3.0.2 → 0.3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/telemetry/sink.rb +45 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4232dd7cc989788094d9f1fdc6e26e1be6dbe4d3
|
4
|
+
data.tar.gz: a903d2a73c86cca54109dad9cc4659f79a3ffa02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66070195dee9f9a98ce3159d38ced027bbc63af8a87c0479c89c504e0943024e3e9181c37475572bd02d34469f455528fa798dd413ce4e6233e1c5c65569518e
|
7
|
+
data.tar.gz: bdc41431c61a77ccb3fbdc888d9c8a181593efdd28e5c606e2ca87b8690ff6c7c6b2a47712fda8e452ddf312fd7e7872440ba67e274368c339e240ca0e9aa900
|
data/lib/telemetry/sink.rb
CHANGED
@@ -37,6 +37,17 @@ class Telemetry
|
|
37
37
|
return subset.any? &blk
|
38
38
|
end
|
39
39
|
end
|
40
|
+
|
41
|
+
detect_once_method_name = "recorded_#{signal}_once?"
|
42
|
+
send(:define_method, detect_once_method_name) do |&blk|
|
43
|
+
subset = send(subset_method_name)
|
44
|
+
|
45
|
+
if blk.nil?
|
46
|
+
return subset.count == 1
|
47
|
+
else
|
48
|
+
return subset.one? &blk
|
49
|
+
end
|
50
|
+
end
|
40
51
|
end
|
41
52
|
alias :record :record_macro
|
42
53
|
end
|
@@ -52,6 +63,8 @@ class Telemetry
|
|
52
63
|
|
53
64
|
Record = Struct.new :signal, :time, :data
|
54
65
|
|
66
|
+
Error = Class.new(RuntimeError)
|
67
|
+
|
55
68
|
def records
|
56
69
|
@records ||= []
|
57
70
|
end
|
@@ -72,6 +85,17 @@ class Telemetry
|
|
72
85
|
record
|
73
86
|
end
|
74
87
|
|
88
|
+
def record(signal, time, data=nil, force: nil)
|
89
|
+
force ||= false
|
90
|
+
|
91
|
+
record = nil
|
92
|
+
if force || record?(signal)
|
93
|
+
record = Record.new signal, time, data
|
94
|
+
records << record
|
95
|
+
end
|
96
|
+
record
|
97
|
+
end
|
98
|
+
|
75
99
|
def recorded?(&blk)
|
76
100
|
if blk.nil?
|
77
101
|
return !records.empty?
|
@@ -80,15 +104,29 @@ class Telemetry
|
|
80
104
|
end
|
81
105
|
end
|
82
106
|
|
83
|
-
def
|
84
|
-
|
107
|
+
def recorded_once?(&blk)
|
108
|
+
if blk.nil?
|
109
|
+
return records.count == 1
|
110
|
+
else
|
111
|
+
return records.one? &blk
|
112
|
+
end
|
113
|
+
end
|
85
114
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
115
|
+
def one_record(&blk)
|
116
|
+
records = self.records
|
117
|
+
|
118
|
+
unless blk.nil?
|
119
|
+
records = records.select(&blk)
|
120
|
+
end
|
121
|
+
|
122
|
+
case records.count
|
123
|
+
when 0
|
124
|
+
return nil
|
125
|
+
when 1
|
126
|
+
return records[0]
|
127
|
+
else
|
128
|
+
raise Error, "More than one matching record was recorded"
|
90
129
|
end
|
91
|
-
record
|
92
130
|
end
|
93
131
|
end
|
94
132
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evt-telemetry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.0
|
4
|
+
version: 0.3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Eventide Project
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: evt-dependency
|