chickadee » nomads » filename-joiner

filename-patternparameter
filename-partitionerparameter
filename-joinerparameter
versionerparameter
version?parameter
version-less?parameter
version-equal?parameter
version->stringparameter
string->versionparameter

The following example sets up a versioning scheme that uses timestamps

(use nomads nomads-sql-de-lite numbers)

(versioner (lambda (max-version)
            (inexact->exact (current-seconds))))

(filename-partitioner      
 (lambda (filename)
   (let ((parts (string-split filename "-")))
     (cond
      ((null? parts) (cons #f ""))
      ((string->number (car parts))
       => (lambda (num)
            (cons (number->string (inexact->exact num)) (string-join (cdr parts) "-"))))
      (else (cons #f filename))))))

(filename-joiner           
 (lambda (version file)
    (sprintf "~A-~A" version file)))

 ;;we need to bind it to the number's version of those
(version? number?)

(define (->number what)
  (inexact->exact (if (string? what) (string->number what) what)))

(version-less?
 (lambda (l r)
   (< (->number l) (->number r))))

(version-equal?
 (lambda (l r)
   (equal? (->number l) (->number r))))