Sha256: a0b12a529bf7866cbdbc7f177dfbb6ca87040d5616c30a8b6b6a2a0ffcc5d618

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

%w[
  bundler
].each(&method(:require))

%w[
  errors
  config/fetcher
  config/file_finder
  config/validator
  commands
  voting
].each { |file| require "diffend/#{file}" }

%w[
  request
  versions/local
  versions/remote
].each { |file| require "diffend/voting/#{file}" }

# Diffend main namespace
module Diffend
  # Current plugin version
  VERSION = '0.2.18'
  # Diffend homepage
  HOMEPAGE = 'https://diffend.io'

  class << self
    # Registers the plugin and add before install all hook
    def register
      Bundler::Plugin.add_hook('before-install-all') do |_|
        Diffend::Voting.call(
          command,
          build_definition(command)
        )
      end
    end

    # Build clean instance of bundler definition, as we don't want to pollute the main one
    #
    # @param command [String] bundler command that we are executing
    #
    # @return [Bundler::Definition]
    def build_definition(command)
      unlock = command == 'update' ? true : nil

      Bundler.configure

      Bundler::Definition.build(
        Bundler.default_gemfile,
        Bundler.default_lockfile,
        unlock
      )
    end

    # Command that was run with bundle
    #
    # @return [String]
    def command
      ARGV.first || Diffend::Commands::INSTALL
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
diffend-0.2.18 lib/diffend.rb