Sha256: a7ca699247b3916ea151bef81901f948522ee02aec0a1904da43be67344961c9
Contents?: true
Size: 1.9 KB
Versions: 2
Compression:
Stored size: 1.9 KB
Contents
module Munge class Bootstrap class << self def new_from_dir(root_path:) new_from_fs( root_path: root_path, config_path: config_path(root_path), setup_path: setup_path(root_path), rules_path: rules_path(root_path) ) end def new_from_fs(root_path:, config_path:, setup_path:, rules_path:) new( root_path: root_path, config: read_config(config_path), setup_string: File.read(setup_path), setup_path: setup_path, rules_string: File.read(rules_path), rules_path: rules_path ) end private def read_config(config_path) Munge::Util::Config.read(config_path) end def config_path(root_path) File.join(root_path, "config.yml") end def setup_path(root_path) File.join(root_path, "setup.rb") end def rules_path(root_path) File.join(root_path, "rules.rb") end end def initialize(root_path:, config:, setup_string:, rules_string:, setup_path:, rules_path:) @setup_path = setup_path @rules_path = rules_path @binding = binding system = Munge::System.new(root_path, config) import(setup_path, setup_string) @app = Munge::Application.new(system) import(rules_path, rules_string) end def root_path File.dirname(@setup_path) end def config_path File.join(root_path, "config") end def import(file_path, file_contents = nil) absolute_file_path = File.expand_path(file_path, root_path) contents = file_contents || File.read(absolute_file_path) @binding.eval(contents, absolute_file_path) end attr_reader :app end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
munge-0.7.0 | lib/munge/bootstrap.rb |
munge-0.6.0 | lib/munge/bootstrap.rb |