Object
The Radius parser. Initialize a parser with a Context object that defines how tags should be expanded. See the QUICKSTART for a detailed explaination of its usage.
Creates a new parser object initialized with a Context.
# File lib/radius/parser.rb, line 19 def initialize(context = Context.new, options = {}) if context.kind_of?(Hash) and options.empty? options, context = context, (context[:context] || context['context']) end options = Utility.symbolize_keys(options) self.context = context ? context.dup : Context.new self.tag_prefix = options[:tag_prefix] || 'radius' self.scanner = options[:scanner] || default_scanner end
# File lib/radius/parser.rb, line 68 def default_scanner if RUBY_PLATFORM == 'java' require 'java' require 'radius/parser/java_scanner.jar' ::Radius.send(:include_package, 'radius.parser') Radius::JavaScanner.new(JRuby.runtime) else Radius::Scanner.new end end
# File lib/radius/parser.rb, line 43 def stack_up @tokens.each do |t| if t.is_a? String @stack.last.contents << t next end case t[:flavor] when :open @stack.push(ParseContainerTag.new(t[:name], t[:attrs])) when :self @stack.last.contents << ParseTag.new {@context.render_tag(t[:name], t[:attrs])} when :close popped = @stack.pop raise WrongEndTagError.new(popped.name, t[:name], @stack) if popped.name != t[:name] popped.on_parse { |b| @context.render_tag(popped.name, popped.attributes) { Utility.array_to_s(b.contents) } } @stack.last.contents << popped when :tasteless raise TastelessTagError.new(t, @stack) else raise UndefinedFlavorError.new(t, @stack) end end raise MissingEndTagError.new(@stack.last.name, @stack) if @stack.length != 1 end
Generated with the Darkfish Rdoc Generator 2.