Class: Hocon::Impl::Parseable::ParseableFile
Overview
NOTE: Skipping ‘ParseableURL` for now as we probably won’t support this right away
Constant Summary
MAX_INCLUDE_DEPTH
Instance Method Summary
collapse
#content_type, #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_value, #parse_value_from_origin, #post_construct, #raw_parse_document, #raw_parse_document_from_io, #raw_parse_value, #raw_parse_value_from_io, #reader, relative_to, syntax_from_extension, trace
#options, #origin, #parse
Constructor Details
#initialize(input, options) ⇒ ParseableFile
Returns a new instance of ParseableFile.
397
398
399
400
401
|
# File 'lib/hocon/impl/parseable.rb', line 397
def initialize(input, options)
super()
@input = input
post_construct(options)
end
|
Instance Method Details
#custom_reader ⇒ Object
403
404
405
406
407
408
409
410
|
# File 'lib/hocon/impl/parseable.rb', line 403
def custom_reader
if Hocon::Impl::ConfigImpl.trace_loads_enabled
self.class.trace("Loading config from a String: #{@input}")
end
self
end
|
#open ⇒ Object
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
|
# File 'lib/hocon/impl/parseable.rb', line 412
def open
begin
if block_given?
File.open(@input, :encoding => 'bom|utf-8') do |f|
yield f
end
else
File.open(@input, :encoding => 'bom|utf-8')
end
rescue Errno::ENOENT
if @initial_options.allow_missing?
return Hocon::Impl::SimpleConfigObject.empty
end
raise Hocon::ConfigError::ConfigIOError.new(nil, "File not found. No file called #{@input}")
end
end
|
#relative_to(filename) ⇒ Object
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
|
# File 'lib/hocon/impl/parseable.rb', line 434
def relative_to(filename)
sibling = nil
if Pathname.new(filename).absolute?
sibling = File.new(filename)
else
sibling = Hocon::Impl::Parseable.relative_to(@input, filename)
end
if sibling.nil?
nil
elsif File.exists?(sibling)
self.class.trace("#{sibling} exists, so loading it as a file")
Hocon::Impl::Parseable.new_file(sibling, options.set_origin_description(nil))
else
self.class.trace("#{sibling} does not exist, so trying it as a resource")
super(filename)
end
end
|
#to_s ⇒ Object
457
458
459
|
# File 'lib/hocon/impl/parseable.rb', line 457
def to_s
"#{self.class.name.split('::').last} (#{@input})"
end
|