<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -4,6 +4,9 @@
 
 == rufus-decision - 1.1    not yet released
 
+- todo #25670 : :ruby_eval settable at table initialization
+- todo #25667 : :ignore_case, :through and :accumulate settable at table
+                initialization (instead of only in the csv table itself)
 - todo #25647 : now accepts horizontal and vertical decision tables
 - todo #25642 : introducing bin/rufus_decided -t table.csv -i input.csv
 - todo #25629 : implemented Rufus::Decision.transpose(a)</diff>
      <filename>CHANGELOG.txt</filename>
    </modified>
    <modified>
      <diff>@@ -29,16 +29,24 @@ USAGE = %{
 
   == options
 
-  -v, --version   : print the version of itog.rb and exits
-  -h, --help      : print this help text and exits
+  -v, --version     : print the version of itog.rb and exits
+  -h, --help        : print this help text and exits
 
-  -i, --input     : points to input file (mandatory)
-  -t, --table     : points to the decision table file (mandatory)
+  -i, --input       : points to input file (mandatory)
+  -t, --table       : points to the decision table file (mandatory)
 
-  -r, --ruby      : output as a Ruby hash representation instead of CSV
-  -j, --json      : output as a JSON hash representation instead of CSV
+  -r, --ruby        : output as a Ruby hash representation instead of CSV
+  -j, --json        : output as a JSON hash representation instead of CSV
 
-  -g, --goal      : points to an ideal target CSV file (decision table testing)
+  -T, --through     : don't stop at first match, run each row
+  -I, --ignore-case : ignore case when comparing values for row matching
+  -A, --accumulate  : use with -t, each time a new match is made for an 'out',
+                      values are not overriden but gathered in an array
+  -R, --ruby-eval   : allow evaluation of embedded ruby code (potentially 
+                      harmful)
+
+  -g, --goal        : points to an ideal target CSV file
+                      (decision table testing)
 
 }
 
@@ -70,7 +78,13 @@ end
 input = Rufus::Decision.csv_to_a(ipath)
 input = Rufus::Decision.transpose(input)
 
-table = Rufus::Decision::Table.new(tpath)
+params = {}
+params[:ignore_case] = opts['-I'] || opts['--ignore-case']
+params[:ruby_eval] = opts['-R'] || opts['--ruby-eval']
+params[:through] = opts['-T'] || opts['--through']
+params[:accumulate] = opts['-A'] || opts['--accumulate']
+
+table = Rufus::Decision::Table.new(tpath, params)
 
 goal = gpath ? Rufus::Decision.csv_to_a(gpath) : nil
 </diff>
      <filename>bin/rufus_decide</filename>
    </modified>
    <modified>
      <diff>@@ -238,11 +238,12 @@ module Decision
     # (of arrays), a File object. The CSV parser coming with Ruby will take
     # care of it and a DecisionTable instance will be built.
     #
-    def initialize (csv)
+    def initialize (csv, params={})
 
-      @first_match = true
-      @ignore_case = false
-      @accumulate = false
+      @first_match = (params[:through] != true)
+      @ignore_case = params[:ignore_case] || params[:ignorecase]
+      @accumulate = params[:accumulate]
+      @ruby_eval = params[:ruby_eval]
 
       @rows = Rufus::Decision.csv_to_a(csv)
 
@@ -255,7 +256,7 @@ module Decision
     #
     def transform (hash, options={})
 
-      transform!(hash.dup, options)
+      transform!(hash.dup)
     end
 
     # Passes the hash through the decision table and returns it,
@@ -264,7 +265,7 @@ module Decision
     def transform! (hash, options={})
 
       hash = Rufus::Decision::EvalHashFilter.new(hash) \
-        if options[:ruby_eval] == true
+        if @ruby_eval || options[:ruby_eval] == true
 
       @rows.each do |row|
         next unless matches?(row, hash)
@@ -285,17 +286,17 @@ module Decision
 
     private
 
+    # Returns true if the hash matches the in: values for this row
+    #
     def matches? (row, hash)
 
-      #return false if empty_row?(row)
-
-      @header.ins.each_with_index do |in_header, icol|
+      @header.ins.each_with_index do |in_header, x|
 
         in_header = &quot;${#{in_header}}&quot;
 
         value = Rufus::dsub(in_header, hash)
 
-        cell = row[icol]
+        cell = row[x]
 
         next if cell == nil || cell == ''
 </diff>
      <filename>lib/rufus/decision.rb</filename>
    </modified>
    <modified>
      <diff>@@ -193,36 +193,52 @@ cloudy,   ,     no
     assert_not_equal h0.object_id, h1.object_id
   end
 
-  CSV5 = %{
-through,ignorecase,,
-,,,
-in:fx, in:fy, out:fX, out:fY
-,,,
-a,   ,    true,
-,    a,   ,     true
-b,   ,    false,
-,    b,   ,     false
-}
 
-  def test_5
-
-    wi = {
-      &quot;fx&quot; =&gt; &quot;a&quot;,
-      &quot;fy&quot; =&gt; &quot;a&quot;
+  def test_through_and_ignorecase
+
+    table = %{
+      through,ignorecase,,
+      ,,,
+      in:fx, in:fy, out:fX, out:fY
+      ,,,
+      a,   ,    true,
+      ,    a,   ,     true
+      b,   ,    false,
+      ,    b,   ,     false
     }
-    do_test(CSV5, wi, {}, { &quot;fX&quot; =&gt; &quot;true&quot;, &quot;fY&quot; =&gt; &quot;true&quot; }, false)
 
-    wi = {
-      &quot;fx&quot; =&gt; &quot;a&quot;,
-      &quot;fy&quot; =&gt; &quot;b&quot;
-    }
-    do_test(CSV5, wi, {}, { &quot;fX&quot; =&gt; &quot;true&quot;, &quot;fY&quot; =&gt; &quot;false&quot; }, false)
+    wi = { 'fx' =&gt; 'a', 'fy' =&gt; 'a' }
+    do_test(table, wi, {}, { 'fX' =&gt; 'true', 'fY' =&gt; 'true' }, false)
 
-    wi = {
-      &quot;fx&quot; =&gt; &quot;A&quot;,
-      &quot;fy&quot; =&gt; &quot;b&quot;
+    wi = { 'fx' =&gt; 'a', 'fy' =&gt; 'b' }
+    do_test(table, wi, {}, { 'fX' =&gt; 'true', 'fY' =&gt; 'false' }, false)
+
+    wi = { 'fx' =&gt; 'A', 'fy' =&gt; 'b' }
+    do_test(table, wi, {}, { 'fX' =&gt; 'true', 'fY' =&gt; 'false' }, false)
+  end
+
+  def test_through_and_ignorecase_set_at_table_initialization
+
+    table = %{
+      in:fx, in:fy, out:fX, out:fY
+      ,,,
+      a,   ,    true,
+      ,    a,   ,     true
+      b,   ,    false,
+      ,    b,   ,     false
     }
-    do_test(CSV5, wi, {}, { &quot;fX&quot; =&gt; &quot;true&quot;, &quot;fY&quot; =&gt; &quot;false&quot; }, false)
+
+    table = Rufus::Decision::Table.new(
+      table, :through =&gt; true, :ignore_case =&gt; true)
+
+    wi = { 'fx' =&gt; 'a', 'fy' =&gt; 'a' }
+    do_test(table, wi, {}, { 'fX' =&gt; 'true', 'fY' =&gt; 'true' }, false)
+
+    wi = { 'fx' =&gt; 'a', 'fy' =&gt; 'b' }
+    do_test(table, wi, {}, { 'fX' =&gt; 'true', 'fY' =&gt; 'false' }, false)
+
+    wi = { 'fx' =&gt; 'A', 'fy' =&gt; 'b' }
+    do_test(table, wi, {}, { 'fX' =&gt; 'true', 'fY' =&gt; 'false' }, false)
   end
 
   #
@@ -293,19 +309,24 @@ e,f,2
   end
 
   CSV9 = %{
-in:fx,in:fy,out:fz
-a,b,0
-c,d,${r: 1 + 2}
-e,f,2
-}
+    in:fx,in:fy,out:fz
+    a,b,0
+    c,d,${r: 1 + 2}
+    e,f,2
+  }
 
-  def test_9
+  def test_ruby_eval
 
-    wi = {
-      &quot;fx&quot; =&gt; &quot;c&quot;,
-      &quot;fy&quot; =&gt; &quot;d&quot;
-    }
-    do_test(CSV9, wi, { :ruby_eval =&gt; true }, { &quot;fz&quot; =&gt; &quot;3&quot; }, false)
+    wi = { 'fx' =&gt; 'c', 'fy' =&gt; 'd' }
+    do_test(CSV9, wi, { :ruby_eval =&gt; true }, { 'fz' =&gt; '3' }, false)
+  end
+
+  def test_ruby_eval_set_at_table_initialization
+
+    table = Rufus::Decision::Table.new(CSV9, :ruby_eval =&gt; true)
+
+    wi = { 'fx' =&gt; 'c', 'fy' =&gt; 'd' }
+    do_test(table, wi, {}, { 'fz' =&gt; '3' }, false)
   end
 
   CSV10 = %{</diff>
      <filename>test/decision_0_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -16,8 +16,9 @@ module DecisionTestMixin
 
   def do_test (table_data, h, options, expected_result, verbose=false)
 
-    #table = Rufus::DecisionTable.new(table_data)
-    table = Rufus::Decision::Table.new(table_data)
+    table = table_data.is_a?(Rufus::Decision::Table) ?
+      table_data :
+      Rufus::Decision::Table.new(table_data)
 
     if verbose
       puts
@@ -28,7 +29,7 @@ module DecisionTestMixin
       p h
     end
 
-    h = table.transform! h, options
+    h = table.transform!(h, options)
 
     if verbose
       puts</diff>
      <filename>test/test_base.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>6db5f06274ce933e46d714163b0e3e72190bf077</id>
    </parent>
  </parents>
  <author>
    <name>John Mettraux</name>
    <email>jmettraux@gmail.com</email>
  </author>
  <url>http://github.com/jmettraux/rufus-decision/commit/c6add19e47a596b59987f54a7bf74553fc296124</url>
  <id>c6add19e47a596b59987f54a7bf74553fc296124</id>
  <committed-date>2009-04-24T19:24:58-07:00</committed-date>
  <authored-date>2009-04-24T19:24:58-07:00</authored-date>
  <message>- todo #25670 : :ruby_eval settable at table initialization
- todo #25667 : :ignore_case, :through and :accumulate settable at table initialization (instead of only in the csv table itself)</message>
  <tree>fe45a22e4674f3eaa62a28d1f535444d64037900</tree>
  <committer>
    <name>John Mettraux</name>
    <email>jmettraux@gmail.com</email>
  </committer>
</commit>
