dyndoc-ruby 1.0.23 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: efaa2c1fbc83d0e19a3def894d93ab4a686e6e59
4
- data.tar.gz: 1d7f133b282633fd10a4529e7c866e1a985e5ae6
2
+ SHA256:
3
+ metadata.gz: 7fb3f2c7f43257295393916babc73a24a01b5be83f2497be40f4d6516fc0a8e3
4
+ data.tar.gz: 8a3d7d4ea1676d9192213b5062a7a25b80c8063c236e10d15378276bf5388ac8
5
5
  SHA512:
6
- metadata.gz: 9211516dd73b49480a4c54118cea317beca896926e58c423fa1c3039d29fa2be48d15042d0bf2a4431a8baee4409776ddbb217b2e5307db9652e443a6f43b691
7
- data.tar.gz: ce3033c3e02bbc937cd14e3ed40583722b1a4fdb3aa8ddf14852247442ec62af96446fc368e70a41cb235bf18348f75338143678a0c850447839f256c5145c4f
6
+ metadata.gz: 925f6d28081d121501344010bdcda7bbe71fbff2d412ed42673952aae9ef0a91bd0f539323316cf324b5f7e30464e71c879bd5f6939070c4290f75ff94b21b59
7
+ data.tar.gz: a5754bd8233d1b94ad5073bf1c69e28d62f7de77176a44b0c3353ac579d68a807762ac4437866b0fef71fef0cb66c73401a0a49c81e10d03336f3701042d5e20
data/bin/dyn CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'dyndoc/document'
4
4
 
5
+ puts "bin" ;p $0
5
6
  ## p Dyndoc.cfg_dir
6
7
 
7
8
  ## To be used for remote at the end
@@ -35,10 +36,15 @@ OptionParser.new do |opts|
35
36
 
36
37
  opts.on('-t','--tags TAGS',Array,'filter tags') {|t| Settings["cfg_dyn.tag_tmpl"] = t}
37
38
 
38
- opts.on('-C',"--content-only", "content only mode (no header!)") do
39
+ opts.on('-C',"--content_only", "content only mode (no header!)") do
39
40
  Settings["cfg_dyn.model_doc"] = "Content"
40
41
  end
41
42
 
43
+ opts.on('-x',"--exec_only", "exec only mode (no document!)") do
44
+ Settings["cfg_dyn.model_doc"] = "Content"
45
+ Settings["cfg_dyn.exec_mode"] = "yes"
46
+ end
47
+
42
48
  opts.on('-c', '--cmd COMMAND','[a(rchive old)][r(emove old)][s(ave)][pdf(latex)]') {|c|
43
49
  cmd =[:make_content]
44
50
  cmd << :save_old if c.include? "a"
@@ -72,6 +78,10 @@ OptionParser.new do |opts|
72
78
  Settings['cfg_dyn.debug']=true
73
79
  end
74
80
 
81
+ opts.on('-r','--rb_only','ruby only mode') do
82
+ Settings['cfg_dyn.ruby_only']=true
83
+ end
84
+
75
85
  opts.on("-p", "--pandoc ", "filter for pandoc (tex2docx,...)") do |f|
76
86
  #p [:pandoc,f]
77
87
  Settings["cfg_dyn.pandoc_filter"] = f
@@ -3,8 +3,8 @@
3
3
  require 'dyndoc/cli/interactive-client.rb'
4
4
 
5
5
  # USAGE:
6
- # dyndoc-ruby-client.rb|dyn-cli test.dyn[@127.0.0.1] [output_filename.html]
7
- # dyndoc-ruby-client.rb|dyn-cli test.dyn,layout.dyn[@127.0.0.1] [output_filename.html]
6
+ # dyn-cli test.dyn[@127.0.0.1] [output_filename.html]
7
+ # dyn-cli test.dyn,layout.dyn[@127.0.0.1] [output_filename.html]
8
8
 
9
9
  next_i=0
10
10
  dyn_tag_tmpl=nil
@@ -57,7 +57,6 @@ when "unwatch"
57
57
  Dyndoc::HtmlServers.unwatch_rm path
58
58
  end
59
59
 
60
-
61
60
  when "start"
62
61
  status=SRVS.map do |srv|
63
62
  `#{srv} status`.empty?
@@ -89,7 +88,7 @@ when "new"
89
88
  FileUtils.mkdir_p File.join(ENV["HOME"],"dyndoc",'log')
90
89
 
91
90
  unless File.exists? DYNCTL_PLIST
92
- plist= <<-END.sub(/CMD/,CMD).sub(/DYN_CMD/,`which #{CMD}`.strip).sub(/ERR_FILE/,DYNCTL_ERR_FILE).sub(/OUT_FILE/,DYNCTL_OUT_FILE).sub(/DYN_PATH/,ENV["PATH"]).sub(/DYN_LANG/,ENV["LANG"]).sub(/DYN_JULIA_DIR/,ENV["JULIA_DIR"] || "")
91
+ plist= <<-END.sub(/CMD/,CMD).sub(/DYN_CMD/,`which #{CMD}`.strip).sub(/ERR_FILE/,DYNCTL_ERR_FILE).sub(/OUT_FILE/,DYNCTL_OUT_FILE).sub(/DYN_PATH/,ENV["PATH"]).sub(/DYN_LANG/,ENV["LANG"]).sub(/DYN_JULIA_DIR/,ENV["JULIA_DIR"] || "").sub(/DYN_JULIA_RUBYLIB_PATH/,ENV["JULIA_RUBYLIB_PATH"])
93
92
  <?xml version="1.0" encoding="UTF-8"?>
94
93
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
95
94
  <plist version="1.0">
@@ -102,6 +101,10 @@ when "new"
102
101
  <string>DYN_LANG</string>
103
102
  <key>JULIA_DIR</key>
104
103
  <string>DYN_JULIA_DIR</string>
104
+ <key>JULIA_RUBYLIB_PATH</key>
105
+ <string>DYN_JULIA_RUBYLIB_PATH</string>
106
+ <key>OBJC_DISABLE_INITIALIZE_FORK_SAFETY</key>
107
+ <string>YES</string>
105
108
  </dict>
106
109
  <key>Label</key>
107
110
  <string>CMD</string>
@@ -0,0 +1,134 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'dyndoc/cli/interactive-client.rb'
4
+
5
+ # USAGE:
6
+ # dyn-x test.dyn[@127.0.0.1]
7
+
8
+ next_i=0
9
+ dyn_tag_tmpl=nil
10
+ ## very limited tags system
11
+ if ARGV[0] =~ /\-t\=/
12
+ next_i=1
13
+ dyn_tag_tmpl="[#<]{#opt]"+ARGV[0][3..-1].strip+"[#opt}"
14
+ end
15
+
16
+ arg=ARGV[next_i]
17
+ dyn_output=ARGV[next_i + 1]
18
+
19
+
20
+
21
+ if arg and arg.include? "@"
22
+ arg,addr=arg.split("@")
23
+ else
24
+ addr="127.0.0.1"
25
+ end
26
+
27
+ dyn_file,dyn_layout,dyn_libs,dyn_pre_code,dyn_post_code=nil,nil,nil,nil,nil
28
+
29
+ if arg and arg.include? ","
30
+ dyn_file,dyn_layout=arg.split(",")
31
+ else
32
+ dyn_file=arg
33
+ if i=(dyn_file =~ /\_?(?:html|tex)?\.dyn$/)
34
+ dyn_layout=dyn_file[0...i]+"_layout.dyn" if File.exist? dyn_file[0...i]+"_layout.dyn"
35
+ end
36
+ end
37
+
38
+ if !dyn_layout and File.exist? ".dyn_layout"
39
+ dyn_layout=File.read(".dyn_layout").strip
40
+ end
41
+
42
+ # Can be extended to other output?
43
+ if !dyn_layout and dyn_file =~ /\_(?:html|tex)(_[a-z,A-Z,0-9,-]*)\.dyn$/ # I guess this cpuld be very useful!
44
+ dyn_layout=$1 #layout class (not a path!) defined
45
+ end
46
+
47
+ # If you want a default layout put it inside ~/dyndoc/etc/dyn-cli/dyn_layout
48
+ if !dyn_layout and File.exist?(etc_dyn_layout=File.join(ENV["HOME"],"dyndoc","etc","dyn-cli","dyn_layout"))
49
+ dyn_layout=File.read(etc_dyn_layout).strip
50
+ end
51
+
52
+ # dyn library to require automatically
53
+ if !dyn_libs and File.exist? ".dynlibs"
54
+ dyn_libs=File.read(".dynlibs").strip
55
+ end
56
+
57
+ if !dyn_libs and File.exist?(etc_dyn_libs=File.join(ENV["HOME"],"dyndoc","etc","dyn-cli","dyn_libs"))
58
+ dyn_libs=File.read(etc_dyn_libs).strip
59
+ end
60
+
61
+ # very similar to dyn_libs but can preload any dyndoc
62
+ if i=(dyn_file =~ /\_?(?:html|tex)?\.dyn$/)
63
+ dyn_pre_code=File.read(dyn_file[0...i]+"_pre.dyn") if File.exist? dyn_file[0...i]+"_pre.dyn"
64
+ dyn_post_code=File.read(dyn_file[0...i]+"_post.dyn") if File.exist? dyn_file[0...i]+"_post.dyn"
65
+ end
66
+
67
+ if !dyn_pre_code and File.exist?(etc_dyn_pre_code=".dyn_pre_code")
68
+ etc_dyn_pre_code=File.read(etc_dyn_pre_code).strip
69
+ dyn_pre_code=File.read(etc_dyn_pre_code) if File.exist? etc_dyn_pre_code
70
+ end
71
+
72
+ if !dyn_libs and File.exist?(etc_dyn_pre_code=File.join(ENV["HOME"],"dyndoc","etc","dyn-cli","dyn_pre_code"))
73
+ etc_dyn_pre_code=File.read(etc_dyn_pre_code).strip
74
+ dyn_pre_code=File.read(etc_dyn_pre_code) if File.exist? etc_dyn_pre_code
75
+ end
76
+
77
+ # very similar to dyn_libs but can preload any dyndoc
78
+ if i=(dyn_file =~ /\_?(?:html|tex)?\.dyn$/)
79
+ dyn_pre_code=File.read(dyn_file[0...i]+"_pre.dyn") if File.exist? dyn_file[0...i]+"_pre.dyn"
80
+ dyn_post_code=File.read(dyn_file[0...i]+"_post.dyn") if File.exist? dyn_file[0...i]+"_post.dyn"
81
+ end
82
+
83
+ # similar to pre_code but for post_code
84
+ if !dyn_post_code and File.exist?(etc_dyn_post_code=".dyn_post_code")
85
+ etc_dyn_post_code=File.read(etc_dyn_post_code).strip
86
+ dyn_post_code=File.read(etc_dyn_post_code) if File.exist? etc_dyn_post_code
87
+ end
88
+
89
+ if !dyn_post_code and File.exist?(etc_dyn_post_code=File.join(ENV["HOME"],"dyndoc","etc","dyn-cli","dyn_post_code"))
90
+ etc_dyn_post_code=File.read(etc_dyn_post_code).strip
91
+ dyn_post_code=File.read(etc_dyn_post_code) if File.exist? etc_dyn_post_code
92
+ end
93
+
94
+
95
+ dyn_file=nil unless dyn_file and File.exist? dyn_file
96
+ if dyn_layout and !File.exist? dyn_layout
97
+ dyn_layout_path = ""
98
+ dyn_layout_path << File.read(etc_dyn_cli_layout_path).strip if File.exist?(etc_dyn_cli_layout_path=File.join(ENV["HOME"],"dyndoc","etc","dyn_cli_layout_path"))
99
+ dyn_layout_path << (dyn_layout_path.empty? ? "" : ";") << File.join(ENV["HOME"],"dyndoc","etc","dyn-cli","layout")
100
+ dyn_layouts=dyn_layout_path.split(";").map{|p| (File.exists? (tmp=File.join(p,dyn_layout+".dyn"))) ? tmp : nil }.compact
101
+ dyn_layout=dyn_layouts[0] #can be nil!
102
+ end
103
+
104
+ if dyn_file
105
+ code=File.read(dyn_file)
106
+ if dyn_libs or dyn_pre_code
107
+ code_pre = ""
108
+ code_pre += dyn_pre_code + "\n" if dyn_pre_code
109
+ code_pre += '[#require]'+"\n"+dyn_libs if dyn_libs
110
+ code = code_pre + '[#main][#>]' + code
111
+ end
112
+ code += "\n" + dyn_post_code if dyn_post_code
113
+ code = dyn_tag_tmpl+code if dyn_tag_tmpl
114
+ dyndoc_start=[:dyndoc_libs,:dyndoc_layout]
115
+ ## tag tmpl attempt to communicate to the server
116
+ if dyn_tag_tmpl
117
+ ##TODO: :dyndoc_tag_tmpl to add to dyndoc_start
118
+ ## but also to dyndoc-server-simple.rb
119
+ end
120
+
121
+ cli=Dyndoc::InteractiveClient.new(code,File.expand_path(dyn_file),addr,dyndoc_start)
122
+
123
+ if dyn_layout
124
+ cli=Dyndoc::InteractiveClient.new(File.read(dyn_layout),"",addr) #File.expand_path(dyn_layout),addr)
125
+ end
126
+
127
+ if dyn_output and Dir.exist? File.dirname(dyn_output)
128
+ File.open(dyn_output,"w") do |f|
129
+ f << cli.content
130
+ end
131
+ else
132
+ puts cli.content
133
+ end
134
+ end
@@ -0,0 +1,181 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'dyndoc/document'
4
+
5
+ args=ARGV.select{|name|
6
+ if (name[0,2]!="--" and name.include? "=")
7
+ key,*val=name.split("=")
8
+ val=val.join("=")
9
+ Settings["cfg_dyn.user_input"] << [key,val]
10
+ false
11
+ else
12
+ true
13
+ end
14
+ }
15
+
16
+ args=["-h"] if args.empty?
17
+
18
+ # Default for dyn-yml is without :R and :jl and :exec_mode activated since it is tailor-made for managing task
19
+ # use option -R to activate :R (and :jl if declared in ~/.dyndoc.yml)
20
+ Settings['cfg_dyn.ruby_only']=true
21
+ # use option -w (like write) to deactivate exec_mode
22
+ Settings["cfg_dyn.model_doc"] = "Content"
23
+ Settings["cfg_dyn.exec_mode"] = "yes"
24
+
25
+ require 'optparse'
26
+
27
+ OptionParser.new do |opts|
28
+ opts.banner = "Usage: dyndoc-compile.rb [options]"
29
+
30
+ opts.on("-d", "--docs one,two,three", Array, "list of documents to compile") do |list|
31
+ Settings["cfg_dyn.doc_list"] = list
32
+ end
33
+
34
+ opts.on("-f", "--format ", "format of the dyndoc document") do |format|
35
+ Settings["cfg_dyn.format_doc"] = format.to_sym
36
+ end
37
+
38
+ opts.on('-t','--tags TAGS',Array,'filter tags') {|t| Settings["cfg_dyn.tag_tmpl"] = t}
39
+
40
+ opts.on('-C',"--content_only", "content only mode (no header!)") do
41
+ Settings["cfg_dyn.model_doc"] = "Content"
42
+ end
43
+
44
+ opts.on('-w',"--no_exec_only", "exec only mode (no document!)") do
45
+ Settings["cfg_dyn.model_doc"] = "default"
46
+ Settings["cfg_dyn.exec_mode"] = "no"
47
+ end
48
+
49
+ opts.on('-c', '--cmd COMMAND','[a(rchive old)][r(emove old)][s(ave)][pdf(latex)]') {|c|
50
+ cmd =[:make_content]
51
+ cmd << :save_old if c.include? "a"
52
+ cmd << :rm_old if c.include? "r"
53
+ cmd << :save if c.include? "s"
54
+ ## cmd << :cat if c.include? "c"
55
+ cmd << :pdf if c =~ /(E)?pdf([1-3])?/ #if c.include? "pdf"
56
+ Settings["cfg_dyn.options.pdflatex_echo"]=true if $1 # useable for log sytem (to introduce possibly later)
57
+ Settings["cfg_dyn.options.pdflatex_nb_pass"]=$2.to_i if $2
58
+ ## cmd << :png if c.include? "png"
59
+ ## cmd << :view if c.include? "v"
60
+ ## cmd << :save << :view if c.include? "x"
61
+ ## cmd =[:cat] if cmd.empty? #and cfg_dyn[:model_doc]=="content"
62
+ ## cmd = [:pdf] if c=="pdf" #only pdflatex
63
+ Settings["cfg_dyn.cmd_doc"] = cmd
64
+ }
65
+
66
+ opts.on("-l", "--list", "list of documents available") do
67
+ Settings["cfg_dyn.cmd_doc"] = [:list]
68
+ end
69
+
70
+ opts.on("-j", "--jl", "import julia") do
71
+ Settings["cfg_dyn.langs"] << :jl
72
+ end
73
+
74
+ # opts.on("-r", "--remote", "pandoc or pdflatex (dyn)task performed remotely") do
75
+ # Settings["cfg_dyn.remote_dyntask"] = true
76
+ # end
77
+
78
+ opts.on('-D','--debug','debug mode') do
79
+ Settings['cfg_dyn.debug']=true
80
+ end
81
+
82
+ opts.on('-R','--no_rb_only','no ruby only mode') do
83
+ Settings['cfg_dyn.ruby_only']=false
84
+ end
85
+
86
+ opts.on("-p", "--pandoc ", "filter for pandoc (tex2docx,...)") do |f|
87
+ #p [:pandoc,f]
88
+ Settings["cfg_dyn.pandoc_filter"] = f
89
+ end
90
+
91
+ # opts.on('--docker',"docker mode") do
92
+ # Settings["cfg_dyn.docker_mode"]=true
93
+ # end
94
+
95
+ end.parse!(args)
96
+
97
+ ## ARGV is consumed before except
98
+ doc=args[0]
99
+
100
+ doc += "_dyn.yml" unless doc =~ /_dyn.yml$/
101
+ require 'yaml'
102
+ require 'fileutils'
103
+
104
+ doc =~ /^(.*)_dyn\.yml$/
105
+ docname=$1
106
+
107
+ cfg_lines=File.readlines(doc)
108
+ i=0
109
+ i += 1 if cfg_lines[i][0,3] == "---"
110
+
111
+ if cfg_lines[i][0,9] == "dyntask: "
112
+ ## regular _dyn.yml file
113
+ cfg_yml=YAML::load(cfg_lines.join("\n"))
114
+ else
115
+ cfg_txt = cfg_lines[0..i].join("\n")
116
+ cfg_lines[(i+1)..-1].each do |line|
117
+ if line[0,2] == " "
118
+ cfg_txt << line
119
+ else
120
+ tn,td=line.split(":")
121
+ cfg_txt << tn.strip << ": |\n"
122
+ cfg_txt << " " << td.strip << "\n"
123
+ end
124
+ end
125
+ puts "ici\n"
126
+ puts cfg_txt
127
+ cfg_yml=YAML::load(cfg_txt.strip)
128
+ end
129
+
130
+
131
+ unless cfg_yml["dyntask"]
132
+ #attempt to know if format is the simplified one for workflow
133
+ ks=cfg_yml.keys
134
+ cfg2={"dyntask" => "workflow", "params" => {"id" => ks[0], "workdir" => cfg_yml[ks[0]]}}
135
+ tasks={}
136
+ ks[1..-1].each do |t|
137
+ kt,*pt=cfg_yml[t].strip.split("\n")
138
+ wt,tn=kt.strip.split("->").map{|e| e.strip if e}
139
+ if tn
140
+ tasks[t]={"dyntask" => tn}
141
+ wt="init" if wt.empty?
142
+ tasks[t]["wait"]=wt
143
+ pt=YAML::load(pt.join("\n"))
144
+ tasks[t]["params"]=pt
145
+ else
146
+ puts "Warning: task "+ t + " not considered because malformed"
147
+ end
148
+ end
149
+ cfg2["params"]["tasks"]=tasks
150
+ cfg_yml=cfg2
151
+ end
152
+
153
+ dyntaskname=cfg_yml["dyntask"]
154
+
155
+ if dyntaskname
156
+ puts dyntaskname
157
+ dyntaskname += "_task.dyn" unless dyntaskname=~/_task.dyn$/
158
+ dyntaskpath=dyntaskname
159
+ is_dyntask=File.exists? dyntaskpath
160
+ unless is_dyntask
161
+ dyntaskpath=File.join(ENV["HOME"],"dyndoc","tasks",dyntaskname)
162
+ is_dyntask=File.exists? dyntaskpath
163
+ end
164
+ unless is_dyntask
165
+ share_path=File.expand_path("../../share", __FILE__)
166
+ dyntaskpath=File.join(share_path,"dyntasks",dyntaskname)
167
+ is_dyntask=File.exists? dyntaskpath
168
+ end
169
+ if is_dyntask
170
+ dynfile=docname+".dyn"
171
+ FileUtils.cp dyntaskpath, dynfile
172
+ $params=cfg_yml["params"]
173
+ $dyntask=dyntaskname
174
+ cfg_yml["params"].each do |key,val|
175
+ Settings["cfg_dyn.user_input"] << [key,val]
176
+ end
177
+
178
+ d=Dyndoc::TemplateDocument.new(dynfile)
179
+ d.make_all
180
+ end
181
+ end
@@ -18,6 +18,9 @@ module Dyndoc
18
18
  if html_file =~ /^(.*)_(rmd|adoc|ttm)\.html$/
19
19
  html_file = $1+".html"
20
20
  end
21
+ if html_file =~ /^(.*)_erb\.html$/
22
+ html_file = $1+".erb"
23
+ end
21
24
 
22
25
  if html_file and Dir.exist? File.dirname(html_file)
23
26
  File.open(html_file,"w") do |f|
@@ -3,10 +3,10 @@ require 'pathname'
3
3
  require 'yaml'
4
4
  require 'filewatcher'
5
5
 
6
- if RUBY_VERSION >= "2.4"
6
+ #if RUBY_VERSION >= "2.4"
7
7
  class FileWatcher < Filewatcher
8
8
  end
9
- end
9
+ #end
10
10
 
11
11
  module Dyndoc
12
12
  module Browser
@@ -296,11 +296,19 @@ module Dyndoc
296
296
  if html_file =~ /^(.*)_(rmd|adoc|ttm)\.html$/
297
297
  html_file = $1+".html"
298
298
  end
299
+ if html_file =~ /^(.*)_erb\.html$/
300
+ erb_page=File.join(pages_root,$1)
301
+ if File.exists? erb_page+"_erb.html"
302
+ FileUtils.mv erb_page+"_erb.html",erb_page+".erb"
303
+ end
304
+ html_file = "erb"+$1
305
+ end
299
306
  puts dyn_file[1..-1]+" processed => "+html_file+" created!"
300
307
  options[:first] = html_file != old_html_file
301
308
  if html_file != old_html_file
302
309
  old_html_file = html_file
303
310
  url=File.join(base_url,html_file)
311
+ ## p [:url,url]
304
312
  Dyndoc::Browser.load(url)
305
313
  else
306
314
  Dyndoc::Browser.reload
@@ -20,6 +20,11 @@ module Dyndoc
20
20
  Dyndoc::Linter.simplify_dyndoc_tags(tags)
21
21
  break
22
22
  end
23
+ if (tags[i][1] == "{@"+tags[i+1][1][2..-2]+"]" and tags[i+1][1] == "[@"+tags[i][1][2..-2]+"}") or (tags[i][1][0]=="{" and tags[i+1][1]=="[@}")
24
+ tags.delete_at i+1;tags.delete_at i
25
+ Dyndoc::Linter.simplify_dyndoc_tags(tags)
26
+ break
27
+ end
23
28
  end
24
29
  return tags
25
30
  end
@@ -0,0 +1 @@
1
+ [#rb<]$params["files"].each {|f| system("rm "+f)}
@@ -0,0 +1 @@
1
+ [#rb<]system("pdflatex "+$params['input'])
@@ -0,0 +1,82 @@
1
+ [#%]Création de tâches à lancer en mode asynchone (mode synchrone comme un cas particulier)
2
+
3
+ L'idée est :
4
+ * de créer des fichiers _dyn.yml qui seront en charge de définir les tâches à exécuter en asynchrone
5
+ * de créer en même temps le script bash pour effectivement lancer ces tâches
6
+ * puis en fin de lancer le script de tâche qui sera exécuté dans un répertoire de travail associé au projet
7
+
8
+ [#?]!(wd=$params["workdir"]).empty? [#%]Rien à faire si pas de workdir
9
+ [#=]prj_id[:{$params["id"]}]
10
+ [#<]
11
+
12
+ {#def]waitfor[#,]task[][#,]cond[] [#,]cpt_max[20] [#,]lag[.5]
13
+ [#rb<]
14
+ prj=$params["id"]
15
+ wait_cond=#{=cond}.split("&").map{|e| " [ ! -e " + prj + "-" + e.strip + ".task ]" }.join(" && ")
16
+ [#>][
17
+ waitfor_:{prj}_#{task}() {
18
+ local cpt="0"
19
+ echo "waiting for task #{task} in project :{prj}"
20
+ while :{wait_cond} && [ $cpt != "#{cpt_max}" ]
21
+ do
22
+ sleep #{lag}
23
+ # echo -ne "."
24
+ cpt=$(($cpt+1))
25
+ done
26
+ #echo ""
27
+ if [ $cpt -eq "#{cpt_max}" ]
28
+ then
29
+ return 1
30
+ else
31
+ return 0
32
+ fi
33
+ }
34
+ ]
35
+ [#def}
36
+
37
+ [#rb<]
38
+ require 'yaml'
39
+ cfg_yml = File.join(Dyndoc.home,"etc","dyn-html.yml")
40
+ dynworld_root=cfg_yml["dynworld_root"] || File.join(ENV["HOME"],".dyndoc-world")
41
+ wd=File.join(dynworld_root,wd)
42
+
43
+ FileUtils.rm_rf wd if Dir.exist? wd
44
+ FileUtils.mkdir_p wd
45
+ shscript=""
46
+ prj_id=#{=prj_id}
47
+ # Creation of dyn tasks (_dyn.yml files)
48
+ tasks=$params["tasks"]
49
+ #p [:tasks,tasks.keys]
50
+ ## shell fcts
51
+ tasks.keys.each do |task| #
52
+ ## puts "task: "+task+"\n"
53
+ task_id = (task[-1,1]==">" ? task[0..-2] : task)
54
+ task_cond=tasks[task]["wait"]
55
+ {#<][#rb<]
56
+ |shscript << %Q(
57
+ |{#waitfor]:{task_id}[#cond]:{task_cond}[#}
58
+ |)
59
+ [#<}
60
+ end
61
+ ## shell script
62
+ shscript << "cd " + wd + "\n"
63
+ tasks.keys.each do |task| #
64
+ ## puts "task: "+task+"\n"
65
+ task_id = (task[-1,1]==">" ? task[0..-2] : task)
66
+ task_yml = File.join(wd,prj_id+"-"+task_id+"_dyn.yml")
67
+ puts "Creating "+task_yml+"\n"
68
+ begin
69
+ dyntask=(tasks[task].is_a? String) ? tasks[tasks[task]] : tasks[task]
70
+ dyntask=dyntask.select{|k| ["dyntask","params"].include? k}
71
+ #p [:dyntask,dyntask,dyntask.empty?]
72
+ File.open(task_yml,"w") {|f| f << dyntask.to_yaml } unless dyntask.empty?
73
+ rescue
74
+ puts "Task not created\n"
75
+ end
76
+ shscript << "{ waitfor_" << prj_id << "_" << task_id << " && dyn-yml " << ( task_id[0,1] == task_id[0,1].upcase ? "-R " : "") << ( task_id == task ? "" : "-w ") << prj_id << "-" << task_id << "_dyn.yml " << "&& touch " << prj_id << "-" << task_id << ".task; } &\n"
77
+ end
78
+ shscript << "touch "+ prj_id + "-init.task\n"
79
+ #p [:script,shscript]
80
+ File.open(File.join(wd,"task.sh"),"w") {|f| f << shscript}
81
+ Process.spawn(". " +File.join(wd,"task.sh"))
82
+ [#?]end
@@ -10,6 +10,12 @@ cfg.merge! YAML::load_file(cfg_yml) if File.exist? cfg_yml
10
10
  root = cfg["root"] || File.join(ENV["HOME"],"RCqls","RodaServer")
11
11
  $public_root = cfg["public_root"] || File.join(root ,"public")
12
12
  ##p [:public_root,$public_root]
13
+ $dynworld_root=cfg["dynworld_root"] || File.join(ENV["HOME"],".dyndoc-world")
14
+ $dynworld_tools=cfg["dynworld_tools"] || File.join(ENV["HOME"],"Gogs","dynworld")
15
+ if Dir.exists? $dynworld_tools
16
+ require File.join($dynworld_tools,"tools.rb")
17
+ puts "Dynworld activated"
18
+ end
13
19
 
14
20
  class App < Roda
15
21
  use Rack::Session::Cookie, :secret => (secret="Thanks like!")
@@ -20,12 +26,14 @@ class App < Roda
20
26
  plugin :multi_route
21
27
  ###Dir[File.expand_path("../routes/*.rb",__FILE__)].each{|f| require f}
22
28
  plugin :header_matchers
29
+ plugin :json
30
+ plugin :json_parser
23
31
  plugin :render,
24
- :views => File.expand_path("../views",__FILE__),
32
+ :views => File.join($public_root,"views"),
25
33
  :escape=>true,
26
34
  :check_paths=>true,
27
- :allowed_paths=>[File.expand_path("../views",__FILE__),$public_root]
28
-
35
+ :allowed_paths=>[File.join($public_root,"views"),$public_root]
36
+ plugin :route_csrf
29
37
  route do |r|
30
38
 
31
39
  # GET / request
@@ -33,6 +41,56 @@ class App < Roda
33
41
  r.redirect "/hello"
34
42
  end
35
43
 
44
+ r.on "dynworld" do
45
+
46
+ r.post "file-save" do
47
+ puts "file-save"
48
+ prj,yml,@file,@content=r['prj'].strip,r['yml'].strip,r['file'].strip,r['content']
49
+ p [prj,yml,@file,@content]
50
+ success=false
51
+ unless yml.empty?
52
+ yml="---\n" + yml unless yml[0,4] == "---\n"
53
+ yml=YAML::load(yml)
54
+ p [:yml, yml]
55
+ require 'fileutils'
56
+ if @file and !(@file.include? "../") and (DyndocWorld.yml?(prj,yml))
57
+ if Dir.exists? $dynworld_root
58
+ prj_dir=DyndocWorld.prj_dir(prj,yml)
59
+ dynworld_file=File.join($dynworld_root,prj_dir,@file)
60
+ FileUtils.mkdir_p File.dirname dynworld_file
61
+ File.open(dynworld_file,"w") {|f| f << @content.strip}
62
+ success=true
63
+ end
64
+ end
65
+ end
66
+ "{success: " + success.to_s + "}"
67
+ end
68
+
69
+ r.post "file-upload" do
70
+ uploaded_io = r[:file]
71
+ ##
72
+ p [:uploaded_io, uploaded_io]
73
+ @upload_dir=r["upload_dir"]
74
+ p [:file_upload_dir,@upload_dir]
75
+ # FileUtils.mkdir_p File.join(@upload_dir_root,@upload_dir)
76
+ # uploaded_io[:filename].gsub("'","_") if uploaded_io[:filename].include? "'"
77
+ # File.open(File.join(@upload_dir_root,@upload_dir, uploaded_io[:filename]), 'wb') do |file|
78
+ # file.write(uploaded_io[:tempfile].read)
79
+ # end
80
+ "{success: true}"
81
+ end
82
+
83
+ r.post "file-delete" do
84
+ @upload_dir=r["upload_dir"]
85
+ p @upload_dir
86
+ # deleted_file=File.join(@upload_dir_root,@upload_dir,r[:file_name])
87
+ # ##p deleted_file
88
+ # FileUtils.rm(deleted_file)
89
+ "{success: true}"
90
+ end
91
+
92
+ end
93
+
36
94
  #r.multi_route
37
95
 
38
96
  # /hello branch
@@ -78,10 +136,31 @@ class App < Roda
78
136
  =end
79
137
 
80
138
  r.get do
139
+ check_csrf!
81
140
  page=r.remaining_path
141
+ p [:captures,r.remaining_path,r.captures,r.scope,r.params]
82
142
  static_root=File.join($public_root,"pages")
143
+
144
+ ## Added for erb
145
+ is_erb = (page[0...4] == "/erb")
146
+ if is_erb
147
+ page=page[4..-1]
148
+ @params=r.params
149
+ end
150
+
151
+ ## Added to protect page
152
+ @protect = "no"
153
+ if (page[0...8] == "/protect")
154
+ page=page[8..-1]
155
+ if page =~ /^\/([^\/]*)\/(.*)$/
156
+ @protect, page = $1, '/' + $2
157
+ end
158
+ p [:protect, @protect, page]
159
+ end
160
+
83
161
  ##p [:page,File.join(static_root,"**",page+".html")]
84
- pattern=(page=~/[^\.]*\.(?:R|Rmd|css|js|htm|html|rb|red|r|jpeg|jpg|png|gif|pdf)/) ? page : page+".html"
162
+
163
+ pattern=(page=~/[^\.]*\.(?:R|Rmd|css|js|htm|html|rb|red|r|jpeg|jpg|png|gif|pdf)/) ? page : page+(is_erb ? ".erb" : ".html")
85
164
 
86
165
  html_files=Dir[File.join(static_root,"**",pattern)]
87
166
  html_files=Dir[File.join(static_root,"*","**",pattern)] if html_files.empty?
@@ -98,13 +177,16 @@ class App < Roda
98
177
 
99
178
  ##DEBUG: p html_files
100
179
 
101
- ##p html_files
102
180
  unless html_files.empty?
103
181
  html_file="pages/"+Pathname(html_files[0]).relative_path_from(Pathname(static_root)).to_s
104
- if File.extname(html_file) == ".html"
105
- html_file=File.join(File.dirname(html_file),File.basename(html_file,".html"))
182
+ if [".html",".erb"].include? (html_file_ext=File.extname(html_file))
183
+ html_file=File.join(File.dirname(html_file),File.basename(html_file,html_file_ext))
106
184
  p html_file
107
- render html_file, :engine=>'html', :views=>$public_root
185
+ if is_erb
186
+ erb_yml=File.join($public_root,html_file+"_erb.yml")
187
+ @cfg_erb=(File.exists? erb_yml) ? YAML::load_file(erb_yml) : {}
188
+ end
189
+ render html_file, :engine=> (is_erb ? "erb" : 'html'), :views=>$public_root
108
190
  else
109
191
  r.redirect html_file
110
192
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dyndoc-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.23
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - RCqls
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-24 00:00:00.000000000 Z
11
+ date: 2019-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: R4rb
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.0.0
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: '1.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +27,9 @@ dependencies:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: 1.0.0
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: dyndoc-ruby-core
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -31,6 +37,9 @@ dependencies:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
33
39
  version: 1.0.0
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '1.0'
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -38,6 +47,9 @@ dependencies:
38
47
  - - ">="
39
48
  - !ruby/object:Gem::Version
40
49
  version: 1.0.0
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '1.0'
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: dyndoc-ruby-doc
43
55
  requirement: !ruby/object:Gem::Requirement
@@ -45,6 +57,9 @@ dependencies:
45
57
  - - ">="
46
58
  - !ruby/object:Gem::Version
47
59
  version: 1.0.0
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.0'
48
63
  type: :runtime
49
64
  prerelease: false
50
65
  version_requirements: !ruby/object:Gem::Requirement
@@ -52,6 +67,9 @@ dependencies:
52
67
  - - ">="
53
68
  - !ruby/object:Gem::Version
54
69
  version: 1.0.0
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '1.0'
55
73
  - !ruby/object:Gem::Dependency
56
74
  name: dyndoc-ruby-exec
57
75
  requirement: !ruby/object:Gem::Requirement
@@ -59,6 +77,9 @@ dependencies:
59
77
  - - ">="
60
78
  - !ruby/object:Gem::Version
61
79
  version: 0.1.0
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.1'
62
83
  type: :runtime
63
84
  prerelease: false
64
85
  version_requirements: !ruby/object:Gem::Requirement
@@ -66,10 +87,16 @@ dependencies:
66
87
  - - ">="
67
88
  - !ruby/object:Gem::Version
68
89
  version: 0.1.0
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '0.1'
69
93
  - !ruby/object:Gem::Dependency
70
94
  name: asciidoctor
71
95
  requirement: !ruby/object:Gem::Requirement
72
96
  requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '1.5'
73
100
  - - ">="
74
101
  - !ruby/object:Gem::Version
75
102
  version: 1.5.3
@@ -77,6 +104,9 @@ dependencies:
77
104
  prerelease: false
78
105
  version_requirements: !ruby/object:Gem::Requirement
79
106
  requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '1.5'
80
110
  - - ">="
81
111
  - !ruby/object:Gem::Version
82
112
  version: 1.5.3
@@ -84,6 +114,9 @@ dependencies:
84
114
  name: redcarpet
85
115
  requirement: !ruby/object:Gem::Requirement
86
116
  requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '3.3'
87
120
  - - ">="
88
121
  - !ruby/object:Gem::Version
89
122
  version: 3.3.4
@@ -91,6 +124,9 @@ dependencies:
91
124
  prerelease: false
92
125
  version_requirements: !ruby/object:Gem::Requirement
93
126
  requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: '3.3'
94
130
  - - ">="
95
131
  - !ruby/object:Gem::Version
96
132
  version: 3.3.4
@@ -98,20 +134,29 @@ dependencies:
98
134
  name: filewatcher
99
135
  requirement: !ruby/object:Gem::Requirement
100
136
  requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '1.0'
101
140
  - - ">="
102
141
  - !ruby/object:Gem::Version
103
- version: 0.5.3
142
+ version: 1.0.1
104
143
  type: :runtime
105
144
  prerelease: false
106
145
  version_requirements: !ruby/object:Gem::Requirement
107
146
  requirements:
147
+ - - "~>"
148
+ - !ruby/object:Gem::Version
149
+ version: '1.0'
108
150
  - - ">="
109
151
  - !ruby/object:Gem::Version
110
- version: 0.5.3
152
+ version: 1.0.1
111
153
  - !ruby/object:Gem::Dependency
112
154
  name: foreverb
113
155
  requirement: !ruby/object:Gem::Requirement
114
156
  requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.3'
115
160
  - - ">="
116
161
  - !ruby/object:Gem::Version
117
162
  version: 0.3.3
@@ -119,6 +164,9 @@ dependencies:
119
164
  prerelease: false
120
165
  version_requirements: !ruby/object:Gem::Requirement
121
166
  requirements:
167
+ - - "~>"
168
+ - !ruby/object:Gem::Version
169
+ version: '0.3'
122
170
  - - ">="
123
171
  - !ruby/object:Gem::Version
124
172
  version: 0.3.3
@@ -137,6 +185,7 @@ executables:
137
185
  - dyn-auto
138
186
  - dyn-ctl
139
187
  - dyn-4ever
188
+ - dyn-yml
140
189
  extensions: []
141
190
  extra_rdoc_files: []
142
191
  files:
@@ -152,6 +201,8 @@ files:
152
201
  - bin/dyn-lint
153
202
  - bin/dyn-scan
154
203
  - bin/dyn-srv
204
+ - bin/dyn-x
205
+ - bin/dyn-yml
155
206
  - install/README.md
156
207
  - install/dyn-upstart.sh
157
208
  - install/dyndoc_install_ubuntu.sh
@@ -173,6 +224,9 @@ files:
173
224
  - share/demo/test_atom.dyn
174
225
  - share/dyndoc.yml/README.md
175
226
  - share/dyndoc.yml/example.dyndoc.yml
227
+ - share/dyntasks/clean_task.dyn
228
+ - share/dyntasks/pdflatex_task.dyn
229
+ - share/dyntasks/workflow_task.dyn
176
230
  - share/etc/alias
177
231
  - share/etc/dyn-cli/dyn_layout
178
232
  - share/etc/dyn-cli/layout/default.dyn
@@ -429,7 +483,7 @@ files:
429
483
  homepage: http://cqls.upmf-grenoble.fr
430
484
  licenses:
431
485
  - MIT
432
- - GPL-2
486
+ - GPL-2.0
433
487
  metadata: {}
434
488
  post_install_message:
435
489
  rdoc_options: []
@@ -447,8 +501,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
447
501
  version: '0'
448
502
  requirements:
449
503
  - none
450
- rubyforge_project:
451
- rubygems_version: 2.6.13
504
+ rubygems_version: 3.0.6
452
505
  signing_key:
453
506
  specification_version: 4
454
507
  summary: R and Ruby in text document