<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/outputs/cron/output_redirection.rb</filename>
    </added>
    <added>
      <filename>test/output_redirection_test.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -38,9 +38,11 @@ module Whenever
     end
     
     def command(task, options = {})
-      @output = :unset unless defined?(@output)
-      options[:output]   ||= options.has_key?(:output) ? options[:output] : @output
-      options[:class]    ||= Whenever::Job::Default
+      # :cron_log was an old option for output redirection, it remains for backwards compatibility
+      options[:output] = (options[:cron_log] || @cron_log) if defined?(@cron_log) || options.has_key?(:cron_log)
+      # :output is the newer, more flexible option.
+      options[:output] = @output if defined?(@output) &amp;&amp; !options.has_key?(:output)
+      options[:class] ||= Whenever::Job::Default
       @jobs[@current_time_scope] ||= []
       @jobs[@current_time_scope] &lt;&lt; options[:class].new(@options.merge(:task =&gt; task).merge(options))
     end
@@ -141,7 +143,6 @@ module Whenever
       @jobs.each do |time, jobs|
         jobs.each do |job|
           Whenever::Output::Cron.output(time, job) do |cron|
-            cron &lt;&lt; job.redirect_output 
             cron &lt;&lt; &quot;\n\n&quot;
             
             if cron.starts_with?(&quot;@&quot;)</diff>
      <filename>lib/job_list.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,64 +2,22 @@ module Whenever
   module Job
     class Default
       
-      attr_accessor :task, :at, :redirect
+      attr_accessor :task, :at, :output, :output_redirection
     
       def initialize(options = {})
-        @task        = options[:task]
-        @at          = options[:at]
-        @redirect    = options[:output]
-        @environment = options[:environment] || :production
-        @path        = options[:path] || Whenever.path
+        @task               = options[:task]
+        @at                 = options[:at]
+        @output_redirection = options.has_key?(:output) ? options[:output] : :not_set
+        @environment        = options[:environment] || :production
+        @path               = options[:path] || Whenever.path
       end
     
       def output
         task
       end
       
-      def redirect_output
-        case @redirect
-        when String
-          redirect_from_string
-        when Hash
-          redirect_from_hash
-        when NilClass
-          &quot; &gt;&gt; /dev/null 2&gt;&amp;1&quot;
-        else
-          ''
-        end 
-      end
-      
     protected
       
-      def stdout
-        return unless @redirect.has_key?(:standard)
-        @redirect[:standard].nil? ? '/dev/null' : @redirect[:standard]
-      end
-      
-      def stderr
-        return unless @redirect.has_key?(:error)
-        @redirect[:error].nil? ? '/dev/null' : @redirect[:error]
-      end
-      
-      def redirect_from_hash
-        case
-        when stdout == '/dev/null' &amp;&amp; stderr == '/dev/null'
-          &quot; &gt;&gt; /dev/null 2&gt;&amp;1&quot;
-        when stdout &amp;&amp; stderr
-          &quot; &gt;&gt; #{stdout} 2&gt; #{stderr}&quot;
-        when stderr
-          &quot; 2&gt; #{stderr}&quot;
-        when stdout
-          &quot; &gt;&gt; #{stdout}&quot;
-        else
-          ''
-        end
-      end
-      
-      def redirect_from_string
-        &quot; &gt;&gt; #{@redirect} 2&gt;&amp;1&quot;
-      end
-      
       def path_required
         raise ArgumentError, &quot;No path available; set :path, '/your/path' in your schedule file&quot; if @path.blank?
       end</diff>
      <filename>lib/job_types/default.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,10 +5,11 @@ module Whenever
 
       attr_accessor :time, :task
 
-      def initialize(time = nil, task = nil, at = nil)
+      def initialize(time = nil, task = nil, at = nil, output_redirection = nil)
         @time = time
         @task = task
         @at   = at.is_a?(String) ? (Chronic.parse(at) || 0) : (at || 0)
+        @output_redirection = output_redirection
       end
 
       def self.enumerate(item)
@@ -24,11 +25,14 @@ module Whenever
       def self.output(times, job)
         enumerate(times).each do |time|
           enumerate(job.at).each do |at|
-            out = new(time, job.output, at)
-            yield &quot;#{out.time_in_cron_syntax} #{out.task}&quot;
+            yield new(time, job.output, at, job.output_redirection).output
           end
         end
       end
+      
+      def output
+        [time_in_cron_syntax, task, output_redirection].compact.join(' ').strip
+      end
 
       def time_in_cron_syntax
         case @time
@@ -37,6 +41,10 @@ module Whenever
           else parse_time
         end
       end
+      
+      def output_redirection
+        OutputRedirection.new(@output_redirection).to_s unless @output_redirection == :not_set
+      end
 
     protected
 </diff>
      <filename>lib/outputs/cron.rb</filename>
    </modified>
    <modified>
      <diff>@@ -32,5 +32,6 @@ job_types/default
 job_types/rake_task 
 job_types/runner 
 outputs/cron
+outputs/cron/output_redirection
 command_line 
 }.each { |file| require	File.expand_path(File.dirname(__FILE__) + &quot;/#{file}&quot;) }
\ No newline at end of file</diff>
      <filename>lib/whenever.rb</filename>
    </modified>
    <modified>
      <diff>@@ -33,275 +33,5 @@ class OutputCommandTest &lt; Test::Unit::TestCase
       assert_match &quot;0 * * * * second&quot;, @output
     end
   end
-
-  context &quot;A command when the output is set to nil&quot; do
-    setup do
-      @output = Whenever.cron \
-      &lt;&lt;-file
-        set :output, nil
-        every 2.hours do
-          command &quot;blahblah&quot;
-        end
-      file
-    end
-    
-    should &quot;output the command with the log syntax appended&quot; do
-      assert_match /^.+ .+ .+ .+ blahblah &gt;&gt; \/dev\/null 2&gt;&amp;1$/, @output
-    end
-  end
-
-  
-  context &quot;A command when the output is set&quot; do
-    setup do
-      @output = Whenever.cron \
-      &lt;&lt;-file
-        set :output, 'logfile.log'
-        every 2.hours do
-          command &quot;blahblah&quot;
-        end
-      file
-    end
-    
-    should &quot;output the command with the log syntax appended&quot; do
-      assert_match /^.+ .+ .+ .+ blahblah &gt;&gt; logfile.log 2&gt;&amp;1$/, @output
-    end
-  end
-
-  context &quot;A command when the error and standard output is set by the command&quot; do
-    setup do
-      @output = Whenever.cron \
-      &lt;&lt;-file
-        every 2.hours do
-          command &quot;blahblah&quot;, :output =&gt; {:standard =&gt; 'dev_null', :error =&gt; 'dev_err'}
-        end
-      file
-    end
-
-    should &quot;output the command without the log syntax appended&quot; do
-      assert_match /^.+ .+ .+ .+ blahblah &gt;&gt; dev_null 2&gt; dev_err$/, @output
-    end
-  end
-  
-  context &quot;A command when the output is set and the comand overrides it&quot; do
-    setup do
-      @output = Whenever.cron \
-      &lt;&lt;-file
-        set :output, 'logfile.log'
-        every 2.hours do
-          command &quot;blahblah&quot;, :output =&gt; 'otherlog.log'
-        end
-      file
-    end
-    
-    should &quot;output the command with the command syntax appended&quot; do
-      assert_no_match /.+ .+ .+ .+ blahblah &gt;&gt; logfile.log 2&gt;&amp;1/, @output
-      assert_match /^.+ .+ .+ .+ blahblah &gt;&gt; otherlog.log 2&gt;&amp;1$/, @output
-    end
-  end
-
-  context &quot;A command when the output is set and the comand overrides with standard and error&quot; do
-    setup do
-      @output = Whenever.cron \
-      &lt;&lt;-file
-        set :output, 'logfile.log'
-        every 2.hours do
-          command &quot;blahblah&quot;, :output =&gt; {:error =&gt; 'dev_err', :standard =&gt; 'dev_null' }
-        end
-      file
-    end
     
-    should &quot;output the command with the overridden redirection syntax appended&quot; do
-      assert_no_match /.+ .+ .+ .+ blahblah &gt;&gt; logfile.log 2&gt;&amp;1/, @output
-      assert_match /^.+ .+ .+ .+ blahblah &gt;&gt; dev_null 2&gt; dev_err$/, @output
-    end
-  end
-
-  context &quot;A command when the output is set and the comand rejects it&quot; do
-    setup do
-      @output = Whenever.cron \
-      &lt;&lt;-file
-        set :output, 'logfile.log'
-        every 2.hours do
-          command &quot;blahblah&quot;, :output =&gt; false
-        end
-      file
-    end
-
-    should &quot;output the command without the log syntax appended&quot; do
-      assert_no_match /.+ .+ .+ .+ blahblah &gt;&gt; logfile.log 2&gt;&amp;1/, @output
-      assert_match /^.+ .+ .+ .+ blahblah$/, @output
-    end
-  end
-  
-  context &quot;A command when the output is set and is overridden by the :set option&quot; do
-    setup do
-      @output = Whenever.cron :set =&gt; 'output=otherlog.log', :string =&gt; \
-      &lt;&lt;-file
-        set :output, 'logfile.log'
-        every 2.hours do
-          command &quot;blahblah&quot;
-        end
-      file
-    end
-
-    should &quot;output the otherlog.log as the log file&quot; do
-      assert_no_match /.+ .+ .+ .+ blahblah &gt;&gt; logfile.log 2&gt;&amp;1/, @output
-      assert_match /^.+ .+ .+ .+ blahblah &gt;&gt; otherlog.log 2&gt;&amp;1/, @output
-    end
-  end
-  
-  context &quot;A command when the error and standard output is set&quot; do
-    setup do
-      @output = Whenever.cron \
-      &lt;&lt;-file
-        set :output, {:error =&gt; 'dev_err', :standard =&gt; 'dev_null' }
-        every 2.hours do
-          command &quot;blahblah&quot;
-        end
-      file
-    end
-
-    should &quot;output the command without the redirection syntax appended&quot; do
-      assert_match /^.+ .+ .+ .+ blahblah &gt;&gt; dev_null 2&gt; dev_err$/, @output
-    end
-  end
-
-  context &quot;A command when error output is set&quot; do
-    setup do
-      @output = Whenever.cron \
-      &lt;&lt;-file
-        set :output, {:error =&gt; 'dev_null'}
-        every 2.hours do
-          command &quot;blahblah&quot;
-        end
-      file
-    end
-
-    should &quot;output the command without the standard errror syntax appended&quot; do
-      assert_match /^.+ .+ .+ .+ blahblah 2&gt; dev_null$/, @output
-    end
-  end
-  
-  context &quot;A command when the standard output is set&quot; do
-    setup do
-      @output = Whenever.cron \
-      &lt;&lt;-file
-        set :output, {:standard =&gt; 'dev_out'}
-        every 2.hours do
-          command &quot;blahblah&quot;
-        end
-      file
-    end
-
-    should &quot;output the command with standard output syntax appended&quot; do
-      assert_match /^.+ .+ .+ .+ blahblah &gt;&gt; dev_out$/, @output
-    end
-  end
-
-  context &quot;A command when error output is set by the command&quot; do
-    setup do
-      @output = Whenever.cron \
-      &lt;&lt;-file
-        every 2.hours do
-          command &quot;blahblah&quot;, :output =&gt; {:error =&gt; 'dev_err'}
-        end
-      file
-    end
-
-    should &quot;output the command without the log syntax appended&quot; do
-      assert_match /^.+ .+ .+ .+ blahblah 2&gt; dev_err$/, @output
-    end
-  end
-  
-  context &quot;A command when standard output is set by the command&quot; do
-    setup do
-      @output = Whenever.cron \
-      &lt;&lt;-file
-        every 2.hours do
-          command &quot;blahblah&quot;, :output =&gt; {:standard =&gt; 'dev_out'}
-        end
-      file
-    end
-
-    should &quot;output the command without the log syntax appended&quot; do
-      assert_match /^.+ .+ .+ .+ blahblah &gt;&gt; dev_out$/, @output
-    end
-  end
-
-  context &quot;A command when standard output is set to nil&quot; do
-    setup do
-      @output = Whenever.cron \
-      &lt;&lt;-file
-        every 2.hours do
-          command &quot;blahblah&quot;, :output =&gt; {:standard =&gt; nil}
-        end
-      file
-    end
-
-    should &quot;output the command with stdout directed to /dev/null&quot; do
-      assert_match /^.+ .+ .+ .+ blahblah &gt;&gt; \/dev\/null$/, @output
-    end
-  end
-
-  context &quot;A command when standard error is set to nil&quot; do
-    setup do
-      @output = Whenever.cron \
-      &lt;&lt;-file
-        every 2.hours do
-          command &quot;blahblah&quot;, :output =&gt; {:error =&gt; nil}
-        end
-      file
-    end
-
-    should &quot;output the command with stderr directed to /dev/null&quot; do
-      assert_match /^.+ .+ .+ .+ blahblah 2&gt; \/dev\/null$/, @output
-    end
-  end
-
-  context &quot;A command when standard output and standard error is set to nil&quot; do
-    setup do
-      @output = Whenever.cron \
-      &lt;&lt;-file
-        every 2.hours do
-          command &quot;blahblah&quot;, :output =&gt; {:error =&gt; nil, :standard =&gt; nil}
-        end
-      file
-    end
-
-    should &quot;output the command with stderr directed to /dev/null&quot; do
-      assert_match /^.+ .+ .+ .+ blahblah &gt;&gt; \/dev\/null 2&gt;&amp;1$/, @output
-    end
-  end
-
-  context &quot;A command when standard output is set and standard error is set to nil&quot; do
-    setup do
-      @output = Whenever.cron \
-      &lt;&lt;-file
-        every 2.hours do
-          command &quot;blahblah&quot;, :output =&gt; {:error =&gt; nil, :standard =&gt; 'my.log'}
-        end
-      file
-    end
-
-    should &quot;output the command with stderr directed to /dev/null&quot; do
-      assert_match /^.+ .+ .+ .+ blahblah &gt;&gt; my.log 2&gt; \/dev\/null$/, @output
-    end
-  end
-
-  context &quot;A command when standard output is nil and standard error is set&quot; do
-    setup do
-      @output = Whenever.cron \
-      &lt;&lt;-file
-        every 2.hours do
-          command &quot;blahblah&quot;, :output =&gt; {:error =&gt; 'my_error.log', :standard =&gt; nil}
-        end
-      file
-    end
-
-    should &quot;output the command with stderr directed to /dev/null&quot; do
-      assert_match /^.+ .+ .+ .+ blahblah &gt;&gt; \/dev\/null 2&gt; my_error.log$/, @output
-    end
-  end
-
-  
 end
\ No newline at end of file</diff>
      <filename>test/output_command_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>be38dd1139a40c2f08d2d40ec20a7c54004fb154</id>
    </parent>
  </parents>
  <author>
    <name>Javan Makhmali</name>
    <email>javan@javan.us</email>
  </author>
  <url>http://github.com/javan/whenever/commit/295cabe56ca75667c68d4dc6b6f27b84e0fd2ebf</url>
  <id>295cabe56ca75667c68d4dc6b6f27b84e0fd2ebf</id>
  <committed-date>2009-10-20T08:52:09-07:00</committed-date>
  <authored-date>2009-10-20T08:52:09-07:00</authored-date>
  <message>added new output redirection features, moved most of it into a new class.</message>
  <tree>17f11ccc0caf14a672f6aa137c0a96fef2ba7ac2</tree>
  <committer>
    <name>Javan Makhmali</name>
    <email>javan@javan.us</email>
  </committer>
</commit>
