Skip to content

Commit fc23c4a

Browse files
committed
Fix(Spectrum,Controller): Bug Fix
- Bad Class object reference - Add real uptime field in detail api response - Generated json Signed-off-by: duangsuse <fedora-opensuse@outlook.com>
1 parent ab5276f commit fc23c4a

File tree

3 files changed

+1445
-6
lines changed

3 files changed

+1445
-6
lines changed

spectrum.rb

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -356,21 +356,30 @@ def ClientShowcase.from_file(path = Dir.glob('*.geekspec').first)
356356
end
357357

358358
def ClientShowcase.map_response(spec, resp)
359-
if (r = spec.return).is_a? ReturnTypeAndObject
359+
if (r = spec.return).is_a? Spectrum::Interface::ReturnTypeAndObject
360360
json = JSON.parse(resp.body)
361361
mapper = "map_resp_#{r.name}"
362362
if ClientShowcase.respond_to?(mapper)
363363
case r.type
364-
when 'object' then return ClientShowcase.send(mapper, json)
365-
when 'array' then return json.map { |it| ClientShowcase.send(mapper, it) }
364+
when 'object' then return ClientShowcase.send(mapper, json, resp)
365+
when 'array' then return json.map { |it| ClientShowcase.send(mapper, it, resp) }
366366
end
367367
end
368368
return json
369-
elsif spec.return.is_a? ReturnTypesAndNames
370-
return JSON.parse(resp.body)
369+
elsif spec.return.is_a? Spectrum::Interface::ReturnTypesAndNames
370+
return JSON.parse(resp.body) # plain map
371371
end
372372

373-
resp
373+
mapper = "map_resp_text_#{spec.return}"
374+
if ClientShowcase.respond_to?(mapper) then ClientShowcase.send(mapper, resp.body, resp) else resp.body end
375+
end
376+
377+
def ClientShowcase.map_resp_text_datetime(body, _)
378+
if body.match(/[0-9]+/)
379+
Time.at(0, body.to_i, :millisecond)
380+
else
381+
Time.new(body)
382+
end
374383
end
375384

376385
def ClientShowcase.setup_auth(req, auth)

0 commit comments

Comments
 (0)