optimus-ep 0.6.9 → 0.6.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.6.9.1 3/10/2008
2
+ * Bug fix:
3
+ * Fix for parsing eprime log files in which leaf frames don't occur at the
4
+ highest log level
5
+
1
6
  == 0.6.9 2/25/2008
2
7
  * New features:
3
8
  * Supports parsing raw tab-delmimted files
@@ -25,7 +25,6 @@ module Eprime
25
25
 
26
26
  attr_reader :frames
27
27
  attr_reader :levels
28
- attr_reader :top_level
29
28
  # Valid things for the options hash:
30
29
  # :columns => an array of strings, predefining the expected columns
31
30
  # (and their order)
@@ -37,8 +36,6 @@ module Eprime
37
36
  @force = options[:force]
38
37
  @file = file
39
38
  @levels = [''] # The 0 index should be blank.
40
- @top_level = 0 # This is the level of the frame that'll
41
- # generate output rows
42
39
  @found_cols = ColumnList.new()
43
40
  end
44
41
 
@@ -60,7 +57,7 @@ module Eprime
60
57
 
61
58
  @columns ||= @found_cols.names
62
59
  data = Eprime::Data.new(@columns)
63
- self.top_frames.each do |frame|
60
+ self.leaf_frames.each do |frame|
64
61
  row = data.add_row
65
62
  @found_cols.names_with_cols.each do |pair|
66
63
  name, col = *pair
@@ -71,8 +68,8 @@ module Eprime
71
68
  return data
72
69
  end
73
70
 
74
- def top_frames
75
- return frames.find_all { |frame| frame.level == @top_level }
71
+ def leaf_frames
72
+ return frames.find_all { |frame| frame.leaf? }
76
73
  end
77
74
 
78
75
  # Define this as a column we *should not* include in out output.
@@ -102,7 +99,6 @@ module Eprime
102
99
  if !in_frame
103
100
  if key == LEVEL_KEY
104
101
  frame.level = val.to_i
105
- @top_level = frame.level if frame.level > @top_level
106
102
  elsif key == FRAME_START
107
103
  in_frame = true
108
104
  end
@@ -166,6 +162,8 @@ module Eprime
166
162
  def set_parents!
167
163
  parents = []
168
164
  @frames.reverse_each do |frame|
165
+ child = parents[frame.level-1]
166
+
169
167
  parents[frame.level] = frame
170
168
  frame.parent = parents[frame.level-1] # This will be nil for empty slots.
171
169
  end
@@ -176,13 +174,29 @@ module Eprime
176
174
 
177
175
  attr_accessor :level
178
176
  attr_accessor :parent
177
+ attr_accessor :children
179
178
  def initialize(parser)
180
179
  @level = nil
181
180
  @parent = nil
181
+ @children = []
182
182
  @data = Hash.new
183
183
  @parser = parser
184
184
  end
185
185
 
186
+ def parent=(new_parent)
187
+ if @parent
188
+ if new_parent != @parent
189
+ @parent.children.delete(self)
190
+ end
191
+ end
192
+ @parent = new_parent
193
+ @parent.children << self if @parent
194
+ end
195
+
196
+ def leaf?
197
+ @children.empty?
198
+ end
199
+
186
200
  # Methods to make this behave hashlike. Don't just delegate to
187
201
  # the @data hash; that's less clear.
188
202
  def [](key)
data/lib/version.rb CHANGED
@@ -2,7 +2,7 @@ module Eprime
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 6
5
- TINY = 9
5
+ TINY = 91
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -27,16 +27,16 @@ describe Eprime::Reader::LogfileParser do
27
27
  @reader.frames.detect{ |c| c.keys.size == 0}.should be_nil
28
28
  end
29
29
 
30
- it "should have a level 3 frame at the start" do
31
- @reader.frames.first.level.should == 3
30
+ it "should have a level 2 frame at the start" do
31
+ @reader.frames.first.level.should == 2
32
32
  end
33
33
 
34
34
  it "should have a level 1 frame at the end" do
35
35
  @reader.frames.last.level.should == 1
36
36
  end
37
37
 
38
- it "should have a known TypeA key in first frame" do
39
- @reader.frames.first["TypeA"].should_not be_nil
38
+ it "should have a known BlockTitle key in first frame" do
39
+ @reader.frames.first["BlockTitle"].should_not be_nil
40
40
  end
41
41
 
42
42
  it "should not have a known Gibberish key in first frame" do
@@ -55,12 +55,8 @@ describe Eprime::Reader::LogfileParser do
55
55
  @reader.levels.should include("Session")
56
56
  end
57
57
 
58
- it "should find a top_level of 3" do
59
- @reader.top_level.should == 3
60
- end
61
-
62
- it "should have three top frames" do
63
- @reader.top_frames.length.should == 3
58
+ it "should have four leaves" do
59
+ @reader.leaf_frames.length.should == 4
64
60
  end
65
61
 
66
62
  it "should have a parent in the first frame" do
@@ -72,8 +68,8 @@ describe Eprime::Reader::LogfileParser do
72
68
  @eprime = @reader.to_eprime
73
69
  end
74
70
 
75
- it "should generate three rows from the example file" do
76
- @eprime.length.should == 3
71
+ it "should generate four rows from the example file" do
72
+ @eprime.length.should == 4
77
73
  end
78
74
 
79
75
  it "should follow the column order in the example file" do
@@ -105,7 +101,7 @@ describe Eprime::Reader::LogfileParser do
105
101
 
106
102
  it "should compute task counters" do
107
103
  @eprime.first["Block"].should == 1
108
- @eprime.last["Block"].should == 2
104
+ @eprime.last["Block"].should == 3
109
105
  @eprime.last["Trial"].should == 2
110
106
  end
111
107
 
@@ -131,8 +127,8 @@ describe Eprime::Reader::LogfileParser do
131
127
  @eprime.columns.first.should == "ExperimentName"
132
128
  end
133
129
 
134
- it "should have three rows" do
135
- @eprime.length.should == 3
130
+ it "should have four rows" do
131
+ @eprime.length.should == 4
136
132
  end
137
133
 
138
134
 
@@ -19,20 +19,13 @@ Subject: 1
19
19
  Session: 1
20
20
  Display.RefreshRate: 60.000
21
21
  *** Header End ***
22
- Level: 3
23
- *** LogFrame Start ***
24
- BlockList: 1
25
- TypeA: Danger
26
- TypeB: 2
27
- Procedure: RunTrial
28
- BlockList.Cycle: 1
29
- BlockList.Sample: 1
30
- Running: TestList
31
- StartTime: 5000
32
- Stim1.OnsetTime: 88684
33
- Stim1.OffsetTime: 93583
34
- CarriedVal: TrialLevel
35
- *** LogFrame End ***
22
+ Level: 2
23
+ *** LogFrame Start ***
24
+ Procedure: Prep
25
+ Running: prepProc
26
+ CarriedVal: BlockLevel
27
+ BlockTitle: Prep
28
+ *** LogFrame End ***
36
29
  Level: 2
37
30
  *** LogFrame Start ***
38
31
  BlockTitle: My Task
data/spec/spec_helper.rb CHANGED
@@ -6,6 +6,30 @@
6
6
  # Imaging and Behavior, University of Wisconsin - Madison
7
7
 
8
8
  module EprimeTestHelper
9
+
10
+ class RoundTrip
11
+ def initialize(expected)
12
+ @expected = expected
13
+ end
14
+
15
+ def matches?(target)
16
+ @parsed = target.parse(@expected).to_s
17
+ @parsed == @expected
18
+ end
19
+
20
+ def failure_message
21
+ "expected #{@parsed} to parse to #{@expected}"
22
+ end
23
+
24
+ def negative_failure_message
25
+ "Expected #{@parsed} to not parse to #{@expected}"
26
+ end
27
+ end
28
+
29
+ def round_trip(expected)
30
+ RoundTrip.new(expected)
31
+ end
32
+
9
33
  unless constants.include?('SAMPLE_DIR')
10
34
  SAMPLE_DIR = File.join(File.dirname(__FILE__), 'samples')
11
35
  LOG_FILE = File.join(SAMPLE_DIR, 'optimus_log.txt')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optimus-ep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.9
4
+ version: 0.6.91
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Vack
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-25 00:00:00 -06:00
12
+ date: 2009-03-10 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency