Module: Rubydora::FedoraUrlHelpers
- Included in:
- RestApiClient
- Defined in:
- lib/rubydora/fedora_url_helpers.rb
Constant Summary collapse
- API_DOCUMENTATION =
Fedora API documentation available at https://wiki.duraspace.org/display/FCR30/REST+API
'https://wiki.duraspace.org/display/FCR30/REST+API'
Instance Method Summary collapse
-
#datastream_content_url(pid, dsid = nil, options = nil) ⇒ String
URI.
-
#datastream_history_url(pid, dsid = nil, options = nil) ⇒ String
URI.
-
#datastream_url(pid, dsid = nil, options = nil) ⇒ String
Generate a base datastream REST API endpoint URI.
-
#dissemination_url(pid, sdef = nil, method = nil, options = nil) ⇒ String
Generate a base object dissemination REST API endpoint URI.
-
#export_object_url(pid, options = nil) ⇒ String
URI.
-
#find_objects_url(options = nil) ⇒ String
URI.
-
#new_object_relationship_url(pid, options = nil) ⇒ String
URI.
-
#next_pid_url(options = nil) ⇒ String
URI.
-
#object_relationship_url(pid, options = nil) ⇒ String
URI.
-
#object_url(pid, options = nil) ⇒ String
Generate a base object REST API endpoint URI.
-
#object_versions_url(pid, options = nil) ⇒ String
URI.
-
#object_xml_url(pid, options = nil) ⇒ String
URI.
-
#url_for(base, options = nil) ⇒ String
Generate a REST API compatible URI.
-
#validate_object_url(pid, options = nil) ⇒ String
URI.
Instance Method Details
#datastream_content_url(pid, dsid = nil, options = nil) ⇒ String
Returns URI.
60 61 62 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 60 def datastream_content_url pid, dsid = nil, = nil url_for(datastream_url(pid, dsid) + "/content", ) end |
#datastream_history_url(pid, dsid = nil, options = nil) ⇒ String
Returns URI.
68 69 70 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 68 def datastream_history_url pid, dsid = nil, = nil url_for(datastream_url(pid, dsid) + "/history", ) end |
#datastream_url(pid, dsid = nil, options = nil) ⇒ String
Generate a base datastream REST API endpoint URI
51 52 53 54 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 51 def datastream_url pid, dsid = nil, = nil raise "" unless pid url_for(object_url(pid) + "/datastreams" + (("/#{CGI::escape(dsid)}" if dsid) || ''), ) end |
#dissemination_url(pid, sdef = nil, method = nil, options = nil) ⇒ String
Generate a base object dissemination REST API endpoint URI
41 42 43 44 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 41 def dissemination_url pid, sdef = nil, method = nil, = nil raise "" unless pid url_for(object_url(pid) + "/methods" + (("/#{CGI::escape(sdef)}" if sdef) || '') + (("/#{CGI::escape(method)}" if method) || ''), ) end |
#export_object_url(pid, options = nil) ⇒ String
Returns URI.
82 83 84 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 82 def export_object_url pid, = nil url_for(object_url(pid) + "/export", ) end |
#find_objects_url(options = nil) ⇒ String
Returns URI.
31 32 33 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 31 def find_objects_url = nil url_for("objects", ) end |
#new_object_relationship_url(pid, options = nil) ⇒ String
Returns URI.
110 111 112 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 110 def new_object_relationship_url pid, = nil url_for(object_relationship_url(pid) + "/new", ) end |
#next_pid_url(options = nil) ⇒ String
Returns URI.
25 26 27 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 25 def next_pid_url = nil url_for("objects/nextPID", ) end |
#object_relationship_url(pid, options = nil) ⇒ String
Returns URI.
103 104 105 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 103 def object_relationship_url pid, = nil url_for(object_url(pid) + "/relationships", ) end |
#object_url(pid, options = nil) ⇒ String
Generate a base object REST API endpoint URI
19 20 21 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 19 def object_url pid, = nil url_for("objects" + (("/#{CGI::escape(pid.to_s.gsub('info:fedora/', ''))}" if pid) || ''), ) end |
#object_versions_url(pid, options = nil) ⇒ String
Returns URI.
89 90 91 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 89 def object_versions_url pid, = nil url_for(object_url(pid) + "/versions", ) end |
#object_xml_url(pid, options = nil) ⇒ String
Returns URI.
96 97 98 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 96 def object_xml_url pid, = nil url_for(object_url(pid) + "/objectXML", ) end |
#url_for(base, options = nil) ⇒ String
Generate a REST API compatible URI
10 11 12 13 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 10 def url_for base, = nil return base unless .is_a? Hash "#{base}" + (("?#{.map { |key, value| "#{CGI::escape(key.to_s)}=#{CGI::escape(value.to_s)}"}.join("&") }" if and not .empty?) || '') end |
#validate_object_url(pid, options = nil) ⇒ String
Returns URI.
75 76 77 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 75 def validate_object_url pid, = nil url_for(object_url(pid) + "/validate", ) end |