Sha256: a5fc8a13b1272a4b01bb6ea99232c9c1a6fe81cf22d68feda696c8a4c9bb5466

Contents?: true

Size: 1.95 KB

Versions: 368

Compression:

Stored size: 1.95 KB

Contents

class WorkflowRESTClient

  def workflow_description
    WorkflowRESTClient.get_raw(File.join(url, 'description'))
  end

  def documentation
    @documention ||= IndiferentHash.setup(WorkflowRESTClient.get_json(File.join(url, "documentation"),{}))
  end

  def task_info(task)
    @task_info ||= {}
    @task_info[task]
    
    if @task_info[task].nil?
      task_info = WorkflowRESTClient.get_json(File.join(url, task.to_s, 'info'))
      task_info = WorkflowRESTClient.fix_hash(task_info)

      task_info[:result_type] = task_info[:result_type].to_sym
      task_info[:export] = task_info[:export].to_sym
      task_info[:input_types] = WorkflowRESTClient.fix_hash(task_info[:input_types], true)
      task_info[:inputs] = task_info[:inputs].collect{|input| input.to_sym }

      @task_info[task] = task_info
    end
    @task_info[task]
  end

  def exported_tasks
    (@asynchronous_exports  + @synchronous_exports + @exec_exports).compact.flatten
  end

  def tasks
    @tasks ||= Hash.new do |hash,task_name| 
      info = task_info(task_name)
      task = Task.setup info do |*args|
        raise "This is a remote task" 
      end
      task.name = task_name.to_sym
      hash[task_name] = task
    end
  end

  def load_tasks
    exported_tasks.each{|name| tasks[name]}
    nil
  end

  def task_dependencies
    @task_dependencies ||= Hash.new do |hash,task| 
      hash[task] = if exported_tasks.include? task
        WorkflowRESTClient.get_json(File.join(url, task.to_s, 'dependencies'))
      else
        []
      end
    end
  end

  def init_remote_tasks
    task_exports = WorkflowRESTClient.get_json(url)
    @asynchronous_exports = task_exports["asynchronous"].collect{|task| task.to_sym }
    @synchronous_exports = task_exports["synchronous"].collect{|task| task.to_sym }
    @exec_exports = task_exports["exec"].collect{|task| task.to_sym }
    @stream_exports = task_exports["stream"].collect{|task| task.to_sym }
    @can_stream = task_exports["can_stream"]
  end
end

Version data entries

368 entries across 368 versions & 1 rubygems

Version Path
rbbt-util-5.26.157 lib/rbbt/rest/client/adaptor.rb
rbbt-util-5.26.156 lib/rbbt/rest/client/adaptor.rb
rbbt-util-5.26.155 lib/rbbt/rest/client/adaptor.rb
rbbt-util-5.26.154 lib/rbbt/rest/client/adaptor.rb
rbbt-util-5.26.153 lib/rbbt/rest/client/adaptor.rb
rbbt-util-5.26.152 lib/rbbt/rest/client/adaptor.rb
rbbt-util-5.26.151 lib/rbbt/rest/client/adaptor.rb
rbbt-util-5.26.150 lib/rbbt/rest/client/adaptor.rb
rbbt-util-5.26.149 lib/rbbt/rest/client/adaptor.rb
rbbt-util-5.26.148 lib/rbbt/rest/client/adaptor.rb
rbbt-util-5.26.147 lib/rbbt/rest/client/adaptor.rb
rbbt-util-5.26.146 lib/rbbt/rest/client/adaptor.rb
rbbt-util-5.26.145 lib/rbbt/rest/client/adaptor.rb
rbbt-util-5.26.144 lib/rbbt/rest/client/adaptor.rb
rbbt-util-5.26.143 lib/rbbt/rest/client/adaptor.rb
rbbt-util-5.26.142 lib/rbbt/rest/client/adaptor.rb
rbbt-util-5.26.141 lib/rbbt/rest/client/adaptor.rb
rbbt-util-5.26.140 lib/rbbt/rest/client/adaptor.rb
rbbt-util-5.26.139 lib/rbbt/rest/client/adaptor.rb
rbbt-util-5.26.138 lib/rbbt/rest/client/adaptor.rb