Module: Diffend::Plugin
- Defined in:
- lib/diffend/plugin.rb
Class Method Summary collapse
- .build_outdated_version_message(version) ⇒ String
-
.command ⇒ String
Command that was run with bundle.
-
.enabled? ⇒ Boolean
Checks if plugin is enabled.
-
.execute ⇒ Object
Execute diffend plugin.
-
.installed_version ⇒ String
Installed plugin version.
-
.register ⇒ Object
Registers the plugin and add before install all hook.
- .verify_version ⇒ Object
Class Method Details
.build_outdated_version_message(version) ⇒ String
109 110 111 112 113 114 |
# File 'lib/diffend/plugin.rb', line 109 def (version) " \\nYou are running an outdated version (\#{version}) of the plugin, which will lead to issues.\n \\nPlease upgrade to the latest one (\#{VERSION}) by executing \"rm -rf .bundle/plugin\".\\n\n MSG\nend\n" |
.command ⇒ String
Command that was run with bundle
119 120 121 |
# File 'lib/diffend/plugin.rb', line 119 def command ARGV.first || ::Bundler.feature_flag.default_cli_command.to_s end |
.enabled? ⇒ Boolean
Checks if plugin is enabled
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/diffend/plugin.rb', line 95 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
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 45 def execute return unless enabled? verify_version config = Diffend::Config.call Diffend::Execute.call(command, config) rescue Diffend::Errors::HandledException return if ENV['DIFFEND_IGNORE_ERRORS'] == 'true' exit 255 rescue StandardError => e Diffend::HandleErrors::Report.call( exception: e, config: config, message: :unhandled_exception, report: true, raise_exception: false ) return if ENV['DIFFEND_IGNORE_ERRORS'] == 'true' exit 255 end |
.installed_version ⇒ String
Returns installed plugin version.
82 83 84 85 86 87 88 89 90 |
# File 'lib/diffend/plugin.rb', line 82 def installed_version ::Bundler::Plugin .index .plugin_path('diffend') .basename .to_s .split('-') .last end |
.register ⇒ Object
Registers the plugin and add before install all hook
38 39 40 41 42 |
# File 'lib/diffend/plugin.rb', line 38 def register ::Bundler::Plugin.add_hook('before-install-all') do |_| execute end end |
.verify_version ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/diffend/plugin.rb', line 71 def verify_version return if ENV['DIFFEND_DEVELOPMENT'] == 'true' return if installed_version == Diffend::VERSION (installed_version) .tap(&::Bundler.ui.method(:error)) exit 2 end |