Sha256: 53dca27e267789b3e58fcaab0ea2abb285e209efc5cda217b05602aa5695c4b5

Contents?: true

Size: 871 Bytes

Versions: 54

Compression:

Stored size: 871 Bytes

Contents

# encoding: utf-8
module Sinatra
  module ProcessesHandler
    extend Hexacta

    def enable_processes
      p "Enabling processes..."

      get '/processes' do
        return "" if ProcessManager.instance.find(params[:class],authenticated(User).id).nil?
        content_type :json
        process = ProcessManager.instance.find(params[:class],authenticated(User).id)
        return { 'name' => process.name, 'progress' => process.progress }.to_json
      end

      post '/processes/:clazz' do |clazz|
        ProcessManager.instance.clean(clazz,authenticated(User).id)
        200
      end

      post '/process' do
        params[:user_id] = authenticated(User).id
        klass = Object.const_get("#{params[:class]}")
        a_handler = ProcessManager.instance.run(klass,params)
        a_handler.to_json
      end
    end

  end
  register ProcessesHandler
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
sinatra-hexacta-1.7.20 lib/sinatra/handlers/processes.rb
sinatra-hexacta-1.7.19 lib/sinatra/handlers/processes.rb
sinatra-hexacta-1.7.18 lib/sinatra/handlers/processes.rb
sinatra-hexacta-1.7.17 lib/sinatra/handlers/processes.rb
sinatra-hexacta-1.7.16 lib/sinatra/handlers/processes.rb
sinatra-hexacta-1.7.15 lib/sinatra/handlers/processes.rb
sinatra-hexacta-1.7.14 lib/sinatra/handlers/processes.rb
sinatra-hexacta-1.7.13 lib/sinatra/handlers/processes.rb
sinatra-hexacta-1.7.12 lib/sinatra/handlers/processes.rb
sinatra-hexacta-1.7.11 lib/sinatra/handlers/processes.rb
sinatra-hexacta-1.7.10 lib/sinatra/handlers/processes.rb
sinatra-hexacta-1.7.9 lib/sinatra/handlers/processes.rb
sinatra-hexacta-1.7.8 lib/sinatra/handlers/processes.rb
sinatra-hexacta-1.7.7 lib/sinatra/handlers/processes.rb
sinatra-hexacta-1.7.6 lib/sinatra/handlers/processes.rb
sinatra-hexacta-1.7.5 lib/sinatra/handlers/processes.rb
sinatra-hexacta-1.7.4 lib/sinatra/handlers/processes.rb
sinatra-hexacta-1.7.3 lib/sinatra/handlers/processes.rb
sinatra-hexacta-1.7.2 lib/sinatra/handlers/processes.rb
sinatra-hexacta-1.7.0 lib/sinatra/handlers/processes.rb