dyntask-ruby 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3960a72b5fb658355f5e33807c8a4056c6a0f0a
4
- data.tar.gz: 44abacaeb363999ee59a8f6307b1c05e2fd3327c
3
+ metadata.gz: e7945c071a49caf43f626c7200795e6a4da3d65f
4
+ data.tar.gz: bbad192aa401193a9a815c1c0b6950b0d526a059
5
5
  SHA512:
6
- metadata.gz: 18ca229bb5dc01baae76018a08c0561bca8de2bb9244f63ff2027e11d586f7e882250dc1ad0f2c70ecf43a01722c6d0036c9d401e6b2427e8b08b3e2ad786c69
7
- data.tar.gz: 198f3023db1ee6b0f98b7e48b08221da2a030c8dd5e7c12ff9180b8ccc846d5b707762ea926a0ee5425d66edc450f8f566676c576734b5505b8034e5beaa56c3
6
+ metadata.gz: 5d04058801c4fcc97b86e65a95acbdaa58280975fad07a243f6c5ab7c2b20a56a15fc1bd0d9ea1e74cabc9cb4d824592ce520cc3be29c2ef82f272bb46593b65
7
+ data.tar.gz: 6df4f27a53b959ec0fcbe52167723fbcaba8be145b70e463ebc7bf340f9dfee5818f101d10d64a9d9b1c69fd5d3cf9e47499e1fbe4d3b2a9870bec30c0983104
data/bin/dyntask-init CHANGED
@@ -23,7 +23,11 @@ end
23
23
 
24
24
  Trollop::die Trollop::educate if(ARGV.size == 0)
25
25
 
26
- if ARGV[0] == "pandoc-extra"
26
+ case ARGV[0] || "first"
27
+ when "first"
28
+ FileUtils.mkdir_p DynTask.cfg_dir[:root] unless File.directory? DynTask.cfg_dir[:root]
29
+ FileUtils.cp_r File.expand_path('../../share',__FILE__),DynTask.cfg_dir[:share] unless File.directory? File.join(DynTask.cfg_dir[:share])
30
+ when "pandoc-extra"
27
31
  case ARGV[1]
28
32
  when "ls"
29
33
  if File.directory? DynTask.cfg_pandoc[:extra_dir]
@@ -55,36 +59,85 @@ if ARGV[0] == "pandoc-extra"
55
59
 
56
60
  end
57
61
  exit
58
- end
59
-
60
-
61
-
62
- if ARGV.size == 1 and ARGV[0]=="ls"
63
- Dir[File.join(DynTask.cfg_dir[:etc],"tasks","**/*")].each do |f|
64
- puts "#{File.basename(f)}: #{File.read(f)}"
65
- end
66
- exit
67
- end
68
-
69
- etc_tasks=File.join(DynTask.cfg_dir[:etc],"tasks",ARGV[0])
70
-
71
- if ARGV.size==1
72
- if options[:rm] and options[:force]
73
- require 'fileutils'
74
- FileUtils.rm etc_tasks
75
- end
76
- else
77
- if File.exists? etc_tasks and !options[:force]
78
- puts "Error: file #{etc_tasks} already exist. Use --force or -f to modify this file!"
79
- exit
80
- else
81
- require 'fileutils'
82
- FileUtils.mkdir_p File.dirname(etc_tasks)
83
- dyntask_tasks=ARGV[1..-1].join(" ")
84
- File.open(etc_tasks,"w") do |f|
85
- f << dyntask_tasks
62
+ when "srv" #MacOSX user only
63
+ if RUBY_PLATFORM =~ /darwin/
64
+ dyntask_srv_plist=File.expand_path("~/Library/LaunchAgents/dyntask-srv.plist")
65
+ case ARGV[1] || "help"
66
+ when "help"
67
+ puts <<-DOC
68
+ launchctl helpers to launch dyntask-srv service.
69
+ Usage:
70
+ dyntask-init srv new|load => create when not existing the dyntask-srv service
71
+ dyntask-init srv unload => unload existing service
72
+ dyntask-init srv start/stop => start/stop the dyntask-srv service
73
+ dyntask-init srv list => list dyntask-srv service
74
+ DOC
75
+ when "load","new"
76
+ unless File.exists? dyntask_srv_plist
77
+ plist= <<-END.sub(/DYNTASKSRV/,`which dynask-srv`.strip)
78
+ <?xml version="1.0" encoding="UTF-8"?>
79
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
80
+ <plist version="1.0">
81
+ <dict>
82
+ <key>Label</key>
83
+ <string>dyntask-srv</string>
84
+ <key>ProgramArguments</key>
85
+ <array>
86
+ <string>DYNTASKSRV</string>
87
+ </array>
88
+ <key>RunAtLoad</key>
89
+ <true/>
90
+ <key>KeepAlive</key>
91
+ <dict>
92
+ <key>Crashed</key>
93
+ <true/>
94
+ </dict>
95
+ <key>StandardErrorPath</key>
96
+ <string>/tmp/dyntask-srv.err</string>
97
+ <key>StandardOutPath</key>
98
+ <string>/tmp/dyntask-srv.out</string>
99
+ </dict>
100
+ </plist>
101
+ END
102
+ File.open(dyntask_srv_plist,"w") do |f|
103
+ f << plist
104
+ end
105
+ end
106
+ `launchctl load #{dyn_srv_plist}`
107
+ when "unload"
108
+ if File.exists? dyntask_srv_plist
109
+ `launchctl unload #{dyntask_srv_plist}`
110
+ else
111
+ puts "Service dyntask-srv not available. Create it first: dyntask-init srv new"
112
+ end
113
+ when "start", "stop"
114
+ `launchctl #{mode} dyntask-srv`
115
+ when "list"
116
+ puts `launchctl list | grep dyn`
86
117
  end
87
- end
118
+ end
88
119
  end
89
120
 
90
- puts "#{etc_tasks} contains: #{File.read(etc_tasks)}" if File.exists? etc_tasks
121
+
122
+ # etc_tasks=File.join(DynTask.cfg_dir[:etc],"tasks",ARGV[0])
123
+ #
124
+ # if ARGV.size==1
125
+ # if options[:rm] and options[:force]
126
+ # require 'fileutils'
127
+ # FileUtils.rm etc_tasks
128
+ # end
129
+ # else
130
+ # if File.exists? etc_tasks and !options[:force]
131
+ # puts "Error: file #{etc_tasks} already exist. Use --force or -f to modify this file!"
132
+ # exit
133
+ # else
134
+ # require 'fileutils'
135
+ # FileUtils.mkdir_p File.dirname(etc_tasks)
136
+ # dyntask_tasks=ARGV[1..-1].join(" ")
137
+ # File.open(etc_tasks,"w") do |f|
138
+ # f << dyntask_tasks
139
+ # end
140
+ # end
141
+ # end
142
+ #
143
+ # puts "#{etc_tasks} contains: #{File.read(etc_tasks)}" if File.exists? etc_tasks
data/bin/dyntask-server CHANGED
@@ -11,28 +11,27 @@ options = Trollop::options do
11
11
  banner <<-EOS
12
12
  dyntask-server scans the filesystem and executes shell commands when files changes.
13
13
  Usage:
14
- dyntask-server [--restart] '<command type>'
15
- Comment:
16
- when file ~/.dyntask_workdir exists and contains a valid directory name, this becomes the working directory to watch unless -w option is provided at command line.
14
+ dyntask-server
17
15
  Options:
18
16
  EOS
19
17
  opt :dontwait, "Do not wait for filesystem updates before running", :short => 'd', :type => :boolean, :default => false
20
- opt :restart, "Restart process when filesystem is updated", :short => 'r', :type => :boolean, :default => false
18
+ #opt :restart, "Restart process when filesystem is updated", :short => 'r', :type => :boolean, :default => false
21
19
  opt :list, "Print name of files being watched"
22
20
  opt :interval, "Interval to scan filesystem.", :short => 'i', :type => :float, :default => 0.5
23
21
  opt :spinner, "Show an ascii spinner", :short => 's', :type => :boolean, :default => false
24
22
  end
25
23
 
26
- Trollop::die Trollop::educate if(ARGV.size == 0)
24
+ ##Trollop::die Trollop::educate if(ARGV.size == 0)
27
25
 
28
- tasks_to_watch = []
29
- ARGV[0..-1].each do |a|
30
- if !(a.include? ",") and File.exists? (etc_tasks=File.join(DynTask.cfg_dir[:etc],"tasks",a))
31
- tasks_to_watch += File.read(etc_tasks).strip.split(/\s+/)
32
- else
33
- tasks_to_watch << a
34
- end
35
- end
26
+ tasks_to_watch = DynTask::TaskMngr::TASKS
27
+
28
+ # ARGV[0..-1].each do |a|
29
+ # if !(a.include? ",") and File.exists? (etc_tasks=File.join(DynTask.cfg_dir[:etc],"tasks",a))
30
+ # tasks_to_watch += File.read(etc_tasks).strip.split(/\s+/)
31
+ # else
32
+ # tasks_to_watch << a
33
+ # end
34
+ # end
36
35
 
37
36
 
38
37
  # root working directory
@@ -55,63 +54,61 @@ end
55
54
 
56
55
  #puts "Root directory is #{dyntask_root}"
57
56
 
58
- if tasks_to_watch.empty?
59
- puts "Stop: no tasks to serve!\n Launch: dyntask-init <NAME> <WORKDIR>:<LIST OF COMMA SEPARATED TASKS> to set of tasks to be called by <NAME>!"
60
- exit
61
- end
57
+ # if tasks_to_watch.empty?
58
+ # puts "Stop: no tasks to serve!\n Launch: dyntask-init <NAME> <WORKDIR>:<LIST OF COMMA SEPARATED TASKS> to set of tasks to be called by <NAME>!"
59
+ # exit
60
+ # end
62
61
 
63
62
  files_to_watch=[]
63
+ rundir=DynTask.cfg_dir[:run]
64
64
  tasks_to_watch.each do |e|
65
- workdir,tasks=e.split(":")
66
- workdir=workdir.sub("~",ENV["HOME"])
67
- tasks.split(",").each do |t|
68
- files_to_watch << File.join(workdir,"**/*" +DynTask::TaskMngr::TASK_EXT+t) #if DynTask::TaskMngr::TASKS.include? file
69
- end
65
+ files_to_watch << File.join(rundir,"*" +DynTask::TaskMngr::TASK_EXT+e) #if DynTask::TaskMngr::TASKS.include? file
70
66
  end
71
67
 
72
68
  files_to_watch.uniq!
73
69
 
74
70
  puts "Tasks watched: #{files_to_watch}"
75
71
 
76
- def restart(child_pid, env, cmd)
77
- Process.kill(9,child_pid)
78
- Process.wait(child_pid)
79
- rescue Errno::ESRCH
80
- # already killed
81
- ensure
82
- child_pid = Process.spawn({}, cmd)
83
- end
72
+ # def restart(child_pid, env, cmd)
73
+ # Process.kill(9,child_pid)
74
+ # Process.wait(child_pid)
75
+ # rescue Errno::ESRCH
76
+ # # already killed
77
+ # ensure
78
+ # child_pid = Process.spawn({}, cmd)
79
+ # end
84
80
 
85
- if(options[:restart])
86
- rd, wr = IO.pipe
87
- child_pid = nil
88
- end
81
+ # if(options[:restart])
82
+ # rd, wr = IO.pipe
83
+ # child_pid = nil
84
+ # end
89
85
 
90
86
  begin
91
87
  ##p files
92
88
  fw = FileWatcher.new(files_to_watch, options[:list], options[:dontwait], options[:spinner])
93
- task_mngr=DynTask::TaskMngr.new
89
+
94
90
  fw.watch(options[:interval]) do |filename, event|
95
91
  cmd=nil
96
92
  if([:changed,:new].include? event)
97
93
  path = Pathname.new(filename).realpath.to_s
98
- cmd = "dyntask-reader "+path
99
-
100
- if(options[:restart])
101
- if(child_pid == nil)
102
- child_pid = Process.spawn({}, cmd)
103
- else
104
- child_id = restart(child_pid, {}, cmd)
105
- end
106
- else
107
- begin
108
- p "cmd: <#{cmd}>"
109
- pid = Process.spawn({}, cmd)
110
- Process.wait()
111
- rescue SystemExit, Interrupt
112
- exit(0)
113
- end
114
- end
94
+ DynTask.read_tasks path
95
+
96
+ # cmd = "dyntask-reader "+path
97
+ # if(options[:restart])
98
+ # if(child_pid == nil)
99
+ # child_pid = Process.spawn({}, cmd)
100
+ # else
101
+ # child_id = restart(child_pid, {}, cmd)
102
+ # end
103
+ # else
104
+ # begin
105
+ # p "cmd: <#{cmd}>"
106
+ # pid = Process.spawn({}, cmd)
107
+ # Process.wait()
108
+ # rescue SystemExit, Interrupt
109
+ # exit(0)
110
+ # end
111
+ # end
115
112
  end
116
113
  end
117
114
  rescue SystemExit, Interrupt
data/bin/dyntask-writer CHANGED
@@ -26,18 +26,18 @@ ARGV[1..-1].each do |task|
26
26
  key,*value=o.split("=")
27
27
  value=value.join("=")
28
28
  #p [:value,value]
29
-
29
+
30
30
  begin
31
31
  task2[key.to_sym]=Object.class_eval(value)
32
32
  rescue Exception
33
33
  task2[key.to_sym]=value
34
34
  end
35
35
  }
36
- [:source,:target].each {|t|
37
- task2[t]=Pathname.new(task2[t]).expand_path.to_s if task2[t] and !(task2[t] =~ /^\%/)
36
+ [:source,:target].each {|t|
37
+ task2[t]=Pathname.new(task2[t]).expand_path.to_s if task2[t] and !(task2[t] =~ /^\%/)
38
38
  }
39
39
  p [:added,task2]
40
- DynTask.add_task(task2)
40
+ id=DynTask.add_task(task2)
41
41
  end
42
-
43
- DynTask.save_tasks(task_basename)
42
+
43
+ DynTask.save_tasks(task_basename)
@@ -2,19 +2,25 @@
2
2
  require 'dyndoc-software'
3
3
  require 'dyndoc-converter'
4
4
  require "fileutils"
5
+ require 'pathname'
5
6
 
6
7
  module DynTask
7
8
 
8
9
  @@task_mngr=nil
10
+ @@task_cpt=-1
9
11
 
10
- def self.add_task(task)
12
+ def self.inc_task_cpt
13
+ ((@@task_cpt += 1) == 9999 ? (@@task_cpt = 0) : @@task_cpt)
14
+ end
15
+
16
+ def self.add_task(task,id=nil) #id.nil? => new task
11
17
  @@task_mngr ||= DynTask::TaskMngr.new
12
- @@task_mngr.add_task(task)
18
+ @@task_mngr.add_task(task,id)
13
19
  end
14
20
 
15
- def self.save_tasks(task_basename)
21
+ def self.save_tasks(task_basename,task_dirname=nil)
16
22
  return unless @@task_mngr
17
- @@task_mngr.save_tasks(task_basename)
23
+ @@task_mngr.save_tasks(task_basename,task_dirname)
18
24
  end
19
25
 
20
26
  def self.read_tasks(task_filename)
@@ -28,16 +34,48 @@ module DynTask
28
34
  def self.cfg_dir
29
35
  return @@cfg_dir if @@cfg_dir
30
36
  root=File.join(ENV["HOME"],".dyntask")
37
+ ## the idea is that any path has to be relative to some system root
38
+ sys_root=(ENV["HOMEDRIVE"]||"")+"/" # local mode
31
39
  @@cfg_dir={
32
40
  :root => root,
33
41
  :etc => File.join(root,"etc"),
34
42
  :share => File.join(root,"share"),
35
43
  :tasks => File.join(root,"share","tasks"),
36
- :plugins => File.join(root,"share","plugins")
44
+ :plugins => File.join(root,"share","plugins"),
45
+ :run => File.join(root,"run") # default folder to watch. In a perfect world (this is my goal), only this folder to watch!
37
46
  }
47
+ ## File containing the sys_root_path (used in atom package)
48
+ @@cfg_dir[:sys_root_path_cfg]=File.join(@@cfg_dir[:etc],"sys_root_path")
49
+ self.update_sys_root(sys_root)
38
50
  @@cfg_dir
39
51
  end
40
52
 
53
+ ## to be able to change sys_root path depending on local or remote mode
54
+ def self.update_sys_root(path)
55
+ @@cfg_dir[:sys_root]=path
56
+ ## save sys_root_path to some config file (used in atom package)
57
+ FileUtils.mkdir_p File.dirname(@@cfg_dir[:sys_root_path_cfg])
58
+ File.open(@@cfg_dir[:sys_root_path_cfg],"w") do |f|
59
+ f << @@cfg_dir[:sys_root]
60
+ end
61
+ end
62
+
63
+ def self.sys_root_path(rel_path)
64
+ File.expand_path File.join(self.cfg_dir[:sys_root],rel_path)
65
+ end
66
+
67
+ def self.relative_path_from_sys_root(abs_path)
68
+ begin
69
+ #p abs_path
70
+ #p self.cfg_dir[:sys_root]
71
+ ap=Pathname.new(abs_path).realpath
72
+ #p ap
73
+ ap.relative_path_from(Pathname.new(self.cfg_dir[:sys_root])).to_s
74
+ rescue
75
+ nil
76
+ end
77
+ end
78
+
41
79
  @@cfg_pandoc=nil
42
80
 
43
81
  def self.cfg_pandoc(renew=false)
@@ -64,7 +102,7 @@ module DynTask
64
102
  class TaskMngr
65
103
 
66
104
  # TODO: to put outside to be extended by users!
67
- TASKS=["pdflatex","pandoc","png","dyn","sh"]
105
+ TASKS=["pdflatex","pandoc","png","dyn","sh","dyn_cli"]
68
106
  TASK_EXT=".task_"
69
107
 
70
108
  def initialize
@@ -72,7 +110,7 @@ module DynTask
72
110
  end
73
111
 
74
112
  def init_tasks
75
- @tasks=[]
113
+ @tasks={}
76
114
  end
77
115
 
78
116
  ## Comment on writing task:
@@ -81,60 +119,80 @@ module DynTask
81
119
  ## However, :source and :target are recommanded keynames for describing source and target filename
82
120
 
83
121
  ## possibly add condition to check before applying command+options
84
- def add_task(task)
85
- @tasks << task
122
+ def add_task(task,id=nil)
123
+ task_cpt=id || DynTask.inc_task_cpt
124
+ @tasks[task_cpt] = [] unless @tasks[task_cpt]
125
+ @tasks[task_cpt] << task
126
+ task_cpt #id of the task
86
127
  end
87
128
 
88
- def save_tasks(task_basename)
89
- task_filename=task_basename+TASK_EXT+@tasks[0][:cmd].to_s
90
- File.open(task_filename,"w") do |f|
91
- f << @tasks.inspect
92
- end
129
+ ##
130
+ def save_tasks(id,task_basename,task_dirname=nil)
131
+ task_dirname=DynTask.cfg_dir[:run] unless task_dirname
132
+ task_dirname=File.expand_path task_dirname
133
+ FileUtils.mkdir_p task_dirname unless File.directory? task_dirname
134
+ if (tasks_to_save=@tasks[id])
135
+ tasks_to_save[0][:id]=id
136
+ task_filename=File.join(task_dirname,("%04d" % id)+"_"+task_basename+TASK_EXT+tasks_to_save[0][:cmd].to_s)
137
+ File.open(task_filename,"w") do |f|
138
+ f << tasks_to_save.inspect
139
+ end
140
+ else
141
+ puts "DynTask WARNING: Nothing to save!"
142
+ end
93
143
  end
94
144
 
95
145
  def write_tasks(task_basename,tasks)
96
146
  @tasks=tasks
97
- save_tasks(task_basename)
147
+ id=DynTask.inc_task_cpt
148
+ save_tasks(id,task_basename)
98
149
  end
99
150
 
100
151
  ## maybe to maintain only one task, remove current task when the new one is created
101
152
  def read_tasks(task_filename)
102
153
  @task_filename=task_filename
103
- @workdir=File.dirname(@task_filename)
104
154
  @tasks=Object.class_eval(File.read(@task_filename))
105
155
  ##p @tasks
106
156
  if @tasks.length>=1
107
157
  @task=@tasks.shift #first task to deal with
108
158
  ##p @task
109
- make_task
110
- if @tasks.length>=1
111
- dirname=File.dirname(task_filename)
112
- basename=File.basename(task_filename,".*")
113
- task_basename=File.join(dirname,basename)
114
- save_tasks(task_basename)
159
+ if @task[:workdir]
160
+ # if workdir is specified inside the first task (almost required now)
161
+ @workdir = @task[:workdir]
162
+ # workdir is always relative from sys_root which could differ depending on the computer (or vm)
163
+ @workdir = DynTask.sys_root_path(@workdir)
164
+ if File.exist? @workdir
165
+
166
+ make_task
167
+ if @tasks.length>=1
168
+ dirname=File.dirname(task_filename)
169
+ basename=File.basename(task_filename,".*")
170
+ task_basename=File.join(dirname,basename)
171
+ save_tasks(@task[:id],task_basename) # same id since it is a chaining (TO CHECK: when remote action maybe prefer uuid instead of counter to gnerate id)
172
+ end
173
+ # remove since it is executed!
174
+ FileUtils.rm(task_filename)
175
+ end
115
176
  end
116
- # remove since it is executed!
117
- FileUtils.rm(task_filename)
118
177
  end
119
178
  end
120
179
 
121
180
  ## if option to not remove taskfiles, this is a clean!
122
- def task_clean_taskfiles(task_filename)
123
- dirname=File.dirname(task_filename)
124
- basename=File.basename(task_filename,TASK_EXT+"*")
125
-
126
- Dir[File.join(dirname,basename+TASK_EXT+"*")].each do |f|
127
- FileUtils.rm(f)
128
- end
129
- end
181
+ # def task_clean_taskfiles(task_filename)
182
+ # dirname=File.dirname(task_filename)
183
+ # basename=File.basename(task_filename,TASK_EXT+"*")
184
+ #
185
+ # Dir[File.join(dirname,basename+TASK_EXT+"*")].each do |f|
186
+ # FileUtils.rm(f)
187
+ # end
188
+ # end
130
189
 
131
190
  def load_user_task_plugins
132
- Dir[File.join(DynTask.cfg_dir[:plugins],"*.rb")].each {|lib| require lib} if File.exists? DynTask.cfg_dir[:plugins]
191
+ Dir[File.join(DynTask.cfg_dir[:plugins],"*.rb")].each {|lib| require lib} if File.exists? DynTask.cfg_dir[:plugins]
133
192
  end
134
193
 
135
194
  def info_file(filename)
136
195
  return {} unless filename
137
- filename=File.join(@workdir,filename[1..-1]) if filename =~ /^\%/
138
196
 
139
197
  ##p [:info_file,filename]
140
198
 
@@ -150,10 +208,10 @@ module DynTask
150
208
 
151
209
  def make_task
152
210
 
153
- ##
154
- @source=@task[:source] ? info_file(@task[:source]) : info_file(@task_filename)
211
+ ##
212
+ @source=info_file(DynTask.sys_root_path(@task[:source]))
155
213
  #p [:info,@task[:source]]
156
-
214
+
157
215
  #p [:source,@source]
158
216
  @basename=@source[:basename]
159
217
  @extname=@source[:extname]
@@ -161,7 +219,7 @@ module DynTask
161
219
  @filename=@source[:filename]
162
220
 
163
221
  @target=info_file(@task[:target]) if @task[:target]
164
-
222
+
165
223
  cd_new
166
224
 
167
225
  ## This is a rule, if a @task contains both :source and :content
@@ -190,7 +248,7 @@ module DynTask
190
248
  # end
191
249
 
192
250
  cd_old
193
-
251
+
194
252
  end
195
253
 
196
254
  def cd_new
@@ -248,28 +306,28 @@ module DynTask
248
306
 
249
307
  def make_pdflatex_pass(echo_mode=false)
250
308
  unless File.exists? @basename+".tex"
251
- msg="No pdflatex #{@basename} in #{@dirname} since file does not exist!"
309
+ msg="No pdflatex #{@basename} in #{@workdir} since file does not exist!"
252
310
  print "\n==> "+msg
253
311
  end
254
312
  if File.read(@basename+".tex").empty?
255
- msg="No pdflatex #{@basename} in #{@dirname} since empty file!"
313
+ msg="No pdflatex #{@basename} in #{@workdir} since empty file!"
256
314
  print "\n==> "+msg
257
315
  ###$dyn_logger.write("ERROR pdflatex: "+msg+"\n") unless Dyndoc.cfg_dyn[:dyndoc_mode]==:normal
258
316
  return ""
259
317
  end
260
- print "\n==> #{Dyndoc.pdflatex} #{@basename} in #{@dirname}"
318
+ print "\n==> #{Dyndoc.pdflatex} #{@basename} in #{@workdir}"
261
319
 
262
320
  out=`#{Dyndoc.pdflatex} -halt-on-error -file-line-error -interaction=nonstopmode #{@basename}`
263
- out=out.b if RUBY_VERSION >= "1.9" #because out is not necessarily utf8 encoded
321
+ out=out.b if RUBY_VERSION >= "1.9" #because out is not necessarily utf8 encoded
264
322
  out=out.split("\n")
265
323
  puts out if echo_mode
266
324
  if out[-2].include? "Fatal error"
267
325
  #if Dyndoc.cfg_dyn[:dyndoc_mode]==:normal
268
326
  # print " -> NOT OKAY!!!\n==> "
269
327
  # puts out[-4...-1]
270
- # raise SystemExit
328
+ # raise SystemExit
271
329
  #end
272
- else
330
+ else
273
331
  print " -> OKAY!!!\n"
274
332
  ###@cfg[:created_docs] << @basename+".pdf" #( @dirname.empty? ? "" : @dirname+"/" ) + @basename+".pdf"
275
333
  end
@@ -305,7 +363,7 @@ module DynTask
305
363
  pandoc_file_output=@basename+append_doc+".html"
306
364
  when "md2slidy"
307
365
  cmd_pandoc_options= cfg_pandoc["md2slidy"] || ["-s","--webtex","-i","-t","slidy"]
308
- pandoc_file_output=@basename+append_doc+".html"
366
+ pandoc_file_output=@basename+append_doc+".html"
309
367
  when "md2s5"
310
368
  cmd_pandoc_options= cfg_pandoc["md2s5"] || ["-s","--self-contained","--webtex","-i","-t","s5"]
311
369
  pandoc_file_output=@basename+append_doc+".html"
@@ -316,9 +374,9 @@ module DynTask
316
374
  cmd_pandoc_options=["-s","--mathjax","-i","-t","slideous"]
317
375
  pandoc_file_output=@basename+append_doc+".html"
318
376
  end
319
-
377
+
320
378
  opts=cmd_pandoc_options #OBSOLETE NOW!: +["-o",pandoc_file_output]
321
-
379
+
322
380
  output=if pandoc_file_input
323
381
  opts << pandoc_file_input
324
382
  Dyndoc::Converter.pandoc(nil,opts.join(" "))
@@ -334,7 +392,7 @@ module DynTask
334
392
  f << output
335
393
  end
336
394
  end
337
-
395
+
338
396
  end
339
397
 
340
398
 
@@ -345,7 +403,7 @@ module DynTask
345
403
  make_dvipng
346
404
  end
347
405
 
348
- # make latex and dvipng
406
+ # make latex and dvipng
349
407
 
350
408
  def make_dvipng
351
409
  system "latex #{@basename}.tex"
@@ -355,7 +413,7 @@ module DynTask
355
413
  end
356
414
 
357
415
  # make ttm
358
-
416
+
359
417
  def make_ttm
360
418
  #puts "make_ttm:begin"
361
419
  Dyndoc::Converter.ttm(File.read(@task[:filename]))
@@ -0,0 +1,6 @@
1
+ pandoc-extra management
2
+ =======================
3
+
4
+ 1) Location of pandoc-extra directory containing extra installations of reveal-js, s5, ..., is read in ~/.dyntask/etc/pandoc_extra_dir file and accessed in dyntask-ruby gem via DynTask.cfg_dir[:pandoc_extra] (used, for example, inside ~/.dyntask/share/pandoc/config.rb)
5
+ 2) config.rb is located inside ~/.dyntask/share/pandoc directory to be easily saved in Github. The pandoc-extra contents is not at the same place to avoid to be located in Github. The command "dyndocker pandoc-extra" (for docker setting) and "dyntask-init --pandoc-extra" (nomal setting) is used to offer a scriptable way to get these extra installations of reveal-js and s5.
6
+
@@ -0,0 +1,12 @@
1
+ ## This file is in share/pandoc since it is saved in Github.
2
+ ## How the different file works:
3
+ ## 1) ~/.dyntask/etc/pandoc_extra_dir contains the location of DynTask.cfg_dir[:pandoc_extra]
4
+ ## 2) DynTask.cfg_dir[:pandoc_extra] can be located:
5
+ ## a) outside a docker machine (example: /dyndoc-library/pandoc-extra)
6
+ ## is located outside share/pandoc folder to be
7
+ ## updated by the user.
8
+ {
9
+ "md2s5" => ["-t","s5","--webtex","-s","-V","s5-url=#{DynTask.cfg_pandoc[:extra_dir]}/s5-ui/default", "--self-contained"],
10
+ "md2revealjs" => ["-t","revealjs","--webtex","-s","-V","theme=sky","-V","revealjs-url=#{DynTask.cfg_pandoc[:extra_dir]}/reveal.js-3.1.0", "--self-contained"]
11
+ }
12
+ # --mathjax='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
@@ -0,0 +1 @@
1
+ Plugins folder for user-defined task
@@ -0,0 +1,8 @@
1
+ [
2
+ {
3
+ :workdir => "%workdir%",
4
+ :source=>"%basename%.dyn",
5
+ :cmd=> "dyn_cli",
6
+ :target=>"%basename%.html"
7
+ }
8
+ ]
@@ -0,0 +1,8 @@
1
+ [
2
+ {
3
+ :workdir => "%workdir%",
4
+ :source=>"%basename%.dyn",
5
+ :cmd=> "dyn",
6
+ :options=>"-f html"
7
+ }
8
+ ]
@@ -0,0 +1,8 @@
1
+ [
2
+ {
3
+ :workdir => "%workdir%",
4
+ :source=>"%basename%.dyn",
5
+ :cmd=> "dyn",
6
+ :options=>"-cpdf"
7
+ }
8
+ ]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dyntask-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - CQLS
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-26 00:00:00.000000000 Z
11
+ date: 2016-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trollop
@@ -63,6 +63,12 @@ extra_rdoc_files: []
63
63
  files:
64
64
  - lib/dyntask.rb
65
65
  - lib/dyntask/task_mngr.rb
66
+ - share/pandoc/README.INSTALL
67
+ - share/pandoc/config.rb
68
+ - share/plugins/README
69
+ - share/tasks/task_dyn2html-cli.rb
70
+ - share/tasks/task_dyn2html.rb
71
+ - share/tasks/task_dyn2tex2pdf.rb
66
72
  - bin/dyntask-server
67
73
  - bin/dyntask-reader
68
74
  - bin/dyntask-writer