Sha256: 462d117347dcd1caa2a590e320bd07a6d996ccf0e3fae96c959afa3b917b5666

Contents?: true

Size: 852 Bytes

Versions: 38

Compression:

Stored size: 852 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, **)
        super(**)
        @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

38 entries across 38 versions & 1 rubygems

Version Path
gemsmith-22.10.0 lib/gemsmith/tools/installer.rb
gemsmith-22.9.0 lib/gemsmith/tools/installer.rb
gemsmith-22.8.0 lib/gemsmith/tools/installer.rb
gemsmith-22.7.0 lib/gemsmith/tools/installer.rb
gemsmith-22.6.0 lib/gemsmith/tools/installer.rb
gemsmith-22.5.0 lib/gemsmith/tools/installer.rb
gemsmith-22.4.0 lib/gemsmith/tools/installer.rb
gemsmith-22.3.0 lib/gemsmith/tools/installer.rb
gemsmith-22.2.0 lib/gemsmith/tools/installer.rb
gemsmith-22.1.0 lib/gemsmith/tools/installer.rb
gemsmith-22.0.0 lib/gemsmith/tools/installer.rb
gemsmith-21.10.0 lib/gemsmith/tools/installer.rb
gemsmith-21.9.0 lib/gemsmith/tools/installer.rb
gemsmith-21.6.0 lib/gemsmith/tools/installer.rb
gemsmith-21.5.1 lib/gemsmith/tools/installer.rb
gemsmith-21.5.0 lib/gemsmith/tools/installer.rb
gemsmith-21.4.0 lib/gemsmith/tools/installer.rb
gemsmith-21.3.0 lib/gemsmith/tools/installer.rb
gemsmith-21.2.0 lib/gemsmith/tools/installer.rb
gemsmith-21.1.0 lib/gemsmith/tools/installer.rb