lib/runners/generic_runner.rb in optimus-ep-0.6.0 vs lib/runners/generic_runner.rb in optimus-ep-0.6.5
- old
+ new
@@ -3,23 +3,13 @@
# Copyright (C) 2008 Board of Regents of the University of Wisconsin System
#
# Written by Nathan Vack <njvack@wisc.edu>, at the Waisman Laborotory for Brain
# Imaging and Behavior, University of Wisconsin - Madison
-# A runner to take eprime data files, chew them through a pesudo-templater,
-# and produce delicious files for importing into other packages. They'll look
-# like:
#
-# presented onset offset
-# stim1 5992 6493
-# stim2 7294 7981
-#
# This class should handle argument processing, file I/O, and such.
-# TODO: Think up a clever way to make this handle arbitrary transformers
-# Probably this is possible by passing the class of the transformer to
-# this runner, and instance_eval()'ing the template file in its presence.
require 'eprime'
require 'eprime_reader'
require 'tabfile_writer'
require 'transformers/timing_extractor'
@@ -30,13 +20,15 @@
module Runners
class GenericRunner
include ::Eprime::Transformers
attr_accessor :out, :err
- def initialize(extractor_class, script_name, *args)
+ def initialize(extractor_class, *args)
@extractor_class = extractor_class
- @script_name = script_name
+ # caller() returns an array of 'filename:line' -- the last element
+ # should contain the name of the script that started this process
+ @script_name = File.basename(caller.last.split(':').first)
@out = STDOUT
@err = STDERR
@args = args
@data = nil
@timing_extractor = nil
@@ -49,14 +41,13 @@
extract_timings
write_timings
end
def read_data
- data = Eprime::Data.new
+ data = Eprime::Data.new()
@options.input_files.each do |infile|
File.open(infile) do |f|
- new_data = Eprime::Reader.new(f).eprime_data
- data.merge!(new_data)
+ data.merge!(Eprime::Reader.new(f).eprime_data)
end
end
@data = data
end
\ No newline at end of file