lib/ruote/parser.rb in ruote-2.1.6 vs lib/ruote/parser.rb in ruote-2.1.7

- old
+ new

@@ -33,10 +33,12 @@ module Ruote # # A process definition parser. # + # Can parse XML, JSON, Ruby (and more) process definition representations. + # class Parser def initialize (context) @context = context @@ -53,15 +55,13 @@ (return Rufus::Json.decode(definition)) rescue nil (return ruby_eval(definition)) rescue nil if definition.index("\n") == nil - u = URI.parse(definition) - raise ArgumentError.new( "remote process definitions are not allowed" - ) if u.scheme != nil && @context['remote_definition_allowed'] != true + ) if Ruote::Parser.remote?(definition) && @context['remote_definition_allowed'] != true return parse(open(definition).read) end raise ArgumentError.new( @@ -143,9 +143,18 @@ # Turns the process definition tree (ruote syntax tree) to a JSON String. # def self.to_json (tree) tree.to_json + end + + # Returns true if the defintion is a remote URI + # + def self.remote? (definition) + + u = URI.parse(definition) + + (u.scheme != nil) && ( ! ('A'..'Z').include?(u.scheme)) end protected # Evaluates the ruby string in the code, but at fist, thanks to the