<commit_before>require 'librarian/resolver/implementation'
require 'librarian/manifest_set'
require 'librarian/resolution'

module Librarian
  class Resolver

    attr_accessor :environment
    private :environment=

    def initialize(environment)
      self.environment = environment
    end

    def resolve(spec, partial_manifests = [])
      manifests = implementation(spec).resolve(partial_manifests)
      if manifests
        enforce_consistency!(spec.dependencies, manifests)
        manifests = sort(manifests)
        Resolution.new(spec.dependencies, manifests)
      end
    end

  private

    def implementation(spec)
      Implementation.new(self, spec)
    end

    def enforce_consistency!(dependencies, manifests)
      manifest_set = ManifestSet.new(manifests)
      return if manifest_set.in_compliance_with?(dependencies)<commit_msg>Prefer return-early style to nested code.<commit_after>require 'librarian/resolver/implementation'
require 'librarian/manifest_set'
require 'librarian/resolution'

module Librarian
  class Resolver

    attr_accessor :environment
    private :environment=

    def initialize(environment)
      self.environment = environment
    end

    def resolve(spec, partial_manifests = [])
      manifests = implementation(spec).resolve(partial_manifests)
      manifests or return
      enforce_consistency!(spec.dependencies, manifests)
      manifests = sort(manifests)
      Resolution.new(spec.dependencies, manifests)
    end

  private

    def implementation(spec)
      Implementation.new(self, spec)
    end

    def enforce_consistency!(dependencies, manifests)
      manifest_set = ManifestSet.new(manifests)
      return if manifest_set.in_compliance_with?(dependencies)
{'fraction_non_alphanumeric': 0.07403123192596876, 'fraction_numerical': 0.0, 'mean_word_length': 3.914772727272727, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2851626', 'n_tokens_mistral': 506, 'n_tokens_neox': 458, 'n_words': 100}