summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2006-02-03 21:03:00 +0100
committerHans Hagen <pragma@wxs.nl>2006-02-03 21:03:00 +0100
commit78097dfcd572aa98629093eec31f6ab42971a248 (patch)
tree724bbe3637c0aadc450eb97e082e15d51328b212 /scripts
parent3769e0c58a9ab5e4b6a226dc31dc318c592f540e (diff)
downloadcontext-78097dfcd572aa98629093eec31f6ab42971a248.tar.gz
stable 2006.02.03 21:03
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/ruby/base/tex.rb2
-rw-r--r--scripts/context/ruby/ctxtools.rb39
2 files changed, 39 insertions, 2 deletions
diff --git a/scripts/context/ruby/base/tex.rb b/scripts/context/ruby/base/tex.rb
index 15b18f255..ea909aabc 100644
--- a/scripts/context/ruby/base/tex.rb
+++ b/scripts/context/ruby/base/tex.rb
@@ -1246,7 +1246,7 @@ class TEX
envs = envs.uniq.join(',')
mods = mods.uniq.join(',')
- report("using search method '#{Kpse.searchmethod}'") if verbose
+ report("using search method '#{Kpse.searchmethod}'") if getvariable('verbose')
report("using environments #{envs}") if envs.length > 0
report("using modules #{mods}") if mods.length > 0
diff --git a/scripts/context/ruby/ctxtools.rb b/scripts/context/ruby/ctxtools.rb
index a8fb4dde2..4c47d643e 100644
--- a/scripts/context/ruby/ctxtools.rb
+++ b/scripts/context/ruby/ctxtools.rb
@@ -17,7 +17,7 @@
#
# todo: move kpse call to kpse class/module
-banner = ['CtxTools', 'version 1.3.0', '2004/2005', 'PRAGMA ADE/POD']
+banner = ['CtxTools', 'version 1.3.1', '2004/2006', 'PRAGMA ADE/POD']
unless defined? ownpath
ownpath = $0.sub(/[\\\/][a-z0-9\-]*?\.rb/i,'')
@@ -1493,6 +1493,41 @@ class Commands
end
+class Commands
+
+ include CommandBase
+
+ def platformize
+
+ pattern = if @commandline.arguments.empty? then "*.{rb,pl,py}" else @commandline.arguments end
+ recurse = @commandline.option("recurse")
+ force = @commandline.option("force")
+ pattern = "#{if recurse then '**/' else '' end}#{pattern}"
+ Dir.glob(pattern).each do |file|
+ if File.file?(file) then
+ size = File.size(file)
+ data = IO.readlines(file)
+ if force then
+ if f = File.open(file,'w')
+ data.each do |line|
+ f.puts(line.chomp)
+ end
+ f.close
+ end
+ if File.size(file) == size then # not robust
+ report("file '#{file}' is unchanged")
+ else
+ report("file '#{file}' is platformized")
+ end
+ else
+ report("file '#{file}' is a candidate")
+ end
+ end
+ end
+ end
+
+end
+
logger = Logger.new(banner.shift)
commandline = CommandLine.new
@@ -1519,6 +1554,8 @@ commandline.registeraction('listentities', 'create doctype entity definition fro
commandline.registeraction('brandfiles', 'add context copyright notice [--force]')
+commandline.registeraction('platformize', 'replace line-endings [--recurse --force] [pattern]')
+
commandline.registervalue('type','')
commandline.registerflag('recurse')