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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/reflekt.rb +29 -5
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 432283c96d3dbe26216affd0ec264e41d9ca611a5769a1cda0bda659e4d073dd
4
- data.tar.gz: 66dc60d9f623a55a2b4fa78035dabc4d7bc02f9e6f3b90046681529f24ddb1ce
3
+ metadata.gz: 6a460a27dcd832266459649d57e9b9ba8ae599ec653944d5ea375803cd549f28
4
+ data.tar.gz: a4665017add098fdf3c12e73a27600767e432a71d7b45ea7b64be5ef8c0f0667
5
5
  SHA512:
6
- metadata.gz: c5a3977885e6c92e02b4a9ed1ff36a33887749190e90adb758dc1f149bcdebfffab4f6290677cfeb2ab3375b51b356ef76fece338137e3bee8f3210ee034d157
7
- data.tar.gz: c8d92ecfe7980cdd1b6c74368a4767121843c1d8057531759e766fcee30e7d44346e8d6b17149dbc2d3bad08ded1e75a7e406c1574f30214c040f4293cbf4f20
6
+ metadata.gz: 18191d516773841418776543dea540e708964a0783038a13fa7b28b59913ec9f41a6148208c6bc375274ff82adeae2e96da803397a2203a518166c9ca303ad6d
7
+ data.tar.gz: 8c5ca58649349c019370fdcb0b83bda51ebd3dbdca7ac2a1e745b35dd64856811fe791c3d148c756ee47b24154a79d229656fb4f8c0b2f0598555da742dddc17
@@ -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
- p error
93
+ reflection["status"] = "error"
94
+ reflection["error"] = error
95
+ # When success.
85
96
  else
86
- puts "Success."
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
- # TODO: Allow override of path via global config.
105
- dir_path = File.join(Dir.pwd, 'reflections')
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({items: []})
135
+ @@db.defaults({"reflections" => []})
112
136
 
113
137
  return true
114
138
  end
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.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maedi Prichard