Module: Lutaml::Xml::Schema::Xsd::Glob

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

Instance Method Summary collapse

Instance Method Details

#http_get(url) ⇒ Object



48
49
50
# File 'lib/lutaml/xml/schema/xsd/glob.rb', line 48

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

#include_schema(schema_location) ⇒ Object



52
53
54
55
56
# File 'lib/lutaml/xml/schema/xsd/glob.rb', line 52

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

  schema_path.include_schema(schema_location)
end

#locationObject



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

def location
  @location
end

#location?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/lutaml/xml/schema/xsd/glob.rb', line 44

def location?
  url? || path?
end

#location_for(schema_location) ⇒ Object



58
59
60
61
62
# File 'lib/lutaml/xml/schema/xsd/glob.rb', line 58

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

  schema_path.location_for(schema_location)
end

#path?Boolean

Returns:

  • (Boolean)


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

def path?
  !@path.nil?
end

#path_or_url(location) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/lutaml/xml/schema/xsd/glob.rb', line 22

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

  @schema_path = SchemaPath.new(location,
                                schema_mappings: schema_mappings)
  @location = location
  @url = @schema_path.url&.to_s
  @path = @schema_path.path
end

#resolve_schema_location(schema_location) ⇒ Object



68
69
70
# File 'lib/lutaml/xml/schema/xsd/glob.rb', line 68

def resolve_schema_location(schema_location)
  schema_path.resolve_schema_location(schema_location)
end

#schema_location_path(schema_location) ⇒ Object



64
65
66
# File 'lib/lutaml/xml/schema/xsd/glob.rb', line 64

def schema_location_path(schema_location)
  schema_path.schema_location_path(schema_location)
end

#schema_mappingsObject



12
13
14
# File 'lib/lutaml/xml/schema/xsd/glob.rb', line 12

def schema_mappings
  @schema_mappings ||= []
end

#schema_mappings=(mappings) ⇒ Object



16
17
18
19
20
# File 'lib/lutaml/xml/schema/xsd/glob.rb', line 16

def schema_mappings=(mappings)
  @schema_mappings = mappings || []
  @schema_path = SchemaPath.new(location,
                                schema_mappings: @schema_mappings)
end

#url?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/lutaml/xml/schema/xsd/glob.rb', line 40

def url?
  !@url.nil?
end

#with_location(location) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/lutaml/xml/schema/xsd/glob.rb', line 72

def with_location(location)
  snapshot = {
    location: @location,
    path: @path,
    url: @url,
    schema_path: @schema_path,
  }
  path_or_url(location)
  yield
ensure
  @location = snapshot[:location]
  @path = snapshot[:path]
  @url = snapshot[:url]
  @schema_path = snapshot[:schema_path]
end