summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/context/ruby/rlxtools.rb
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-11-18 01:37:52 +0000
committerKarl Berry <karl@freefriends.org>2006-11-18 01:37:52 +0000
commit5c91b9f8a88e06f057a6a08b0a755a224d08e019 (patch)
tree57cfafb6bd6c146dcdfc911dbef8db622c6476bd /Master/texmf-dist/scripts/context/ruby/rlxtools.rb
parent983736c2ab572e9a860c74f0f781b3decd282f13 (diff)
context 17nov06 update
git-svn-id: svn://tug.org/texlive/trunk@2449 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/context/ruby/rlxtools.rb')
-rw-r--r--Master/texmf-dist/scripts/context/ruby/rlxtools.rb66
1 files changed, 48 insertions, 18 deletions
diff --git a/Master/texmf-dist/scripts/context/ruby/rlxtools.rb b/Master/texmf-dist/scripts/context/ruby/rlxtools.rb
index 1225dedb301..40a45bd51a8 100644
--- a/Master/texmf-dist/scripts/context/ruby/rlxtools.rb
+++ b/Master/texmf-dist/scripts/context/ruby/rlxtools.rb
@@ -12,10 +12,7 @@
banner = ['RlxTools', 'version 1.0.1', '2004/2005', 'PRAGMA ADE/POD']
-unless defined? ownpath
- ownpath = $0.sub(/[\\\/][a-z0-9\-]*?\.rb/i,'')
- $: << ownpath
-end
+$: << File.expand_path(File.dirname($0)) ; $: << File.join($:.last,'lib') ; $:.uniq!
require 'base/switch'
require 'base/logger'
@@ -98,6 +95,9 @@ class Commands
if conversion = variables['conversion'] then
report("testing for conversion #{conversion}")
if suffix = variables['suffix'].downcase then
+ if ! suffix.empty? && variables['file'] && variables['file'] !~ /\.([a-z]+)$/i then
+ variables['file'] += ".#{suffix}"
+ end
if file = variables['file'] then
report("conversion #{conversion} for suffix #{suffix} for file #{file}")
else
@@ -251,17 +251,43 @@ class Commands
include CommandBase
- def identify
- @commandline.arguments.each do |filename|
- if state = do_identify(filename) then
- begin
- File.open(filename+'.rli','w') do |f|
- f << state
+ @@xmlbanner = "<?xml version='1.0' standalone='yes'?>"
+
+ def identify(resultfile='rlxtools.rli')
+ if @commandline.option('collect') then
+ begin
+ File.open(resultfile,'w') do |f|
+ f << "#{@@xmlbanner}\n"
+ f << "<rl:identification>\n"
+ @commandline.arguments.each do |filename|
+ if state = do_identify(filename) then
+ report("#{filename} is identified")
+ f << state
+ else
+ report("unable to identify #{filename}")
+ end
+ end
+ f << "</rl:identification>\n"
+ report("result saved in #{resultfile}")
+ end
+ rescue
+ report("error in writing result")
+ end
+ else
+ @commandline.arguments.each do |filename|
+ if state = do_identify(filename) then
+ begin
+ File.open(filename+'.rli','w') do |f|
+ f << "#{@@xmlbanner}\n"
+ f << state
+ end
+ rescue
+ report("error in identifying #{filename}")
+ else
+ report("#{filename} is identified")
end
- rescue
- report("error in identifying #{filename}")
else
- report("#{filename} is identified")
+ report("unable to identify #{filename}")
end
end
end
@@ -269,11 +295,15 @@ class Commands
private
- def do_identify(filename)
+ def do_identify(filename,centimeters=false)
begin
str = nil
if FileTest.file?(filename) then
- result = `identify -format \"x=%x,y=%y,w=%w,h=%h,b=%b\" #{filename}`.chomp.split(',')
+ if centimeters then
+ result = `identify -units PixelsPerCentimeter -format \"x=%x,y=%y,w=%w,h=%h,b=%b\" #{filename}`.chomp.split(',')
+ else
+ result = `identify -units PixelsPerInch -format \"x=%x,y=%y,w=%w,h=%h,b=%b\" #{filename}`.chomp.split(',')
+ end
tags = Hash.new
result.each do |r|
if rr = r.split("=") then
@@ -285,7 +315,6 @@ class Commands
height = unified(tags['h']||0,tags['y']||'1')
if size > 0 then
str = ''
- str << "<?xml version='1.0' standalone='yes'?>\n"
str << "<rl:identify name='#{File.basename(filename)}'>\n"
str << " <rl:size>#{size}</rl:size>\n"
str << " <rl:path>#{File.dirname(filename).sub(/\\/o,'/')}</rl:path>\n"
@@ -322,13 +351,14 @@ end
logger = Logger.new(banner.shift)
commandline = CommandLine.new
-commandline.registeraction('manipulate', ' [--test] manipulatorfile resourselog')
-commandline.registeraction('identify', 'filename')
+commandline.registeraction('manipulate', '[--test] manipulatorfile resourselog')
+commandline.registeraction('identify' , '[--collect] filename')
commandline.registeraction('help')
commandline.registeraction('version')
commandline.registerflag('test')
+commandline.registerflag('collect')
commandline.expand