Sha256: 9e6fd4f65d63c54140cc681609c5a7e8cf4a16ec94c87ff5e020ac3ab3809342

Contents?: true

Size: 1009 Bytes

Versions: 6

Compression:

Stored size: 1009 Bytes

Contents

# frozen_string_literal: true

require "bundler"
require "bundler/cli"
require "refinements/io"
require "refinements/pathname"

module Rubysmith
  module Extensions
    # Ensures gem dependencies are installed.
    class Bundler
      include Import[:settings, :logger]

      using Refinements::IO
      using Refinements::Pathname

      def initialize(client: ::Bundler::CLI, **)
        @client = client
        super(**)
      end

      def call
        logger.info { "Installing gem dependencies..." }
        install
      rescue ::Bundler::HTTPError
        log_error
      end

      private

      attr_reader :client

      def install
        settings.project_root.change_dir do
          client.start %w[install --quiet]
          STDOUT.squelch { client.start %w[lock --add-platform x86_64-linux --update] }
        end

        true
      end

      def log_error
        logger.error { "Unable to install gem dependencies. Is your network stable?" }
        false
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubysmith-7.9.0 lib/rubysmith/extensions/bundler.rb
rubysmith-7.8.0 lib/rubysmith/extensions/bundler.rb
rubysmith-7.7.0 lib/rubysmith/extensions/bundler.rb
rubysmith-7.6.0 lib/rubysmith/extensions/bundler.rb
rubysmith-7.5.0 lib/rubysmith/extensions/bundler.rb
rubysmith-7.4.0 lib/rubysmith/extensions/bundler.rb