-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
suleman-uzair
committed
Nov 22, 2024
1 parent
bce680f
commit 35d0ccd
Showing
8 changed files
with
113 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# frozen_string_literal: true | ||
|
||
module Lutaml | ||
module Xsd | ||
module Glob | ||
module_function | ||
|
||
def set_path_or_url(location) | ||
return nullify_path_and_url if location.nil? | ||
|
||
@location = location | ||
@url = location if location.start_with?(/http\w?:\/{2}[^.]+/) | ||
@path = File.expand_path(location) unless @url | ||
rescue => e | ||
raise Error, "Invalid location: #{location}" | ||
end | ||
|
||
def location | ||
@location | ||
end | ||
|
||
def path? | ||
!@path.nil? | ||
end | ||
|
||
def url? | ||
!@url.nil? | ||
end | ||
|
||
def location? | ||
url? || path? | ||
end | ||
|
||
def schema_location_path(schema_location) | ||
if schema_location.start_with?("/") || location.end_with?("/") | ||
location + schema_location | ||
else | ||
location + "/" + schema_location | ||
end | ||
end | ||
|
||
private | ||
|
||
def nullify_location | ||
@location = nil | ||
@path = nil | ||
@url = nil | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters