Sha256: 5cffd7028d3c4e4da67ea4f6f76145724301744010123140718b2b63c682d081

Contents?: true

Size: 1.03 KB

Versions: 7

Compression:

Stored size: 1.03 KB

Contents

require_relative '../coverage_reporter'
require_relative 'client'
require_relative 'configuration'

module CircleCI
  module CoverageReporter
    # A sandbox isolates the enclosed code into an environment that looks 'new'
    # meaning globally accessed objects are reset for the duration of the sandbox.
    #
    # @note This module is not normally available. You must require
    #   `circleci/coverage_reporter/sandbox` to load it.
    module Sandbox
      # Execute a provided block with CircleCI::CoverageReporter global objects(
      # configuration, client) reset.
      #
      # @yield [Configuration]
      # @return [void]
      def self.sandboxed
        orig_config = CoverageReporter.configuration
        orig_client = CoverageReporter.client

        CoverageReporter.configuration = Configuration.new
        CoverageReporter.client = Client.new

        yield CoverageReporter.configuration
      ensure
        CoverageReporter.configuration = orig_config
        CoverageReporter.client = orig_client
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
circleci-coverage_reporter-0.8.0 lib/circleci/coverage_reporter/sandbox.rb
circleci-coverage_reporter-0.7.0 lib/circleci/coverage_reporter/sandbox.rb
circleci-coverage_reporter-0.6.0 lib/circleci/coverage_reporter/sandbox.rb
circleci-coverage_reporter-0.5.0 lib/circleci/coverage_reporter/sandbox.rb
circleci-coverage_reporter-0.4.0 lib/circleci/coverage_reporter/sandbox.rb
circleci-coverage_reporter-0.3.1 lib/circleci/coverage_reporter/sandbox.rb
circleci-coverage_reporter-0.3.0 lib/circleci/coverage_reporter/sandbox.rb