lib/openwfe/expressions/expressionmap.rb in openwferu-0.9.16 vs lib/openwfe/expressions/expressionmap.rb in openwferu-0.9.17

- old
+ new

@@ -1,8 +1,8 @@ # #-- -# Copyright (c) 2006-2007, John Mettraux, OpenWFE.org +# Copyright (c) 2006-2008, John Mettraux, OpenWFE.org # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # @@ -35,14 +35,15 @@ # "made in Japan" # # John Mettraux at openwfe.org # +require 'openwfe/expressions/raw' require 'openwfe/expressions/environment' require 'openwfe/expressions/fe_define' require 'openwfe/expressions/fe_misc' -require 'openwfe/expressions/fe_value' +require 'openwfe/expressions/fe_set' require 'openwfe/expressions/fe_if' require 'openwfe/expressions/fe_equals' require 'openwfe/expressions/fe_sequence' require 'openwfe/expressions/fe_subprocess' require 'openwfe/expressions/fe_concurrence' @@ -140,13 +141,22 @@ register ListenExpression register TimeoutExpression + register EvalExpression + register ExpExpression + register Environment # # only used by get_expression_names() + + register_ancestors RawExpression + #register_ancestors XmlRawExpression + #register_ancestors ProgRawExpression + # + # just register the ancestors for those two end # # Returns the expression class corresponding to the given # expression name @@ -183,20 +193,37 @@ # from the given expression_class. # def get_expression_names (expression_class) return expression_class.expression_names \ - if expression_class.method_defined? :expression_names + if expression_class.method_defined?(:expression_names) names = [] @expressions.each do |k, v| names << k if v.ancestors.include? expression_class end names end # + # Returns an array of expression classes that have the given + # class/module among their ancestors. + # + def get_expression_classes (ancestor) + + @ancestors[ancestor] + end + + def to_s + s = "" + @expressions.keys.sort.each do |name| + s << "- '#{name}' -> '#{@expressions[name].to_s}'\n" + end + s + end + + # # Registers an Expression class within this expression map. # This method is usually never called from out of the ExpressionMap # class, but, who knows, it could prove useful one day as a 'public' # method. # @@ -204,30 +231,23 @@ expression_class.expression_names.each do |name| name = OpenWFE::to_dash(name) @expressions[name] = expression_class end - expression_class.ancestors.each do |ancestor| - (@ancestors[ancestor] ||= []) << expression_class - end + register_ancestors expression_class end - # - # Returns an array of expression classes that have the given - # class/module among their ancestors. - # - def get_expression_classes (ancestor) + protected - @ancestors[ancestor] - end + # + # registers all the ancestors of an expression class + # + def register_ancestors (expression_class) - def to_s - s = "" - @expressions.keys.sort.each do |name| - s << "- '#{name}' -> '#{@expressions[name].to_s}'\n" + expression_class.ancestors.each do |ancestor| + (@ancestors[ancestor] ||= []) << expression_class + end end - s - end end end