bin/dyn-yml in dyndoc-ruby-1.2.2 vs bin/dyn-yml in dyndoc-ruby-1.3.0

- old
+ new

@@ -96,86 +96,86 @@ ## ARGV is consumed before except doc=args[0] doc += "_dyn.yml" unless doc =~ /_dyn.yml$/ -require 'yaml' -require 'fileutils' -doc =~ /^(.*)_dyn\.yml$/ -docname=$1 +require 'dyndoc-tasks' -cfg_lines=File.readlines(doc) -i=0 -i += 1 if cfg_lines[i][0,3] == "---" +DyndocTasks.dyn_yml doc -if cfg_lines[i][0,9] == "dyntask: " - ## regular _dyn.yml file - cfg_yml=YAML::load(cfg_lines.join("\n")) -else - cfg_txt = cfg_lines[0..i].join("\n") - cfg_lines[(i+1)..-1].each do |line| - if line[0,2] == " " - cfg_txt << line - else - tn,td=line.split(":") - cfg_txt << tn.strip << ": |\n" - cfg_txt << " " << td.strip << "\n" - end - end - puts "ici\n" - puts cfg_txt - cfg_yml=YAML::load(cfg_txt.strip) -end +# require 'yaml' +# require 'fileutils' +# cfg_lines=File.readlines(doc) +# i=0 +# i += 1 if cfg_lines[i][0,3] == "---" -unless cfg_yml["dyntask"] - #attempt to know if format is the simplified one for workflow - ks=cfg_yml.keys - cfg2={"dyntask" => "workflow", "params" => {"id" => ks[0], "workdir" => cfg_yml[ks[0]]}} - tasks={} - ks[1..-1].each do |t| - kt,*pt=cfg_yml[t].strip.split("\n") - wt,tn=kt.strip.split("->").map{|e| e.strip if e} - if tn - tasks[t]={"dyntask" => tn} - wt="init" if wt.empty? - tasks[t]["wait"]=wt - pt=YAML::load(pt.join("\n")) - tasks[t]["params"]=pt - else - puts "Warning: task "+ t + " not considered because malformed" - end - end - cfg2["params"]["tasks"]=tasks - cfg_yml=cfg2 -end +# if cfg_lines[i][0,9] == "dyntask: " +# ## regular _dyn.yml file +# cfg_yml=YAML::load(cfg_lines.join("\n")) +# else +# cfg_txt = cfg_lines[0..i].join("\n") +# cfg_lines[(i+1)..-1].each do |line| +# if line[0,2] == " " +# cfg_txt << line +# else +# tn,td=line.split(":") +# cfg_txt << tn.strip << ": |\n" +# cfg_txt << " " << td.strip << "\n" +# end +# end +# cfg_yml=YAML::load(cfg_txt.strip) +# end -dyntaskname=cfg_yml["dyntask"] -if dyntaskname - puts dyntaskname - dyntaskname += "_task.dyn" unless dyntaskname=~/_task.dyn$/ - dyntaskpath=dyntaskname - is_dyntask=File.exists? dyntaskpath - unless is_dyntask - dyntaskpath=File.join(ENV["HOME"],"dyndoc","tasks",dyntaskname) - is_dyntask=File.exists? dyntaskpath - end - unless is_dyntask - share_path=File.expand_path("../../share", __FILE__) - dyntaskpath=File.join(share_path,"dyntasks",dyntaskname) - is_dyntask=File.exists? dyntaskpath - end - if is_dyntask - dynfile=docname+".dyn" - FileUtils.cp dyntaskpath, dynfile - $params=cfg_yml["params"] - $dyntask=dyntaskname - cfg_yml["params"].each do |key,val| - Settings["cfg_dyn.user_input"] << [key,val] - end +# unless cfg_yml["dyntask"] +# #attempt to know if format is the simplified one for workflow +# ks=cfg_yml.keys +# cfg2={"dyntask" => "workflow", "params" => {"id" => ks[0], "workdir" => cfg_yml[ks[0]]}} +# tasks={} +# ks[1..-1].each do |t| +# kt,*pt=cfg_yml[t].strip.split("\n") +# wt,tn=kt.strip.split("->").map{|e| e.strip if e} +# if tn +# tasks[t]={"dyntask" => tn} +# wt="init" if wt.empty? +# tasks[t]["wait"]=wt +# pt=YAML::load(pt.join("\n")) +# tasks[t]["params"]=pt +# else +# puts "Warning: task "+ t + " not considered because malformed" +# end +# end +# cfg2["params"]["tasks"]=tasks +# cfg_yml=cfg2 +# end - d=Dyndoc::TemplateDocument.new(dynfile) - d.make_all - end -end +# dyntaskname=cfg_yml["dyntask"] + +# if dyntaskname +# puts dyntaskname +# dyntaskname += "_task.dyn" unless dyntaskname=~/_task.dyn$/ +# dyntaskpath=dyntaskname +# is_dyntask=File.exists? dyntaskpath +# unless is_dyntask +# dyntaskpath=File.join(ENV["HOME"],"dyndoc","tasks",dyntaskname) +# is_dyntask=File.exists? dyntaskpath +# end +# unless is_dyntask +# share_path=File.expand_path("../../share", __FILE__) +# dyntaskpath=File.join(share_path,"dyntasks",dyntaskname) +# is_dyntask=File.exists? dyntaskpath +# end +# if is_dyntask +# dynfile=docname+".dyn" +# FileUtils.cp dyntaskpath, dynfile +# $params=cfg_yml["params"] +# $dyntask=dyntaskname +# cfg_yml["params"].each do |key,val| +# Settings["cfg_dyn.user_input"] << [key,val] +# end + +# d=Dyndoc::TemplateDocument.new(dynfile) +# d.make_all +# end +# end \ No newline at end of file