engines/adva_newsletter/vendor/gems/cronedit-0.3.0/lib/cronedit.rb
# Parses cron definition from a stream
# returns [hash of CronEntries, Array of all lines (and placeholders)]
Parses cron definition from a stream
returns [hash of CronEntries, Array of all lines (and placeholders)]
Parses cron definition from a stream returns [ hash of CronEntries Array of all lines ( and placeholders ) ]
def parseCrontabFull anIO
                lines=[]
                entries = {}
                idx = 0
                id = nil
                anIO.each_line { |l|
                    l.strip!
                    lines << l if l.empty? 
                    next if l.empty?
                    return [entries, lines] unless (l =~ /^no crontab/).nil? 
                    if l=~/^#/    
                        id = EntryPlaceholder.Create l
                        lines << l unless id 
                    elsif not (l =~ /^\w+\ *=/).nil?  
                        lines << l
                        id = nil
                    else 
                        id = EntryPlaceholder.new(idx+=1) unless id 
                        lines << id 
                        key = id.id  
                        entries[key.to_s]=l
                        id = nil
                    end
                }
                [entries, lines]
        end
def parseCrontabFull anIO lines = [ ] entries = { } idx = 0 id = nil anIO . each_line { | l | l . strip! lines << l if l . empty? next if l . empty? return [ entries , lines ] unless ( l =~ / ^no crontab / ) . nil? if l =~ / ^# / id = EntryPlaceholder . Create l lines << l unless id elsif not ( l =~ / ^ \w + \  *= / ) . nil? lines << l id = nil else id = EntryPlaceholder . new ( idx += 1 ) unless id lines << id key = id . id entries [ key . to_s ] = l id = nil end } [ entries , lines ] end
Parses cron definition from a stream
returns [hash of CronEntries, Array of all lines (and placeholders)]
Parses cron definition from a stream returns [ hash of CronEntries Array of all lines ( and placeholders ) ]
#  keep empty lines           and opts[:keepformat] # if crontab contains no schedule it returns 'no crontab for ...' #is it comment or ID ? #add the raw line to the lines if no id # is it variable definition ? # it should be cron entry definition # if there is no id generate an anonymous id #add placeholder to lines
anIO