lib/licensed/source/bundler.rb
def gem_spec(dependency)
        return unless dependency

        # find a specifiction from the resolved ::Bundler::Definition specs
        spec = definition.resolve.find { |s| s.satisfies?(dependency) }

        # a nil spec should be rare, generally only seen from bundler
        return bundle_exec_gem_spec(dependency.name) if spec.nil?

        # try to find a non-lazy specification that matches `spec`
        # spec.source.specs gives access to specifications with more
        # information than spec itself, including platform-specific gems.
        # these objects should have all the information needed to detect license metadata
        source_spec = spec.source.specs.find { |s| s.name == spec.name && s.version == spec.version }
        return source_spec if source_spec

        # look for a specification at the bundler specs path
        spec_path = ::Bundler.specs_path.join("#{spec.full_name}.gemspec")
        return Gem::Specification.load(spec_path.to_s) if File.exist?(spec_path.to_s)

        # if the specification file doesn't exist, get the specification using
        # the bundler and gem CLI
        bundle_exec_gem_spec(dependency.name)
      end
# Returns a Gem::Specification for the provided gem argument.  If a
# Gem::Specification isn't found, an error will be raised.
Returns a Gem::Specification for the provided gem argument.  If a
Gem::Specification isn't found, an error will be raised.
Returns a Gem :: Specification for the provided gem argument . If a Gem :: Specification isn ' t found an error will be raised .
def gem_spec(dependency)
        return unless dependency
        spec = definition.resolve.find { |s| s.satisfies?(dependency) }
        return bundle_exec_gem_spec(dependency.name) if spec.nil?
        source_spec = spec.source.specs.find { |s| s.name == spec.name && s.version == spec.version }
        return source_spec if source_spec
        spec_path = ::Bundler.specs_path.join("#{spec.full_name}.gemspec")
        return Gem::Specification.load(spec_path.to_s) if File.exist?(spec_path.to_s)
        bundle_exec_gem_spec(dependency.name)
      end
def gem_spec ( dependency ) return unless dependency spec = definition . resolve . find { | s | s . satisfies? ( dependency ) } return bundle_exec_gem_spec ( dependency . name ) if spec . nil? source_spec = spec . source . specs . find { | s | s . name == spec . name && s . version == spec . version } return source_spec if source_spec spec_path = :: Bundler . specs_path . join ( "#{spec.full_name}.gemspec" ) return Gem :: Specification . load ( spec_path . to_s ) if File . exist? ( spec_path . to_s ) bundle_exec_gem_spec ( dependency . name ) end
Returns a Gem::Specification for the provided gem argument.
Returns a Gem :: Specification for the provided gem argument .
# find a specifiction from the resolved ::Bundler::Definition specs # a nil spec should be rare, generally only seen from bundler # try to find a non-lazy specification that matches `spec` # spec.source.specs gives access to specifications with more # information than spec itself, including platform-specific gems. # these objects should have all the information needed to detect license metadata # look for a specification at the bundler specs path # if the specification file doesn't exist, get the specification using # the bundler and gem CLI
dependency