Module: MetzScan::ProjectIndex::RubydexBackend::LocationFormatting
- Included in:
- MetzScan::ProjectIndex::RubydexBackend
- Defined in:
- lib/metz_scan/project_index/rubydex_backend/location_formatting.rb
Instance Method Summary collapse
- #path_from_file_location(location) ⇒ Object
- #path_from_location(location) ⇒ Object
- #path_from_uri(uri) ⇒ Object
- #path_from_uri_location(location) ⇒ Object
Instance Method Details
#path_from_file_location(location) ⇒ Object
15 16 17 18 19 |
# File 'lib/metz_scan/project_index/rubydex_backend/location_formatting.rb', line 15 def path_from_file_location(location) location.to_file_path if location.respond_to?(:to_file_path) rescue StandardError nil end |
#path_from_location(location) ⇒ Object
9 10 11 12 13 |
# File 'lib/metz_scan/project_index/rubydex_backend/location_formatting.rb', line 9 def path_from_location(location) return unless location path_from_file_location(location) || path_from_uri_location(location) || location.to_s end |
#path_from_uri(uri) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/metz_scan/project_index/rubydex_backend/location_formatting.rb', line 25 def path_from_uri(uri) string = uri.to_s return URI(string).path if string.start_with?("file:") string rescue URI::InvalidURIError string end |
#path_from_uri_location(location) ⇒ Object
21 22 23 |
# File 'lib/metz_scan/project_index/rubydex_backend/location_formatting.rb', line 21 def path_from_uri_location(location) path_from_uri(location.uri) if location.respond_to?(:uri) end |