class DGD::Manifest::DGDRuntimeConfig
Constants
- CONFIG_KEYS
- DEFAULT_CONFIG
Attributes
app_root[R]
Public Class Methods
new(config_data)
click to toggle source
# File lib/dgd-tools/manifest.rb, line 545 def initialize(config_data) @app_root = config_data["app_root"] || "app" @ports = { "*" => 50100, } @telnet_ports = { "*" => 50110, } @statedir = config_data["statedir"] || "state" @dump_file = if config_data["dump_file"] "../" + config_data["dump_file"] else "../#{@statedir}/dump" end @config = DEFAULT_CONFIG.dup @raw_data = config_data @config.keys.each do |prop| # For now, assume and require that JSON data is the correct type if present @config[prop] = config_data[prop.to_s] if config_data[prop.to_s] end unexpected_config_keys = config_data.keys - CONFIG_KEYS unless unexpected_config_keys.empty? raise "Unexpected key names in DGD configuration: #{unexpected_config_keys.inspect}!" end if config_data["telnet_ports"] @telnet_ports = config_to_ports(config_data["telnet_ports"]) end if config_data["ports"] @ports = config_to_ports(config_data["ports"]) end end
Public Instance Methods
as_file()
click to toggle source
# File lib/dgd-tools/manifest.rb, line 597 def as_file return <<DGD_CONFIG telnet_port = ([ #{@telnet_ports.map { |ip, p| "#{ip.inspect}:#{p}" }.join(",\n ") } ]); /* legacy telnet ports */ binary_port = ([ #{@ports.map { |ip, p| "#{ip.inspect}:#{p}" }.join(",\n ") } ]); /* binary ports */ directory = "./#{GENERATED_ROOT}"; users = #{@config[:users]}; /* max # of connections */ editors = #{@config[:editors]}; /* max # of built-in-editor sessions */ ed_tmpfile = "../#{@statedir}/ed"; /* proto editor tmpfile */ swap_file = "../#{@statedir}/swap"; /* swap file */ swap_size = #{@config[:swap_size]}; /* # sectors in swap file */ sector_size = #{@config[:sector_size]}; /* swap sector size */ swap_fragment = #{@config[:swap_fragment]}; /* fragment to swap out */ static_chunk = #{@config[:static_chunk]}; /* static memory chunk */ dynamic_chunk = #{@config[:dynamic_chunk]}; /* dynamic memory chunk */ dump_file = #{@dump_file.inspect}; /* dump file */ dump_interval = #{@config[:dump_interval]}; /* expected statedump interval in seconds */ typechecking = #{@config[:typechecking]}; /* level of typechecking (2 is highest) */ include_file = #{@config[:include_file].inspect}; /* standard include file */ include_dirs = ({ #{@config[:include_dirs].map(&:inspect).join(", ")} }); /* directories to search */ auto_object = #{@config[:auto_object].inspect}; /* auto inherited object */ driver_object = #{@config[:driver_object].inspect}; /* driver object */ create = #{@config[:create].inspect}; /* name of create function */ array_size = #{@config[:array_size]}; /* max array size */ objects = #{@config[:objects]}; /* max # of objects */ call_outs = #{@config[:call_outs]}; /* max # of callouts */ DGD_CONFIG end
config_to_ports(data)
click to toggle source
# File lib/dgd-tools/manifest.rb, line 579 def config_to_ports(data) if data.is_a?(Hash) return data.map { |ip, port| [ip, Integer(port) ] } elsif data.is_a?(Array) if data[0].is_a?(Array) ports = data.map { |ip, port| [ip, Integer(port) ] } return ports end ports = data.map { |p| [ "*", Integer(p) ] } return ports elsif data.is_a?(Integer) return [ [ "*", data ] ] else raise "dgd-manifest: not sure how to get port data from a #{data.class.name} -- #{data.inspect}!" end end