Sha256: 9591deae3e6fe1a9d39cb1100849af1d417283a36fbd0d772156dd1113059756

Contents?: true

Size: 1.29 KB

Versions: 4

Compression:

Stored size: 1.29 KB

Contents

module Bootsnap
  module CompileCache
    Error           = Class.new(StandardError)
    PermissionError = Class.new(Error)

    def self.setup(cache_dir:, iseq:, yaml:)
      if iseq
        if supported?
          require_relative('compile_cache/iseq')
          Bootsnap::CompileCache::ISeq.install!(cache_dir)
        elsif $VERBOSE
          warn("[bootsnap/setup] bytecode caching is not supported on this implementation of Ruby")
        end
      end

      if yaml
        if supported?
          require_relative('compile_cache/yaml')
          Bootsnap::CompileCache::YAML.install!(cache_dir)
        elsif $VERBOSE
          warn("[bootsnap/setup] YAML parsing caching is not supported on this implementation of Ruby")
        end
      end
    end

    def self.permission_error(path)
      cpath = Bootsnap::CompileCache::ISeq.cache_dir
      raise(
        PermissionError,
        "bootsnap doesn't have permission to write cache entries in '#{cpath}' " \
        "(or, less likely, doesn't have permission to read '#{path}')",
      )
    end

    def self.supported?
      # only enable on 'ruby' (MRI), POSIX (darwin, linux, *bsd), and >= 2.3.0
      RUBY_ENGINE == 'ruby' &&
      RUBY_PLATFORM =~ /darwin|linux|bsd/ &&
      Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.3.0")
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/compile_cache.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/compile_cache.rb
bootsnap-1.4.5-java lib/bootsnap/compile_cache.rb
bootsnap-1.4.5 lib/bootsnap/compile_cache.rb