Class: Rub2::JobScript

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ JobScript

Returns a new instance of JobScript.



28
29
30
31
32
33
# File 'lib/rub2.rb', line 28

def initialize(name)
  @name = name
  @shell = '/bin/bash'
  @log_path = make_default_log_path(name)
  @uri = nil
end

Instance Attribute Details

#array_requestObject

Returns the value of attribute array_request.



17
18
19
# File 'lib/rub2.rb', line 17

def array_request
  @array_request
end

#commandsObject

Returns the value of attribute commands.



17
18
19
# File 'lib/rub2.rb', line 17

def commands
  @commands
end

#inherit_environmentObject

Returns the value of attribute inherit_environment.



17
18
19
# File 'lib/rub2.rb', line 17

def inherit_environment
  @inherit_environment
end

#logObject

Returns the value of attribute log.



17
18
19
# File 'lib/rub2.rb', line 17

def log
  @log
end

#log_pathObject

Returns the value of attribute log_path.



17
18
19
# File 'lib/rub2.rb', line 17

def log_path
  @log_path
end

#nameObject (readonly)

Returns the value of attribute name.



26
27
28
# File 'lib/rub2.rb', line 26

def name
  @name
end

#queueObject

Returns the value of attribute queue.



17
18
19
# File 'lib/rub2.rb', line 17

def queue
  @queue
end

#resourceObject

Returns the value of attribute resource.



17
18
19
# File 'lib/rub2.rb', line 17

def resource
  @resource
end

#shellObject

Returns the value of attribute shell.



17
18
19
# File 'lib/rub2.rb', line 17

def shell
  @shell
end

#sourceObject (readonly)

Returns the value of attribute source.



26
27
28
# File 'lib/rub2.rb', line 26

def source
  @source
end

#uriObject

Returns the value of attribute uri.



17
18
19
# File 'lib/rub2.rb', line 17

def uri
  @uri
end

Instance Method Details

#buildObject



35
36
37
# File 'lib/rub2.rb', line 35

def build
  @source = ERB.new(ScriptTemplate, nil, '-').result(binding)
end

#make_array_request_stringObject

Range (1..100) or Array [1,10,50] -> ‘-t 1-100’ or -t ‘1,10,50’



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rub2.rb', line 40

def make_array_request_string
  @array_request = (1..@commands.size) if @array_request.nil?
  limit = ''
  unless @slot_limit.nil?
    limit = "%#{@slot_limit}"
  end

  if @array_request.kind_of?(Range)
    last = nil
    if @array_request.exclude_end?
      last = @array_request.last - 1
    else
      last = @array_request.last
    end
    return sprintf("%d-%d%s", @array_request.first, last, limit)
  end
  return @array_request.sort.join(',') + limit
end