cgi/run.rb in tap-0.11.0 vs cgi/run.rb in tap-0.11.1

- old
+ new

@@ -12,13 +12,23 @@ module Tap module Support module Server module_function + def parse_schema(params) + argh = pair_parse(params) + + parser = Parser.new + parser.parse(argh['nodes'] || []) + parser.parse(argh['joins'] || []) + parser.schema + end + def pair_parse(params) pairs = {} params.each_pair do |key, values| + next if key == nil key = key.chomp("%w") if key =~ /%w$/ slot = pairs[key] ||= [] values.each do |value| value = value.respond_to?(:read) ? value.read : value @@ -38,30 +48,50 @@ cgi = CGI.new("html3") # add HTML generation methods cgi.out() do case cgi.request_method when /GET/i - env.render('run.erb', :env => env, :tascs => [] ) - + schema = Tap::Support::Server.parse_schema(cgi.params).compact + env.render('run.erb', :env => env, :schema => schema) + when /POST/i action = cgi.params['action'][0] case action when 'add' index = cgi.params['index'][0].to_i - 1 - cgi.params['selected_tasks'].collect do |task| + sources = cgi.params['sources'].flatten.collect {|source| source.to_i } + targets = cgi.params['targets'].flatten.collect {|target| target.to_i } + + lines = [] + cgi.params['tasc'].select do |name| + name && !name.empty? + end.each do |name| index += 1 - tasc = env.tasks.search(task).constantize - env.render('run/task.erb', :tasc => tasc, :index => index ) - end.join("\n") + targets << index + lines << env.render('run/node.erb', :env => env, :node => Tap::Support::Node.new([name]), :index => index ) + end + join = case + when sources.length > 1 && targets.length == 1 + Tap::Support::Schema::Utils.format_merge(sources, targets, {}) + when sources.length == 1 && targets.length > 0 + Tap::Support::Schema::Utils.format_fork(sources, targets, {}) + else nil + end + + lines << env.render('run/join.erb', :env => env, :join => join) if join + lines.join("\n") + when 'remove' - when 'update' + else + # run cgi.pre do - argh = Tap::Support::Server.pair_parse(cgi.params) - Tap::Support::Schema.parse(argh['schema']).dump.to_yaml + schema = Tap::Support::Server.parse_schema(cgi.params) + schema.compact.dump.to_yaml + #env.build(schema) end end else raise ArgumentError, "unhandled request method: #{cgi.request_method}" end -end \ No newline at end of file +end