Module: Lutaml::Xsd::Glob

Extended by:
Glob
Included in:
Glob
Defined in:
lib/lutaml/xsd/glob.rb

Instance Method Summary collapse

Instance Method Details

#http_get(url) ⇒ Object



36
37
38
# File 'lib/lutaml/xsd/glob.rb', line 36

def http_get(url)
  Net::HTTP.get(URI.parse(url))
end

#include_schema(schema_location) ⇒ Object



40
41
42
43
44
45
# File 'lib/lutaml/xsd/glob.rb', line 40

def include_schema(schema_location)
  return unless location? && schema_location

  schema_path = schema_location_path(schema_location)
  url? ? http_get(schema_path) : File.read(schema_path)
end

#locationObject



20
21
22
# File 'lib/lutaml/xsd/glob.rb', line 20

def location
  @location
end

#location?Boolean



32
33
34
# File 'lib/lutaml/xsd/glob.rb', line 32

def location?
  url? || path?
end

#path?Boolean



24
25
26
# File 'lib/lutaml/xsd/glob.rb', line 24

def path?
  !@path.nil?
end

#path_or_url(location) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/lutaml/xsd/glob.rb', line 10

def path_or_url(location)
  return nullify_location if location.nil?

  @location = location
  @url = location if location.start_with?(%r{http\w?:/{2}[^.]+})
  @path = File.expand_path(location) unless @url
rescue Errno::ENOENT
  raise Error, "Invalid location: #{location}"
end

#url?Boolean



28
29
30
# File 'lib/lutaml/xsd/glob.rb', line 28

def url?
  !@url.nil?
end