ratch 0.2.2 → 0.2.3

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 (73) hide show
  1. data/COPYING +674 -0
  2. data/README +5 -5
  3. data/bin/lt +11 -11
  4. data/bin/ratch +3 -2
  5. data/demo/README +1 -0
  6. data/demo/WILMA +1 -0
  7. data/demo/doc/rdoc/created.rid +1 -1
  8. data/demo/doc/rdoc/files/README.html +1 -1
  9. data/demo/doc/rdoc/files/lib/foo/foo_rb.html +1 -1
  10. data/demo/doc/rdoc/index.html +3 -3
  11. data/demo/p.rb +9 -0
  12. data/demo/r.rb +6 -0
  13. data/demo/t.rb +3 -0
  14. data/demo/task/config.yaml +2 -0
  15. data/demo/{util → task}/one +0 -0
  16. data/demo/task/rdoc +88 -0
  17. data/demo/task/rdoc-old +182 -0
  18. data/demo/task/simplebuild +15 -0
  19. data/demo/task/stats +6 -0
  20. data/demo/task/task +6 -0
  21. data/demo/{util → task}/tryme +0 -0
  22. data/lib/ratch/argvutils.rb +57 -14
  23. data/lib/ratch/batch.rb +73 -21
  24. data/lib/ratch/batchable.rb +56 -26
  25. data/lib/ratch/batchfile.rb +95 -0
  26. data/lib/ratch/buildable.rb +117 -42
  27. data/lib/ratch/configutils.rb +43 -13
  28. data/lib/ratch/consoleutils.rb +76 -19
  29. data/lib/ratch/emailutils.rb +24 -0
  30. data/lib/ratch/facets/multiglob.rb +160 -0
  31. data/lib/ratch/fileutils.rb +40 -8
  32. data/lib/ratch/options.rb +43 -4
  33. data/lib/ratch/taskable.rb +48 -12
  34. data/{data/ratch/rubyproject → lib/ratch/toolset/ruby}/announce +0 -0
  35. data/lib/ratch/toolset/ruby/crosstest +305 -0
  36. data/{data/ratch/rubyproject → lib/ratch/toolset/ruby}/extest +0 -0
  37. data/{data/ratch/rubyproject → lib/ratch/toolset/ruby}/install +0 -0
  38. data/lib/ratch/toolset/ruby/isotest +293 -0
  39. data/{data/ratch/rubyproject → lib/ratch/toolset/ruby}/load +0 -0
  40. data/lib/ratch/toolset/ruby/loadtest +28 -0
  41. data/{data/ratch/rubyproject → lib/ratch/toolset/ruby}/notes +0 -0
  42. data/{data/ratch/rubyproject → lib/ratch/toolset/ruby}/publish +0 -0
  43. data/lib/ratch/toolset/ruby/rdoc +88 -0
  44. data/{data/ratch/rubyproject → lib/ratch/toolset/ruby}/setup +0 -0
  45. data/{data/ratch/rubyproject → lib/ratch/toolset/ruby}/stats +0 -0
  46. data/lib/ratch/toolset/ruby/syntax +29 -0
  47. data/lib/ratch/toolset/ruby/test +26 -0
  48. data/lib/ratch/uploadutils.rb +25 -4
  49. data/log/history.rd +10 -0
  50. data/log/recent.rd +8 -0
  51. data/log/todo.rd +2 -0
  52. data/man/ratch.man +73 -0
  53. data/meta/MANIFEST +45 -31
  54. data/meta/{RATCH-0.2.2.roll → ratch-0.2.3.roll} +3 -3
  55. data/task/clobber/package +10 -0
  56. data/task/config.yaml +4 -0
  57. data/task/man +14 -0
  58. data/task/publish +1 -1
  59. data/task/rdoc +6 -0
  60. metadata +64 -40
  61. data/LICENSE +0 -344
  62. data/data/ratch/rubyproject/rdoc +0 -42
  63. data/demo/util/conf/rdoc +0 -4
  64. data/demo/util/rdoc +0 -39
  65. data/dev/install +0 -89
  66. data/dev/install.0 +0 -49
  67. data/dev/install.1 +0 -63
  68. data/dev/ludo +0 -25
  69. data/dev/oldtaskable.rb +0 -573
  70. data/dev/taskable-simple.rb +0 -42
  71. data/dev/taskable.rb +0 -120
  72. data/lib/ratch/t.rb +0 -0
  73. data/lib/ratch/taskutils.rb +0 -41
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ratch
2
+
3
+ main :needtest do
4
+
5
+ file 'DINO' => ['FRED'] do
6
+ cp 'FRED', 'DINO'
7
+ end
8
+
9
+ file 'FRED' => ['WILMA'] do
10
+ cp 'WILMA', 'FRED'
11
+ end
12
+
13
+ build 'DINO'
14
+ end
15
+
data/demo/task/stats ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ratch
2
+
3
+ p "here"
4
+
5
+ load('ratch/toolset/ruby/stats')
6
+
data/demo/task/task ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ratch
2
+
3
+ main :task => [ 'one' ] do
4
+ puts "Will it?"
5
+ end
6
+
File without changes
@@ -1,40 +1,64 @@
1
+ # TITLE:
2
+ #
3
+ # ArgvUtils
4
+ #
5
+ # COPYING:
6
+ #
7
+ # Copyright (c) 2007 Psi T Corp.
8
+ #
9
+ # This file is part of the ProUtils' 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/>.
1
23
 
2
24
  module Ratch
3
25
 
4
- # No fuss access to ARGV. This shows up as #argv in the ratch api.
26
+ # No fuss access to ARGV. This shows up as #commandline in the ratch api.
5
27
  #
6
28
  # Ratch uses '=' for parameterized flags b/c this make parsing stupid simple
7
- # and that's a good thing!!!
29
+ # and that's a good thing!!! However you can use value! if need be.
8
30
 
9
31
  module ArgvUtils
10
32
 
11
- def argv
12
- @argv ||= (ARGV.dup).extend(Ext)
33
+ def commandline
34
+ @commandline ||= (ARGV.dup).extend(Ext)
13
35
  end
36
+ alias_method :argument_vector, :commandline
14
37
 
15
38
  module Ext
16
39
 
17
- def flags
18
- @flags ||= collect{ |e| e =~ /^-/ && e !~ /=/ }
19
- end
20
-
21
40
  def arguments
22
- @arguments ||= collect{ |e| e !~ /=/ }
41
+ @arguments ||= select{ |e| e !~ /^-/ && e !~ /=/ }
23
42
  end
24
43
 
25
- def parameters
26
- @parameters ||= (
44
+ def options
45
+ @options ||= (
27
46
  pms = {}
28
- collect{ |e| e =~ /=/ }.each do |e|
47
+ select{ |e| e =~ /=/ }.each do |e|
29
48
  pms.store(*split('='))
30
49
  end
31
50
  pms
32
51
  )
33
52
  end
34
53
 
35
- # Does ARGV include a specifc flag?
54
+ def flags
55
+ @flags ||= select{ |e| e =~ /^-/ || e !~ /=/ }
56
+ end
57
+
58
+ # Have specific flag?
59
+
36
60
  def flag?(flag)
37
- include?(flag)
61
+ flags.include?(flag)
38
62
  end
39
63
 
40
64
  # You can use this if you want to use parameterized
@@ -51,6 +75,25 @@ module Ratch
51
75
  fetch(index(flag)+1)
52
76
  end
53
77
 
78
+ #
79
+ def value!(flag)
80
+ @values ||= {}
81
+ @values[flag] ||= (
82
+ delete(index(flag))
83
+ delete(index(flag))
84
+ )
85
+ end
86
+
87
+ # #
88
+ # def [](x)
89
+ # case x
90
+ # when Integer
91
+ # super(x)
92
+ # else
93
+ # value(x.to_s)
94
+ # end
95
+ # end
96
+
54
97
  end
55
98
  end
56
99
  end
data/lib/ratch/batch.rb CHANGED
@@ -1,19 +1,61 @@
1
+ # TITLE:
2
+ #
3
+ # BatchFile
4
+ #
5
+ # COPYING:
6
+ #
7
+ # Copyright (c) 2007 Psi T Corp.
8
+ #
9
+ # This file is part of the ProUtils' 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
+
1
24
  #require 'shellwords'
25
+ require 'yaml'
2
26
  require 'rbconfig' # replace with facets/rbsystem in future ?
3
- require 'ratch/taskutils'
27
+ #require 'facets/hash/merge' # for reverse_merge
28
+
29
+ require 'ratch/options'
30
+
31
+ require 'ratch/consoleutils'
32
+ require 'ratch/configutils'
33
+ require 'ratch/emailutils'
34
+ require 'ratch/fileutils'
35
+ require 'ratch/argvutils'
36
+
37
+ require 'ratch/taskable'
38
+ require 'ratch/buildable'
4
39
  require 'ratch/batchable'
5
40
 
41
+
6
42
  module Ratch
7
43
 
8
- # Batch File class, is used as an executionm context for a
9
- # ratch script.
44
+ # BatchScript module defines the DSL available to a ratch script.
10
45
 
11
- class BatchFile < Module
46
+ module BatchScript #< Module
12
47
 
13
- include TaskUtils
48
+ include GeneralOptions
14
49
 
50
+ include ConsoleUtils
51
+ include ArgvUtils
52
+ include FileUtils
53
+ include ConfigUtils
54
+ include EmailUtils
55
+
56
+ include Buildable
57
+ include Taskable
15
58
  include Batchable
16
- include OpenBatchable
17
59
 
18
60
  # Quick start, equivalent to calling new.run(file).
19
61
 
@@ -23,27 +65,37 @@ module Ratch
23
65
 
24
66
  # New Batch File
25
67
 
26
- def initialize(file)
27
- abort "missing batch file -- #{file}" unless File.file?(file)
28
- @file = file
29
- end
68
+ #def initialize(file)
69
+ # abort "missing batch file -- #{file}" unless File.file?(file)
70
+ # @file = file
71
+ #end
30
72
 
31
73
  # TODO What todo about arguments?
32
74
 
33
- def call(arguments=nil)
34
- script = File.read($0 = @file)
35
- eval(script, binding, $0) #instance_eval(script)
36
- #@main.call if @main
37
- task_manager.call_main
38
- #run(:main) if task_manager.main
39
- end
75
+ #def call(arguments=nil)
76
+ # script = File.read($0 = @file)
77
+ #puts script
78
+ #p $0
79
+ #puts
80
+ # eval(script, binding, $0) #instance_eval(script)
81
+ # #@main.call if @main
82
+ # task_manager.call_main
83
+ # #run(:main) if task_manager.main
84
+ # end
40
85
 
41
86
  end
42
87
 
43
88
  end
44
89
 
45
- # Load TaskUtils directly into to main runspace.
90
+ # Load BatchScript into to main runspace.
91
+ #
92
+ # TODO: Should this be in all Object space (ie. no class << self)?
93
+ class << self
94
+ include Ratch::BatchScript
95
+ end
96
+
97
+ $batch_binding = binding
46
98
 
47
- #class << self
48
- # include TaskUtils
49
- #end
99
+ END {
100
+ task_manager.call_main
101
+ }
@@ -1,3 +1,26 @@
1
+ # TITLE:
2
+ #
3
+ # Batchable
4
+ #
5
+ # COPYING:
6
+ #
7
+ # Copyright (c) 2007 Psi T Corp.
8
+ #
9
+ # This file is part of the ProUtils' 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
+
1
24
  module Ratch
2
25
 
3
26
  class BatchManager
@@ -6,7 +29,8 @@ module Ratch
6
29
  attr :cache
7
30
 
8
31
  # New BatchManager.
9
- def initialize
32
+ def initialize(runspace)
33
+ @runspace = runspace
10
34
  @cache = {}
11
35
  end
12
36
 
@@ -15,14 +39,16 @@ module Ratch
15
39
  @cache[batchfile] ||= run(batchfile, arguments)
16
40
  end
17
41
 
18
- # TODO How to handle arguments?
42
+ # Run a batch file.
43
+ # TODO: How to handle arguments?
44
+
19
45
  def run(batchfile, arguments=nil)
20
- BatchFile.new(batchfile).call
21
- # # TODO probably should raise error instead
22
- # abort "missing batch file -- #{batchfile}" unless File.file?(batchfile)
23
- # script = File.read($0 = batchfile)
24
- # #instance_eval(script)
25
- # eval(script, binding, $0)
46
+ # # TODO probably should raise error instead
47
+ # abort "missing batch file -- #{batchfile}" unless File.file?(batchfile)
48
+
49
+ #BatchFile.new(batchfile).call # Old way with batch execution context object.
50
+ script = File.read($0 = batchfile)
51
+ eval(script, $batch_binding, $0)
26
52
  end
27
53
 
28
54
  #
@@ -38,7 +64,7 @@ module Ratch
38
64
 
39
65
  # Reference batch manager.
40
66
  def batch_manager
41
- @batch_manager ||= BatchManager.new
67
+ @batch_manager ||= BatchManager.new(self)
42
68
  end
43
69
 
44
70
  # Batch run, ie. run and cache.
@@ -71,17 +97,20 @@ module Ratch
71
97
  end
72
98
  end
73
99
 
100
+ # Is a file a local batch file?
101
+
102
+ def batch?(path)
103
+ b = File.dirname($0) + "/#{path}"
104
+ b.chomp!('!')
105
+ b if FileTest.file?(b) && FileTest.executable?(b)
106
+ end
107
+
74
108
  # Abort running.
75
109
  #def abort(msg=nil)
76
110
  # puts msg if msg
77
111
  # exit 0
78
112
  #end
79
113
 
80
- end
81
-
82
- #
83
- module OpenBatchable
84
-
85
114
  # If method is missing try to run an external task
86
115
  # or binary by that name. If it is a binary, arguments
87
116
  # translate into commandline parameters. For example:
@@ -107,14 +136,14 @@ module Ratch
107
136
 
108
137
  name = sym.to_s
109
138
 
110
- task = task?(name)
111
- done = task && done?(task)
112
- cache = task && !done && name[1,-1] != '!'
113
- bin = bin?(name) if (!task || done)
114
- none = task && done && !bin
115
- #task = name if bin
139
+ bat = batch?(name)
140
+ done = bat && done?(bat)
141
+ cache = bat && !done && name[1,-1] != '!'
142
+ bin = bin?(name) if (!bat || done)
143
+ none = bat && done && !bin
144
+ #bat = name if bin
116
145
 
117
- return super unless task || bin
146
+ return super unless bat || bin
118
147
 
119
148
  return if none # nothing to do
120
149
 
@@ -123,13 +152,14 @@ module Ratch
123
152
  if bin
124
153
  cmd = "#{File.basename(bin)} #{params}"
125
154
  res = sh(cmd)
126
- elsif task
127
- cmd = "./#{task} #{params}"
155
+ elsif bat
156
+ cmd = "./#{bat} #{params}"
128
157
  puts "--> #{cache ? '' : 'not-'}cached execution: #{cmd}" if trace?
129
- res = run(task, args)
158
+ res = batch(bat, args)
130
159
  if cache
131
- #@batch_catch[task] ||= (system(cmd); true)
132
- batch_catch[task] ||= res
160
+ #@batch_catch[bat] ||= (system(cmd); true)
161
+ #batch_cache[bat] ||= res
162
+ batch_manager.cache ||= res
133
163
  end
134
164
  end
135
165
 
@@ -0,0 +1,95 @@
1
+ # TITLE:
2
+ #
3
+ # BatchFile
4
+ #
5
+ # COPYING:
6
+ #
7
+ # Copyright (c) 2007 Psi T Corp.
8
+ #
9
+ # This file is part of the ProUtils' 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 'shellwords'
25
+ require 'yaml'
26
+ require 'rbconfig' # replace with facets/rbsystem in future ?
27
+ #require 'facets/hash/merge' # for reverse_merge
28
+
29
+ require 'ratch/options'
30
+
31
+ require 'ratch/consoleutils'
32
+ require 'ratch/configutils'
33
+ require 'ratch/emailutils'
34
+ require 'ratch/fileutils'
35
+ require 'ratch/argvutils'
36
+
37
+ require 'ratch/taskable'
38
+ require 'ratch/buildable'
39
+ require 'ratch/batchable'
40
+
41
+
42
+ module Ratch
43
+
44
+ # Batch File class, is used as an executionm context for a
45
+ # ratch script.
46
+
47
+ class BatchFile < Module
48
+
49
+ include GeneralOptions
50
+
51
+ include ConsoleUtils
52
+ include ArgvUtils
53
+ include FileUtils
54
+ include ConfigUtils
55
+ include EmailUtils
56
+
57
+ include Buildable
58
+ include Taskable
59
+ include Batchable
60
+
61
+ # Quick start, equivalent to calling new.run(file).
62
+
63
+ #def self.start(file)
64
+ # new(file).call
65
+ #end
66
+
67
+ # New Batch File
68
+
69
+ def initialize(file)
70
+ abort "missing batch file -- #{file}" unless File.file?(file)
71
+ @file = file
72
+ end
73
+
74
+ # TODO What todo about arguments?
75
+
76
+ def call(arguments=nil)
77
+ script = File.read($0 = @file)
78
+ puts script
79
+ p $0
80
+ puts
81
+ eval(script, binding, $0) #instance_eval(script)
82
+ #@main.call if @main
83
+ task_manager.call_main
84
+ #run(:main) if task_manager.main
85
+ end
86
+
87
+ end
88
+
89
+ end
90
+
91
+ # Load TaskUtils directly into to main runspace.
92
+
93
+ #class << self
94
+ # include TaskUtils
95
+ #end