Module: Sinatra::ProcessesHandler

Extended by:
Hexacta
Defined in:
lib/sinatra/handlers/processes.rb

Constant Summary

Constants included from Hexacta

Hexacta::GEM_FILE_DIR

Instance Method Summary collapse

Methods included from Hexacta

copy_all_files, copy_dir_structure, copy_file, gem_path, setup_dir

Instance Method Details

#enable_processesObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/sinatra/handlers/processes.rb', line 6

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