Sha256: 1739d429f3c1221471fd4b2eb82ad490cc617f42aa1c29b960c1edb1ca921c12
Contents?: true
Size: 1.85 KB
Versions: 8
Compression:
Stored size: 1.85 KB
Contents
# frozen_string_literal: true %w[ bundler ].each(&method(:require)) %w[ version logger latest_version errors build_bundler_definition commands config configs/fetcher configs/validator handle_errors/messages handle_errors/build_exception_payload handle_errors/display_to_stdout handle_errors/report request_object request local_context/diffend local_context/host local_context/packages local_context/platform local_context request_verdict execute track ].each { |file| require "diffend/#{file}" } module Diffend module Plugin class << self # Registers the plugin and add before install all hook def register ::Bundler::Plugin.add_hook('before-install-all') do |_| execute end end # Execute diffend plugin def execute return unless enabled? config = Diffend::Config.new(severity: Diffend::Logger::INFO) Diffend::LatestVersion.call(config) Diffend::Execute.call(config) rescue Diffend::Errors::HandledException # config will not be initialized when configuration file is missing return if config&.ignore_errors? exit 255 rescue StandardError => e Diffend::HandleErrors::Report.call( exception: e, config: config, message: :unhandled_exception, report: true, raise_exception: false ) return if config.ignore_errors? exit 255 end # Checks if plugin is enabled # # @return [Boolean] true if enabled, false otherwise def enabled? ::Bundler .default_gemfile .read .split("\n") .reject(&:empty?) .map(&:strip) .select { |line| line.start_with?('plugin') } .any? { |line| line.include?('diffend') } end end end end
Version data entries
8 entries across 8 versions & 2 rubygems