Sha256: cd2c82d894910aa37a23ea46015d5ea1c4684229940d3884ca04b2d0fe3a8e25

Contents?: true

Size: 1.39 KB

Versions: 13

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

require "bundler/match_platform"

# Bundler normally raises a "GemNotFound" error when a specification
# can't be materialized which halts bundler dependency enumeration.

# This monkey patch instead creates MissingSpecification objects to
# identify missing specs without raising errors and halting enumeration.
# It was the most minimal-touch solution I could think of that should reliably
# work across many bundler versions

module Licensed
  module Bundler
    class MissingSpecification < Gem::BasicSpecification
      include ::Bundler::MatchPlatform

      attr_reader :name, :version, :platform, :source
      def initialize(name:, version:, platform:, source:)
        @name = name
        @version = version
        @platform = platform
        @source = source
      end

      def dependencies
        []
      end

      def gem_dir; end
      def gems_dir
        Gem.dir
      end
      def summary; end
      def homepage; end

      def error
        "could not find #{name} (#{version}) in any sources"
      end
    end

    module LazySpecification
      def __materialize__
        spec = super
        return spec if spec

        Licensed::Bundler::MissingSpecification.new(name: name, version: version, platform: platform, source: source)
      end
    end
  end
end

module Bundler
  class LazySpecification
    prepend ::Licensed::Bundler::LazySpecification
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
licensed-3.7.2 lib/licensed/sources/bundler/missing_specification.rb
licensed-3.7.1 lib/licensed/sources/bundler/missing_specification.rb
licensed-3.7.0 lib/licensed/sources/bundler/missing_specification.rb
licensed-3.6.0 lib/licensed/sources/bundler/missing_specification.rb
licensed-3.5.0 lib/licensed/sources/bundler/missing_specification.rb
licensed-3.4.4 lib/licensed/sources/bundler/missing_specification.rb
licensed-3.4.3 lib/licensed/sources/bundler/missing_specification.rb
licensed-3.4.2 lib/licensed/sources/bundler/missing_specification.rb
licensed-3.4.1 lib/licensed/sources/bundler/missing_specification.rb
licensed-3.4.0 lib/licensed/sources/bundler/missing_specification.rb
licensed-3.3.1 lib/licensed/sources/bundler/missing_specification.rb
licensed-3.3.0 lib/licensed/sources/bundler/missing_specification.rb
licensed-3.2.3 lib/licensed/sources/bundler/missing_specification.rb