Class: FtrRuby::TestInfra
- Inherits:
-
Object
- Object
- FtrRuby::TestInfra
- Defined in:
- lib/test_infrastructure.rb
Instance Attribute Summary collapse
-
#basepath ⇒ Object
Returns the value of attribute basepath.
-
#test_host ⇒ Object
Returns the value of attribute test_host.
-
#test_protocol ⇒ Object
Returns the value of attribute test_protocol.
Instance Method Summary collapse
-
#get_tests_metrics(tests:) ⇒ Object
there is a need to map between a test and its registered Metric in FS.
-
#initialize(test_host:, basepath:, test_protocol:) ⇒ TestInfra
constructor
A new instance of TestInfra.
Constructor Details
#initialize(test_host:, basepath:, test_protocol:) ⇒ TestInfra
Returns a new instance of TestInfra.
5 6 7 8 9 |
# File 'lib/test_infrastructure.rb', line 5 def initialize(test_host:, basepath:, test_protocol:) @test_host = test_host @test_protocol = test_protocol @basepath = basepath end |
Instance Attribute Details
#basepath ⇒ Object
Returns the value of attribute basepath.
3 4 5 |
# File 'lib/test_infrastructure.rb', line 3 def basepath @basepath end |
#test_host ⇒ Object
Returns the value of attribute test_host.
3 4 5 |
# File 'lib/test_infrastructure.rb', line 3 def test_host @test_host end |
#test_protocol ⇒ Object
Returns the value of attribute test_protocol.
3 4 5 |
# File 'lib/test_infrastructure.rb', line 3 def test_protocol @test_protocol end |
Instance Method Details
#get_tests_metrics(tests:) ⇒ Object
there is a need to map between a test and its registered Metric in FS. This will return the label for the test in principle, we cojuld return a more complex object, but all I need now is the label
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/test_infrastructure.rb', line 13 def get_tests_metrics(tests:) labels = {} landingpages = {} tests.each do |testid| warn "getting dcat for #{testid} #{test_protocol}://#{test_host}/#{basepath}/#{testid}" dcat = RestClient::Request.execute({ method: :get, url: "#{test_protocol}://#{test_host}/#{basepath}/#{testid}", headers: { "Accept" => "application/json" } }).body parseddcat = JSON.parse(dcat) # this next line should probably be done with SPARQL # # TODO TODO TODO jpath = JsonPath.new('[0]["http://semanticscience.org/resource/SIO_000233"][0]["@id"]') # is implementation of metricurl = jpath.on(parseddcat).first begin g = RDF::Graph.load(metricurl, format: :turtle) rescue StandardError => e warn "DCAT Metric loading failed #{e.inspect}" g = RDF::Graph.new end title = g.query([nil, RDF::Vocab::DC.title, nil])&.first&.object&.to_s lp = g.query([nil, RDF::Vocab::DCAT.landingPage, nil])&.first&.object&.to_s labels[testid] = if title != "" title else "Metric label not available" end landingpages[testid] = if lp != "" lp else "" end end [labels, landingpages] end |