[ruby-talk:02370] Re: crontab

From: Clemens Hintze <clemens.hintze@...>
Date: 2000-04-06 11:27:07 UTC
List: ruby-talk #2370
GOTO Kentaro writes:
> Hi,

Hi gotoken,

again you have done a fine piece of work! Playing with it I have found
two, ehrm ..., quirks! But perhaps I have only misunderstood your
intention so please forgive me in that case.

Furthermore I have an 'improvement' proposal yet. Ehrm ... not a real
improvement, indeed. I want to propose to have following Exceptions:

   Crontab::Error < Exception
   Crontab::FormatError < Crontab::Error

If sometime in the future Crontab would be extend to e.g. write a
crontab file, all further exceptions could be assigned under
Crontab::Error then. So I would have the possibility to have a common
Crontab exception root.

Just a thought!

\cle

> 
> In message "[ruby-talk:02361] crontab"
>     on 00/04/05, Hugh Sasse Staff Elec Eng <hgs@dmu.ac.uk> writes:
> >I want to have a program that may be run between certain times.
> >It seems silly to invent a format to specify the start and end times
> >when I can use that from crontab.  So, has anyone already produced
> >code that will tell if "now" matches a crontab entry, using Ruby?
> 
> I've wrote. How about?
> 
> http://www.math.sci.hokudai.ac.jp/~gotoken/ruby/p/crontab/
> 
> -- gotoken

Attachments (1)

crontab.patch (1.11 KB, text/x-diff)
*** crontab/crontab.rb	Wed Apr  5 20:05:55 2000
--- ./crontab.rb	Thu Apr  6 13:02:23 2000
***************
*** 8,14 ****
  
    require "crontab"
  
!   tab = Crontab.new("/var/cron/tabs/" + ENV('USER'))
  
    tab = Crontab.new
    tab.add("5,35 0-23/2 * * *"){system "a_program"}
--- 8,14 ----
  
    require "crontab"
  
!   tab = Crontab.open("/var/cron/tabs/" + ENV['USER'])
  
    tab = Crontab.new
    tab.add("5,35 0-23/2 * * *"){system "a_program"}
***************
*** 100,106 ****
  
    def add(str, job = nil)
      job = proc if iterator?
!     @table.push((parse_timedate(str) + job).extend CronRecord)
    end
  
    attr_reader :table
--- 100,106 ----
  
    def add(str, job = nil)
      job = proc if iterator?
!     @table.push((parse_timedate(str) << job).extend CronRecord)
    end
  
    attr_reader :table
***************
*** 199,205 ****
  
    WDAY = %w(sun mon tue wed thu fri sut)
  
!   class FormatError < Exception; end
  end
  
  if __FILE__ == $0
--- 199,206 ----
  
    WDAY = %w(sun mon tue wed thu fri sut)
  
!   class Error < Exception; end
!   class FormatError < Error; end
  end
  
  if __FILE__ == $0

In This Thread