module HelixVersioningEngine # Stream manipulation # # Streams are a little different from other spec types, in that the singluar # 'stream' is identified by a depot-style path, as opposed to kind of a # name. (And since our paths start with two slashes, we ignore those). class App < Sinatra::Base get '/p4/:api/streams' do require_p4 p4 = env['p4'] streams = p4.run_streams streams.to_json end post '/p4/:api/streams' do require_p4 p4 = env['p4'] p4.save_stream(filter_params(params)) '' end get '/p4/:api/streams/*' do require_p4 p4 = env['p4'] sub_path = params[:splat].join('') stream = "//#{sub_path}" results = p4.run_stream('-o', stream) results.first.to_json end patch '/p4/:api/streams/*' do require_p4 p4 = env['p4'] sub_path = params[:splat].join('') stream = "//#{sub_path}" spec = p4.run_stream('-o', stream)[0] spec = spec.merge(filter_params(params)) p4.save_stream(spec) '' end delete '/p4/:api/streams/*' do require_p4 p4 = env['p4'] sub_path = params[:splat].join('') stream = "//#{sub_path}" p4.run_stream('-d', stream) '' end end end