Module: Ripe::Library

Defined in:
lib/ripe/library.rb

Overview

This singleton class represents a library containing all the components accessible to ripe (tasks and workflows) based on what is contained in the RIPELIB environment variable.

Class Method Summary collapse

Class Method Details

.find(comp, filename) ⇒ String?

Search throughout the library for a task or workflow component by the name of handle. When there is more than one match, give precendence to component whose path is declared first.

Parameters:

  • comp (Symbol)

    Type of component: either :workflow or :task.

  • filename (String)

    Filename of component

Returns:

  • (String, nil)

    Full path of the component if found, and nil otherwise.



34
35
36
37
38
39
40
41
# File 'lib/ripe/library.rb', line 34

def find(comp, filename)
  search = paths.map do |path|
    file = "#{path}/#{comp}s/#{filename}"
    (File.exists? file) ? file : nil
  end

  search.compact.first
end

.pathsList

Provide a list of search paths

Returns:

  • (List)

    Return the list of search paths



17
18
19
20
21
# File 'lib/ripe/library.rb', line 17

def paths
  # Prepend the working directory to the list of paths so that the
  # working directory is always looked in first.
  "#{Dir.pwd}/#{Repo::REPOSITORY_PATH}:#{ENV['RIPELIB']}".split(/:/)
end