summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/context/ruby/base/kpse/drb.rb57
-rw-r--r--scripts/context/ruby/base/kpse/soap.rb82
-rw-r--r--scripts/context/ruby/base/kpse/trees.rb84
-rw-r--r--scripts/context/ruby/texmfstart.rb22
-rw-r--r--tex/context/base/cont-new.tex2
-rw-r--r--tex/context/base/context.tex2
-rw-r--r--tex/context/interface/keys-cz.xml2
-rw-r--r--tex/context/interface/keys-de.xml2
-rw-r--r--tex/context/interface/keys-en.xml2
-rw-r--r--tex/context/interface/keys-fr.xml2
-rw-r--r--tex/context/interface/keys-it.xml2
-rw-r--r--tex/context/interface/keys-nl.xml2
-rw-r--r--tex/context/interface/keys-ro.xml2
13 files changed, 252 insertions, 11 deletions
diff --git a/scripts/context/ruby/base/kpse/drb.rb b/scripts/context/ruby/base/kpse/drb.rb
new file mode 100644
index 000000000..db1ce0eec
--- /dev/null
+++ b/scripts/context/ruby/base/kpse/drb.rb
@@ -0,0 +1,57 @@
+require 'drb'
+require 'base/kpse/trees'
+
+class KpseServer
+
+ attr_accessor :port
+
+ def initialize(port=7000)
+ @port = port
+ end
+
+ def start
+ puts "starting drb service at port #{@port}"
+ DRb.start_service("druby://localhost:#{@port}", KpseTrees.new)
+ trap(:INT) do
+ DRb.stop_service
+ end
+ DRb.thread.join
+ end
+
+ def stop
+ # todo
+ end
+
+end
+
+class KpseClient
+
+ attr_accessor :port
+
+ def initialize(port=7000)
+ @port = port
+ @kpse = nil
+ end
+
+ def start
+ # only needed when callbacks are used / slow, due to Socket::getaddrinfo
+ # DRb.start_service
+ end
+
+ def object
+ @kpse = DRbObject.new(nil,"druby://localhost:#{@port}")
+ end
+
+end
+
+
+# SERVER_URI="druby://localhost:8787"
+#
+# # Start a local DRbServer to handle callbacks.
+# #
+# # Not necessary for this small example, but will be required
+# # as soon as we pass a non-marshallable object as an argument
+# # to a dRuby call.
+# DRb.start_service
+#
+# timeserver = DRbObject.new_with_uri(SERVER_URI)
diff --git a/scripts/context/ruby/base/kpse/soap.rb b/scripts/context/ruby/base/kpse/soap.rb
new file mode 100644
index 000000000..5ec45e954
--- /dev/null
+++ b/scripts/context/ruby/base/kpse/soap.rb
@@ -0,0 +1,82 @@
+require 'soap/rpc/standaloneServer'
+require 'soap/rpc/driver'
+
+require 'base/kpse/trees'
+
+class KpseService < SOAP::RPC::StandaloneServer
+
+ def on_init
+ kpse = KpseTrees.new
+ add_method(kpse, 'choose', 'files', 'environment')
+ add_method(kpse, 'load', 'files', 'environment')
+ add_method(kpse, 'expand_variables', 'tree')
+ add_method(kpse, 'expand_braces', 'tree', 'str')
+ add_method(kpse, 'expand_path', 'tree', 'str')
+ add_method(kpse, 'expand_var', 'tree', 'str')
+ add_method(kpse, 'show_path', 'tree', 'str')
+ add_method(kpse, 'var_value', 'tree', 'str')
+ add_method(kpse, 'find_file', 'tree', 'filename')
+ add_method(kpse, 'find_files', 'tree', 'filename', 'first')
+ end
+
+end
+
+class KpseServer
+
+ @@url = 'http://kpse.thismachine.org/KpseService'
+
+ attr_accessor :port
+
+ def initialize(port=7000)
+ @port = port
+ @server = nil
+ end
+
+ def start
+ puts "starting soap service at port #{@port}"
+ @server = KpseService.new('KpseServer', @@url, '0.0.0.0', @port.to_i)
+ trap(:INT) do
+ @server.shutdown
+ end
+ status = @server.start
+ end
+
+ def stop
+ @server.shutdown rescue false
+ end
+
+end
+
+class KpseClient
+
+ @@url = 'http://kpse.thismachine.org/KpseService'
+
+ attr_accessor :port
+
+ def initialize(port=7000)
+ @port = port
+ @kpse = nil
+ end
+
+ def start
+ @kpse = SOAP::RPC::Driver.new("http://localhost:#{port}/", @@url)
+ @kpse.add_method('choose','files', 'environment')
+ @kpse.add_method('load','files', 'environment')
+ @kpse.add_method('expand_variables', 'tree')
+ @kpse.add_method('expand_braces', 'tree', 'str')
+ @kpse.add_method('expand_path', 'tree', 'str')
+ @kpse.add_method('expand_var', 'tree', 'str')
+ @kpse.add_method('show_path', 'tree', 'str')
+ @kpse.add_method('var_value', 'tree', 'str')
+ @kpse.add_method('find_file', 'tree', 'filename')
+ @kpse.add_method('find_files', 'tree', 'filename', 'first')
+ end
+
+ def object
+ @kpse
+ end
+
+end
+
+
+
diff --git a/scripts/context/ruby/base/kpse/trees.rb b/scripts/context/ruby/base/kpse/trees.rb
new file mode 100644
index 000000000..9c872eb18
--- /dev/null
+++ b/scripts/context/ruby/base/kpse/trees.rb
@@ -0,0 +1,84 @@
+require 'monitor'
+require 'base/kpsefast'
+
+class KpseTrees < Monitor
+
+ def initialize
+ @trees = Hash.new
+ end
+
+ def pattern(filenames)
+ filenames.join('|').gsub(/\\+/o,'/').downcase
+ end
+
+ def choose(filenames,environment)
+ current = pattern(filenames)
+ load(filenames,environment) unless @trees[current]
+ puts "enabling tree #{current}"
+ current
+ end
+
+ def fetch(filenames,environment) # will send whole object !
+ current = pattern(filenames)
+ load(filenames,environment) unless @trees[current]
+ puts "fetching tree #{current}"
+ @trees[current]
+ end
+
+ def load(filenames,environment)
+ current = pattern(filenames)
+ puts "loading tree #{current}"
+ @trees[current] = KpseFast.new
+ @trees[current].push_environment(environment)
+ @trees[current].load_cnf(filenames)
+ @trees[current].expand_variables
+ @trees[current].load_lsr
+ end
+
+ def set(tree,key,value)
+ case key
+ when 'progname' then @trees[tree].progname = value
+ when 'engine' then @trees[tree].engine = value
+ when 'format' then @trees[tree].format = value
+ end
+ end
+ def get(tree,key)
+ case key
+ when 'progname' then @trees[tree].progname
+ when 'engine' then @trees[tree].engine
+ when 'format' then @trees[tree].format
+ end
+ end
+
+ def load_cnf(tree)
+ @trees[tree].load_cnf
+ end
+ def load_lsr(tree)
+ @trees[tree].load_lsr
+ end
+ def expand_variables(tree)
+ @trees[tree].expand_variables
+ end
+ def expand_braces(tree,str)
+ @trees[tree].expand_braces(str)
+ end
+ def expand_path(tree,str)
+ @trees[tree].expand_path(str)
+ end
+ def expand_var(tree,str)
+ @trees[tree].expand_var(str)
+ end
+ def show_path(tree,str)
+ @trees[tree].show_path(str)
+ end
+ def var_value(tree,str)
+ @trees[tree].var_value(str)
+ end
+ def find_file(tree,filename)
+ @trees[tree].find_file(filename)
+ end
+ def find_files(tree,filename,first)
+ @trees[tree].find_files(filename,first)
+ end
+
+end
diff --git a/scripts/context/ruby/texmfstart.rb b/scripts/context/ruby/texmfstart.rb
index 0320ce97a..72c90ad8f 100644
--- a/scripts/context/ruby/texmfstart.rb
+++ b/scripts/context/ruby/texmfstart.rb
@@ -32,12 +32,30 @@
$ownpath = File.expand_path(File.dirname($0)) unless defined? $ownpath
+# base/kpseremote
+# texmfstart-lib/base/kpseremote
+# ../../texmf-local/scripts/context/ruby
+# ../../texmf/scripts/context/ruby
+
$: << $ownpath
+$: << File.expand_path("#{$ownpath}/texmfstart-lib")
+$: << File.expand_path("#{$ownpath}/../../texmf-local/scripts/context/ruby")
+$: << File.expand_path("#{$ownpath}/../../texmf/scripts/context/ruby")
require "rbconfig"
-require 'base/kpseremote'
-require 'base/kpsedirect'
+['base/kpseremote','base/kpsedirect'].each do |basemodule|
+ begin
+ require basemodule
+ rescue Exception
+ puts("unable to locate #{basemodule} on library paths:\n\n")
+ puts($:.join("\n") + "\n")
+ puts("an option is to copy\n\n")
+ puts(" <texmf-local or texmf>/scripts/context/ruby/base\n\n")
+ puts("to e.g.\n\n")
+ puts(" <path of texmfstart script>/texmfstart-lib/base")
+ end
+end
$mswindows = Config::CONFIG['host_os'] =~ /mswin/
$separator = File::PATH_SEPARATOR
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex
index 804583925..a01eb21d6 100644
--- a/tex/context/base/cont-new.tex
+++ b/tex/context/base/cont-new.tex
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2006.04.06 23:00}
+\newcontextversion{2006.04.07 11:24}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex
index 0a9a38122..1025fbbf9 100644
--- a/tex/context/base/context.tex
+++ b/tex/context/base/context.tex
@@ -31,7 +31,7 @@
%D 2004.8.30 the low level interface is english. Watch out and adapt
%D your styles an modules.
-\def\contextversion{2006.04.06 23:00}
+\def\contextversion{2006.04.07 11:24}
%D For those who want to use this:
diff --git a/tex/context/interface/keys-cz.xml b/tex/context/interface/keys-cz.xml
index 9b8bca360..91f5060a8 100644
--- a/tex/context/interface/keys-cz.xml
+++ b/tex/context/interface/keys-cz.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
-<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="cz" version="2006.04.06 23:00">
+<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="cz" version="2006.04.07 11:24">
<cd:variables>
<cd:variable name="one" value="jedna"/>
diff --git a/tex/context/interface/keys-de.xml b/tex/context/interface/keys-de.xml
index 3b085f885..e204e5449 100644
--- a/tex/context/interface/keys-de.xml
+++ b/tex/context/interface/keys-de.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
-<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="de" version="2006.04.06 23:00">
+<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="de" version="2006.04.07 11:24">
<cd:variables>
<cd:variable name="one" value="eins"/>
diff --git a/tex/context/interface/keys-en.xml b/tex/context/interface/keys-en.xml
index fae771b3a..ecf91bbb6 100644
--- a/tex/context/interface/keys-en.xml
+++ b/tex/context/interface/keys-en.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
-<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="en" version="2006.04.06 23:00">
+<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="en" version="2006.04.07 11:24">
<cd:variables>
<cd:variable name="one" value="one"/>
diff --git a/tex/context/interface/keys-fr.xml b/tex/context/interface/keys-fr.xml
index 092430860..dee533da7 100644
--- a/tex/context/interface/keys-fr.xml
+++ b/tex/context/interface/keys-fr.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
-<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="fr" version="2006.04.06 23:00">
+<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="fr" version="2006.04.07 11:24">
<cd:variables>
<cd:variable name="one" value="un"/>
diff --git a/tex/context/interface/keys-it.xml b/tex/context/interface/keys-it.xml
index bedc84080..a17916613 100644
--- a/tex/context/interface/keys-it.xml
+++ b/tex/context/interface/keys-it.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
-<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="it" version="2006.04.06 23:00">
+<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="it" version="2006.04.07 11:24">
<cd:variables>
<cd:variable name="one" value="uno"/>
diff --git a/tex/context/interface/keys-nl.xml b/tex/context/interface/keys-nl.xml
index 0cbd21069..be7acbab7 100644
--- a/tex/context/interface/keys-nl.xml
+++ b/tex/context/interface/keys-nl.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
-<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="nl" version="2006.04.06 23:00">
+<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="nl" version="2006.04.07 11:24">
<cd:variables>
<cd:variable name="one" value="een"/>
diff --git a/tex/context/interface/keys-ro.xml b/tex/context/interface/keys-ro.xml
index 0632ec388..c5dc3bc0e 100644
--- a/tex/context/interface/keys-ro.xml
+++ b/tex/context/interface/keys-ro.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
-<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="ro" version="2006.04.06 23:00">
+<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="ro" version="2006.04.07 11:24">
<cd:variables>
<cd:variable name="one" value="unu"/>