module Isomorfeus module Puppetmaster class << self attr_accessor :app, :download_path, :server_port, :session attr_writer :server_host, :server_scheme def boot_app @served_app = Isomorfeus::Puppetmaster::Server.new(app, port: server_port, host: server_host).boot end def block_source_code(&block) source_block = Parser::CurrentRuby.parse(block.source.strip) unless source_block.type == :block source_block = source_block.children[source_block.children.index { |c| c.respond_to?(:type) && c.type == :block }] end source_block = source_block.children[2] Unparser.unparse(source_block) end def compile_ruby_source(source_code) Opal.compile(source_code) end def opal_prelude @opal_prelude ||= build_opal_prelude end def served_app @served_app ||= boot_app end def server_host @server_host ||= '127.0.0.1' end def server_scheme @server_scheme ||= 'http' end private def build_opal_prelude Opal::Builder.new.build_str("require 'opal'\n", 'puppetmaster_opal_prelude').to_s end end end end