Class: Hocon::Impl::Parseable::ParseableResources
Overview
NOTE: this is not a faithful port of the ParseableResources class from the
upstream, because at least for now we're not going to try to do anything
crazy like look for files on the ruby load path. However, there is a decent
chunk of logic elsewhere in the codebase that is written with the assumption
that this class will provide the 'last resort' attempt to find a config file
before giving up, so we're basically port just enough to have it provide
that last resort behavior
Constant Summary
MAX_INCLUDE_DEPTH
Class Method Summary
collapse
Instance Method Summary
collapse
#content_type, #custom_reader, #fixup_options, force_parsed_to_object, #include_context, new_file, new_not_found, new_resources, new_string, #options, #origin, #parse, #parse_config_document, #parse_document, #parse_document_from_origin, parse_stack, #parse_value, #parse_value_from_origin, #post_construct, #raw_parse_document, #raw_parse_document_from_io, #raw_parse_value_from_io, relative_to, syntax_from_extension, trace
#options, #origin, #parse
Constructor Details
Returns a new instance of ParseableResources.
481
482
483
484
485
|
# File 'lib/hocon/impl/parseable.rb', line 481
def initialize(resource, options)
super()
@resource = resource
post_construct(options)
end
|
Class Method Details
.parent(resource) ⇒ Object
503
504
505
506
507
508
509
510
511
512
513
514
|
# File 'lib/hocon/impl/parseable.rb', line 503
def self.parent(resource)
i = resource.rindex("/")
if i < 0
nil
else
resource.slice(0..i)
end
end
|
Instance Method Details
#create_origin ⇒ Object
536
537
538
|
# File 'lib/hocon/impl/parseable.rb', line 536
def create_origin
Hocon::Impl::SimpleConfigOrigin.new_resource(@resource)
end
|
#guess_syntax ⇒ Object
499
500
501
|
# File 'lib/hocon/impl/parseable.rb', line 499
def guess_syntax
Hocon::Impl::Parseable.syntax_from_extension(@resource)
end
|
#raw_parse_value(origin, final_options) ⇒ Object
491
492
493
494
495
496
497
|
# File 'lib/hocon/impl/parseable.rb', line 491
def raw_parse_value(origin, final_options)
raise IOError, "resource not found: #{@resource}"
end
|
#reader ⇒ Object
487
488
489
|
# File 'lib/hocon/impl/parseable.rb', line 487
def reader
raise Hocon::ConfigError::ConfigBugOrBrokenError, "reader() should not be called on resources"
end
|
#relative_to(sibling) ⇒ Object
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
|
# File 'lib/hocon/impl/parseable.rb', line 516
def relative_to(sibling)
if sibling.start_with?("/")
Hocon::Impl::Parseable.new_resources(sibling.slice(1), options.set_origin_description(nil))
else
parent = self.class.parent(@resource)
if parent.nil?
Hocon::Impl::Parseable.new_resources(sibling, options.set_origin_description(nil))
else
Hocon::Impl::Parseable.new_resources("#{parent}/sibling", options.set_origin_description(nil))
end
end
end
|
#to_s ⇒ Object
540
541
542
|
# File 'lib/hocon/impl/parseable.rb', line 540
def to_s
"#{self.class.name.split('::').last}(#{@resource})"
end
|