trevl 0.1.0 → 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/README.md +2 -2
- data/lib/trevl/renderer/transform.rb +5 -1
- data/lib/trevl/renderer.rb +7 -2
- data/lib/trevl/version.rb +1 -1
- 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: eec93861d586409e4fd6cd6c02dff9a6e06ab68c92b34a899eca5b5f6c6be4c7
|
|
4
|
+
data.tar.gz: 3dff7f729d56d1807f7bdf1c1f3bfc459f9c52b2226bf15edb6c40e3d9537ca0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0c1f5e72fd29d9c26825008279f30a01d9e45910b63044072fd61275e90f1f572e167c6344bfb2dfb75c299ef5cc4a69390ff8d3f56ea9c6e1373eb9774e1b59
|
|
7
|
+
data.tar.gz: f284d99524a6a8be3abe5b4644071eb1fd8cdbab8c7f5cf20d27039f77a2984fa3b93ba26249bdc8b1232c72393c690e73e3e25e6e7c3c110ac9820b82a2acc3
|
data/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<img src="assets/trendence-logo.svg" alt="Trendence" width="140" />
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
|
-
<h3 align="center">Write YAML, get Highcharts.</h3>
|
|
7
|
+
<h3 align="center">Write YAML, get Highcharts. Efficient assembly of dashboards on well-grounded rails.</h3>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<a href="https://trevl.trendence.com">DSL Documentation</a> ·
|
|
@@ -63,7 +63,7 @@ Trevl.render(yaml)
|
|
|
63
63
|
## Installation
|
|
64
64
|
|
|
65
65
|
```ruby
|
|
66
|
-
gem "trevl"
|
|
66
|
+
gem "trevl"
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
**Prerequisites:** Ruby >= 3.1, Node.js (`brew install node`) for computed fields.
|
|
@@ -33,7 +33,10 @@ module Trevl
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# Applies postprocess JavaScript to the full dataset.
|
|
36
|
-
|
|
36
|
+
# `raw_results`, when given, collects what the JavaScript actually
|
|
37
|
+
# returned per ref key, including a non-Array that gets discarded below.
|
|
38
|
+
# That is what tooling needs to explain a postprocess that did nothing.
|
|
39
|
+
def apply_postprocess(rows_by_ref_key, component, warnings, raw_results: nil)
|
|
37
40
|
code = component["postprocess"]
|
|
38
41
|
return rows_by_ref_key unless code.is_a?(String) && !code.strip.empty?
|
|
39
42
|
|
|
@@ -41,6 +44,7 @@ module Trevl
|
|
|
41
44
|
js = "(function() { var $result = #{rows.to_json}; #{code.strip.chomp(";")}; return $result; })()"
|
|
42
45
|
begin
|
|
43
46
|
result = ExecJS.eval(js)
|
|
47
|
+
raw_results[rk] = result if raw_results
|
|
44
48
|
if result.is_a?(Array)
|
|
45
49
|
rows_by_ref_key[rk] = result
|
|
46
50
|
else
|
data/lib/trevl/renderer.rb
CHANGED
|
@@ -6,7 +6,8 @@ require_relative "renderer/transform"
|
|
|
6
6
|
|
|
7
7
|
module Trevl
|
|
8
8
|
class Renderer
|
|
9
|
-
attr_reader :component, :query_params, :data_sources, :inline_source, :raw_data, :warnings
|
|
9
|
+
attr_reader :component, :query_params, :data_sources, :inline_source, :raw_data, :warnings,
|
|
10
|
+
:postprocess_rows, :postprocess_raw_results
|
|
10
11
|
|
|
11
12
|
def initialize(component_hash, query_params = {}, data_sources: {}, data: nil)
|
|
12
13
|
@component = component_hash
|
|
@@ -92,7 +93,11 @@ module Trevl
|
|
|
92
93
|
counts_before = rows_by_ref_key.transform_values(&:length)
|
|
93
94
|
|
|
94
95
|
rows_by_ref_key = @transform.apply_computed_fields(rows_by_ref_key, payload_by_ref_key, component)
|
|
95
|
-
|
|
96
|
+
|
|
97
|
+
raw_results = {}
|
|
98
|
+
rows_by_ref_key = @transform.apply_postprocess(rows_by_ref_key, component, @warnings, raw_results: raw_results)
|
|
99
|
+
@postprocess_raw_results = raw_results unless raw_results.empty?
|
|
100
|
+
@postprocess_rows = CoreExt::Hash.deep_dup(rows_by_ref_key)
|
|
96
101
|
|
|
97
102
|
rows_by_ref_key.each do |key, rows|
|
|
98
103
|
warn_postprocess_emptied(key, counts_before[key]) if rows.empty? && counts_before[key].to_i > 0
|
data/lib/trevl/version.rb
CHANGED