Module: Diffend::Plugin
- Defined in:
- lib/diffend/plugin.rb
Class Method Summary collapse
-
.enabled? ⇒ Boolean
Checks if plugin is enabled.
-
.execute ⇒ Object
Execute diffend plugin.
-
.register ⇒ Object
Registers the plugin and add before install all hook.
Class Method Details
.enabled? ⇒ Boolean
Checks if plugin is enabled
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/diffend/plugin.rb', line 74 def enabled? ::Bundler .default_gemfile .read .split("\n") .reject(&:empty?) .map(&:strip) .select { |line| line.start_with?('plugin') } .any? { |line| line.include?('diffend') } end |
.execute ⇒ Object
Execute diffend plugin
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/diffend/plugin.rb', line 44 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 |
.register ⇒ Object
Registers the plugin and add before install all hook
37 38 39 40 41 |
# File 'lib/diffend/plugin.rb', line 37 def register ::Bundler::Plugin.add_hook('before-install-all') do |_| execute end end |