lib/ddr/utils.rb in ddr-models-1.13.2 vs lib/ddr/utils.rb in ddr-models-1.14.0

- old
+ new

@@ -25,18 +25,18 @@ def self.file_or_path? file file_path(file) rescue ArgumentError false end - + def self.file_path? file # length is a sanity check file.is_a?(String) && (file.length < 1024) && File.exists?(file) end def self.file_path file - if file.respond_to?(:path) + if file.respond_to?(:path) File.absolute_path(file.path) elsif file_path?(file) file else raise ArgumentError, "File argument is neither a File nor a path to an existing file." @@ -58,11 +58,11 @@ raise ArgumentError, "file_name argument must be a string" unless file_name.is_a?(String) raise ArgumentError, "file_name argument must not include path" if file_name.include?(File::SEPARATOR) file_name.gsub(/[^\w\.\-]/,"_") end - # Return file path for URI string + # Return file path for URI string # Should reverse .path_to_uri # "file:/path/to/file" => "/path/to/file" def self.path_from_uri(uri) URI.unescape(URI.parse(uri).path) end @@ -77,11 +77,11 @@ end def self.ds_as_of_date_time(ds) ds.create_date_string end - + # Find an object with a given identifier and return its PID. # Returns the PID if a single object is found. # Returns nil if no object is found. # Raises Ddr::Models::Error if more than one object is found. # Options can be provided to limit the scope of matching objects @@ -154,7 +154,7 @@ # nothing to do here except that we can't return the reflection object class end end return klass end - -end \ No newline at end of file + +end