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,174 +0,0 @@
1
- # = TITLE:
2
- #
3
- # Build 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
- module Builds
28
-
29
- # Define a build target.
30
-
31
- def file(name, &block)
32
- name, deps, block = *parse_build_dependencies(name, &block)
33
- define_file(name, *deps, &block)
34
- end
35
-
36
- # Build target(s).
37
-
38
- def build(path)
39
- # TODO How to handle more than one matching means of building?
40
- #warn "More than one build definition matches #{path} using #{means.first}" if means.size > 1
41
- if build = find_build(path)
42
- if build.needed_for?(path) || force?
43
- list, todo = *build_plan(build, path)
44
- todo.each{|bld, pth| bld.call(pth) } #@builds[name].call }
45
- build.call(path)
46
- end
47
- else
48
- raise "build not found -- #{path}"
49
- end
50
- end
51
-
52
- private
53
-
54
- def builds; @builds ||= [] ; end
55
-
56
- #
57
- def parse_build_dependencies(name_deps, &block)
58
- if Hash===name_deps
59
- name = name_deps.keys[0]
60
- deps = name_deps.values[0]
61
- else
62
- name = name_deps
63
- deps = []
64
- end
65
- [name, deps, block]
66
- end
67
-
68
- # Define a file build task.
69
-
70
- def define_file(name, *depend, &block)
71
- build = Build.new(name, *depend, &block)
72
- builds << build
73
- end
74
-
75
- #
76
-
77
- def find_build(path)
78
- builds.find{ |b| b.match?(path) }
79
- end
80
-
81
- # Prepare build plan, checking for circular dependencies.
82
-
83
- def build_plan(build, path, list=[], todo=[])
84
- #if list.include?(build)
85
- # raise "Circular build dependency #{build.name}."
86
- #end
87
-
88
- build.needed_paths.each do |npath|
89
- next if list.include?(npath)
90
- if nbuild = find_build(npath)
91
- build_plan(nbuild, npath, list, todo)
92
- todo << [nbuild, npath]
93
- else
94
- list << npath
95
- end
96
- end
97
-
98
- return list, todo
99
- end
100
-
101
- end
102
-
103
- # This class encapsulates the build procedure for creating
104
- # a file (or directory).
105
-
106
- class Build
107
-
108
- attr :match
109
- attr :needs
110
- attr :action
111
-
112
- alias_method :name, :match
113
-
114
- # Create a new build definition.
115
-
116
- def initialize(match, *needs, &action)
117
- @match = match
118
- @needs = needs
119
- @action = action
120
- end
121
-
122
- # Call this build process for the given path.
123
-
124
- def call(path)
125
- if needs.empty?
126
- dated = true
127
- elsif File.exist?(path)
128
- mtime = File.mtime(path)
129
- dated = needs.find do |file|
130
- !File.exist?(file) || File.mtime(file) > mtime
131
- end
132
- else
133
- dated = true
134
- end
135
- action.call(path) if dated
136
- end
137
-
138
- # Does a file match this build definition?
139
-
140
- def match?(path)
141
- case match
142
- when String
143
- File.fnmatch(match, path)
144
- when Regexp
145
- match =~ path
146
- else
147
- false # ???
148
- end
149
- end
150
-
151
- # Is this build needed to update/create path?
152
-
153
- def needed_for?(path)
154
- return true unless File.exist?(path)
155
- return true if needed_paths.empty? # TODO: if there are no prereqs then the file is always considered needed. Correct?
156
- mtimes = needed_paths.collect do |f|
157
- File.exist?(f) ? File.mtime(f) : Time.now
158
- end
159
- mtimes.max > File.mtime(path)
160
- end
161
-
162
- # Glob expanded needs.
163
-
164
- def needed_paths
165
- #exact = needs.select{|n| File.fnmatch?(n,n)} +
166
- exact = needs.select{|n| n !~ /[\[*?]/ }
167
- globs = needs.collect{|n| Dir.glob(n)}.flatten
168
- (exact + globs).uniq
169
- end
170
-
171
- end
172
-
173
- end
174
- end
@@ -1,108 +0,0 @@
1
- # = TITLE:
2
- #
3
- # Email 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
- begin
25
- require 'facets/net/smtp_tls'
26
- rescue LoadError
27
- require 'net/smtp'
28
- end
29
-
30
- module Ratch
31
- module Dsl
32
-
33
- module Email
34
-
35
- # Email function to easily send out an email.
36
- #
37
- # Settings:
38
- #
39
- # subject Subject of email message.
40
- # from Message FROM address [email].
41
- # to Email address to send announcemnt.
42
- # server Email server to route message.
43
- # port Email server's port.
44
- # domain Email server's domain name.
45
- # account Email account name if needed.
46
- # password Password for login..
47
- # login Login type: plain, cram_md5 or login [plain].
48
- # secure Uses TLS security, true or false? [false]
49
- # message Mesage to send -or-
50
- # file File that contains message.
51
-
52
- def email(message, settings)
53
- settings ||= {}
54
- settings.rekey
55
-
56
- server = settings[:server]
57
- account = settings[:account] || ENV['EMAIL_ACCOUNT']
58
- passwd = settings[:password] || ENV['EMAIL_PASSWORD']
59
- login = settings[:login].to_sym
60
- subject = settings[:subject]
61
- mail_to = settings[:to] || settings[:mail_to]
62
- mail_from = settings[:from] || settings[:mail_from]
63
- secure = settings[:secure]
64
- domain = settings[:domain] || server
65
-
66
- port ||= (secure ? 465 : 25)
67
- account ||= mail_from
68
- login ||= :plain
69
-
70
- #mail_to = nil if mail_to.empty?
71
-
72
- raise ArgumentError, "missing email field -- server" unless server
73
- raise ArgumentError, "missing email field -- account" unless account
74
- raise ArgumentError, "missing email field -- subject" unless subject
75
- raise ArgumentError, "missing email field -- to" unless mail_to
76
- raise ArgumentError, "missing email field -- from" unless mail_from
77
-
78
- passwd ||= password(account)
79
-
80
- mail_to = [mail_to].flatten.compact
81
-
82
- msg = ""
83
- msg << "From: #{mail_from}\n"
84
- msg << "To: #{mail_to.join(';')}\n"
85
- msg << "Subject: #{subject}\n"
86
- msg << ""
87
- msg << message
88
-
89
- begin
90
- Net::SMTP.enable_tls if Net::SMTP.respond_to?(:enable_tls) and secure
91
- Net::SMTP.start(server, port, domain, account, passwd, login) do |s|
92
- s.send_message( msg, mail_from, mail_to )
93
- end
94
- puts "Email sent successfully to #{mail_to.join(';')}."
95
- return true
96
- rescue => e
97
- if trace?
98
- raise e
99
- else
100
- abort "Email delivery failed."
101
- end
102
- end
103
- end
104
-
105
- end
106
-
107
- end
108
- end
@@ -1,205 +0,0 @@
1
- # = TITLE:
2
- #
3
- # File 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 'fileutils'
25
- require 'facets/dir/multiglob'
26
- require 'ratch/support/filetest'
27
-
28
-
29
- module Ratch
30
- module Dsl
31
-
32
- module Filing
33
-
34
- # Delegate access to FileUtils.
35
-
36
- def fileutils
37
- dryrun? ? ::FileUtils::DryRun : ::FileUtils
38
- end
39
-
40
- # Add FileUtils Features
41
-
42
- ::FileUtils.private_instance_methods(false).each do |meth|
43
- next if meth =~ /^fu_/
44
- module_eval %{
45
- def #{meth}(*a,&b)
46
- fileutils.#{meth}(*a,&b)
47
- end
48
- }
49
- end
50
-
51
- # Add FileTest Features
52
-
53
- ::FileTest.private_instance_methods(false).each do |meth|
54
- next if meth =~ /^fu_/
55
- module_eval %{
56
- def #{meth}(*a,&b)
57
- FileTest.#{meth}(*a,&b)
58
- end
59
- }
60
- end
61
-
62
- # Bonus FileUtils features.
63
-
64
- def cd(*a,&b)
65
- puts "cd #{a}" if dryrun? or trace?
66
- fileutils.chdir(*a,&b)
67
- end
68
-
69
- # Read file.
70
-
71
- def file_read(path)
72
- File.read(path)
73
- end
74
-
75
- # Write file.
76
-
77
- def file_write(path, text)
78
- if dryrun?
79
- puts "write #{path}"
80
- else
81
- File.open(path, 'w'){ |f| f << text }
82
- end
83
- end
84
-
85
- # Assert that a path exists.
86
-
87
- def exists?(path)
88
- paths = Dir.glob(path)
89
- paths.not_empty?
90
- end
91
- alias_method :exist?, :exists? ; module_function :exist?
92
- alias_method :path?, :exists? ; module_function :path?
93
-
94
- # Assert that a path exists.
95
-
96
- def exists!(*paths)
97
- abort "path not found #{path}" unless paths.any?{|path| exists?(path)}
98
- end
99
- alias_method :exist!, :exists! ; module_function :exist!
100
- alias_method :path!, :exists! ; module_function :path!
101
-
102
- # Is a given path a regular file? If +path+ is a glob
103
- # then checks to see if all matches are refular files.
104
-
105
- def file?(path)
106
- paths = Dir.glob(path)
107
- paths.not_empty? && paths.all?{ |f| FileTest.file?(f) }
108
- end
109
-
110
- # Assert that a given path is a file.
111
-
112
- def file!(*paths)
113
- abort "file not found #{path}" unless paths.any?{|path| file?(path)}
114
- end
115
-
116
- # Is a given path a directory? If +path+ is a glob
117
- # checks to see if all matches are directories.
118
-
119
- def dir?(path)
120
- paths = Dir.glob(path)
121
- paths.not_empty? && paths.all?{ |f| FileTest.directory?(f) }
122
- end
123
- alias_method :directory?, :dir? ; module_function :directory?
124
-
125
- # Assert that a given path is a directory.
126
-
127
- def dir!(*paths)
128
- paths.each do |path|
129
- abort "Directory not found: '#{path}'." unless dir?(path)
130
- end
131
- end
132
- alias_method :directory!, :dir! ; module_function :directory!
133
-
134
- # # Okay, I'm being a dork, but 'fold' seems like a better word
135
- # # then 'dir', 'folder', or 'directory'.
136
- #
137
- # def fold?(path)
138
- # paths = Dir.glob(path)
139
- # paths.not_empty? && paths.all?{ |f| FileTest.directory?(f) }
140
- # end
141
- #
142
- # # Assert that a given path is a fold (ie. a folder).
143
- #
144
- # def fold!(*paths)
145
- # abort "fold not found #{path}" unless paths.any?{|path| fold?(path)}
146
- # end
147
-
148
- # Glob files.
149
-
150
- def glob(*args, &blk)
151
- Dir.glob(*args, &blk)
152
- end
153
-
154
- def multiglob(*args, &blk)
155
- Dir.multiglob(*args, &blk)
156
- end
157
-
158
- def multiglob_r(*args, &blk)
159
- Dir.multiglob_r(*args, &blk)
160
- end
161
-
162
-
163
- # # Is a file a task?
164
- #
165
- # def task?(path)
166
- # task = File.dirname($0) + "/#{path}"
167
- # task.chomp!('!')
168
- # task if FileTest.file?(task) && FileTest.executable?(task)
169
- # end
170
-
171
- # # Is a file a command executable?
172
- # #
173
- # # TODO Probably needs to be fixed for Windows.
174
- #
175
- # def bin?(path)
176
- # is_bin = command_paths.any? do |f|
177
- # FileTest.exist?(File.join(f, path))
178
- # end
179
- # is_bin ? File.basename(path) : false
180
- # end
181
- #
182
- # # This is a support method of #bin?
183
- #
184
- # def command_paths
185
- # @command_paths ||= ENV['PATH'].split(/[:;]/)
186
- # end
187
- #
188
- # # TODO Make more robust.
189
- #
190
- # UNSAFE = [ '/', '/*', '/**/*' ]
191
- #
192
- # # Is a path considered reasonably "safe"?
193
- #
194
- # def safe?(path)
195
- # case path
196
- # when *UNSAFE
197
- # return false
198
- # end
199
- # true
200
- # end
201
-
202
- end
203
-
204
- end
205
- end