Class: DakeProtocol::Protocol

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

Direct Known Subclasses

AWK, Python, Rscript, Ruby, Shell

Constant Summary collapse

EXT_NAME =
''

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(step, analyzer, dake_db, dry_run) ⇒ Protocol

Returns a new instance of Protocol.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/dake/protocol.rb', line 5

def initialize(step, analyzer, dake_db, dry_run)
  @step = step
  @analyzer = analyzer
  @dake_db = dake_db
  date = DAKE_EXEC_TIME.strftime('%Y%m%d')
  time = DAKE_EXEC_TIME.strftime('%H_%M_%S')
  @exec_path = "#{@dake_db.database_path}/#{date}/#{time}_#{DAKE_EXEC_PID}"
  @script_stdout = "#{@exec_path}/step.#{@step.object_id}.out"
  @script_stderr = "#{@exec_path}/step.#{@step.object_id}.err"
  FileUtils.mkdir_p(@exec_path) if not dry_run and not File.exist? @exec_path
end

Instance Attribute Details

#exec_pathObject (readonly)

Returns the value of attribute exec_path.



4
5
6
# File 'lib/dake/protocol.rb', line 4

def exec_path
  @exec_path
end

#script_stderrObject (readonly)

Returns the value of attribute script_stderr.



4
5
6
# File 'lib/dake/protocol.rb', line 4

def script_stderr
  @script_stderr
end

#script_stdoutObject (readonly)

Returns the value of attribute script_stdout.



4
5
6
# File 'lib/dake/protocol.rb', line 4

def script_stdout
  @script_stdout
end

Instance Method Details

#create_scriptObject



21
22
23
24
25
26
# File 'lib/dake/protocol.rb', line 21

def create_script
  file = File.open(script_file, 'w')
  file.write @step.cmd_text
  file.close
  file
end

#execute_step(log = false) ⇒ Object



28
29
# File 'lib/dake/protocol.rb', line 28

def execute_step(log=false)
end

#script_fileObject



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

def script_file
  "#{@exec_path}/step.#{@step.object_id}.#{self.class::EXT_NAME}"
end