reflekt 0.9.0 → 0.9.1

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
  SHA256:
3
- metadata.gz: e4d3c0c32672fd8813482a3f546032904d3d6f65e592fd4435eb7ada2bb1b201
4
- data.tar.gz: d48f2b100986c4408db5cb055f4ebf1e6a50d99fa99dc6d98e8af8e5d8bcd66e
3
+ metadata.gz: 3589292c5c5cba2f3d7c7d5e1d7e02ee1052afe7339929cfa058b787b89c3158
4
+ data.tar.gz: d33c6774d53d4b7a0978fcfc48fa00e22f3684ccd51e5d42676f01831fb84291
5
5
  SHA512:
6
- metadata.gz: 1422110bc34f7b88f8b4ba71359c408d38f3ebf72235735e51864fd0bd16c32fd5abc20e5cfa8a516478932800590f80f7f1b7b4d0dac3c0ebd18a3d8dfffd54
7
- data.tar.gz: 4019f5868ca20d1aebfa9e4ddb2c5136782aa52185588cb44558f4725f51ea59f90bc75896e8bfac383151d7346bb534d98bc00a11a569c350d0c460fe3b31ab
6
+ metadata.gz: 2e3120f544d87057b4783a4e6e76a9689844f17ed1ad602c8b2c5e5ee241285ef83e276b56fbdb33da0d167c68077eca6f851e859a28392718a26ed129ab18e7
7
+ data.tar.gz: 47d323198d8d27585ef5fb0d493eca120d0cd2ff532a6578ef3b7490ccbc9e4fc38757bab8fb2ad4ab6c05c0a9fd721b27a5925a90c95503c0de5d4fb7483e12
@@ -0,0 +1,7 @@
1
+ require 'Reflection'
2
+
3
+ class Control < Reflection
4
+
5
+ # TODO.
6
+
7
+ end
@@ -5,6 +5,7 @@ class Execution
5
5
  attr_accessor :caller_class
6
6
  attr_accessor :parent
7
7
  attr_accessor :child
8
+ attr_accessor :control
8
9
  attr_accessor :reflections
9
10
  attr_accessor :is_reflecting
10
11
 
@@ -16,6 +17,7 @@ class Execution
16
17
  @parent = nil
17
18
  @child = nil
18
19
 
20
+ @control = []
19
21
  @reflections = Array.new(reflection_count)
20
22
  @is_reflecting = false
21
23
 
@@ -1,6 +1,7 @@
1
1
  require 'set'
2
2
  require 'erb'
3
3
  require 'rowdb'
4
+ require 'Control'
4
5
  require 'Execution'
5
6
  require 'Reflection'
6
7
  require 'ShadowStack'
@@ -65,24 +66,31 @@ module Reflekt
65
66
  if execution.has_empty_reflections? && !execution.is_reflecting?
66
67
  execution.is_reflecting = true
67
68
 
69
+ class_name = execution.caller_class.to_s
70
+ method_name = method.to_s
71
+
72
+ # Create control.
73
+ control = Control.new(execution, method, true)
74
+ execution.control = control
75
+
76
+ # Execute control.
77
+ control.reflect(*args)
78
+
79
+ # Save control.
80
+ @@reflekt_db.get("#{class_name}.#{method_name}.controls").push(control.result())
81
+
68
82
  # Multiple reflections per execution.
69
83
  execution.reflections.each_with_index do |value, index|
70
84
 
71
- # Flag first reflection is a control.
72
- is_control = false
73
- is_control = true if index == 0
74
-
75
85
  # Create reflection.
76
- reflection = Reflection.new(execution, method, is_control)
86
+ reflection = Reflection.new(execution, method, false)
77
87
  execution.reflections[index] = reflection
78
88
 
79
89
  # Execute reflection.
80
90
  reflection.reflect(*args)
81
91
 
82
- # Add result.
83
- class_name = execution.caller_class.to_s
84
- method_name = method.to_s
85
- @@reflekt_db.get("#{class_name}.#{method_name}").push(reflection.result())
92
+ # Save reflection.
93
+ @@reflekt_db.get("#{class_name}.#{method_name}.reflections").push(reflection.result())
86
94
 
87
95
  end
88
96
 
@@ -22,6 +22,7 @@ body {
22
22
  /* Structure */
23
23
  ul.classes,
24
24
  ul.methods,
25
+ ul.controls,
25
26
  ul.reflections {
26
27
  padding-left: 0;
27
28
  }
@@ -49,8 +50,17 @@ li.method-container {
49
50
  background: #D04700;
50
51
  }
51
52
 
53
+ /* Buttons. */
54
+ .method .buttons {
55
+ margin-left: auto;
56
+ margin-right: 1rem;
57
+ }
58
+ .buttons button {
59
+ padding: 1rem 2rem;
60
+ }
61
+
52
62
  /* Stats. */
53
- .stats {
63
+ .class .stats {
54
64
  margin-left: auto;
55
65
  }
56
66
  .stat {
@@ -85,6 +95,7 @@ li.method-container {
85
95
  }
86
96
 
87
97
  /* Reflection. */
98
+ .control,
88
99
  .reflection {
89
100
  list-style: none;
90
101
  margin-left: 2rem;
@@ -95,6 +106,7 @@ li.method-container {
95
106
  padding: 0.5rem 1.5rem;
96
107
  margin-bottom: 0.3rem;
97
108
  }
109
+ .control .time,
98
110
  .reflection .time {
99
111
  color: #777777;
100
112
  margin-right: 2rem;
@@ -32,17 +32,18 @@
32
32
 
33
33
  function getData() {
34
34
 
35
- var reflections = JSON.parse(<%= @@reflekt_json %>);
36
- console.log("REFLECTIONS:");
37
- console.log(reflections);
35
+ var data = JSON.parse(<%= @@reflekt_json %>);
38
36
  var results = {};
39
37
 
40
- if ('reflekt' in reflections) {
41
- delete(reflections.reflekt);
38
+ console.log("DATA:");
39
+ console.log(data);
40
+
41
+ if ('reflekt' in data) {
42
+ delete(data.reflekt);
42
43
  }
43
44
 
44
45
  // Classes.
45
- for ([class_id, class_value] of Object.entries(reflections)) {
46
+ for ([class_id, class_value] of Object.entries(data)) {
46
47
 
47
48
  // Class pass rate.
48
49
  results[class_id] = {
@@ -57,17 +58,17 @@
57
58
  // Methods.
58
59
  for ([method_id, method] of Object.entries(class_value)) {
59
60
 
60
- // Method pass rate.
61
- var pass_count = method.reduce(function(obj, v) {
61
+ // Reflection pass rate.
62
+ var pass_count = method.reflections.reduce(function(obj, v) {
62
63
  obj[v[STATUS]] = (obj[v[STATUS]] || 0) + 1;
63
64
  return obj;
64
65
  }, {});
65
66
 
66
- var pass_rate = (pass_count[PASS] / method.length) * 100;
67
+ var pass_rate = (pass_count[PASS] / method.reflections.length) * 100;
67
68
  results[class_id]['methods'][method_id] = {
68
69
  'stats': {
69
70
  'pass_rate': pass_rate,
70
- 'test_count': method.length,
71
+ 'test_count': method.reflections.length,
71
72
  'pass_count': pass_count[PASS]
72
73
  }
73
74
  };
@@ -79,7 +80,7 @@
79
80
  }
80
81
 
81
82
  // Class pass rate.
82
- results[class_id]['stats']['test_count'] += method.length;
83
+ results[class_id]['stats']['test_count'] += method.reflections.length;
83
84
  results[class_id]['stats']['pass_count'] += pass_count[PASS];
84
85
 
85
86
  }
@@ -97,7 +98,7 @@
97
98
  }
98
99
 
99
100
  return {
100
- reflections: reflections,
101
+ data: data,
101
102
  results: results
102
103
  };
103
104
  }
@@ -134,15 +135,19 @@
134
135
  <template x-for="[method_id, method] in Object.entries(klass['methods'])" :key="method_id">
135
136
  <li class="method-container">
136
137
 
137
- <div class="status-row method" x-bind:class="`${method.status}`" @click="method['show'] = !method['show']" :aria-expanded="method['show'] ? 'true' : 'false'" :class="{ 'active': method['show'] }">
138
+ <div class="status-row method" x-bind:class="`${method.status}`" :class="{ 'active': method['show_reflections'] }" :class="{ 'active': method['show_controls'] }">
138
139
  <h3 x-text="`${method_id}()`"></h3>
140
+ <div class="buttons">
141
+ <button @click="method['show_controls'] = !method['show_controls']">Controls</button>
142
+ <button @click="method['show_reflections'] = !method['show_reflections']">Reflections</button>
143
+ </div>
139
144
  <div class="stats">
140
145
  <div class="stat" x-text="`${method.stats.pass_rate.toFixed(2)}%`"></div>
141
146
  </div>
142
147
  </div>
143
148
 
144
- <ul class="reflections" x-show="method['show']">
145
- <template x-for="[reflection_id, reflection] in Object.entries(reflections[class_id][method_id])">
149
+ <ul class="reflections" x-show="method['show_reflections']">
150
+ <template x-for="[reflection_id, reflection] in Object.entries(data[class_id][method_id].reflections)">
146
151
 
147
152
  <li class="reflection">
148
153
 
@@ -192,6 +197,57 @@
192
197
  </template>
193
198
  </ul>
194
199
 
200
+ <ul class="controls" x-show="method['show_controls']">
201
+ <template x-for="[control_id, control] in Object.entries(data[class_id][method_id].controls)">
202
+
203
+ <li class="control">
204
+
205
+ <div class="time" x-text="`${new Date(control.t * 1000).getFullYear()}/${new Date(control.t * 1000).getMonth() + 1}/${new Date(control.t * 1000).getDate()} ${new Date(control.t * 1000).getHours()}:${new Date(control.t * 1000).getMinutes()}:${new Date(control.t * 1000).getSeconds()}`"></div>
206
+
207
+ <template x-for="[input_id, input] in Object.entries(control.i)">
208
+
209
+ <div class="info">
210
+ <h4>Input</h4>
211
+ <div class="info-items">
212
+ <div class="info-item">
213
+ <strong>Type:</strong><div class="input" x-text="input.T"></div>
214
+ </div>
215
+ <template x-if="input.V != undefined">
216
+ <div class="info-item">
217
+ <strong>Value:</strong><pre><div class="output" x-text="input.V"></div></pre>
218
+ </div>
219
+ </template>
220
+ <template x-if="input.C != undefined">
221
+ <div class="info-item">
222
+ <strong>Count:</strong><div class="input" x-text="input.C"></div>
223
+ </div>
224
+ </template>
225
+ </div>
226
+ </div>
227
+
228
+ </template>
229
+
230
+ <div class="info">
231
+ <h4>Output</h4>
232
+ <div class="info-items">
233
+ <div class="info-item">
234
+ <strong>Type:</strong><div class="output" x-text="control.o.T"></div>
235
+ </div>
236
+ <template x-if="control.o.C != undefined">
237
+ <div class="info-item">
238
+ <strong>Count:</strong><div class="output" x-text="control.o.C"></div>
239
+ </div>
240
+ </template>
241
+ <div class="info-item">
242
+ <strong>Value:</strong><pre><div class="output" x-text="control.o.V"></div></pre>
243
+ </div>
244
+ </div>
245
+ </div>
246
+ </li>
247
+
248
+ </template>
249
+ </ul>
250
+
195
251
  </li>
196
252
  </template>
197
253
  </ul>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reflekt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maedi Prichard
@@ -30,6 +30,7 @@ executables: []
30
30
  extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
+ - lib/Control.rb
33
34
  - lib/Execution.rb
34
35
  - lib/Reflection.rb
35
36
  - lib/ShadowStack.rb