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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32df473416ea671d565651d749ea83fdd43d8c8e
4
- data.tar.gz: 7b5e1a9c43b19551ec35330e1e1f8a06ce735165
3
+ metadata.gz: 002b62cb26d3be08a52f4ca611374c3bffe77516
4
+ data.tar.gz: e7604dc0fd14ac038678972c0cdcb7e4a7c86d2c
5
5
  SHA512:
6
- metadata.gz: 7a439e181630ca61a6be46cf0bbc27968405433499cca6fb05aade855db8f70394db6ba8a6f4c30f4edd216d541a27afcd3073f72d4d551408240e35886cb6d1
7
- data.tar.gz: 576e6296fbf1ad0d393a7605d73e88bfba28dfb94514e4084819b54be52209cb8bbd95d39562b669e9c624c92710b246d15a1c110816fbe5a89d617c3914320d
6
+ metadata.gz: 25f1f5031438b090a6e06d6485bc6791cad03b890f02eb0e2fc1555c22dce484fa12b9c2ea16e1a2cf3c1fc85e456170f062f6457efbbfd85d9ed4ee3dc281f3
7
+ data.tar.gz: d49d5e9f344fc0589fb8bc151a953a9a942632beb5e1945bfabda1d3173e2290bf478c5636854aeb9d2a185b2a4db440c4fd70901cfbadb4777091e8cb62c3f4
@@ -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
- newdir=File.expand_path ARGV[2]
41
- if File.directory? newdir and !rundirs.include? newdir
42
- rundirs << newdir
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
- newdir=File.expand_path ARGV[2]
50
- if File.directory? newdir and rundirs.include? newdir
51
- rundirs -= [newdir]
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
@@ -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
- files_to_watch << File.join(rundir,"*" +DynTask::TaskMngr::TASK_EXT+"*" ) ##+e) #if DynTask::TaskMngr::TASKS.include? file
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
 
@@ -110,7 +110,7 @@ module DynTask
110
110
  end
111
111
 
112
112
  def init_tasks
113
- @tasks={}
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
- @tasks[task_cpt] = [] unless @tasks[task_cpt]
125
- @tasks[task_cpt] << task
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=@tasks[id])
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
- # workdir is always relative from sys_root which could differ depending on the computer (or vm)
163
- @workdir = DynTask.sys_root_path(@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.0
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-18 00:00:00.000000000 Z
11
+ date: 2016-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trollop