reflekt 0.3.1 → 0.4.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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/reflekt.rb +29 -20
  3. data/lib/template.html.erb +20 -0
  4. metadata +5 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7eecfaacf0ed26a06a1ab774a55f5ecf62713a71a685162a0da0fbd40696afec
4
- data.tar.gz: 8a64d9fc0c39102423e6c95cfbdecbc53d9510097b63c35cb2f4cb4fb89d8870
3
+ metadata.gz: 9dab0fd8f1b076c4d4a4d6d7f571af7a6488e6d7a2a2fb430c4563cf12a8b011
4
+ data.tar.gz: 22ac5bf780e0d048b50a902ce498f679d03c24a6e251b48ce31511c3d0829a6c
5
5
  SHA512:
6
- metadata.gz: d6029337485e9d149bd225e1a2786a37f7646115f3ea2adb6835adc8f686a1f93d090e7f68a3787ec37870f724f1a47dddf2df8b4ca58ad8dd6e7f0bda504c7c
7
- data.tar.gz: da9b95e714e27bc6b96475784129aa66c8468657544d6bc368fb89edee5b4fbc2c4022770482b0d1fa3095bb310ec215c72fd2a63221b897c307748f2eff80cd
6
+ metadata.gz: 251b7a98ea53230c50f2b3f77e602b5456b4a60b59a73c41e511b498d25b72c50a632cbadce1d887644c08ae32c90a30e36fb0ea51cffb437e0c3037a857ae7d
7
+ data.tar.gz: ba4872b5ef00a2fec12e9a2ebb662f3024e1411f529bc467fdd6d8c67a54382fb99c72e800c7cb07671eee165e00f6e231d1e600e9dfb91c59b175d3e48989d3
@@ -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
- @@clone_count = 5
16
+ @@reflekt_clone_count = 5
23
17
 
24
18
  def initialize(*args)
25
19
 
@@ -33,12 +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
+
40
36
  # Save results.
41
- @@db.write()
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
+
42
49
  end
43
50
  end
44
51
 
@@ -58,7 +65,7 @@ module Reflekt
58
65
 
59
66
  def reflekt_fork()
60
67
 
61
- @@clone_count.times do |clone|
68
+ @@reflekt_clone_count.times do |clone|
62
69
  @reflekt_clones << self.clone
63
70
  end
64
71
 
@@ -100,8 +107,8 @@ module Reflekt
100
107
  end
101
108
 
102
109
  # Save reflection.
103
- @@db.get("#{class_name}.#{method_name}")
104
- .push(reflection)
110
+ @@reflekt_db.get("#{class_name}.#{method_name}")
111
+ .push(reflection)
105
112
 
106
113
  end
107
114
 
@@ -111,31 +118,33 @@ module Reflekt
111
118
  def self.prepended(base)
112
119
  base.singleton_class.prepend(Klass)
113
120
 
114
- @@setup ||= setup_klass
121
+ @@reflekt_setup ||= reflekt_setup_klass
115
122
  end
116
123
 
117
124
  # Setup Klass.
118
- def self.setup_klass()
125
+ def self.reflekt_setup_klass()
119
126
 
120
127
  # Receive configuration from host application.
121
128
  $ENV ||= {}
122
129
  $ENV[:reflekt] ||= $ENV[:reflekt] = {}
123
130
 
131
+ @@reflekt_path = File.dirname(File.realpath(__FILE__))
132
+
124
133
  # Create "reflections" directory in configured path.
125
134
  if $ENV[:reflekt][:output_path]
126
- dir_path = File.join($ENV[:reflekt][:output_path], 'reflections')
135
+ @@reflekt_output_path = File.join($ENV[:reflekt][:output_path], 'reflections')
127
136
  # Create "reflections" directory in current execution path.
128
137
  else
129
- dir_path = File.join(Dir.pwd, 'reflections')
138
+ @@reflekt_output_path = File.join(Dir.pwd, 'reflections')
130
139
  end
131
140
 
132
- unless Dir.exist? dir_path
133
- Dir.mkdir(dir_path)
141
+ unless Dir.exist? @@reflekt_output_path
142
+ Dir.mkdir(@@reflekt_output_path)
134
143
  end
135
144
 
136
145
  # Create database.
137
- @@db = Rowdb.new(dir_path + '/db.json')
138
- @@db.defaults({"reflections" => []})
146
+ @@reflekt_db = Rowdb.new(@@reflekt_output_path + '/db.json')
147
+ @@reflekt_db.defaults({ :reflekt => { :api_version => 1 }}).write()
139
148
 
140
149
  return true
141
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.3.1
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-21 00:00:00.000000000 Z
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: Reflective testing that's completely automated.
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: Reflective testing that's completely automated.
57
+ summary: Reflective testing.
57
58
  test_files: []