[Sciviews-commits] r120 - pkg/svTools/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Mar 6 16:20:07 CET 2009


Author: romain
Date: 2009-03-06 16:20:07 +0100 (Fri, 06 Mar 2009)
New Revision: 120

Modified:
   pkg/svTools/R/sidekick.R
Log:
modify sidekick so that it can take a function as its argument (a temp file is ued in that case)

Modified: pkg/svTools/R/sidekick.R
===================================================================
--- pkg/svTools/R/sidekick.R	2009-03-02 18:37:29 UTC (rev 119)
+++ pkg/svTools/R/sidekick.R	2009-03-06 15:20:07 UTC (rev 120)
@@ -16,8 +16,15 @@
 #' cat( "jitter <- " , deparse( jitter ), sep = "\n", file = tf )
 #' sidekick( tf )
 #' unlink( tf )
-sidekick <- function( file, encoding = "unknown" ){
+#' TODO :make this S3 instead of dispatching
+sidekick <- function( file, encoding = getOption("encoding") ){
 	
+	if( file %of% "function" ){
+		tf <- tempfile( ); on.exit( unlink( tf ) )
+		dump( "file" , tf )
+		file <- tf
+	}
+	
 	if( is.character(file) ){
 		if( file %~% '^rwd:' ){
 			file <- sub( 'rwd:', getwd(), file ) 
@@ -26,8 +33,8 @@
 		filename <- file
 		file <- file( filename, encoding = encoding )
 		on.exit( close( file ) )
-	} else{
-		filename <- summary(f)$description
+	} else {
+		filename <- summary(file)$description
 	}
 	
 	### try to parse and return an error if failed



More information about the Sciviews-commits mailing list