summaryrefslogtreecommitdiff
path: root/lib/gitlab/plugin.rb
blob: 5339c4dbbc8744e029cc877487bff61c3a4c5f6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module Gitlab
  module Plugin
    def self.files
      Dir.glob(Rails.root.join('plugins/*')).select do |entry|
        File.file?(entry)
      end
    end

    def self.execute_all_async(data)
      files.each do |file|
        PluginWorker.perform_async(file, data)
      end
    end

    def self.execute(file, data)
      _output, exit_status = Gitlab::Popen.popen([file]) do |stdin|
        stdin.write(data.to_json)
      end

      exit_status.zero?
    end
  end
end