ftr_ruby 0.1.10 → 0.1.11
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/CHANGELOG.md +10 -0
- data/lib/ftr_ruby/version.rb +1 -1
- data/lib/test_infrastructure.rb +48 -35
- 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: be4cb2cd61574feb95c0359b6d3c1534ae2bd13090c9cc77c874e7efeda209f2
|
|
4
|
+
data.tar.gz: 1b20953f8acffa00d4ef3b6af4658a5eb05e657728f3c55bdf7230311ecccd9d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '0983e92af3a5199f1ba54a9023edb50bacbde94cb46805ae1c913a9110beabdc2c9da6d2a2968677b506f2cde1c7c41171f9143b1689fa3222c4b43f70f6d932'
|
|
7
|
+
data.tar.gz: 3f2853d3956422992ca5d640c92113b34eb0336633724e039f2f70689d79758a32f5e46e7841ee6ee7ba12e14b6f74ebcb9ce34ed08f7687fee1b14ff75e07a5
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.1.11] - 2026-05-26
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
- `TestInfra#get_tests_metrics` now fetches all test metrics in parallel using Ruby threads, significantly reducing latency when querying 40+ tests
|
|
7
|
+
- Refactored `TestInfra` internals into focused private helpers (`fetch_metric`, `fetch_metric_url`, `load_metric_graph`, `query_metric_graph`)
|
|
8
|
+
- `test_infrastructure.rb` now explicitly requires `jsonpath` rather than relying on transitive loading
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- RSpec tests for `TestInfra#get_tests_metrics` and `#fetch_metric_url` covering happy path, missing metadata, RDF load failures, and empty input
|
|
12
|
+
|
|
3
13
|
## [0.1.0] - 2026-03-28
|
|
4
14
|
|
|
5
15
|
- Initial release
|
data/lib/ftr_ruby/version.rb
CHANGED
data/lib/test_infrastructure.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require "jsonpath"
|
|
2
|
+
|
|
1
3
|
module FtrRuby
|
|
2
4
|
class TestInfra
|
|
3
5
|
attr_accessor :test_protocol, :test_host, :basepath
|
|
@@ -8,46 +10,57 @@ module FtrRuby
|
|
|
8
10
|
@basepath = basepath
|
|
9
11
|
end
|
|
10
12
|
|
|
11
|
-
# there is a need to map between a test and its registered Metric in FS.
|
|
12
|
-
#
|
|
13
|
+
# there is a need to map between a test and its registered Metric in FS.
|
|
14
|
+
# This will return the label for the test
|
|
15
|
+
# in principle, we cojuld return a more complex object,
|
|
16
|
+
# but all I need now is the label
|
|
13
17
|
def get_tests_metrics(tests:)
|
|
18
|
+
threads = tests.map { |testid| Thread.new(testid) { |tid| fetch_metric(tid) } }
|
|
19
|
+
|
|
14
20
|
labels = {}
|
|
15
21
|
landingpages = {}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
url: "#{test_protocol}://#{test_host}/#{basepath}/#{testid}",
|
|
21
|
-
headers: { "Accept" => "application/json" }
|
|
22
|
-
}).body
|
|
23
|
-
parseddcat = JSON.parse(dcat)
|
|
24
|
-
# this next line should probably be done with SPARQL
|
|
25
|
-
# # TODO TODO TODO
|
|
26
|
-
jpath = JsonPath.new('[0]["http://semanticscience.org/resource/SIO_000233"][0]["@id"]') # is implementation of
|
|
27
|
-
metricurl = jpath.on(parseddcat).first
|
|
28
|
-
|
|
29
|
-
begin
|
|
30
|
-
g = RDF::Graph.load(metricurl, format: :turtle)
|
|
31
|
-
rescue StandardError => e
|
|
32
|
-
warn "DCAT Metric loading failed #{e.inspect}"
|
|
33
|
-
g = RDF::Graph.new
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
title = g.query([nil, RDF::Vocab::DC.title, nil])&.first&.object&.to_s
|
|
37
|
-
lp = g.query([nil, RDF::Vocab::DCAT.landingPage, nil])&.first&.object&.to_s
|
|
38
|
-
|
|
39
|
-
labels[testid] = if title != ""
|
|
40
|
-
title
|
|
41
|
-
else
|
|
42
|
-
"Metric label not available"
|
|
43
|
-
end
|
|
44
|
-
landingpages[testid] = if lp != ""
|
|
45
|
-
lp
|
|
46
|
-
else
|
|
47
|
-
""
|
|
48
|
-
end
|
|
22
|
+
threads.each do |t|
|
|
23
|
+
tid, label, lpage = t.value
|
|
24
|
+
labels[tid] = label
|
|
25
|
+
landingpages[tid] = lpage
|
|
49
26
|
end
|
|
50
27
|
[labels, landingpages]
|
|
51
28
|
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def fetch_metric(testid)
|
|
33
|
+
metricurl = fetch_metric_url(testid)
|
|
34
|
+
g = load_metric_graph(metricurl)
|
|
35
|
+
title, lp = query_metric_graph(g)
|
|
36
|
+
label = title.to_s != "" ? title : "Metric label not available"
|
|
37
|
+
[testid, label, lp.to_s]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def fetch_metric_url(testid)
|
|
41
|
+
warn "getting dcat for #{testid} #{test_protocol}://#{test_host}/#{basepath}/#{testid}"
|
|
42
|
+
dcat = RestClient::Request.execute({
|
|
43
|
+
method: :get,
|
|
44
|
+
url: "#{test_protocol}://#{test_host}/#{basepath}/#{testid}",
|
|
45
|
+
headers: { "Accept" => "application/json" }
|
|
46
|
+
}).body
|
|
47
|
+
parseddcat = JSON.parse(dcat)
|
|
48
|
+
# TODO: this should probably be done with SPARQL
|
|
49
|
+
jpath = JsonPath.new('[0]["http://semanticscience.org/resource/SIO_000233"][0]["@id"]') # is implementation of
|
|
50
|
+
jpath.on(parseddcat).first
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def load_metric_graph(metricurl)
|
|
54
|
+
RDF::Graph.load(metricurl, format: :turtle)
|
|
55
|
+
rescue StandardError => e
|
|
56
|
+
warn "DCAT Metric loading failed #{e.inspect}"
|
|
57
|
+
RDF::Graph.new
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def query_metric_graph(graph)
|
|
61
|
+
title = graph.query([nil, RDF::Vocab::DC.title, nil])&.first&.object&.to_s
|
|
62
|
+
lp = graph.query([nil, RDF::Vocab::DCAT.landingPage, nil])&.first&.object&.to_s
|
|
63
|
+
[title, lp]
|
|
64
|
+
end
|
|
52
65
|
end
|
|
53
66
|
end
|