optimus-ep 0.6.91 → 0.8.0

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.
Files changed (60) hide show
  1. data/CHANGELOG +13 -0
  2. data/{License.txt → LICENSE} +1 -1
  3. data/{Manifest.txt → Manifest} +23 -11
  4. data/{README.txt → README} +1 -1
  5. data/Rakefile +9 -10
  6. data/autotest/discover.rb +1 -0
  7. data/bin/eprime2tabfile +10 -10
  8. data/bin/extract_timings +4 -4
  9. data/lib/eprimetab_parser.rb +3 -3
  10. data/lib/excel_parser.rb +2 -2
  11. data/lib/expression_parser/evaluators.rb +188 -0
  12. data/lib/expression_parser/expressions.rb +173 -0
  13. data/lib/log_file_parser.rb +9 -9
  14. data/lib/optimus.rb +30 -0
  15. data/lib/{eprime_data.rb → optimus_data.rb} +12 -29
  16. data/lib/{eprime_reader.rb → optimus_reader.rb} +27 -13
  17. data/lib/parsed_calculator.rb +92 -0
  18. data/lib/raw_tab_parser.rb +3 -3
  19. data/lib/runners/generic_runner.rb +7 -7
  20. data/lib/runners/yaml_template/option_parser.rb +33 -0
  21. data/lib/runners/yaml_template/runner.rb +19 -0
  22. data/lib/tabfile_parser.rb +6 -6
  23. data/lib/tabfile_writer.rb +7 -7
  24. data/lib/transformers/basic_transformer.rb +35 -24
  25. data/lib/transformers/column_calculator.rb +131 -326
  26. data/lib/transformers/multipasser.rb +10 -6
  27. data/lib/transformers/row_filter.rb +7 -12
  28. data/lib/transformers/timing_extractor.rb +3 -3
  29. data/lib/version.rb +3 -3
  30. data/lib/writers/stimtimes_writer.rb +6 -6
  31. data/optimus-ep.gemspec +37 -0
  32. data/spec/eprimetab_parser_spec.rb +7 -7
  33. data/spec/excel_parser_spec.rb +6 -6
  34. data/spec/expression_parser/evaluators_spec.rb +241 -0
  35. data/spec/expression_parser/expressions_spec.rb +119 -0
  36. data/spec/log_file_parser_spec.rb +30 -30
  37. data/spec/{eprime_data_spec.rb → optimus_data_spec.rb} +20 -20
  38. data/spec/{eprime_reader_spec.rb → optimus_reader_spec.rb} +36 -24
  39. data/spec/parsed_calculator_spec.rb +112 -0
  40. data/spec/raw_tab_parser_spec.rb +26 -0
  41. data/spec/runners/generic_runner_spec.rb +5 -12
  42. data/spec/runners/yaml_template/option_parser_spec.rb +25 -0
  43. data/spec/runners/yaml_template/runner_spec.rb +20 -0
  44. data/spec/samples/optimus_log.txt +103 -103
  45. data/spec/samples/optimus_log_utf16le.txt +0 -0
  46. data/spec/samples/raw_tsv.txt +4 -0
  47. data/spec/spec_helper.rb +75 -12
  48. data/spec/tabfile_parser_spec.rb +18 -18
  49. data/spec/tabfile_writer_spec.rb +12 -12
  50. data/spec/transformers/basic_transformer_spec.rb +18 -8
  51. data/spec/transformers/column_calculator_spec.rb +109 -364
  52. data/spec/transformers/multipasser_spec.rb +14 -7
  53. data/spec/transformers/row_filter_spec.rb +11 -6
  54. data/spec/transformers/timing_extractor_spec.rb +8 -8
  55. data/spec/writers/stimtimes_writer_spec.rb +3 -3
  56. metadata +103 -50
  57. data/History.txt +0 -45
  58. data/lib/calculator.rb +0 -51
  59. data/lib/eprime.rb +0 -24
  60. data/spec/calculator_spec.rb +0 -70
@@ -1,6 +1,6 @@
1
1
  # Part of the Optimus package for managing E-Prime data
2
2
  #
3
- # Copyright (C) 2008 Board of Regents of the University of Wisconsin System
3
+ # Copyright (C) 2008-09 Board of Regents of the University of Wisconsin System
4
4
  #
5
5
  # Written by Nathan Vack <njvack@wisc.edu>, at the Waisman Laborotory for Brain
6
6
  # Imaging and Behavior, University of Wisconsin - Madison
@@ -8,11 +8,11 @@
8
8
  # This class is a bit ugly around the edges -- I'm not quite sure how to
9
9
  # architect it, yet.
10
10
 
11
- require 'eprime'
11
+ require 'optimus'
12
12
  require 'transformers/column_calculator'
13
13
  require 'transformers/row_filter'
14
14
 
15
- module Eprime
15
+ module Optimus
16
16
  class StimtimesWriter
17
17
  include Transformers
18
18
 
@@ -25,11 +25,11 @@ module Eprime
25
25
 
26
26
  def initialize(argv)
27
27
  # Look through our necessary class variables and do some odd stuff
28
- edata = Eprime::Data.new
28
+ edata = Optimus::Data.new
29
29
  argv.each do |filename|
30
30
  File.open(filename, 'r') do |f|
31
- reader = Eprime::Reader.new(f)
32
- edata.merge!(reader.eprime_data)
31
+ reader = Optimus::Reader.new(f)
32
+ edata.merge!(reader.optimus_data)
33
33
  end
34
34
 
35
35
  @calc = ColumnCalculator.new
@@ -0,0 +1,37 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{optimus-ep}
5
+ s.version = "0.8.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Nate Vack"]
9
+ s.date = %q{2010-11-01}
10
+ s.description = %q{Utilities to process behavioral data generated by E-Prime}
11
+ s.email = %q{njvack@wisc.edu}
12
+ s.executables = ["eprime2tabfile", "extract_timings"]
13
+ s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "bin/eprime2tabfile", "bin/extract_timings", "lib/eprimetab_parser.rb", "lib/excel_parser.rb", "lib/expression_parser/evaluators.rb", "lib/expression_parser/expressions.rb", "lib/log_file_parser.rb", "lib/optimus.rb", "lib/optimus_data.rb", "lib/optimus_reader.rb", "lib/parsed_calculator.rb", "lib/raw_tab_parser.rb", "lib/runners/generic_runner.rb", "lib/runners/yaml_template/option_parser.rb", "lib/runners/yaml_template/runner.rb", "lib/tabfile_parser.rb", "lib/tabfile_writer.rb", "lib/transformers/basic_transformer.rb", "lib/transformers/column_calculator.rb", "lib/transformers/multipasser.rb", "lib/transformers/row_filter.rb", "lib/transformers/timing_extractor.rb", "lib/version.rb", "lib/writers/stimtimes_writer.rb"]
14
+ s.files = ["CHANGELOG", "GPL.txt", "LICENSE", "Manifest", "README", "Rakefile", "autotest/discover.rb", "bin/eprime2tabfile", "bin/extract_timings", "lib/eprimetab_parser.rb", "lib/excel_parser.rb", "lib/expression_parser/evaluators.rb", "lib/expression_parser/expressions.rb", "lib/log_file_parser.rb", "lib/optimus.rb", "lib/optimus_data.rb", "lib/optimus_reader.rb", "lib/parsed_calculator.rb", "lib/raw_tab_parser.rb", "lib/runners/generic_runner.rb", "lib/runners/yaml_template/option_parser.rb", "lib/runners/yaml_template/runner.rb", "lib/tabfile_parser.rb", "lib/tabfile_writer.rb", "lib/transformers/basic_transformer.rb", "lib/transformers/column_calculator.rb", "lib/transformers/multipasser.rb", "lib/transformers/row_filter.rb", "lib/transformers/timing_extractor.rb", "lib/version.rb", "lib/writers/stimtimes_writer.rb", "spec/eprimetab_parser_spec.rb", "spec/excel_parser_spec.rb", "spec/expression_parser/evaluators_spec.rb", "spec/expression_parser/expressions_spec.rb", "spec/log_file_parser_spec.rb", "spec/optimus_data_spec.rb", "spec/optimus_reader_spec.rb", "spec/parsed_calculator_spec.rb", "spec/raw_tab_parser_spec.rb", "spec/runners/generic_runner_spec.rb", "spec/runners/yaml_template/option_parser_spec.rb", "spec/runners/yaml_template/runner_spec.rb", "spec/samples/bad_excel_tsv.txt", "spec/samples/corrupt_log_file.txt", "spec/samples/eprime_tsv.txt", "spec/samples/excel_tsv.txt", "spec/samples/optimus_log.txt", "spec/samples/optimus_log_utf16le.txt", "spec/samples/raw_tsv.txt", "spec/samples/short_columns.txt", "spec/samples/sorted_columns.txt", "spec/samples/std_columns.txt", "spec/samples/unknown_type.txt", "spec/samples/unreadable_file", "spec/spec_helper.rb", "spec/tabfile_parser_spec.rb", "spec/tabfile_writer_spec.rb", "spec/transformers/basic_transformer_spec.rb", "spec/transformers/column_calculator_spec.rb", "spec/transformers/multipasser_spec.rb", "spec/transformers/row_filter_spec.rb", "spec/transformers/timing_extractor_spec.rb", "spec/writers/stimtimes_writer_spec.rb", "optimus-ep.gemspec"]
15
+ s.homepage = %q{http://github.com/njvack/optimus-ep}
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Optimus-ep", "--main", "README"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{optimus-ep}
19
+ s.rubygems_version = %q{1.3.7}
20
+ s.summary = %q{Utilities to process behavioral data generated by E-Prime}
21
+
22
+ if s.respond_to? :specification_version then
23
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
+ s.specification_version = 3
25
+
26
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
+ s.add_runtime_dependency(%q<rparsec>, [">= 1.0"])
28
+ s.add_development_dependency(%q<rspec>, [">= 0"])
29
+ else
30
+ s.add_dependency(%q<rparsec>, [">= 1.0"])
31
+ s.add_dependency(%q<rspec>, [">= 0"])
32
+ end
33
+ else
34
+ s.add_dependency(%q<rparsec>, [">= 1.0"])
35
+ s.add_dependency(%q<rspec>, [">= 0"])
36
+ end
37
+ end
@@ -1,23 +1,23 @@
1
1
  # Part of the Optimus package for managing E-Prime data
2
2
  #
3
- # Copyright (C) 2008 Board of Regents of the University of Wisconsin System
3
+ # Copyright (C) 2008-09 Board of Regents of the University of Wisconsin System
4
4
  #
5
5
  # Written by Nathan Vack <njvack@wisc.edu>, at the Waisman Laborotory for Brain
6
6
  # Imaging and Behavior, University of Wisconsin - Madison
7
7
 
8
8
  require File.join(File.dirname(__FILE__),'spec_helper')
9
- require File.join(File.dirname(__FILE__), '../lib/eprime')
10
- include EprimeTestHelper
9
+ require File.join(File.dirname(__FILE__), '../lib/optimus')
10
+ include OptimusTestHelper
11
11
 
12
- describe Eprime::Reader::EprimetabParser do
12
+ describe Optimus::Reader::OptimustabParser do
13
13
  before :each do
14
14
  @file = File.open(EPRIME_FILE, 'r')
15
- @reader = Eprime::Reader::EprimetabParser.new(@file)
15
+ @reader = Optimus::Reader::OptimustabParser.new(@file)
16
16
  end
17
17
 
18
- it "should read the sample eprime file" do
18
+ it "should read the sample optimus file" do
19
19
  lambda {
20
- @reader.to_eprime
20
+ @reader.to_optimus
21
21
  }.should_not raise_error
22
22
  end
23
23
  end
@@ -1,26 +1,26 @@
1
1
  # Part of the Optimus package for managing E-Prime data
2
2
  #
3
- # Copyright (C) 2008 Board of Regents of the University of Wisconsin System
3
+ # Copyright (C) 2008-09 Board of Regents of the University of Wisconsin System
4
4
  #
5
5
  # Written by Nathan Vack <njvack@wisc.edu>, at the Waisman Laborotory for Brain
6
6
  # Imaging and Behavior, University of Wisconsin - Madison
7
7
 
8
8
  require File.join(File.dirname(__FILE__),'spec_helper')
9
- require File.join(File.dirname(__FILE__), '../lib/eprime')
10
- include EprimeTestHelper
9
+ require File.join(File.dirname(__FILE__), '../lib/optimus')
10
+ include OptimusTestHelper
11
11
 
12
- describe Eprime::Reader::ExcelParser do
12
+ describe Optimus::Reader::ExcelParser do
13
13
 
14
14
  # We don't need to do much here; the superclass handles almost everything
15
15
 
16
16
  before :each do
17
17
  @file = File.open(EXCEL_FILE, 'r')
18
- @reader = Eprime::Reader::ExcelParser.new(@file)
18
+ @reader = Optimus::Reader::ExcelParser.new(@file)
19
19
  end
20
20
 
21
21
  it "should read the sample excel file" do
22
22
  lambda {
23
- @reader.to_eprime
23
+ @reader.to_optimus
24
24
  }.should_not raise_error
25
25
  end
26
26
  end
@@ -0,0 +1,241 @@
1
+ # Part of the Optimus package for managing E-Prime data
2
+ #
3
+ # Copyright (C) 2008-09 Board of Regents of the University of Wisconsin System
4
+ #
5
+ # Written by Nathan Vack <njvack@wisc.edu>, at the Waisman Laborotory for Brain
6
+ # Imaging and Behavior, University of Wisconsin - Madison
7
+
8
+ require File.join(File.dirname(__FILE__),'../spec_helper')
9
+ require File.join(File.dirname(__FILE__), '../../lib/optimus')
10
+
11
+ require 'parsed_calculator'
12
+ require 'expression_parser/evaluators'
13
+ include OptimusTestHelper
14
+ include Optimus::ParsedCalculator::Evaluators
15
+
16
+ describe Prefix do
17
+ describe 'negation' do
18
+ before :all do
19
+ @neg = Prefix::Neg
20
+ end
21
+
22
+ it "should negate numbers" do
23
+ @neg.call(1).should == -1
24
+ end
25
+
26
+ it "should return NaN when negating non-numbers" do
27
+ @neg.call("a").should be_nan
28
+ end
29
+ end
30
+
31
+ describe 'boolean not' do
32
+ before :all do
33
+ @not = Prefix::Not
34
+ end
35
+
36
+ it "should work with booleans" do
37
+ @not.call(true).should be_false
38
+ @not.call(false).should be_true
39
+ end
40
+
41
+ it "should work with numbers" do
42
+ @not.call(1).should be_false
43
+ @not.call(0.0).should be_false
44
+ end
45
+
46
+ it "should work with strings" do
47
+ @not.call("1").should be_false
48
+ @not.call("").should be_true
49
+ end
50
+ end
51
+ end
52
+
53
+ describe Binary do
54
+ describe 'addition' do
55
+ before :all do
56
+ @plus = Binary::Plus
57
+ end
58
+
59
+ it "should add numbers" do
60
+ @plus.call(1, 1).should == 2
61
+ end
62
+
63
+ it "should return NaN when adding non-numbers" do
64
+ @plus.call(1, 'a').should be_nan
65
+ end
66
+ end
67
+
68
+ describe 'subtraction' do
69
+ before :all do
70
+ @minus = Binary::Minus
71
+ end
72
+
73
+ it "should subtract numbers" do
74
+ @minus.call(2, 1).should == 1
75
+ end
76
+
77
+ it "should return NaN when subtracting non-numbers" do
78
+ @minus.call(2, 'a').should be_nan
79
+ end
80
+ end
81
+
82
+ describe 'multiplication' do
83
+ before :all do
84
+ @times = Binary::Times
85
+ end
86
+
87
+ it "should multiply numbers" do
88
+ @times.call(2, 2).should == 4
89
+ end
90
+
91
+ it "should return NaN when multiplying non-numbers" do
92
+ @times.call(2, 'a').should be_nan
93
+ end
94
+ end
95
+
96
+ describe 'division' do
97
+ before :all do
98
+ @div = Binary::Div
99
+ end
100
+
101
+ it "should divide numbers" do
102
+ @div.call(4, 2).should == 2
103
+ end
104
+
105
+ it "should return NaN when dividing non-numbers" do
106
+ @div.call(2, 'a').should be_nan
107
+ end
108
+
109
+ it "should perform floating point division" do
110
+ res = 1.0/3.0
111
+ @div.call(1,3).should == res
112
+ end
113
+
114
+ it "should return NaN when dividing by 0" do
115
+ @div.call(2,0).should be_nan
116
+ end
117
+ end
118
+
119
+ describe 'concatenation' do
120
+ before :all do
121
+ @cat = Binary::Concat
122
+ end
123
+
124
+ it "should concatenate strings" do
125
+ @cat.call("foo", "bar").should == "foobar"
126
+ end
127
+
128
+ it "should concatenate numbers" do
129
+ @cat.call("foo", 2).should == "foo2"
130
+ end
131
+
132
+ it "should concatenate nil" do
133
+ @cat.call("foo", nil).should == "foo"
134
+ end
135
+ end
136
+
137
+ describe "modulo" do
138
+ before :all do
139
+ @mod = Binary::Mod
140
+ end
141
+
142
+ it "should mod ints" do
143
+ @mod.call(5, 3).should == 2
144
+ end
145
+
146
+ it "should not mod strings" do
147
+ @mod.call(5, 'a').should be_nan
148
+ end
149
+ end
150
+
151
+ describe "and" do
152
+ before :all do
153
+ @and = Binary::And
154
+ end
155
+
156
+ it "should work with booleans" do
157
+ @and.call(true, true).should be_true
158
+ @and.call(false, true).should be_false
159
+ @and.call(false, false).should be_false
160
+ end
161
+
162
+ it "should consider all numbers true" do
163
+ @and.call(0.0, 1).should be_true
164
+ end
165
+
166
+ it "should consider blanks to be false" do
167
+ @and.call('', true).should be_false
168
+ end
169
+ end
170
+
171
+ describe "or" do
172
+ before :all do
173
+ @or = Binary::Or
174
+ end
175
+
176
+ it "should work with booleans" do
177
+ @or.call(true, true).should be_true
178
+ @or.call(true, false).should be_true
179
+ @or.call(false, false).should be_false
180
+ end
181
+
182
+ it "should consider numbers true" do
183
+ @or.call(0.0, 0.0).should be_true
184
+ end
185
+
186
+ it "should consider blanks false" do
187
+ @or.call('', '').should be_false
188
+ end
189
+ end
190
+
191
+ describe "comparisons" do
192
+ nan = 0.0/0.0
193
+ # We're just gonna loop through this table and check...
194
+ comp_table = Binary::OpTable
195
+ comp_ops = %w(= != > < >= <=)
196
+ test_table = {
197
+ :equal_nums =>
198
+ {:lr => [1,1], :true_for => %w(= >= <=), :false_for => %w(!= > <)},
199
+ :equal_strs =>
200
+ {:lr => %w(a a), :true_for => %w(= >= <=), :false_for => %w(!= > <)},
201
+ :equal_num_strnum =>
202
+ {:lr => [1,'1'], :true_for => %w(= >= <=), :false_for => %w(!= > <)},
203
+ :neq_str_num =>
204
+ {:lr => [1, 'a'], :true_for => %w(!=), :false_for => %w(= > < >= <=)},
205
+ :lt_nums =>
206
+ {:lr => [1,2], :true_for => %w(!= < <=), :false_for => %w(= > >=)},
207
+ :lt_num_strnum =>
208
+ {:lr => [1,'2'], :true_for => %w(!= < <=), :false_for => %w(= > >=)},
209
+ :lt_str =>
210
+ {:lr => %w(a b), :true_for => %w(!= < <=), :false_for => %w(= > >=)},
211
+ :gt_nums =>
212
+ {:lr => [2,1], :true_for => %w(!= > >=), :false_for => %w(= < <=)},
213
+ :gt_num_strnum =>
214
+ {:lr => ['2',1], :true_for => %w(!= > >=), :false_for => %w(= < <=)},
215
+ :gt_str =>
216
+ {:lr => %w(b a), :true_for => %w(!= > >=), :false_for => %w(= < <=)},
217
+ :nans =>
218
+ {:lr => [nan,nan], :true_for => %w(!=), :false_for => %w(= > < >= <=)},
219
+ }
220
+
221
+ test_table.each do |name, test_data|
222
+ true_tests = test_data[:true_for]
223
+ false_tests = test_data[:false_for]
224
+ describe "between #{test_data[:lr].inspect}" do
225
+ it "should test all comparisons" do
226
+ (true_tests+false_tests).sort.should == comp_ops.sort
227
+ end
228
+ true_tests.each do |test_name|
229
+ it "should be true for #{test_name}" do
230
+ comp_table[test_name.to_sym].call(*test_data[:lr]).should be_true
231
+ end
232
+ end
233
+ false_tests.each do |test_name|
234
+ it "should be false for #{test_name}" do
235
+ comp_table[test_name.to_sym].call(*test_data[:lr]).should be_false
236
+ end
237
+ end
238
+ end # describe
239
+ end# table.each
240
+ end
241
+ end
@@ -0,0 +1,119 @@
1
+ # Part of the Optimus package for managing E-Prime data
2
+ #
3
+ # Copyright (C) 2008-09 Board of Regents of the University of Wisconsin System
4
+ #
5
+ # Written by Nathan Vack <njvack@wisc.edu>, at the Waisman Laborotory for Brain
6
+ # Imaging and Behavior, University of Wisconsin - Madison
7
+
8
+ require File.join(File.dirname(__FILE__),'../spec_helper')
9
+ require File.join(File.dirname(__FILE__), '../../lib/optimus')
10
+ require 'parsed_calculator'
11
+
12
+ include OptimusTestHelper
13
+
14
+ NaN = 0.0/0.0
15
+
16
+ describe Optimus::ParsedCalculator::ExpressionParser do
17
+ before :all do
18
+ @exp = Optimus::ParsedCalculator::ExpressionParser.new
19
+ end
20
+
21
+ describe "number literals" do
22
+ it "should evaluate number literals" do
23
+ nl = @exp.parse("1")
24
+ nl.should evaluate_to(1)
25
+ end
26
+
27
+ it "should booleanify number literals" do
28
+ nl = @exp.parse("1")
29
+ nl.to_bool.should be_true
30
+ end
31
+ end
32
+
33
+ describe "string literals" do
34
+ it "should evaluate string literals" do
35
+ sl = @exp.parse("'foo'")
36
+ sl.should evaluate_to("foo")
37
+ end
38
+
39
+ it "should interpret full strings as true" do
40
+ sl = @exp.parse("'foo'")
41
+ sl.to_bool.should be_true
42
+ end
43
+ end
44
+
45
+ describe "prefix expressions" do
46
+ it "should negate numbers" do
47
+ px = @exp.parse("-1")
48
+ px.should evaluate_to(-1)
49
+ end
50
+
51
+ it "should return NaN when negating strings" do
52
+ px = @exp.parse("-'a'")
53
+ px.should evaluate_to(NaN)
54
+ end
55
+
56
+ it "should reverse things with not" do
57
+ px = @exp.parse("not 1")
58
+ px.should evaluate_to(false)
59
+ px.to_bool.should be_false
60
+ end
61
+ end
62
+
63
+ describe "binary expressions" do
64
+ it "should add numbers" do
65
+ bx = @exp.parse("1+1")
66
+ bx.should evaluate_to(2)
67
+ end
68
+
69
+ it "should add numbers with grouping" do
70
+ bx = @exp.parse("(1+1)+1")
71
+ bx.should evaluate_to(3)
72
+ end
73
+
74
+ it "should not add strings" do
75
+ bx = @exp.parse("1+'a'")
76
+ bx.should evaluate_to(NaN)
77
+ end
78
+
79
+ it "should subtract numbers" do
80
+ bx = @exp.parse("2-1")
81
+ bx.should evaluate_to(1)
82
+ end
83
+
84
+ it "should not subtract strings" do
85
+ bx = @exp.parse("1-'a'")
86
+ bx.should evaluate_to(NaN)
87
+ end
88
+
89
+ it "should multiply numbers" do
90
+ bx = @exp.parse("2*2")
91
+ bx.should evaluate_to(4)
92
+ end
93
+
94
+ it "should divide numbers" do
95
+ bx = @exp.parse("4/2")
96
+ bx.should evaluate_to(2)
97
+ end
98
+
99
+ it "should concatenate strings" do
100
+ bx = @exp.parse("'foo' & 'bar'")
101
+ bx.should evaluate_to("foobar")
102
+ end
103
+
104
+ it "should mod numbers" do
105
+ bx = @exp.parse("5 % 3")
106
+ bx.should evaluate_to(2)
107
+ end
108
+
109
+ describe "comparisons" do
110
+ it "should understand equality exprs" do
111
+ bx = @exp.parse("1 = 1")
112
+ bx.should evaluate_to(true)
113
+ bx.to_bool.should be_true
114
+ end
115
+ end
116
+
117
+ end
118
+
119
+ end
@@ -1,21 +1,21 @@
1
1
  # Part of the Optimus package for managing E-Prime data
2
2
  #
3
- # Copyright (C) 2008 Board of Regents of the University of Wisconsin System
3
+ # Copyright (C) 2008-09 Board of Regents of the University of Wisconsin System
4
4
  #
5
5
  # Written by Nathan Vack <njvack@wisc.edu>, at the Waisman Laborotory for Brain
6
6
  # Imaging and Behavior, University of Wisconsin - Madison
7
7
 
8
8
  require File.join(File.dirname(__FILE__),'spec_helper')
9
- require File.join(File.dirname(__FILE__), '../lib/eprime')
10
- include EprimeTestHelper
9
+ require File.join(File.dirname(__FILE__), '../lib/optimus')
10
+ include OptimusTestHelper
11
11
 
12
12
 
13
13
 
14
- describe Eprime::Reader::LogfileParser do
14
+ describe Optimus::Reader::LogfileParser do
15
15
  describe "parsing a good file" do
16
16
  before :each do
17
17
  @file = File.open(LOG_FILE, 'r')
18
- @reader = Eprime::Reader::LogfileParser.new(@file)
18
+ @reader = Optimus::Reader::LogfileParser.new(@file)
19
19
  @reader.make_frames!
20
20
  end
21
21
 
@@ -63,50 +63,50 @@ describe Eprime::Reader::LogfileParser do
63
63
  @reader.frames.first.parent.should_not be_nil
64
64
  end
65
65
 
66
- describe "making eprime data" do
66
+ describe "making optimus data" do
67
67
  before :each do
68
- @eprime = @reader.to_eprime
68
+ @optimus = @reader.to_optimus
69
69
  end
70
70
 
71
71
  it "should generate four rows from the example file" do
72
- @eprime.length.should == 4
72
+ @optimus.length.should == 4
73
73
  end
74
74
 
75
75
  it "should follow the column order in the example file" do
76
- @eprime.columns[0].should == "ExperimentName"
77
- @eprime.columns[1].should == "SessionDate"
76
+ @optimus.columns[0].should == "ExperimentName"
77
+ @optimus.columns[1].should == "SessionDate"
78
78
  end
79
79
 
80
80
  it "should ignore extra colons in input data" do
81
- @eprime.first['SessionTime'].should == '11:11:11'
81
+ @optimus.first['SessionTime'].should == '11:11:11'
82
82
  end
83
83
 
84
84
  it "should append level name to ambiguous columns" do
85
- @eprime.columns.should include("CarriedVal[Session]")
85
+ @optimus.columns.should include("CarriedVal[Session]")
86
86
  end
87
87
 
88
88
  it "should not include ambiguous columns without level name" do
89
- @eprime.columns.should_not include("CarriedVal")
89
+ @optimus.columns.should_not include("CarriedVal")
90
90
  end
91
91
 
92
92
  it "should include columns from level 2 and level 1 frames" do
93
- @eprime.columns.should include("RandomSeed")
94
- @eprime.columns.should include("BlockTitle")
93
+ @optimus.columns.should include("RandomSeed")
94
+ @optimus.columns.should include("BlockTitle")
95
95
  end
96
96
 
97
97
  it "should rename Experiment to ExperimentName" do
98
- @eprime.columns.should include("ExperimentName")
99
- @eprime.columns.should_not include("Experiment")
98
+ @optimus.columns.should include("ExperimentName")
99
+ @optimus.columns.should_not include("Experiment")
100
100
  end
101
101
 
102
102
  it "should compute task counters" do
103
- @eprime.first["Block"].should == 1
104
- @eprime.last["Block"].should == 3
105
- @eprime.last["Trial"].should == 2
103
+ @optimus.first["Block"].should == 1
104
+ @optimus.last["Block"].should == 3
105
+ @optimus.last["Trial"].should == 2
106
106
  end
107
107
 
108
108
  it "should have a counter column" do
109
- @eprime.columns.should include("Trial")
109
+ @optimus.columns.should include("Trial")
110
110
  end
111
111
  end
112
112
  end
@@ -114,9 +114,9 @@ describe Eprime::Reader::LogfileParser do
114
114
  describe "with sorted columns" do
115
115
  before :each do
116
116
  @file = File.open(LOG_FILE, 'r')
117
- @reader = Eprime::Reader::LogfileParser.new(@file, :columns => STD_COLUMNS)
117
+ @reader = Optimus::Reader::LogfileParser.new(@file, :columns => STD_COLUMNS)
118
118
  @reader.make_frames!
119
- @eprime = @reader.to_eprime
119
+ @optimus = @reader.to_optimus
120
120
  end
121
121
 
122
122
  after :each do
@@ -124,11 +124,11 @@ describe Eprime::Reader::LogfileParser do
124
124
  end
125
125
 
126
126
  it "should have ExperimentName first" do
127
- @eprime.columns.first.should == "ExperimentName"
127
+ @optimus.columns.first.should == "ExperimentName"
128
128
  end
129
129
 
130
130
  it "should have four rows" do
131
- @eprime.length.should == 4
131
+ @optimus.length.should == 4
132
132
  end
133
133
 
134
134
 
@@ -137,7 +137,7 @@ describe Eprime::Reader::LogfileParser do
137
137
  describe "parsing bad files" do
138
138
  before :each do
139
139
  @file = File.open(CORRUPT_LOG_FILE, 'r')
140
- @reader = Eprime::Reader::LogfileParser.new(@file)
140
+ @reader = Optimus::Reader::LogfileParser.new(@file)
141
141
  end
142
142
  after :each do
143
143
  @file.close
@@ -145,18 +145,18 @@ describe Eprime::Reader::LogfileParser do
145
145
 
146
146
  it "should throw an error when the last frame is not closed" do
147
147
  lambda {@reader.make_frames!}.
148
- should raise_error(Eprime::DamagedFileError)
148
+ should raise_error(Optimus::DamagedFileError)
149
149
  end
150
150
 
151
151
  end
152
152
 
153
153
  end
154
154
 
155
- describe Eprime::Reader::LogfileParser::ColumnList do
155
+ describe Optimus::Reader::LogfileParser::ColumnList do
156
156
  before :each do
157
- @cklass = Eprime::Reader::LogfileParser::Column
157
+ @cklass = Optimus::Reader::LogfileParser::Column
158
158
  @levels = ['', 'Foo', 'Bar']
159
- @list = Eprime::Reader::LogfileParser::ColumnList.new(@levels)
159
+ @list = Optimus::Reader::LogfileParser::ColumnList.new(@levels)
160
160
  end
161
161
 
162
162
  it "should raise error when storing index 0" do