40c5626383ebd5e8cf11a636f864023a2aafcd6bDaniel Couto Valerequire 'date'
40c5626383ebd5e8cf11a636f864023a2aafcd6bDaniel Couto Vale
58721b9d3a8cd6a624269ddf507f80af4417c9bdhenning muellermodule Hets
7bde6e1907fc17b0083a6bcfad10bb74be6e4bcdTim Reddehase include Errors
58721b9d3a8cd6a624269ddf507f80af4417c9bdhenning mueller
435547b6b5df0f76cd04b09532341b07d0defeb1Tim Reddehase def self.minimal_version_string
d73e4334f0cc1103049795c5ce7910c54ab1bfc4Eugen Kuksa "v#{minimum_version}, #{minimum_revision}"
2977875e15fdb6d84be990579c61cda0b6cbb5d0Tim Reddehase end
2977875e15fdb6d84be990579c61cda0b6cbb5d0Tim Reddehase
2977875e15fdb6d84be990579c61cda0b6cbb5d0Tim Reddehase def self.minimum_revision
d73e4334f0cc1103049795c5ce7910c54ab1bfc4Eugen Kuksa Settings.hets.version_minimum_revision
2977875e15fdb6d84be990579c61cda0b6cbb5d0Tim Reddehase end
2977875e15fdb6d84be990579c61cda0b6cbb5d0Tim Reddehase
2977875e15fdb6d84be990579c61cda0b6cbb5d0Tim Reddehase def self.minimum_version
d73e4334f0cc1103049795c5ce7910c54ab1bfc4Eugen Kuksa Settings.hets.version_minimum_version
435547b6b5df0f76cd04b09532341b07d0defeb1Tim Reddehase end
435547b6b5df0f76cd04b09532341b07d0defeb1Tim Reddehase
609a4ff9a0e4cb89a9f529703c81554fe9c34ff6Tim Reddehase def self.qualified_loc_id_for(resource)
193be661f0cdd5e3c0faef2dba6b580c0b734394Tim Reddehase locid = URI.escape(resource.versioned_locid)
cb1256dca3f095718f35c41530a136823dac0774Eugen Kuksa "#{Hostname.url_authority}#{locid}"
609a4ff9a0e4cb89a9f529703c81554fe9c34ff6Tim Reddehase end
609a4ff9a0e4cb89a9f529703c81554fe9c34ff6Tim Reddehase
2f305d7bc01ae84f6b219b562fe4d31392abc1d6Eugen Kuksa def self.parse_via_api(resource, hets_options, structure_only: false)
3856b7bdf70cec553e0ca01ca823c7fc555a06f0Tim Reddehase mode = structure_only ? :fast_run : :default
de26ab920893b505e7914784774de5eb506f60a0Eugen Kuksa HetsInstance.with_instance! do |hets_instance|
de26ab920893b505e7914784774de5eb506f60a0Eugen Kuksa parse_caller = Hets::ParseCaller.new(hets_instance, hets_options)
de26ab920893b505e7914784774de5eb506f60a0Eugen Kuksa parse_caller.call(qualified_loc_id_for(resource), with_mode: mode)
de26ab920893b505e7914784774de5eb506f60a0Eugen Kuksa end
3856b7bdf70cec553e0ca01ca823c7fc555a06f0Tim Reddehase end
3856b7bdf70cec553e0ca01ca823c7fc555a06f0Tim Reddehase
61c65b3e1c87587d1ed5a15220d41a166a5d66d6Eugen Kuksa def self.prove_via_api(resource, prove_options)
de26ab920893b505e7914784774de5eb506f60a0Eugen Kuksa HetsInstance.with_instance! do |hets_instance|
de26ab920893b505e7914784774de5eb506f60a0Eugen Kuksa prove_caller = Hets::ProveCaller.new(hets_instance, prove_options)
de26ab920893b505e7914784774de5eb506f60a0Eugen Kuksa prove_caller.call(qualified_loc_id_for(resource))
de26ab920893b505e7914784774de5eb506f60a0Eugen Kuksa end
11c250a983905f4db9081f934d1efbc25fd0fb65Eugen Kuksa end
11c250a983905f4db9081f934d1efbc25fd0fb65Eugen Kuksa
fb2c319c7cce96c35e06be8fe6f60da7d040c952Eugen Kuksa def self.provers_via_api(resource, provers_options)
de26ab920893b505e7914784774de5eb506f60a0Eugen Kuksa HetsInstance.with_instance! do |hets_instance|
de26ab920893b505e7914784774de5eb506f60a0Eugen Kuksa provers_caller = Hets::ProversCaller.new(hets_instance, provers_options)
de26ab920893b505e7914784774de5eb506f60a0Eugen Kuksa provers_caller.call(qualified_loc_id_for(resource))
de26ab920893b505e7914784774de5eb506f60a0Eugen Kuksa end
fb2c319c7cce96c35e06be8fe6f60da7d040c952Eugen Kuksa end
fb2c319c7cce96c35e06be8fe6f60da7d040c952Eugen Kuksa
a8ab4146c3238374bdd13a36b12d665cde57e078Tim Reddehase def self.filetype(resource)
609a4ff9a0e4cb89a9f529703c81554fe9c34ff6Tim Reddehase iri = qualified_loc_id_for(resource)
de26ab920893b505e7914784774de5eb506f60a0Eugen Kuksa HetsInstance.with_instance! do |hets_instance|
de26ab920893b505e7914784774de5eb506f60a0Eugen Kuksa filetype_caller = Hets::FiletypeCaller.new(hets_instance)
de26ab920893b505e7914784774de5eb506f60a0Eugen Kuksa response_iri, filetype = filetype_caller.call(iri).split(': ')
de26ab920893b505e7914784774de5eb506f60a0Eugen Kuksa end
a8ab4146c3238374bdd13a36b12d665cde57e078Tim Reddehase if response_iri == iri
a8ab4146c3238374bdd13a36b12d665cde57e078Tim Reddehase Mime::Type.lookup(filetype)
a8ab4146c3238374bdd13a36b12d665cde57e078Tim Reddehase else
a8ab4146c3238374bdd13a36b12d665cde57e078Tim Reddehase raise FiletypeNotDeterminedError.new("#{response_iri}: #{filetype}")
a8ab4146c3238374bdd13a36b12d665cde57e078Tim Reddehase end
a8ab4146c3238374bdd13a36b12d665cde57e078Tim Reddehase end
58721b9d3a8cd6a624269ddf507f80af4417c9bdhenning muellerend