reflekt 0.1.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/reflekt.rb +55 -19
- data/lib/template.html.erb +20 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dab0fd8f1b076c4d4a4d6d7f571af7a6488e6d7a2a2fb430c4563cf12a8b011
|
4
|
+
data.tar.gz: 22ac5bf780e0d048b50a902ce498f679d03c24a6e251b48ce31511c3d0829a6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 251b7a98ea53230c50f2b3f77e602b5456b4a60b59a73c41e511b498d25b72c50a632cbadce1d887644c08ae32c90a30e36fb0ea51cffb437e0c3037a857ae7d
|
7
|
+
data.tar.gz: ba4872b5ef00a2fec12e9a2ebb662f3024e1411f529bc467fdd6d8c67a54382fb99c72e800c7cb07671eee165e00f6e231d1e600e9dfb91c59b175d3e48989d3
|
data/lib/reflekt.rb
CHANGED
@@ -1,13 +1,7 @@
|
|
1
1
|
require 'set'
|
2
|
-
|
3
|
-
# Production.
|
2
|
+
require 'erb'
|
4
3
|
require 'rowdb'
|
5
4
|
|
6
|
-
# Development.
|
7
|
-
#require_relative '../../rowdb/lib/rowdb.rb'
|
8
|
-
#require_relative '../../rowdb/lib/adapters/Adapter.rb'
|
9
|
-
#require_relative '../../rowdb/lib/adapters/FileSystem.rb'
|
10
|
-
|
11
5
|
################################################################################
|
12
6
|
# REFLEKT
|
13
7
|
#
|
@@ -19,7 +13,7 @@ require 'rowdb'
|
|
19
13
|
|
20
14
|
module Reflekt
|
21
15
|
|
22
|
-
@@
|
16
|
+
@@reflekt_clone_count = 5
|
23
17
|
|
24
18
|
def initialize(*args)
|
25
19
|
|
@@ -33,10 +27,25 @@ module Reflekt
|
|
33
27
|
# When method called in flow.
|
34
28
|
if @reflekt_forked
|
35
29
|
unless self.class.deflekted?(method)
|
30
|
+
|
36
31
|
# Reflekt on method.
|
37
32
|
@reflekt_clones.each do |clone|
|
38
33
|
reflekt_action(clone, method, *args)
|
39
34
|
end
|
35
|
+
|
36
|
+
# Save results.
|
37
|
+
@@reflekt_db.write()
|
38
|
+
|
39
|
+
# Render results.
|
40
|
+
@@reflekt_json = File.read("#{@@reflekt_output_path}/db.json")
|
41
|
+
template = File.read("#{@@reflekt_path}/template.html.erb")
|
42
|
+
rendered = ERB.new(template).result(binding)
|
43
|
+
|
44
|
+
# Write results.
|
45
|
+
File.open("#{@@reflekt_output_path}/index.html", 'w+') do |f|
|
46
|
+
f.write rendered
|
47
|
+
end
|
48
|
+
|
40
49
|
end
|
41
50
|
end
|
42
51
|
|
@@ -56,7 +65,7 @@ module Reflekt
|
|
56
65
|
|
57
66
|
def reflekt_fork()
|
58
67
|
|
59
|
-
@@
|
68
|
+
@@reflekt_clone_count.times do |clone|
|
60
69
|
@reflekt_clones << self.clone
|
61
70
|
end
|
62
71
|
|
@@ -66,6 +75,9 @@ module Reflekt
|
|
66
75
|
|
67
76
|
def reflekt_action(clone, method, *args)
|
68
77
|
|
78
|
+
class_name = clone.class.to_s
|
79
|
+
method_name = method.to_s
|
80
|
+
|
69
81
|
# Create new arguments.
|
70
82
|
new_args = []
|
71
83
|
args.each do |arg|
|
@@ -80,12 +92,24 @@ module Reflekt
|
|
80
92
|
# Action method with new arguments.
|
81
93
|
begin
|
82
94
|
clone.send(method, *new_args)
|
95
|
+
|
96
|
+
# Build reflection.
|
97
|
+
reflection = {
|
98
|
+
"time" => Time.now.to_i,
|
99
|
+
}
|
100
|
+
# When error.
|
83
101
|
rescue StandardError => error
|
84
|
-
|
102
|
+
reflection["status"] = "error"
|
103
|
+
reflection["error"] = error
|
104
|
+
# When success.
|
85
105
|
else
|
86
|
-
|
106
|
+
reflection["status"] = "success"
|
87
107
|
end
|
88
108
|
|
109
|
+
# Save reflection.
|
110
|
+
@@reflekt_db.get("#{class_name}.#{method_name}")
|
111
|
+
.push(reflection)
|
112
|
+
|
89
113
|
end
|
90
114
|
|
91
115
|
private
|
@@ -94,21 +118,33 @@ module Reflekt
|
|
94
118
|
def self.prepended(base)
|
95
119
|
base.singleton_class.prepend(Klass)
|
96
120
|
|
97
|
-
@@
|
121
|
+
@@reflekt_setup ||= reflekt_setup_klass
|
98
122
|
end
|
99
123
|
|
100
124
|
# Setup Klass.
|
101
|
-
def self.
|
125
|
+
def self.reflekt_setup_klass()
|
126
|
+
|
127
|
+
# Receive configuration from host application.
|
128
|
+
$ENV ||= {}
|
129
|
+
$ENV[:reflekt] ||= $ENV[:reflekt] = {}
|
102
130
|
|
131
|
+
@@reflekt_path = File.dirname(File.realpath(__FILE__))
|
132
|
+
|
133
|
+
# Create "reflections" directory in configured path.
|
134
|
+
if $ENV[:reflekt][:output_path]
|
135
|
+
@@reflekt_output_path = File.join($ENV[:reflekt][:output_path], 'reflections')
|
103
136
|
# Create "reflections" directory in current execution path.
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
137
|
+
else
|
138
|
+
@@reflekt_output_path = File.join(Dir.pwd, 'reflections')
|
139
|
+
end
|
140
|
+
|
141
|
+
unless Dir.exist? @@reflekt_output_path
|
142
|
+
Dir.mkdir(@@reflekt_output_path)
|
108
143
|
end
|
109
144
|
|
110
|
-
|
111
|
-
@@
|
145
|
+
# Create database.
|
146
|
+
@@reflekt_db = Rowdb.new(@@reflekt_output_path + '/db.json')
|
147
|
+
@@reflekt_db.defaults({ :reflekt => { :api_version => 1 }}).write()
|
112
148
|
|
113
149
|
return true
|
114
150
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>Reflekt</title>
|
6
|
+
<meta name="description" content="">
|
7
|
+
<meta name="author" content="">
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
9
|
+
<link rel="stylesheet" href="">
|
10
|
+
<link rel="shortcut icon" href="">
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
|
14
|
+
<script>
|
15
|
+
var reflections = JSON.parse(<%= @@reflekt_json %>)
|
16
|
+
console.log(reflections)
|
17
|
+
</script>
|
18
|
+
|
19
|
+
</body>
|
20
|
+
</html>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reflekt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maedi Prichard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rowdb
|
@@ -24,13 +24,14 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
description:
|
27
|
+
description: Testing that's completely automated.
|
28
28
|
email: maediprichard@gmailcom
|
29
29
|
executables: []
|
30
30
|
extensions: []
|
31
31
|
extra_rdoc_files: []
|
32
32
|
files:
|
33
33
|
- lib/reflekt.rb
|
34
|
+
- lib/template.html.erb
|
34
35
|
homepage: https://github.com/maedi/reflekt
|
35
36
|
licenses:
|
36
37
|
- MPL-2.0
|
@@ -53,5 +54,5 @@ requirements: []
|
|
53
54
|
rubygems_version: 3.0.2
|
54
55
|
signing_key:
|
55
56
|
specification_version: 4
|
56
|
-
summary:
|
57
|
+
summary: Reflective testing.
|
57
58
|
test_files: []
|