module HelixVersioningEngine # Add methods for triggers resources. # # Like protections, there is no singular 'trigger' resource in the Perforce # system, just the list of all of them. class App < Sinatra::Base get '/p4/:api/triggers' do |_| require_p4 p4 = env['p4'] triggers = p4.run_triggers('-o').first triggers.to_json end put '/p4/:api/triggers' do |_| triggers = { 'Triggers' => params['Triggers'] } require_p4 p4 = env['p4'] p4.input = triggers r = p4.run_triggers('-i') r.nil? ? '' : r.to_json end end end