Cross Reference: importer.rb
xref
: /
ontohub
/
lib
/
hets
/
provers
/
importer.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
importer.rb revision f34f85a43d1d3c992613379420c3f5749ab02cae
45
N/A
module
Hets
45
N/A
module
Provers
45
N/A
class
Importer
45
N/A
ALLOWED_KEYS
= %w
(
identifier
name
)
45
N/A
attr_accessor
:
ontology_version
, :
io
45
N/A
45
N/A
# io needs to be an instance of IO or a Tempfile.
45
N/A
def
initialize
(
ontology_version
,
io
)
45
N/A
self.ontology
_version
=
ontology_version
45
N/A
self.io
=
io
45
N/A
end
45
N/A
45
N/A
def
import
45
N/A
hash
=
JSON.parse
(
io.read
)
45
N/A
provers
=
hash
[
'provers'
]
45
N/A
provers.each
do
|
prover_hash
|
45
N/A
prover_hash.select
!
{ |k,
_v
|
ALLOWED_KEYS.include
?
(k)
}
45
N/A
prover
=
Prover.where
(
name
:
prover_hash
[
'identifier'
])
.
45
N/A
first_or_create
!
(
display_name
:
prover_hash
[
'name'
])
45
N/A
unless
ontology_version.provers.include
?
(
prover
)
45
N/A
ontology_version.provers
<< prover
45
N/A
end
45
N/A
end
5340
N/A
ontology_version.save!
45
N/A
end
45
N/A
end
45
N/A
end
45
N/A
end
45
N/A