reflekt 0.1.3 → 0.2.0
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/lib/reflekt.rb +29 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a460a27dcd832266459649d57e9b9ba8ae599ec653944d5ea375803cd549f28
|
4
|
+
data.tar.gz: a4665017add098fdf3c12e73a27600767e432a71d7b45ea7b64be5ef8c0f0667
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18191d516773841418776543dea540e708964a0783038a13fa7b28b59913ec9f41a6148208c6bc375274ff82adeae2e96da803397a2203a518166c9ca303ad6d
|
7
|
+
data.tar.gz: 8c5ca58649349c019370fdcb0b83bda51ebd3dbdca7ac2a1e745b35dd64856811fe791c3d148c756ee47b24154a79d229656fb4f8c0b2f0598555da742dddc17
|
data/lib/reflekt.rb
CHANGED
@@ -37,6 +37,8 @@ module Reflekt
|
|
37
37
|
@reflekt_clones.each do |clone|
|
38
38
|
reflekt_action(clone, method, *args)
|
39
39
|
end
|
40
|
+
# Save results.
|
41
|
+
@@db.write()
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
@@ -80,11 +82,23 @@ module Reflekt
|
|
80
82
|
# Action method with new arguments.
|
81
83
|
begin
|
82
84
|
clone.send(method, *new_args)
|
85
|
+
# Build reflection.
|
86
|
+
reflection = {
|
87
|
+
"time" => Time.now.to_i,
|
88
|
+
"class" => clone.class.to_s,
|
89
|
+
"method" => method.to_s,
|
90
|
+
}
|
91
|
+
# When error.
|
83
92
|
rescue StandardError => error
|
84
|
-
|
93
|
+
reflection["status"] = "error"
|
94
|
+
reflection["error"] = error
|
95
|
+
# When success.
|
85
96
|
else
|
86
|
-
|
97
|
+
reflection["status"] = "success"
|
87
98
|
end
|
99
|
+
# Save reflection.
|
100
|
+
@@db.get('reflections')
|
101
|
+
.push(reflection)
|
88
102
|
|
89
103
|
end
|
90
104
|
|
@@ -100,15 +114,25 @@ module Reflekt
|
|
100
114
|
# Setup Klass.
|
101
115
|
def self.setup_klass()
|
102
116
|
|
117
|
+
# Receive configuration from host application.
|
118
|
+
$ENV ||= {}
|
119
|
+
$ENV[:reflekt] ||= $ENV[:reflekt] = {}
|
120
|
+
|
121
|
+
# Create "reflections" directory in configured path.
|
122
|
+
if $ENV[:reflekt][:output_path]
|
123
|
+
dir_path = File.join($ENV[:reflekt][:output_path], 'reflections')
|
103
124
|
# Create "reflections" directory in current execution path.
|
104
|
-
|
105
|
-
|
125
|
+
else
|
126
|
+
dir_path = File.join(Dir.pwd, 'reflections')
|
127
|
+
end
|
128
|
+
|
106
129
|
unless Dir.exist? dir_path
|
107
130
|
Dir.mkdir(dir_path)
|
108
131
|
end
|
109
132
|
|
133
|
+
# Create database.
|
110
134
|
@@db = Rowdb.new(dir_path + '/db.json')
|
111
|
-
@@db.defaults({
|
135
|
+
@@db.defaults({"reflections" => []})
|
112
136
|
|
113
137
|
return true
|
114
138
|
end
|