Sha256: ae1ac97601d60a5e76c0f691438cdf25e07f395354d1380afbb1f68a5455a09f

Contents?: true

Size: 876 Bytes

Versions: 17

Compression:

Stored size: 876 Bytes

Contents

# frozen_string_literal: true

require "dry/monads"

module Gemsmith
  module Tools
    # Installs a locally built gem.
    class Installer
      include Import[:executor]
      include Dry::Monads[:result, :do]

      # Order matters.
      STEPS = [Tools::Cleaner.new, Tools::Packager.new].freeze

      def initialize steps: STEPS, **dependencies
        super(**dependencies)

        @steps = steps
      end

      def call specification
        steps.each { |step| yield step.call(specification) }
        run specification
      end

      private

      attr_reader :steps

      def run specification
        path = specification.package_path

        executor.capture3("gem", "install", path.to_s).then do |_stdout, _stderr, status|
          status.success? ? Success(specification) : Failure("Unable to install: #{path}.")
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
gemsmith-19.3.0 lib/gemsmith/tools/installer.rb
gemsmith-19.2.0 lib/gemsmith/tools/installer.rb
gemsmith-19.1.0 lib/gemsmith/tools/installer.rb
gemsmith-19.0.0 lib/gemsmith/tools/installer.rb
gemsmith-18.9.0 lib/gemsmith/tools/installer.rb
gemsmith-18.8.0 lib/gemsmith/tools/installer.rb
gemsmith-18.7.0 lib/gemsmith/tools/installer.rb
gemsmith-18.6.0 lib/gemsmith/tools/installer.rb
gemsmith-18.5.0 lib/gemsmith/tools/installer.rb
gemsmith-18.4.0 lib/gemsmith/tools/installer.rb
gemsmith-18.3.0 lib/gemsmith/tools/installer.rb
gemsmith-18.2.0 lib/gemsmith/tools/installer.rb
gemsmith-18.1.1 lib/gemsmith/tools/installer.rb
gemsmith-18.1.0 lib/gemsmith/tools/installer.rb
gemsmith-18.0.2 lib/gemsmith/tools/installer.rb
gemsmith-18.0.1 lib/gemsmith/tools/installer.rb
gemsmith-18.0.0 lib/gemsmith/tools/installer.rb