class Hocon::Impl::Parseable::ParseableFile
NOTE: Skipping ‘ParseableURL` for now as we probably won’t support this right away
Public Class Methods
Source
# File lib/hocon/impl/parseable.rb, line 398 def initialize(input, options) super() @input = input post_construct(options) end
Calls superclass method
Hocon::Impl::Parseable::new
Public Instance Methods
Source
# File lib/hocon/impl/parseable.rb, line 454 def create_origin Hocon::Impl::SimpleConfigOrigin.new_file(@input) end
Source
# File lib/hocon/impl/parseable.rb, line 404 def custom_reader if Hocon::Impl::ConfigImpl.trace_loads_enabled self.class.trace("Loading config from a String: #{@input}") end # we return self here, which will cause `open` to be called on us, so # we can provide an implementation of that. self end
Source
# File lib/hocon/impl/parseable.rb, line 431 def guess_syntax Hocon::Impl::Parseable.syntax_from_extension(File.basename(@input)) end
Source
# File lib/hocon/impl/parseable.rb, line 413 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
Source
# File lib/hocon/impl/parseable.rb, line 435 def relative_to(filename) sibling = nil if Pathname.new(filename).absolute? sibling = File.new(filename) else # this may return nil sibling = Hocon::Impl::Parseable.relative_to(@input, filename) end if sibling.nil? nil elsif File.exist?(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
Calls superclass method
Hocon::Impl::Parseable#relative_to
Source
# File lib/hocon/impl/parseable.rb, line 458 def to_s "#{self.class.name.split('::').last} (#{@input})" end