summaryrefslogtreecommitdiff
path: root/lib/gitlab/plugin.rb
blob: cbc57a5cce36ba439d13180be56d18e55aa9100e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Gitlab
  module Plugin
    def self.all
      files.map do |file|
        file_name = File.basename(file, '.rb')

        # Just give sample data to method and expect it to not crash.
        begin
          klass = Object.const_get(file_name.classify)
          klass.new.execute(Gitlab::DataBuilder::Push::SAMPLE_DATA)
        rescue => e
          Rails.logger.warn("GitLab -> Plugins -> #{file_name} raised an exception during boot check. #{e}")
          next
        else
          Rails.logger.info "GitLab -> Plugins -> #{file_name} passed validation check"
          klass
        end
      end
    end

    def self.files
      Dir.glob(Rails.root.join('plugins', '*_plugin.rb'))
    end
  end
end