circleci
72 of 72 new or added lines in 3 files covered. (100.0%)
180 of 796 relevant lines covered (22.61%)
0.23 hits per line
1 |
# frozen_string_literal: true
|
|
2 |
class DublinCore |
× |
3 |
def initialize(json) |
× |
4 |
@json = json
|
× |
5 |
end
|
× |
6 |
|
|
7 |
def attributes |
× |
8 |
@attributes ||= json_object
|
× |
9 |
end
|
× |
10 |
|
|
11 |
def to_json(options = nil) |
× |
12 |
attributes.to_h.to_json(options) |
× |
13 |
end
|
× |
14 |
|
|
15 |
delegate :[], :[]=, to: :attributes |
× |
16 |
delegate( |
× |
17 |
:title,
|
× |
18 |
:creator,
|
× |
19 |
:subject,
|
× |
20 |
:date,
|
× |
21 |
:identifier,
|
× |
22 |
:language,
|
× |
23 |
:relation,
|
× |
24 |
:publisher,
|
× |
25 |
to: :attributes |
× |
26 |
) |
× |
27 |
|
|
28 |
private |
× |
29 |
|
|
30 |
def json_object |
× |
31 |
return {} if @json.nil? |
× |
32 |
|
|
33 |
parsed = JSON.parse(@json) |
× |
34 |
OpenStruct.new(parsed)
|
× |
35 |
end
|
× |
36 |
end
|
× |