ratch 1.1.0 → 2.0.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.
Files changed (61) hide show
  1. checksums.yaml +7 -0
  2. data/HISTORY.rdoc +87 -0
  3. data/LICENSE.txt +204 -0
  4. data/README.rdoc +133 -0
  5. data/bin/ludo +32 -0
  6. data/bin/ratch +1 -8
  7. data/lib/ratch/batch.rb +541 -0
  8. data/lib/ratch/core_ext/facets.rb +16 -1
  9. data/lib/ratch/core_ext/filetest.rb +29 -0
  10. data/lib/ratch/core_ext/{string.rb → to_actual_filename.rb} +0 -23
  11. data/lib/ratch/core_ext/to_console.rb +30 -12
  12. data/lib/ratch/core_ext/{object.rb → to_yamlfrag.rb} +1 -0
  13. data/lib/ratch/core_ext/unfold_paragraphs.rb +27 -0
  14. data/lib/ratch/core_ext.rb +1 -4
  15. data/lib/ratch/file_list.rb +402 -0
  16. data/lib/ratch/script/help.rb +84 -0
  17. data/lib/ratch/script.rb +99 -5
  18. data/lib/ratch/shell.rb +621 -0
  19. data/lib/ratch/utils/cli.rb +49 -0
  20. data/lib/ratch/utils/config.rb +52 -0
  21. data/lib/ratch/{emailer.rb → utils/email.rb} +58 -98
  22. data/lib/ratch/utils/rdoc.rb +45 -0
  23. data/lib/ratch/utils/tar.rb +132 -0
  24. data/lib/ratch/utils/xdg.rb +38 -0
  25. data/lib/ratch/utils/zlib.rb +55 -0
  26. data/lib/ratch/version.rb +3 -0
  27. data/lib/ratch.rb +12 -0
  28. metadata +160 -126
  29. data/COPYING +0 -22
  30. data/HISTORY +0 -6
  31. data/MANIFEST +0 -53
  32. data/NEWS +0 -12
  33. data/README +0 -87
  34. data/VERSION +0 -1
  35. data/demo/tryme-task.ratch +0 -12
  36. data/demo/tryme1.ratch +0 -6
  37. data/doc/log/basic_stats/index.html +0 -39
  38. data/doc/log/notes.xml +0 -18
  39. data/doc/log/stats.log +0 -14
  40. data/doc/log/syntax.log +0 -0
  41. data/doc/log/testunit.log +0 -156
  42. data/lib/ratch/commandline.rb +0 -16
  43. data/lib/ratch/core_ext/pathname.rb +0 -38
  44. data/lib/ratch/dsl.rb +0 -420
  45. data/lib/ratch/index.rb +0 -4
  46. data/lib/ratch/io.rb +0 -116
  47. data/lib/ratch/plugin.rb +0 -65
  48. data/lib/ratch/service.rb +0 -33
  49. data/lib/ratch/task.rb +0 -249
  50. data/lib/ratch/task2.rb +0 -298
  51. data/man/ratch.1 +0 -28
  52. data/meta/abstract +0 -4
  53. data/meta/author +0 -1
  54. data/meta/contact +0 -1
  55. data/meta/homepage +0 -1
  56. data/meta/name +0 -1
  57. data/meta/requires +0 -4
  58. data/meta/summary +0 -1
  59. data/test/README +0 -1
  60. data/test/test_helper.rb +0 -4
  61. data/test/test_task.rb +0 -46
data/lib/ratch/task2.rb DELETED
@@ -1,298 +0,0 @@
1
- module Taskable
2
-
3
- def self.define_task(base, target_and_requisite, &function)
4
- case base
5
- when Class, Module
6
-
7
- else #Object
8
-
9
- end
10
- end
11
-
12
-
13
- module ClassDSL
14
- # Without an argument, returns list of tasks defined for this class.
15
- #
16
- # If a task's target name is given, will return the first
17
- # task mathing the name found in the class' inheritance chain.
18
- # This is important ot ensure task are inherited in the same manner
19
- # that methods are.
20
- def tasks(target=nil)
21
- if target
22
- target = target.to_sym
23
- anc = ancestors.select{|a| a < DSL}
24
- t = nil; anc.find{|a| t = a.tasks[target]}
25
- return t
26
- else
27
- @tasks ||= {}
28
- end
29
- end
30
-
31
- # Set a description to be used by then next defined task in this class.
32
- def desc(description)
33
- @desc = description
34
- end
35
-
36
- # Define a task.
37
- def task(target_and_requisite, &function)
38
- target, requisite, function = *Task.parse_arguments(target_and_requisite, &function)
39
- task = tasks[target.to_sym] ||= (
40
- tdesc = @desc
41
- @desc = nil
42
- Task.new(self, target, tdesc) #, reqs, actions)
43
- )
44
- task.update(requisite, &function)
45
-
46
- define_method("#{target}Trigger"){ task.run(self) }
47
- define_method("#{target}:task", &function)
48
- end
49
-
50
- end
51
-
52
- #
53
- module ObjectDSL
54
-
55
- # Without an argument, returns list of tasks defined for this class.
56
- #
57
- # If a task's target name is given, will return the first
58
- # task mathing the name found in the class' inheritance chain.
59
- # This is important ot ensure task are inherited in the same manner
60
- # that methods are.
61
- def tasks(target=nil)
62
- if target
63
- target = target.to_sym
64
- anc = ancestors.select{|a| a < DSL}
65
- t = nil; anc.find{|a| t = a.tasks[target]}
66
- return t
67
- else
68
- @tasks ||= {}
69
- end
70
- end
71
-
72
- # Set a description to be used by then next defined task in this class.
73
- def desc(description)
74
- @desc = description
75
- end
76
-
77
- # Define a task.
78
- def task(target_and_requisite, &function)
79
- target, requisite, function = *Task.parse_arguments(target_and_requisite, &function)
80
- task = tasks[target.to_sym] ||= (
81
- tdesc = @desc
82
- @desc = nil
83
- Task.new(self, target, tdesc) #, reqs, actions)
84
- )
85
- task.update(requisite, &function)
86
-
87
- define_method("#{target}Trigger"){ task.run(self) }
88
- define_method("#{target}:task", &function)
89
- end
90
-
91
- end
92
-
93
-
94
-
95
- # Run a task.
96
- #def run(target)
97
- # t = self.class.tasks(target)
98
- # t.run(self)
99
- #end
100
-
101
- # = Task Class
102
- #
103
- class Task
104
- attr :base
105
- attr :target
106
- attr :requisite
107
- attr :function
108
- attr :description
109
-
110
- def initialize(base, target, description=nil, requisite=nil, &function)
111
- @base = base
112
- @target = target.to_sym
113
- @description = description
114
- @requisite = requisite || []
115
- @function = function
116
- end
117
-
118
- #
119
- def update(requisite, &function)
120
- @requisite.concat(requisite).uniq!
121
- @function = function if function
122
- end
123
-
124
- #
125
- def prerequisite
126
- base.ancestors.select{ |a| a < DSL }.collect{ |a|
127
- a.tasks[target].requisite
128
- }.flatten.uniq
129
- end
130
-
131
- # invoke target
132
- def run(object)
133
- rd = rule_dag
134
- rd.each do |t|
135
- object.send("#{t}:task")
136
- end
137
- end
138
-
139
- #
140
- def call(object)
141
- object.instance_eval(&function)
142
- end
143
-
144
- # Collect task dependencies for running.
145
- def rule_dag(cache=[])
146
- prerequisite.each do |r|
147
- next if cache.include?(r)
148
- t = base.tasks[r]
149
- t.rule_dag(cache)
150
- #cache << dep
151
- end
152
- cache << target.to_s
153
- cache
154
- end
155
-
156
- #
157
- def self.parse_arguments(name_and_reqs, &action)
158
- if Hash===name_and_reqs
159
- target = name_and_reqs.keys.first.to_s
160
- reqs = [name_and_reqs.values.first].flatten
161
- else
162
- target = name_and_reqs.to_s
163
- reqs = []
164
- end
165
- return target, reqs, action
166
- end
167
- end
168
-
169
- # = File Task Class
170
- #
171
- class FileTask < Task
172
-
173
- def needed?
174
- if prerequisite.empty?
175
- dated = true
176
- elsif File.exist?(target)
177
- mtime = File.mtime(target)
178
- dated = prerequisite.find do |file|
179
- !File.exist?(file) || File.mtime(file) > mtime
180
- end
181
- else
182
- dated = true
183
- end
184
- return dated
185
- end
186
-
187
- #
188
- def call(object)
189
- object.instance_eval(&function) if needed?
190
- end
191
- end
192
-
193
- end
194
-
195
-
196
- =begin
197
- # turn yaml file into tasks
198
- def parse(file)
199
- script = YAML.load(File.new(file.to_s))
200
-
201
- imports = script.delete('import') || []
202
- #plugins = script.delete('plugin') || []
203
- srvs = script.delete('services') || {}
204
- tgts = script.delete('targets') || {}
205
-
206
- imports.each do |import|
207
- path = Reap::Domain::LIB_DIRECTORY + 'systems' + (import + '.reap').to_s
208
- parse(path)
209
- end
210
-
211
- srvs.each do |label, options|
212
- type = options.delete('type')
213
- @services[label] = domain.send("#{type}_service") # FIXME
214
- end
215
-
216
- tgts.each do |target, options|
217
- @targets[target] = Task.new(self, target, options)
218
- end
219
- end
220
- =end
221
-
222
-
223
-
224
-
225
-
226
-
227
- =begin
228
- # Collect task dependencies for running.
229
- def self.rule_dag(target, cache=[])
230
- t = tasks[target.to_sym]
231
- d = t.prerequisite
232
- d.each do |r|
233
- next if cache.include?(r)
234
- rule_dag(r, cache)
235
- #cache << dep
236
- end
237
-
238
- # file requirements
239
- #q = self.class.ann(name, :reqs) || []
240
- #q.each do |req|
241
- # path = Pathname.new(req)
242
- # next if r.include?(path)
243
- # mat = annotations.select{ |n, a| File.fnmatch?(a[:file].first, req) if a[:file] }.compact
244
- # mat.each do |n, a|
245
- # rule_dag(n, r)
246
- # end
247
- # r << path
248
- #end
249
-
250
- cache << target.to_s
251
- return cache
252
- end
253
-
254
- # invoke target
255
- def run(target)
256
- target = target.to_sym
257
- rd = self.class.rule_dag(target)
258
- rd.each do |t|
259
- send("#{t}:task")
260
- end
261
- end
262
- =end
263
-
264
- =begin
265
- if target == name.to_s
266
- tasks[target].call
267
- else
268
- case action
269
- when Pathname
270
- raise unless action.exist?
271
- else
272
- run_rec(action)
273
- end
274
- end
275
- end
276
- end
277
-
278
- def run_rec(action)
279
- # creates a file?
280
- dated = true
281
- if creates = self.class.ann(action, :file)
282
- if self.class.ann(name, :reqs).empty?
283
- dated = true
284
- elsif File.exist?(creates)
285
- mtime = File.mtime(creates)
286
- dated = self.class.ann(name, :reqs).find do |file|
287
- !File.exist?(file) || File.mtime(file) > mtime
288
- end
289
- else
290
- dated = true
291
- end
292
- end
293
- return unless dated
294
- send(action)
295
- end
296
- =end
297
-
298
-
data/man/ratch.1 DELETED
@@ -1,28 +0,0 @@
1
- .\" NAME
2
- .\" ratch - ruby-based batch files
3
- .\"
4
- .\" SYNOPSIS
5
- .\" reap [-n] [-h] [file]
6
- .\"
7
- .\" DESCRIPTION
8
- .\" Ratch is batch file system using a Ruby=based DSL.
9
- .\"
10
- .\" OPTIONS
11
- .\" -h help This option displays help.
12
- .\" -n dryrun Dry-run/no-harm mode.
13
- .\"
14
- .\" ENVIRONMENT
15
- .\" PAGER name of paging command, usually more(1), or less(1). If not set
16
- .\" falls back to more(1).
17
- .\"
18
- .\" EXAMPLES
19
- .\" Try this command to format this text itself:
20
- .\"
21
- .\" $ txt2man -h 2>&1 | txt2man -T
22
- .\"
23
- .\" SEE ALSO:
24
- .\" ruby(1).
25
- .\"
26
- .\" AUTHOR:
27
- .\" 7rans <transfire@gmail,com>
28
-
data/meta/abstract DELETED
@@ -1,4 +0,0 @@
1
- Ratch is a Ruby-based batch scripting language.
2
- It's a DSL over regular RUby to make the life
3
- of the batch script writter easier.
4
-
data/meta/author DELETED
@@ -1 +0,0 @@
1
- trans <transfire@gmail.com>
data/meta/contact DELETED
@@ -1 +0,0 @@
1
- trans <transfire@gmail.com>
data/meta/homepage DELETED
@@ -1 +0,0 @@
1
- http://ratch.rubyforge.org
data/meta/name DELETED
@@ -1 +0,0 @@
1
- ratch
data/meta/requires DELETED
@@ -1,4 +0,0 @@
1
- facets
2
- folio
3
- clio
4
-
data/meta/summary DELETED
@@ -1 +0,0 @@
1
- Ruby-based Batch Scripting
data/test/README DELETED
@@ -1 +0,0 @@
1
- Yea. I needs to write test very badly.
data/test/test_helper.rb DELETED
@@ -1,4 +0,0 @@
1
- require 'test/unit'
2
-
3
- $LOAD_PATH.unshift('lib')
4
-
data/test/test_task.rb DELETED
@@ -1,46 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper'
2
-
3
- require 'ratch/task'
4
-
5
- class TestTaskable < Test::Unit::TestCase
6
-
7
- RESULT_CACHE = []
8
-
9
- class Example #< Ratch::DSL
10
-
11
- include Taskable
12
-
13
- task :task_with_no_requisites do
14
- RESULT_CACHE << "task_with_no_requisites"
15
- end
16
-
17
- task :task_with_one_requisite => [:task_with_no_requisites] do
18
- RESULT_CACHE << "task_with_one_requisite"
19
- end
20
-
21
- end
22
-
23
-
24
- def setup
25
- RESULT_CACHE.replace([])
26
- @example = Example.new
27
- end
28
-
29
- def teardown
30
- end
31
-
32
- # Replace this with your real tests.
33
- def test_task_with_no_requisite
34
- @example.run :task_with_no_requisites
35
- #@example.task_with_no_requisites_trigger
36
- assert_equal(["task_with_no_requisites"], RESULT_CACHE)
37
- end
38
-
39
- def test_task_with_one_requisite
40
- @example.run :task_with_one_requisite
41
- #@example.task_with_one_requisite_trigger
42
- assert_equal(["task_with_no_requisites", "task_with_one_requisite"], RESULT_CACHE)
43
- end
44
-
45
- end
46
-