Sha256: 8cd4e651cdffe58ed190309c33ec5c5ae52657fbbcf0485c4f1d453682a80def

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

require "librarian/resolver"
require "librarian/spec_change_set"
require "librarian/action/base"
require "librarian/action/persist_resolution_mixin"

module Librarian
  module Action
    class Resolve < Base
      include PersistResolutionMixin

      def run
        if force? || !lockfile_path.exist?
          spec = specfile.read
          manifests = []
        else
          lock = lockfile.read
          spec = specfile.read(lock.sources)
          changes = spec_change_set(spec, lock)
          if changes.same?
            debug { "The specfile is unchanged: nothing to do." }
            return
          end
          manifests = changes.analyze
        end

        spec.dependencies, duplicated = Dependency.remove_duplicate_dependencies(spec.dependencies)
        duplicated.each do |name, dependencies_same_name|
          environment.logger.info { "Dependency '#{name}' duplicated for module #{name}, merging: #{dependencies_same_name.map{|d| d.to_s}}" }
        end

        resolution = resolver.resolve(spec, manifests)
        persist_resolution(resolution)
        resolution
      end

    private

      def force?
        options[:force]
      end

      def resolver
        Resolver.new(environment)
      end

      def spec_change_set(spec, lock)
        SpecChangeSet.new(environment, spec, lock)
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
librarianp-0.6.1 lib/librarian/action/resolve.rb
librarianp-0.6.0 lib/librarian/action/resolve.rb