reflekt 0.1.0 → 0.3.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 +60 -5
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ea7a5f25f96a57be5a969ed1648f50d609dba6072b9a7543a7b4304b7242dbb
|
4
|
+
data.tar.gz: df11f9353775f6af904ac08e8718f324e9c15d8b3975b9a35b21d28a8dc54d2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dca4b9717d22ced3ca520f138b56c1eee19b0ec1e771d045aa1f1e76de7e532bc5f71a9e9482ab39b03ceab6517904da9876750b1e05d3da91a21fe49a505589
|
7
|
+
data.tar.gz: 2b55b64dbafd84e1e0a36e39291f6ef8aa10a91bb25f22e838b2fdc27565a6e677c1cdd010890fa5dca34765e433771529b5516a67c8dc44ca5fb55bcf4873ac
|
data/lib/reflekt.rb
CHANGED
@@ -1,9 +1,17 @@
|
|
1
1
|
require 'set'
|
2
2
|
|
3
|
+
# Production.
|
4
|
+
require 'rowdb'
|
5
|
+
|
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
|
+
|
3
11
|
################################################################################
|
4
12
|
# REFLEKT
|
5
13
|
#
|
6
|
-
#
|
14
|
+
# Usage. Prepend to the class like so:
|
7
15
|
#
|
8
16
|
# class ExampleClass
|
9
17
|
# prepend Reflekt
|
@@ -29,6 +37,8 @@ module Reflekt
|
|
29
37
|
@reflekt_clones.each do |clone|
|
30
38
|
reflekt_action(clone, method, *args)
|
31
39
|
end
|
40
|
+
# Save results.
|
41
|
+
@@db.write()
|
32
42
|
end
|
33
43
|
end
|
34
44
|
|
@@ -58,6 +68,9 @@ module Reflekt
|
|
58
68
|
|
59
69
|
def reflekt_action(clone, method, *args)
|
60
70
|
|
71
|
+
class_name = clone.class.to_s
|
72
|
+
method_name = method.to_s
|
73
|
+
|
61
74
|
# Create new arguments.
|
62
75
|
new_args = []
|
63
76
|
args.each do |arg|
|
@@ -72,17 +85,59 @@ module Reflekt
|
|
72
85
|
# Action method with new arguments.
|
73
86
|
begin
|
74
87
|
clone.send(method, *new_args)
|
88
|
+
|
89
|
+
# Build reflection.
|
90
|
+
reflection = {
|
91
|
+
"time" => Time.now.to_i,
|
92
|
+
}
|
93
|
+
# When error.
|
75
94
|
rescue StandardError => error
|
76
|
-
|
95
|
+
reflection["status"] = "error"
|
96
|
+
reflection["error"] = error
|
97
|
+
# When success.
|
77
98
|
else
|
78
|
-
|
99
|
+
reflection["status"] = "success"
|
79
100
|
end
|
80
101
|
|
102
|
+
# Save reflection.
|
103
|
+
@@db.get("#{class_name}.#{method_name}")
|
104
|
+
.push(reflection)
|
105
|
+
|
81
106
|
end
|
82
107
|
|
108
|
+
private
|
109
|
+
|
83
110
|
# Prepend Klass to the instance's singleton class.
|
84
111
|
def self.prepended(base)
|
85
112
|
base.singleton_class.prepend(Klass)
|
113
|
+
|
114
|
+
@@setup ||= setup_klass
|
115
|
+
end
|
116
|
+
|
117
|
+
# Setup Klass.
|
118
|
+
def self.setup_klass()
|
119
|
+
|
120
|
+
# Receive configuration from host application.
|
121
|
+
$ENV ||= {}
|
122
|
+
$ENV[:reflekt] ||= $ENV[:reflekt] = {}
|
123
|
+
|
124
|
+
# Create "reflections" directory in configured path.
|
125
|
+
if $ENV[:reflekt][:output_path]
|
126
|
+
dir_path = File.join($ENV[:reflekt][:output_path], 'reflections')
|
127
|
+
# Create "reflections" directory in current execution path.
|
128
|
+
else
|
129
|
+
dir_path = File.join(Dir.pwd, 'reflections')
|
130
|
+
end
|
131
|
+
|
132
|
+
unless Dir.exist? dir_path
|
133
|
+
Dir.mkdir(dir_path)
|
134
|
+
end
|
135
|
+
|
136
|
+
# Create database.
|
137
|
+
@@db = Rowdb.new(dir_path + '/db.json')
|
138
|
+
@@db.defaults({"reflections" => []})
|
139
|
+
|
140
|
+
return true
|
86
141
|
end
|
87
142
|
|
88
143
|
module Klass
|
@@ -90,11 +145,11 @@ module Reflekt
|
|
90
145
|
@@deflekted_methods = Set.new
|
91
146
|
|
92
147
|
##
|
93
|
-
#
|
148
|
+
# Skip a method.
|
94
149
|
#
|
95
150
|
# method - A symbol representing the method name.
|
96
151
|
##
|
97
|
-
def
|
152
|
+
def reflekt_skip(method)
|
98
153
|
@@deflekted_methods.add(method)
|
99
154
|
end
|
100
155
|
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maedi Prichard
|
@@ -9,8 +9,22 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2020-07-18 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
13
|
-
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rowdb
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Reflective testing that's completely automated.
|
14
28
|
email: maediprichard@gmailcom
|
15
29
|
executables: []
|
16
30
|
extensions: []
|
@@ -39,5 +53,5 @@ requirements: []
|
|
39
53
|
rubygems_version: 3.0.2
|
40
54
|
signing_key:
|
41
55
|
specification_version: 4
|
42
|
-
summary:
|
56
|
+
summary: Reflective testing that's completely automated.
|
43
57
|
test_files: []
|