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.5.6 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.5.5 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.5.4 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.5.3 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.5.2 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.5.1 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.4.3 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.4.2 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.4.1 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.4.0 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.3.12 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.3.11 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.3.10 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.3.9 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.3.8 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.3.7 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.3.6 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.3.5 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.3.4 lib/universe_compiler/package/bootstrap.rb
universe_compiler-0.3.3 lib/universe_compiler/package/bootstrap.rb