Module: Path

Defined in:
lib/scout/tsv/path.rb,
lib/scout/workflow/path.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.step_file?(path) ⇒ Boolean

Returns:

  • (Boolean)


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/scout/workflow/path.rb', line 2

def self.step_file?(path)
  return false unless path =~ /\.files(?:\/|$)/
  parts = path.split("/")
  job = parts.select{|p| p =~ /\.files$/}.first

  if job
    i = parts.index job
    begin
      workflow, task = parts.values_at i - 2, i - 1
      _loaded = false
      begin
        Kernel.const_get(workflow)
      rescue 
        if ! _loaded
          Workflow.require_workflow workflow 
          _loaded = true
          retry
        end
        raise $!
      end
      return parts[i-2..-1] * "/"
    rescue
      Log.exception $!
    end
  end

  false
end

Instance Method Details

#digest_strObject



33
34
35
36
37
38
39
# File 'lib/scout/workflow/path.rb', line 33

def digest_str
  if step_file = Path.step_file?(self)
    "Step file: #{step_file}"
  else
    original_digest_str
  end
end

#index(*args, **kwargs, &block) ⇒ Object



13
14
15
16
# File 'lib/scout/tsv/path.rb', line 13

def index(*args, **kwargs, &block)
  found = produce_and_find('tsv')
  TSV.index(found, *args, **kwargs, &block)
end

#original_digest_strObject



31
# File 'lib/scout/workflow/path.rb', line 31

alias original_digest_str digest_str

#tsv(*args, **kwargs, &block) ⇒ Object



2
3
4
5
# File 'lib/scout/tsv/path.rb', line 2

def tsv(*args, **kwargs, &block)
  found = produce_and_find('tsv')
  TSV.open(found, *args, **kwargs, &block)
end

#tsv_options(options = {}) ⇒ Object



7
8
9
10
11
# File 'lib/scout/tsv/path.rb', line 7

def tsv_options(options = {})
  self.open do |stream|
    TSV::Parser.new(stream, **options).options
  end
end