class Nymphia::DSL::Context

Attributes

result[R]

Public Class Methods

eval(dsl_code, path) click to toggle source
# File lib/nymphia/dsl/context.rb, line 8
def self.eval(dsl_code, path)
  new(path) do
    eval(dsl_code, binding, path)
  end
end
new(path, &block) click to toggle source
# File lib/nymphia/dsl/context.rb, line 14
def initialize(path, &block)
  @path = path

  @context = {
    identity_files: {},
    gateways: {},
    default_params: {},
    gateway_usage: {},
  }

  @result = {
    hosts: [],
  }

  instance_eval(&block)
end

Private Instance Methods

identity_file(name, path) click to toggle source
# File lib/nymphia/dsl/context.rb, line 33
def identity_file(name, path)
  name = name.to_s
  path = path.to_s
  @context[:identity_files][name] = path
end
include_file(load_file_path) click to toggle source
# File lib/nymphia/dsl/context.rb, line 44
def include_file(load_file_path)
  absolute_load_file_path = Pathname.new(@path).dirname.join(load_file_path)
  dsl_code = File.read(absolute_load_file_path)

  instance_eval(dsl_code, absolute_load_file_path.to_s)
end
load(load_file_path) click to toggle source
# File lib/nymphia/dsl/context.rb, line 39
def load(load_file_path)
  warn "#{caller[0]}: #load method is obsolated. Use #include_file"
  include_file(load_file_path)
end