Sha256: 1c90424ef3ed71eda89e7591704dc37f4b52dfe3b90e60a0040e117ef221bf01

Contents?: true

Size: 986 Bytes

Versions: 29

Compression:

Stored size: 986 Bytes

Contents

module UniverseCompiler
  module Package

    module Bootstrap

      DEFAULT_BOOTSTRAP_FILE = 'main.rb'.freeze

      attr_reader :path

      def path=(path)
        @path = path if path_valid? path
      end

      def path_valid?(path = self.path)
        return false unless path.is_a?(String) && File.readable?(path)
        return true if File.file? path
        File.exist? default_bootstrap_file(path)
      end

      def bootstrap_file
        return nil unless path_valid?
        if File.file? path
          path
        else
          default_bootstrap_file
        end
      end

      def load
        require bootstrap_file
      rescue ScriptError => e
        msg = "Invalid package: '#{bootstrap_file}': #{e.message}"
        UniverseCompiler.logger.error msg
        raise UniverseCompiler::Error.from(e, msg)
      end

      private

      def default_bootstrap_file(path = self.path)
        File.join(path, DEFAULT_BOOTSTRAP_FILE)
      end

    end

  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
universe_compiler-0.3.2 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.3.1 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.3.0 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.2.16 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.2.15 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.2.14 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.2.13 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.2.12 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.2.11 lib/universe_compiler/package/bootstrap.rb