ratch 0.4.1 → 1.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 (107) hide show
  1. data/COPYING +17 -669
  2. data/HISTORY +6 -0
  3. data/MANIFEST +36 -0
  4. data/METADATA +14 -0
  5. data/NEWS +7 -0
  6. data/README +67 -17
  7. data/bin/ratch +5 -78
  8. data/demo/tryme-task.ratch +12 -0
  9. data/demo/tryme1.ratch +6 -0
  10. data/lib/ratch/core_ext.rb +6 -0
  11. data/lib/ratch/core_ext/facets.rb +1 -0
  12. data/lib/ratch/core_ext/filetest.rb +52 -0
  13. data/lib/ratch/core_ext/object.rb +8 -0
  14. data/lib/ratch/core_ext/pathname.rb +38 -0
  15. data/lib/ratch/core_ext/string.rb +44 -0
  16. data/lib/ratch/{dsl/console.rb → core_ext/to_console.rb} +2 -76
  17. data/lib/ratch/core_ext/to_list.rb +29 -0
  18. data/lib/ratch/dsl.rb +494 -49
  19. data/lib/ratch/index.rb +4 -0
  20. data/lib/ratch/io.rb +116 -0
  21. data/lib/ratch/pathglob.rb +73 -0
  22. data/lib/ratch/plugin.rb +55 -0
  23. data/lib/ratch/runmode.rb +69 -0
  24. data/lib/ratch/script.rb +52 -0
  25. data/lib/ratch/service.rb +33 -0
  26. data/lib/ratch/task.rb +249 -0
  27. data/lib/ratch/task2.rb +298 -0
  28. data/test/README +1 -0
  29. data/test/test_helper.rb +4 -0
  30. data/test/test_task.rb +46 -0
  31. metadata +90 -150
  32. data/CHANGES +0 -22
  33. data/TODO +0 -2
  34. data/bin/lt +0 -56
  35. data/bin/ludo +0 -14
  36. data/bin/manifest +0 -451
  37. data/bin/ratch-find +0 -21
  38. data/demo/WILMA +0 -1
  39. data/demo/XR +0 -9
  40. data/demo/lib/foo/foo.rb +0 -7
  41. data/demo/p.rb +0 -9
  42. data/demo/r.rb +0 -6
  43. data/demo/t.rb +0 -3
  44. data/demo/task/config.yaml +0 -4
  45. data/demo/task/one +0 -6
  46. data/demo/task/simplebuild +0 -15
  47. data/demo/task/stats +0 -4
  48. data/demo/task/task +0 -6
  49. data/demo/task/tryme +0 -10
  50. data/lib/ratch/dsl/argv.rb +0 -112
  51. data/lib/ratch/dsl/batch.rb +0 -232
  52. data/lib/ratch/dsl/build.rb +0 -174
  53. data/lib/ratch/dsl/email.rb +0 -108
  54. data/lib/ratch/dsl/file.rb +0 -205
  55. data/lib/ratch/dsl/meta.rb +0 -125
  56. data/lib/ratch/dsl/options.rb +0 -98
  57. data/lib/ratch/dsl/setup.rb +0 -124
  58. data/lib/ratch/dsl/sign.rb +0 -243
  59. data/lib/ratch/dsl/stage.rb +0 -147
  60. data/lib/ratch/dsl/task.rb +0 -139
  61. data/lib/ratch/dsl/upload.rb +0 -436
  62. data/lib/ratch/dsl/zip.rb +0 -59
  63. data/lib/ratch/extra/email.rb +0 -5
  64. data/lib/ratch/extra/stage.rb +0 -5
  65. data/lib/ratch/extra/zip.rb +0 -5
  66. data/lib/ratch/manager.rb +0 -53
  67. data/lib/ratch/manifest.rb +0 -540
  68. data/lib/ratch/metadata/information.rb +0 -258
  69. data/lib/ratch/metadata/package.rb +0 -108
  70. data/lib/ratch/metadata/project.rb +0 -523
  71. data/lib/ratch/metadata/release.rb +0 -108
  72. data/lib/ratch/support/errors.rb +0 -4
  73. data/lib/ratch/support/filename.rb +0 -18
  74. data/lib/ratch/support/filetest.rb +0 -29
  75. data/lib/ratch/toolset/ruby/announce +0 -224
  76. data/lib/ratch/toolset/ruby/compile +0 -49
  77. data/lib/ratch/toolset/ruby/install +0 -77
  78. data/lib/ratch/toolset/ruby/notes +0 -185
  79. data/lib/ratch/toolset/ruby/pack/gem +0 -93
  80. data/lib/ratch/toolset/ruby/pack/tgz +0 -46
  81. data/lib/ratch/toolset/ruby/pack/zip +0 -46
  82. data/lib/ratch/toolset/ruby/publish +0 -57
  83. data/lib/ratch/toolset/ruby/release +0 -8
  84. data/lib/ratch/toolset/ruby/setup +0 -1616
  85. data/lib/ratch/toolset/ruby/stamp +0 -33
  86. data/lib/ratch/toolset/ruby/stats +0 -138
  87. data/lib/ratch/toolset/ruby/test/crosstest +0 -305
  88. data/lib/ratch/toolset/ruby/test/extest +0 -129
  89. data/lib/ratch/toolset/ruby/test/isotest +0 -293
  90. data/lib/ratch/toolset/ruby/test/load +0 -39
  91. data/lib/ratch/toolset/ruby/test/loadtest +0 -28
  92. data/lib/ratch/toolset/ruby/test/syntax +0 -29
  93. data/lib/ratch/toolset/ruby/test/test +0 -26
  94. data/lib/ratch/toolset/sandbox/query +0 -11
  95. data/man/ratch.man +0 -73
  96. data/meta/MANIFEST +0 -130
  97. data/meta/config.yaml +0 -9
  98. data/meta/icli.yaml +0 -16
  99. data/meta/project.yaml +0 -20
  100. data/meta/ratch.roll +0 -2
  101. data/meta/xProjectInfo +0 -41
  102. data/task/clobber/package +0 -10
  103. data/task/man +0 -14
  104. data/task/publish +0 -57
  105. data/task/release +0 -9
  106. data/task/setup +0 -1616
  107. data/task/stats +0 -138
@@ -1,59 +0,0 @@
1
- # = TITLE:
2
- #
3
- # Zip DSL
4
- #
5
- # = COPYING:
6
- #
7
- # Copyright (c) 2007 Psi T Corp.
8
- #
9
- # This file is part of the Ratch program.
10
- #
11
- # Ratch is free software: you can redistribute it and/or modify
12
- # it under the terms of the GNU General Public License as published by
13
- # the Free Software Foundation, either version 3 of the License, or
14
- # (at your option) any later version.
15
- #
16
- # Ratch is distributed in the hope that it will be useful,
17
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- # GNU General Public License for more details.
20
- #
21
- # You should have received a copy of the GNU General Public License
22
- # along with Ratch. If not, see <http://www.gnu.org/licenses/>.
23
-
24
- require 'facets/ziputils'
25
-
26
- module Ratch
27
- module Dsl
28
-
29
- module Zip
30
-
31
- #
32
-
33
- def zip(folder, file=nil, options={})
34
- ziputils.zip(folder, file, options)
35
- end
36
-
37
- #
38
-
39
- def tar_bzip(folder, file=nil, options={})
40
- ziputils.tar_bzip(folder, file, options)
41
- end
42
-
43
- #
44
-
45
- def tar_gzip(folder, file=nil, options={})
46
- ziputils.tar_gzip(folder, file, options)
47
- end
48
- alias_method :tgz, :tar_gzip
49
-
50
- # Delegate access to ZipUtils.
51
-
52
- def ziputils
53
- dryrun? ? ::ZipUtils::DryRun : ::ZipUtils
54
- end
55
-
56
- end
57
-
58
- end
59
- end
@@ -1,5 +0,0 @@
1
- require 'ratch/dsl/email'
2
-
3
- class << self
4
- include Ratch::Dsl::Email
5
- end
@@ -1,5 +0,0 @@
1
- require 'ratch/dsl/stage'
2
-
3
- class << self
4
- include Ratch::Dsl::Stage
5
- end
@@ -1,5 +0,0 @@
1
- require 'ratch/dsl/zip'
2
-
3
- class << self
4
- include Ratch::Dsl::Zip
5
- end
@@ -1,53 +0,0 @@
1
- module Ratch
2
-
3
- class Manager
4
-
5
- # Return master toolset directory. If toolset if given then
6
- # return that toolsets directory.
7
-
8
- def toolset_directory(toolset=nil)
9
- if toolset
10
- File.join(File.dirname(__FILE__), 'toolset', toolset)
11
- else
12
- File.join(File.dirname(__FILE__), 'toolset')
13
- end
14
- end
15
-
16
- # List toolsets.
17
-
18
- def toolsets
19
- files = []
20
- Dir.chdir(toolset_directory) do
21
- files = Dir.glob('*/').map{ |d| d.chomp('/') }
22
- end
23
- files
24
- end
25
-
26
- # List tools for a give toolset.
27
-
28
- def tools(toolset=nil)
29
- files = []
30
- direc = toolset ? File.join(toolset_directory, toolset) : toolset_directory
31
- Dir.chdir(direc) do
32
- files = Dir.glob('**/*') - Dir.glob('**/*/').map{ |d| d.chomp('/') }
33
- end
34
- files
35
- end
36
-
37
- # Verify a toolset exists?
38
-
39
- def toolset?(toolset)
40
- path = File.join(toolset_directory, toolset)
41
- File.exist?(path) ? path : false
42
- end
43
-
44
- # Verify a tool exists for a given toolset.
45
-
46
- def tool?(toolset, batchfile)
47
- path = File.join(toolset_directory, toolset, batchfile)
48
- File.exist?(path) ? path : false
49
- end
50
-
51
- end
52
-
53
- end
@@ -1,540 +0,0 @@
1
- # = TITLE:
2
- #
3
- # Manifest
4
- #
5
- # = SYNOPSIS:
6
- #
7
- # Generate manifest/digest list. Usefule for including in package distributions.
8
- #
9
- # = COPYING:
10
- #
11
- # Copyright (c) 2007 Psi T Corp.
12
- #
13
- # This file is part of the ProUtils' Ratch program.
14
- #
15
- # Ratch is free software: you can redistribute it and/or modify
16
- # it under the terms of the GNU General Public License as published by
17
- # the Free Software Foundation, either version 3 of the License, or
18
- # (at your option) any later version.
19
- #
20
- # Ratch is distributed in the hope that it will be useful,
21
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- # GNU General Public License for more details.
24
- #
25
- # You should have received a copy of the GNU General Public License
26
- # along with Ratch. If not, see <http://www.gnu.org/licenses/>.
27
- #
28
- # = TODO:
29
- # - Integrate file signing and general manifest better (?)
30
- # - Digester is in sign.rb too. Dry-up?
31
- # - Is it problematic to add a digest to the manifest?
32
- # - This needs some TLC. Eg. diff is shelling out, but it would
33
- # be better if internalized.
34
- # - Could just use some over all belt tightening.
35
-
36
- require 'fileutils'
37
- require 'getoptlong'
38
- require 'shellwords'
39
-
40
- require 'facets/dir/multiglob' # for Dir.multiglob_r
41
- require 'facets/file/read' # for File.read_list
42
-
43
- module Ratch
44
-
45
- # Manifest file overwrite error.
46
- #
47
- class OverwriteError < Exception
48
- end
49
-
50
- # No Manifest File Error.
51
- #
52
- class NoManifestError < LoadError
53
- end
54
-
55
- # Manifest stores a list of package files, and optionally checksums.
56
- #
57
- # The class can be used to create and compare package manifests.
58
-
59
- class Manifest
60
-
61
- DEFAULT_EXCLUDE = %w{ InstalledFiles .config *~ CVS _darcs .svn .git }
62
- DEFAULT_FILE = '{,meta/}manifest{,.txt,.list}'
63
-
64
- # Possible file name (was for Fileable?).
65
- def self.filename
66
- DEFAULT_FILE
67
- end
68
-
69
- def self.open(file=nil, options={})
70
- unless file
71
- file = Dir.glob(filename, File::FNM_CASEFOLD).first
72
- raise LoadError, "Manifest file is required." unless file
73
- end
74
- options.update(:file => file)
75
- self.new(options)
76
- end
77
-
78
- # File used to store digest/manifest.
79
-
80
- attr_accessor :file
81
-
82
- # Encryption type
83
-
84
- attr_accessor :digest
85
-
86
- # Do not exclude standard exclusions.
87
-
88
- attr_accessor :all
89
- alias_method :all?, :all
90
-
91
- # What files to exclude from digest.
92
-
93
- attr_accessor :exclude
94
- alias_method :ignore, :exclude
95
-
96
- # Directory to use.
97
-
98
- attr_accessor :directory
99
-
100
- # Layout of digest -- csf or sfv. Default is csf.
101
-
102
- attr_accessor :format
103
-
104
- # Files and checksums listed in file.
105
-
106
- attr_reader :list
107
-
108
- # New Digest object.
109
-
110
- def initialize(options={})
111
- @exclude = []
112
-
113
- change_options(options)
114
-
115
- if @file
116
- read(@file)
117
- #else
118
- #if file = Dir.glob(self.class.filename)[0]
119
- # @file = file
120
- #else
121
- # @file = DEFAULT_FILE
122
- #end
123
- end
124
- end
125
-
126
- # Set options.
127
-
128
- def change_options(opts)
129
- opts.each do |k,v|
130
- k = k.to_s.downcase
131
- send("#{k}=",v||send(k))
132
- end
133
- #@file = options[:file] || @file
134
- #@digest = options[:digest] || @digest
135
- #@all = options[:all] || @all
136
- #@exclude = options[:exclude] || options[:ignore] || @exclude
137
- #@exclude = [@exclude].flatten.compact
138
- end
139
-
140
- #
141
-
142
- def file?
143
- @read_from_file
144
- end
145
-
146
- # Create a digest/manifest file. This saves the list of files
147
- # and optionally their checksum.
148
-
149
- #def create(options=nil)
150
- # change_options(options) if options
151
- # #@file ||= DEFAULT_FILE
152
- # raise OverwriteError if FileTest.file?(file)
153
- # save #(false)
154
- #end
155
-
156
- # Update file.
157
-
158
- def update(options=nil)
159
- change_options(options) if options
160
- raise NoManifestError unless file and FileTest.file?(file)
161
- save
162
- end
163
-
164
- # Save as file.
165
-
166
- def save(options=nil)
167
- change_options(options) if options
168
- File.open(file, 'w') do |file|
169
- file << topline_string
170
- output(file)
171
- end
172
- return file
173
- end
174
-
175
- # Diff file against actual files.
176
-
177
- def diff
178
- raise NoManifestError unless file and FileTest.file?(file)
179
- manifest = create_temporary_manifest
180
- begin
181
- result = `diff -du #{file} #{manifest.file}`
182
- ensure
183
- FileUtils.rm(manifest.file)
184
- end
185
- # pass = result.empty?
186
- return result
187
- end
188
-
189
- # Files listed in manifest, but not found.
190
-
191
- def whatsold
192
- #raise ManifestMissing unless file
193
- filelist - files
194
- end
195
-
196
- # Files found, but not listed in manifest.
197
-
198
- def whatsnew
199
- #raise ManifestMissing unless file
200
- files - (filelist + [filename])
201
- end
202
-
203
- # Clean non-manifest files.
204
-
205
- def clean
206
- cfiles, cdirs = clean_files.partition{ |f| !File.directory?(f) }
207
- FileUtils.rm(cfiles)
208
- FileUtils.rmdir(cdirs)
209
- end
210
-
211
- #
212
-
213
- def clean_files
214
- keep = Dir.glob('*').select{|f| File.directory?(f)}
215
- keep << filename # keep manifest
216
- Dir.glob('**/*') - (files + keep)
217
- end
218
-
219
- # # Clobber non-manifest files.
220
- # #
221
- # def clobber
222
- # clobber_files.each{ |f| rm_r(f) if File.exist?(f) }
223
- # end
224
- #
225
- # #--
226
- # # TODO Should clobber work off the manifest file itself?
227
- # #++
228
- # def clobber_files
229
- # keep = filelist # + [info.manifest]
230
- # Dir.glob('**/*') - keep
231
- # end
232
-
233
- # File's name.
234
-
235
- def filename
236
- File.basename(file)
237
- end
238
-
239
- # File's location.
240
-
241
- def location
242
- #if directory
243
- # directory
244
- #if file
245
- # File.dirname(file)
246
- #else
247
- @location = @directory || Dir.pwd
248
- #end
249
- end
250
-
251
- # List of files as given in the file.
252
-
253
- def filelist
254
- list.keys.sort
255
- end
256
-
257
- # Generate manifest.
258
-
259
- def generate(out=$stdout)
260
- out << topline_string
261
- output(out)
262
- end
263
-
264
- #
265
-
266
- def output(out=$stdout)
267
- Dir.chdir(location) do
268
- rec_output('*', out)
269
- end
270
- end
271
-
272
- # Generate listing on the fly.
273
-
274
- def rec_output(match, out=$stdout)
275
- out.flush
276
- #match = (location == dir ? '*' : File.join(dir,'*'))
277
- files = Dir.glob(match) - exclusions
278
- files.sort!
279
- files.each do |file|
280
- sum = checksum(file,digest)
281
- sum = sum + ' ' if sum
282
- out << "#{sum}#{file}\n"
283
- if File.directory?(file)
284
- rec_output(File.join(file,'*'), out)
285
- end
286
- end
287
- #return out
288
- end
289
- private :rec_output
290
-
291
-
292
- # List files in package.
293
-
294
- def files #(update=false)
295
- #remove = (update ? (exclude + topline.exclude) : exclude)
296
- #remove = exclude
297
- #remove += DEFAULT_EXCLUDE unless all?
298
- #remove += [filename, filename.chomp('~')]
299
-
300
- files = []
301
- Dir.chdir(location) do
302
- files += Dir.multiglob_r('**/*')
303
- files -= Dir.multiglob_r(exclusions)
304
- end
305
- return files
306
- end
307
-
308
- # Compute exclusions.
309
-
310
- def exclusions
311
- @_exclusions ||= (
312
- e = exclude
313
- e += DEFAULT_EXCLUDE unless all?
314
- e += [filename, filename.chomp('~')] if file
315
- e
316
- )
317
- end
318
-
319
- # List of files in package, but omit folders.
320
-
321
- def files_without_folders
322
- files.select{ |f| !File.directory?(f) }
323
- end
324
-
325
- # Produce textual listing less the manifest file.
326
-
327
- def listing
328
- str = ''
329
- output(str)
330
- str
331
-
332
- # #crypt = (update ? (digest || topline.digest) : digest)
333
- # crypt = digest
334
- #
335
- # list = files #(update) #- [filename, filename.chomp('~')]
336
- # list.sort!
337
- # list.collect!{ |file| [checksum(file,crypt), file] }
338
- # list.collect!{ |file| file.compact.join(' ') }
339
- # list.join("\n") + "\n"
340
- end
341
-
342
- # File content.
343
-
344
- def to_s #(update=false)
345
- topline_string + listing #(update) + listing(update)
346
- end
347
-
348
- private
349
-
350
- # Create temporary manifest (for comparison).
351
-
352
- def create_temporary_manifest
353
- temp_manifest = Manifest.new
354
- temp_manifest.save(
355
- :file => file+"~",
356
- :digest => digest,
357
- :exclude => exclude,
358
- :all => all
359
- )
360
- #File.open(tempfile, 'w+') do |f|
361
- # f << to_s(true)
362
- #end
363
- return temp_manifest
364
- end
365
-
366
- # Produce hexdigest/cheksum for a file.
367
- # Default digest type is sha1.
368
-
369
- def checksum(file, digest=nil)
370
- return nil unless digest
371
- if FileTest.directory?(file)
372
- @null_string ||= digester(digest).hexdigest("")
373
- else
374
- digester(digest).hexdigest(File.read(file))
375
- end
376
- end
377
-
378
- # Return a digest class for given +type+.
379
- # Supported digests are:
380
- #
381
- # * md5
382
- # * sha1
383
- # * sha128 (same as sha1)
384
- # * sha256
385
- # * sha512
386
- #
387
- # Default digest type is sha256.
388
-
389
- def digester(type=nil)
390
- require 'openssl'
391
- case type.to_s.downcase
392
- when 'md5'
393
- require 'digest/md5'
394
- ::Digest::MD5
395
- when 'sha128', 'sha1'
396
- require 'digest/sha1' #need?
397
- OpenSSL::Digest::SHA1
398
- when 'sha256'
399
- require 'digest/sha1' #need?
400
- OpenSSL::Digest::SHA256
401
- when 'sha512'
402
- require 'digest/sha1' #need?
403
- OpenSSL::Digest::SHA512
404
- else
405
- raise "unsupported digest #{type}"
406
- end
407
- end
408
-
409
- # Read manifest file.
410
-
411
- def read(file)
412
- @file = file
413
- #@location = File.dirname(File.expand_path(file))
414
-
415
- l = {}
416
- flist = File.read_list(file)
417
- flist.each do |line|
418
- left, right = line.split(/\s+/)
419
- if right
420
- checksum = left
421
- filename = right
422
- l[filename] = checksum
423
- else
424
- filename = left
425
- l[filename] = nil
426
- end
427
- end
428
-
429
- a, d, x = *topline_parse
430
-
431
- @list = l
432
- @all = a
433
- @digest = d
434
- @exclude = x
435
-
436
- @read_from_file = file
437
- end
438
-
439
- # Get topline of Manifest file, parse and cache.
440
- #def topline
441
- # @topline ||= topline_parse
442
- #end
443
-
444
- #TOPLINE_ARITY = {:x=>1, :exclude=>1, :g=>1, :digest=>1}
445
-
446
- #
447
- def topline_parse
448
- if line = read_topline
449
- argv = Shellwords.shellwords(line)
450
- ARGV.replace(argv)
451
- opts = GetoptLong.new(
452
- [ '-g', '--digest' , GetoptLong::REQUIRED_ARGUMENT ],
453
- [ '-x', '--exclude', '--ignore', GetoptLong::REQUIRED_ARGUMENT ],
454
- [ '-a', '--all' , GetoptLong::NO_ARGUMENT ]
455
- )
456
- a, d, x = false, nil, []
457
- opts.each do |opt, arg|
458
- case opt
459
- when '-g': d = arg.downcase
460
- when '-a': a = true
461
- when '-x': x << arg
462
- end
463
- end
464
- return a, d, x
465
- end
466
- end
467
-
468
- #
469
- def read_topline
470
- r = nil
471
- #if file = locate(filename)
472
- File.open(file) do |f|
473
- s = f.readline
474
- if s =~ /^#\s*(.*?)\n/
475
- r = $1
476
- end
477
- end
478
- return r
479
- #end
480
- end
481
-
482
- # Create topline of MANIFEST file.
483
- #
484
- def topline_string(update=false)
485
- if update
486
- a = all #|| topline.all
487
- d = digest #|| topline.digest
488
- x = exclude #+ topline.exclude
489
- else
490
- a, d, x = all, digest, exclude
491
- end
492
- top = []
493
- top << "-a" if a
494
- top << "-g #{d.to_s.downcase}" if d
495
- x.each do |e|
496
- top << "-x #{e}"
497
- end
498
- return "# #{top.join(' ')}\n"
499
- end
500
-
501
- end
502
-
503
- end
504
-
505
-
506
-
507
- =begin
508
- #
509
- def manifest_file
510
- apply_naming_policy(@file || DEFAULT_FILE, 'txt')
511
- end
512
-
513
- private
514
-
515
- # Apply naming policy.
516
- #
517
- def apply_naming_policy(name, ext)
518
- return name unless policy
519
- policies = naming_policy.split(' ')
520
- policies.each do |polic|
521
- case polic
522
- when 'downcase'
523
- name = name.downcase
524
- when 'upcase'
525
- name = name.upcase
526
- when 'capitalize'
527
- name = name.capitalize
528
- when 'extension'
529
- name = name + ".#{ext}"
530
- when 'plain'
531
- name = name.chomp(File.extname(name))
532
- else
533
- name
534
- end
535
- end
536
- return name
537
- end
538
- =end
539
-
540
- #end # module Ratchets