File: simple_include_context.rb

package info (click to toggle)
ruby-hocon 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 768 kB
  • sloc: ruby: 7,903; makefile: 4
file content (37 lines) | stat: -rw-r--r-- 862 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# encoding: utf-8

require_relative '../../hocon/impl'
require_relative '../../hocon/impl/simple_includer'
require_relative '../../hocon/config_include_context'
require_relative '../../hocon/impl/config_impl'

class Hocon::Impl::SimpleIncludeContext
  include Hocon::ConfigIncludeContext

  def initialize(parseable)
    @parseable = parseable
  end

  def with_parseable(parseable)
    if parseable.equal?(@parseable)
      self
    else
      self.class.new(parseable)
    end
  end

  def relative_to(filename)
    if Hocon::Impl::ConfigImpl.trace_loads_enabled
      Hocon::Impl::ConfigImpl.trace("Looking for '#{filename}' relative to #{@parseable}")
    end
    if ! @parseable.nil?
      @parseable.relative_to(filename)
    else
      nil
    end
  end

  def parse_options
    Hocon::Impl::SimpleIncluder.clear_for_include(@parseable.options)
  end
end