Class: Webtask::RakeApplication

Inherits:
Object
  • Object
show all
Defined in:
lib/webtask/rake_application.rb

Class Method Summary collapse

Class Method Details

.build_task_endpoints(application) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/webtask/rake_application.rb', line 11

def build_task_endpoints(application)
  tasks.each do |task|
    application.post "/#{task.name}" do
      argument_list = task.arg_names.map do |arg_name|
        params[:args][arg_name]
      end

      stream_id = Digest::SHA1.hexdigest(rand.to_s)
      application.settings.output_streams[stream_id] = task.shell_command(args: argument_list)

      haml :result, format: :html5, locals: { task: task, stream_id: stream_id }
    end
  end
end

.tasksObject



7
8
9
# File 'lib/webtask/rake_application.rb', line 7

def tasks
  @tasks ||= rake_app.tasks.map { |task| TaskWrapper.new(task) }
end