Class: YamlRefResolver
- Inherits:
-
Object
show all
- Defined in:
- lib/yaml_ref_resolver.rb,
lib/yaml_ref_resolver/cli.rb,
lib/yaml_ref_resolver/version.rb,
lib/yaml_ref_resolver/exceptions.rb
Defined Under Namespace
Classes: CLI, Ref, Yaml, YamlNotFoundException, YamlSyntaxErrorException
Constant Summary
collapse
- VERSION =
"0.5.0"
Instance Method Summary
collapse
Constructor Details
Returns a new instance of YamlRefResolver.
8
9
10
11
|
# File 'lib/yaml_ref_resolver.rb', line 8
def initialize(opts = {})
@key = opts[:key] || '$ref'
@map = {}
end
|
Instance Method Details
#files ⇒ Object
33
34
35
|
# File 'lib/yaml_ref_resolver.rb', line 33
def files
@map.keys
end
|
#reload!(path) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/yaml_ref_resolver.rb', line 20
def reload!(path)
return unless path
backup = @map.delete(path)
begin
preload!(path)
rescue => e
@map[path] = backup
raise e
end
end
|
#resolve!(path) ⇒ Object
13
14
15
16
17
18
|
# File 'lib/yaml_ref_resolver.rb', line 13
def resolve!(path)
entry_point = File.expand_path(path)
preload!(entry_point)
resolve_refs(@map[entry_point].content, entry_point)
end
|