dyntask-ruby 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/dyntask-init +10 -6
- data/bin/dyntask-server +2 -1
- data/lib/dyntask/task_mngr.rb +22 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 002b62cb26d3be08a52f4ca611374c3bffe77516
|
4
|
+
data.tar.gz: e7604dc0fd14ac038678972c0cdcb7e4a7c86d2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25f1f5031438b090a6e06d6485bc6791cad03b890f02eb0e2fc1555c22dce484fa12b9c2ea16e1a2cf3c1fc85e456170f062f6457efbbfd85d9ed4ee3dc281f3
|
7
|
+
data.tar.gz: d49d5e9f344fc0589fb8bc151a953a9a942632beb5e1945bfabda1d3173e2290bf478c5636854aeb9d2a185b2a4db440c4fd70901cfbadb4777091e8cb62c3f4
|
data/bin/dyntask-init
CHANGED
@@ -37,18 +37,22 @@ when "rundir","run"
|
|
37
37
|
when "ls"
|
38
38
|
puts "Additional directories watched: #{rundirs.empty? ? 'none' : rundirs.join(',')}"
|
39
39
|
when "add"
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
subdir = ARGV[2][-1,1] == File::Separator
|
41
|
+
newdir = File.expand_path ARGV[2]
|
42
|
+
newrundir=subdir ? File.join(newdir,"") : newdir
|
43
|
+
if File.directory? newdir and !rundirs.include? newrundir
|
44
|
+
rundirs << newrundir
|
43
45
|
puts "DynTask Server needs to be restarted to apply this change!"
|
44
46
|
etc_rundirs_to_update=true
|
45
47
|
else
|
46
48
|
"Nothing to do!"
|
47
49
|
end
|
48
50
|
when "rm"
|
49
|
-
|
50
|
-
|
51
|
-
|
51
|
+
subdir = ARGV[2][-1,1] == File::Separator
|
52
|
+
newdir = File.expand_path ARGV[2]
|
53
|
+
newrundir=subdir ? File.join(newdir,"") : newdir
|
54
|
+
if File.directory? newdir and rundirs.include? newrundir
|
55
|
+
rundirs -= [newrundir]
|
52
56
|
puts "DynTask Server needs to be restarted to apply this change!"
|
53
57
|
etc_rundirs_to_update=true
|
54
58
|
else
|
data/bin/dyntask-server
CHANGED
@@ -32,7 +32,8 @@ rundirs += File.read(etc_rundirs).strip.split(",").map{|d| d.strip} if File.exis
|
|
32
32
|
files_to_watch=[]
|
33
33
|
rundirs.each do |rundir|
|
34
34
|
##tasks_to_watch.each do |e|
|
35
|
-
|
35
|
+
watchdir = rundir[-1,1] == File::Separator ? [rundir[0...-1],"**"] : rundir
|
36
|
+
files_to_watch << File.join(watchdir,"*" +DynTask::TaskMngr::TASK_EXT+"*" ) ##+e) #if DynTask::TaskMngr::TASKS.include? file
|
36
37
|
##end
|
37
38
|
end
|
38
39
|
|
data/lib/dyntask/task_mngr.rb
CHANGED
@@ -110,7 +110,7 @@ module DynTask
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def init_tasks
|
113
|
-
@
|
113
|
+
@task_ids={}
|
114
114
|
end
|
115
115
|
|
116
116
|
## Comment on writing task:
|
@@ -121,8 +121,8 @@ module DynTask
|
|
121
121
|
## possibly add condition to check before applying command+options
|
122
122
|
def add_task(task,id=nil)
|
123
123
|
task_cpt=id || DynTask.inc_task_cpt
|
124
|
-
@
|
125
|
-
@
|
124
|
+
@task_ids[task_cpt] = [] unless @task_ids[task_cpt]
|
125
|
+
@task_ids[task_cpt] << task
|
126
126
|
task_cpt #id of the task
|
127
127
|
end
|
128
128
|
|
@@ -131,8 +131,10 @@ module DynTask
|
|
131
131
|
task_dirname=DynTask.cfg_dir[:run] unless task_dirname
|
132
132
|
task_dirname=File.expand_path task_dirname
|
133
133
|
FileUtils.mkdir_p task_dirname unless File.directory? task_dirname
|
134
|
-
if (tasks_to_save=@
|
134
|
+
if (tasks_to_save=@task_ids[id])
|
135
|
+
## delegate id
|
135
136
|
tasks_to_save[0][:id]=id
|
137
|
+
## write next tasks to file
|
136
138
|
task_filename=File.join(task_dirname,("%04d" % id)+"_"+task_basename+TASK_EXT+tasks_to_save[0][:cmd].to_s)
|
137
139
|
File.open(task_filename,"w") do |f|
|
138
140
|
f << tasks_to_save.inspect
|
@@ -148,6 +150,13 @@ module DynTask
|
|
148
150
|
save_tasks(id,task_basename)
|
149
151
|
end
|
150
152
|
|
153
|
+
## workdir is now specified which is relative to some root directory
|
154
|
+
## Two modes:
|
155
|
+
## 1) centralized mode (defaul): ~/.dyntask/run folder watched with root specified in ~/.dyntask/etc/sys_root_path
|
156
|
+
## Nice when used everywhere in your local computer
|
157
|
+
## 2) decentralized mode: every watched directory is a working directory
|
158
|
+
## Nice when certain tasks can be performed remotely.
|
159
|
+
|
151
160
|
## maybe to maintain only one task, remove current task when the new one is created
|
152
161
|
def read_tasks(task_filename)
|
153
162
|
@task_filename=task_filename
|
@@ -159,8 +168,14 @@ module DynTask
|
|
159
168
|
if @task[:workdir]
|
160
169
|
# if workdir is specified inside the first task (almost required now)
|
161
170
|
@workdir = @task[:workdir]
|
162
|
-
#
|
163
|
-
@workdir
|
171
|
+
dirname_next_task=nil #means default mode (from sys_root_path)
|
172
|
+
if @workdir == :current #mode current
|
173
|
+
@workdir=File.dirname(File.expand_path(@task_filename))
|
174
|
+
dirname_next_task=@workdir
|
175
|
+
else #mode
|
176
|
+
# workdir is always relative from sys_root which could differ depending on the computer (or vm)
|
177
|
+
@workdir = DynTask.sys_root_path(@workdir)
|
178
|
+
end
|
164
179
|
if File.exist? @workdir
|
165
180
|
|
166
181
|
make_task
|
@@ -168,7 +183,7 @@ module DynTask
|
|
168
183
|
dirname=File.dirname(task_filename)
|
169
184
|
basename=File.basename(task_filename,".*")
|
170
185
|
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)
|
186
|
+
save_tasks(@task[:id],task_basename,dirname_next_task) # same id since it is a chaining (TO CHECK: when remote action maybe prefer uuid instead of counter to gnerate id)
|
172
187
|
end
|
173
188
|
# remove since it is executed!
|
174
189
|
FileUtils.rm(task_filename)
|
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.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CQLS
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trollop
|