ratch 0.4.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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,21 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- name = ARGV[0]
4
-
5
- unless name
6
- puts "file path required"
7
- exit -1
8
- end
9
-
10
- matches = []
11
- paths = ENV['ROLL_PATH'].split(/[:;]/)
12
- paths.each do |path|
13
- matches = Dir.glob(File.join(path,'{*,*/*,*/*/*,*/*/*/*}',name)) # searches up to four layers deep.
14
- end
15
- matches = matches.select{ |f| File.executable?(f) }
16
- matches = matches.sort{ |a,b| File.mtime(b) <=> File.mtime(a) }
17
-
18
- matches.each do |f|
19
- puts "#{File.mtime(f)} #{f}"
20
- end
21
-
data/demo/WILMA DELETED
@@ -1 +0,0 @@
1
- Here
data/demo/XR DELETED
@@ -1,9 +0,0 @@
1
- = Demo of Ratchets
2
-
3
- The Ruby Batch System
4
-
5
- == What Do You Say?
6
-
7
- This is Foo business.
8
-
9
-
@@ -1,7 +0,0 @@
1
-
2
- # Say hello, Gracy.
3
-
4
- def hello
5
- "Hello, Gracy"
6
- end
7
-
data/demo/p.rb DELETED
@@ -1,9 +0,0 @@
1
-
2
-
3
- f = Functor.new do |op,x|
4
- x.send(op,x)
5
- end
6
-
7
- p f + 1
8
- p f + 2
9
-
data/demo/r.rb DELETED
@@ -1,6 +0,0 @@
1
- require 'facets/functor'
2
-
3
- script = File.read($0 = './t.rb')
4
-
5
- eval(script, binding, $0)
6
-
data/demo/t.rb DELETED
@@ -1,3 +0,0 @@
1
-
2
- load('./p.rb')
3
-
@@ -1,4 +0,0 @@
1
-
2
- rdoc:
3
- include: [ README, lib ]
4
-
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ratch
2
-
3
- # run only once
4
-
5
- puts "This should only happen once!"
6
-
@@ -1,15 +0,0 @@
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
-
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ratch
2
-
3
- load('ratch/toolset/ruby/stats')
4
-
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ratch
2
-
3
- main :task => [ 'one' ] do
4
- puts "Will it?"
5
- end
6
-
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ratch
2
-
3
- # try out the task system
4
-
5
- puts "Invoking 'one' three times..."
6
-
7
- one
8
- one
9
- one
10
-
@@ -1,112 +0,0 @@
1
- # = TITLE:
2
- #
3
- # Argv DSL
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
- module Ratch
25
- module Dsl
26
-
27
- # No fuss access to ARGV. This shows up as #commandline in the ratch api.
28
- #
29
- # Ratch uses '=' for parameterized flags b/c this make parsing stupid simple
30
- # and that's a good thing!!! However you can use value! if need be.
31
-
32
- module Argv
33
-
34
- def commandline
35
- @commandline ||= ArgVector.new(ARGV)
36
- end
37
-
38
- alias_method :argument_vector, :commandline
39
-
40
- #
41
-
42
- class ArgVector
43
- attr :argv
44
-
45
- def initialize(argv)
46
- @argv = argv.dup
47
- end
48
-
49
- def arguments
50
- @arguments ||= argv.select{ |e| e !~ /^-/ && e !~ /=/ }
51
- end
52
-
53
- def options
54
- @options ||= (
55
- pms = {}
56
- argv.select{ |e| /[=]/ =~ e }.each do |e|
57
- pms.store(*e.split('='))
58
- end
59
- pms
60
- )
61
- end
62
-
63
- def flags
64
- @flags ||= argv.select{ |e| e =~ /^-/ || e !~ /=/ }
65
- end
66
-
67
- # Have specific flag?
68
-
69
- def flag?(flag)
70
- flags.include?(flag)
71
- end
72
-
73
- #
74
- def [](x)
75
- case x
76
- when Integer
77
- arguments[x]
78
- else
79
- options[x.to_s]
80
- end
81
- end
82
-
83
- # You can use this if you want to use parameterized
84
- # flags w/o the '=', however be aware that the
85
- # parameter value will also be listed amoung the
86
- # bare arguments list. For example:
87
- #
88
- # $ foo tom --say hello
89
- #
90
- # argv.value('--say') #=> "hello"
91
- # argv.arguments #=> ["tom", "hello"]
92
- #
93
-
94
- def value(flag)
95
- argv.fetch(index(flag)+1)
96
- end
97
-
98
- #
99
- def value!(flag)
100
- @values ||= {}
101
- @values[flag] ||= (
102
- argv.delete(index(flag))
103
- argv.delete(index(flag))
104
- )
105
- end
106
-
107
- end
108
-
109
- end
110
-
111
- end
112
- end
@@ -1,232 +0,0 @@
1
- # = TITLE:
2
- #
3
- # Batch DSL
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 'yaml'
25
- #require 'rbconfig' # replace with facets/rbsystem in future ?
26
-
27
- #require 'ratch/dsl/batch/task'
28
- #require 'ratch/dsl/batch/build'
29
- #require 'ratch/dsl/batch/directory'
30
-
31
- module Ratch
32
- module Dsl
33
-
34
- # Batch module defines the DSL for calling other batch files
35
- # and system binaries.
36
-
37
- module Batch
38
-
39
- # Shell runner.
40
-
41
- def sh(cmd)
42
- if noharm?
43
- puts cmd
44
- true
45
- else
46
- puts "--> system call: #{cmd}" if trace?
47
- system(cmd)
48
- end
49
- end
50
-
51
- # Abort running.
52
- #def abort(msg=nil)
53
- # puts msg if msg
54
- # exit 0
55
- #end
56
-
57
- def root_directory
58
- @root_directory ||= Dir.pwd
59
- end
60
-
61
- def call_directory
62
- @call_directory ||= File.expand_path(File.dirname($0))
63
- end
64
-
65
- # TODO Better name? (system_directory ?)
66
-
67
- def batch_directory
68
- # TODO: Better definition?
69
- @batch_directory ||= (
70
- dir = call_directory.sub(root_directory + '/', '').split('/').first
71
- File.join(root_directory, dir)
72
- )
73
- end
74
-
75
- # If a system directory is used (as opposed to a local project directory)
76
- # then the batch directory will need to be set explicitly.
77
-
78
- attr_writer :batch_directory
79
-
80
- # Current batch file, relative to the batch directory.
81
-
82
- def batch_file
83
- File.expand_path($0).sub(batch_directory + '/', '')
84
- end
85
-
86
- # Run batch file and cache result.
87
- #
88
- # Usually this can be taken care of by method_missing.
89
- # But, in some cases, built in method names block batch
90
- # calls, so you have to use #batch to invoke those.
91
-
92
- def batch(batchfile, arguments=nil)
93
- batch_cache[batchfile] ||= batch!(batchfile, arguments)
94
- end
95
-
96
- # Lauch a batch file. Like #batch but not-cached.
97
- # Run a batch file.
98
- # TODO: How to handle arguments?
99
-
100
- def batch!(batchfile, arguments=nil)
101
- #BatchFile.new(batchfile).call # Old way with batch execution context object.
102
-
103
- @main = nil # reset main task
104
-
105
- script = File.read($0 = batchfile)
106
- eval(script, TOPLEVEL_BINDING, $0)
107
-
108
- #batch_file = File.expand_path($0).sub(batch_directory + '/', '')
109
- #run(batch_file)
110
- run_main #(batch_file)
111
- end
112
-
113
- # Is a path a local batch directory?
114
-
115
- def batch_directory?(path)
116
- b = File.join(File.dirname($0), path.to_s)
117
- b if FileTest.directory?(b)
118
- end
119
-
120
- # Is a file a local batch file?
121
-
122
- def batch?(path)
123
- b = File.join(File.dirname($0), path.to_s)
124
- b if FileTest.file?(b) && FileTest.executable?(b)
125
- end
126
-
127
- # Is a batch run complete or in the process of being completed?
128
- # Has the batch file been executed before?
129
-
130
- def done?(batchfile)
131
- batchfile == $0 || batch_cache.key?(batchfile)
132
- end
133
-
134
- # Batch cache, which prevents batch runs from re-executing.
135
-
136
- def batch_cache
137
- @batch_cache ||= {}
138
- end
139
-
140
- # If method is missing try to run an external task
141
- # or binary by that name. If it is a binary, arguments
142
- # translate into commandline parameters. For example:
143
- #
144
- # tar 'foo/', :x=>true, :v=>true, :z=>true, :f=>'foo.tar.gz'
145
- #
146
- # or
147
- #
148
- # tar '-xvzf', "foo.tar.gz", "foo/"
149
- #
150
- # becomes
151
- #
152
- # tar -x -v -z -f foo.tar.gz foo/
153
- #
154
- # If it is a task, it will be cached. Tasks only ever run once.
155
- # To run them more than once you can manually execute them with #run.
156
- # Likewise you can manually run and cache by calling #batch.
157
- # This is good to know, b/c in some cases built in method names
158
- # block task calls, so you have to #batch to invoke them.
159
-
160
- def method_missing(sym,*args)
161
- puts "method_missing: #{sym}" if debug?
162
- #begin
163
- launch(sym,*args)
164
- #rescue ArgumentError
165
- # super
166
- #end
167
- end
168
-
169
- # TODO Better name!!! Better code.
170
-
171
- def launch(name, *args)
172
- name = name.to_s
173
- force = name.chomp!('!')
174
-
175
- # is this a batch directory?
176
- if batch_directory?(name)
177
- return Batch::Space.new(self, name)
178
- end
179
-
180
- params = args.to_params
181
-
182
- # is this a batch file?
183
- if bat = batch?(name)
184
- if force
185
- cmd = "./#{bat} #{params}"
186
- puts "--> non-cached execution: #{cmd}" if trace?
187
- return batch!(bat, args)
188
- else
189
- if done?(bat)
190
- return nil unless bin?(name) # return cache?
191
- else
192
- cmd = "./#{bat} #{params}"
193
- puts "--> cached execution: #{cmd}" if trace?
194
- return batch(bat, args)
195
- end
196
- end
197
- end
198
-
199
- # is this a bin file?
200
- if bin = bin?(name)
201
- cmd = "#{File.basename(bin)} #{params}"
202
- return sh(cmd)
203
- end
204
-
205
- raise ArgumentError, "script not found -- #{name}"
206
- end
207
-
208
- end
209
-
210
- # This is a type of functor, that allows for calling batch files
211
- # that are in subdirectories using "dir.file" notation. Eg.
212
- #
213
- # svn.log
214
- #
215
- # could run the svn/log ratch file.
216
-
217
- class Batch::Space
218
- private *instance_methods.select{ |m| m !~ /^__/ }
219
-
220
- def initialize(manager, directory)
221
- @manager = manager
222
- @directory = directory
223
- end
224
-
225
- def method_missing(sym, *args)
226
- path = File.join(@directory, sym.to_s)
227
- @manager.launch(path, *args)
228
- end
229
- end
230
-
231
- end
232
- end