Sha256: 0f788b350366cf3b167f9576a38d2b1c173657c8818bfe5ea7f75886a62ea7ce

Contents?: true

Size: 1.74 KB

Versions: 107

Compression:

Stored size: 1.74 KB

Contents

module WorkflowRESTHelpers
  attr_accessor :workflow_resources

  def self.workflow_resources
    @@workflow_resources ||= [Rbbt.share.views.find(:lib)]
  end

  def workflow_resources
    [Rbbt.www.views.find(:lib)] + WorkflowRESTHelpers.workflow_resources
  end

  def locate_workflow_template(template, workflow = nil, task = nil)
    resources = workflow_resources
    resources.unshift workflow.libdir.www.views if workflow

    paths = [template]
    paths.unshift [workflow.to_s, template.to_s]*"/" if workflow 
    paths.unshift [workflow.to_s, task.to_s, template.to_s]*"/" if workflow and task

    path = nil
    paths.each do |location|
      path ||= locate_server_file(location, resources, 'haml')
    end

    raise TemplateMissing, "Template not found: [#{ template }, #{workflow}, #{ task }]" if path.nil?

    path
  end

  #def locate_workflow_template_from_resource(resource, template, workflow = nil, task = nil)
  #  template += '.haml' unless template =~ /.+\..+/

  #  paths = []
  #  paths << resource[workflow][task][template] if task and workflow
  #  paths << resource[workflow][template] if workflow
  #  paths << resource[template]

  #  paths.each do |path|
  #    return path.find if path.exists?
  #  end 

  #  nil
  #end   

  #def locate_workflow_template(template, workflow = nil, task = nil)

  #  if workflow
  #    path = locate_workflow_template_from_resource(workflow.libdir.www.views.find, template, workflow, task)
  #    return path if path and path.exists?
  #  end

  #  workflow_resources.each do |resource|
  #    path = locate_workflow_template_from_resource(resource, template, workflow, task)
  #    return path if path and path.exists?
  #  end

  #  raise "Template not found: [#{ template }, #{workflow}, #{ task }]"
  #end


end

Version data entries

107 entries across 107 versions & 1 rubygems

Version Path
rbbt-rest-1.9.1 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.9.0 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.157 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.156 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.155 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.154 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.152 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.151 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.150 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.148 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.147 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.146 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.145 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.144 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.143 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.142 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.140 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.139 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.138 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.137 lib/rbbt/rest/workflow/locate.rb