ratch 0.3.0 → 0.4.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.
- data/{log/history → CHANGES} +0 -0
- data/{log/todo → TODO} +0 -0
- data/bin/manifest +451 -0
- data/bin/ratch +3 -3
- data/demo/task/config.yaml +4 -0
- data/lib/ratch/{batch/argvutils.rb → dsl/argv.rb} +9 -4
- data/lib/ratch/dsl/batch.rb +226 -0
- data/lib/ratch/{batch → dsl}/build.rb +83 -4
- data/lib/ratch/{batch/consoleutils.rb → dsl/console.rb} +13 -5
- data/lib/ratch/{batch/emailutils.rb → dsl/email.rb} +21 -25
- data/lib/ratch/{batch/fileutils.rb → dsl/file.rb} +56 -56
- data/lib/ratch/dsl/meta.rb +132 -0
- data/lib/ratch/{batch → dsl}/options.rb +7 -5
- data/lib/ratch/dsl/setup.rb +124 -0
- data/lib/ratch/{support/signiture.rb → dsl/sign.rb} +9 -18
- data/lib/ratch/dsl/stage.rb +147 -0
- data/lib/ratch/dsl/task.rb +139 -0
- data/lib/ratch/{uploadutils.rb → dsl/upload.rb} +7 -5
- data/lib/ratch/{batch/task.rb → dsl/zip.rb} +30 -14
- data/lib/ratch/dsl.rb +52 -0
- data/lib/ratch/extra/email.rb +5 -0
- data/lib/ratch/extra/stage.rb +5 -0
- data/lib/ratch/extra/zip.rb +5 -0
- data/lib/ratch/manifest.rb +540 -0
- data/lib/ratch/{project → metadata}/information.rb +1 -0
- data/lib/ratch/{project → metadata}/package.rb +28 -2
- data/lib/ratch/{project → metadata}/project.rb +8 -16
- data/lib/ratch/{project → metadata}/release.rb +6 -6
- data/lib/ratch/support/errors.rb +4 -0
- data/lib/ratch/support/filename.rb +18 -0
- data/lib/ratch/toolset/ruby/compile +49 -0
- data/lib/ratch/toolset/ruby/pack/gem +26 -18
- data/lib/ratch/toolset/ruby/pack/tgz +25 -64
- data/lib/ratch/toolset/ruby/pack/zip +46 -0
- data/lib/ratch/toolset/ruby/publish +23 -24
- data/lib/ratch/toolset/ruby/release +8 -0
- data/lib/ratch/toolset/ruby/stamp +33 -0
- data/lib/ratch/toolset/sandbox +11 -0
- data/meta/MANIFEST +101 -23
- data/meta/ROLLRC +1 -1
- data/meta/config.yaml +10 -0
- data/meta/icli.yaml +2 -2
- data/meta/project.yaml +9 -10
- data/meta/xProjectInfo +41 -0
- data/task/release +1 -4
- metadata +82 -156
- data/demo/task/rdoc +0 -88
- data/demo/task/rdoc-old +0 -182
- data/doc/images/clipboard.jpg +0 -0
- data/doc/images/clipboard2.png +0 -0
- data/doc/images/milles-tn.jpg +0 -0
- data/doc/images/mints.png +0 -0
- data/doc/images/ratch2.png +0 -0
- data/doc/images/ruby-sm.png +0 -0
- data/doc/images/silver.gif +0 -0
- data/doc/images/toolbox.jpg +0 -0
- data/doc/index.html +0 -181
- data/doc/notes/original.rb +0 -308
- data/doc/rdoc/classes/Array.html +0 -194
- data/doc/rdoc/classes/Dir.html +0 -317
- data/doc/rdoc/classes/Hash.html +0 -217
- data/doc/rdoc/classes/Ratch/ArgvUtils/Ext.html +0 -285
- data/doc/rdoc/classes/Ratch/ArgvUtils.html +0 -173
- data/doc/rdoc/classes/Ratch/BatchFile.html +0 -207
- data/doc/rdoc/classes/Ratch/BatchManager.html +0 -250
- data/doc/rdoc/classes/Ratch/BatchScript.html +0 -127
- data/doc/rdoc/classes/Ratch/Batchable.html +0 -373
- data/doc/rdoc/classes/Ratch/Build.html +0 -321
- data/doc/rdoc/classes/Ratch/BuildManager.html +0 -319
- data/doc/rdoc/classes/Ratch/Buildable.html +0 -202
- data/doc/rdoc/classes/Ratch/ConfigUtils.html +0 -281
- data/doc/rdoc/classes/Ratch/ConsoleUtils.html +0 -189
- data/doc/rdoc/classes/Ratch/EmailUtils.html +0 -209
- data/doc/rdoc/classes/Ratch/FileUtils.html +0 -674
- data/doc/rdoc/classes/Ratch/GeneralOptions.html +0 -430
- data/doc/rdoc/classes/Ratch/Task.html +0 -201
- data/doc/rdoc/classes/Ratch/TaskManager.html +0 -330
- data/doc/rdoc/classes/Ratch/Taskable.html +0 -231
- data/doc/rdoc/classes/Ratch/UploadUtils.html +0 -566
- data/doc/rdoc/classes/Ratch.html +0 -201
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/COPYING.html +0 -1003
- data/doc/rdoc/files/README.html +0 -143
- data/doc/rdoc/files/lib/ratch/argvutils_rb.html +0 -131
- data/doc/rdoc/files/lib/ratch/batch_rb.html +0 -155
- data/doc/rdoc/files/lib/ratch/batchable_rb.html +0 -131
- data/doc/rdoc/files/lib/ratch/batchfile_rb.html +0 -148
- data/doc/rdoc/files/lib/ratch/buildable_rb.html +0 -131
- data/doc/rdoc/files/lib/ratch/consoleutils_rb.html +0 -131
- data/doc/rdoc/files/lib/ratch/emailutils_rb.html +0 -139
- data/doc/rdoc/files/lib/ratch/facets/multiglob_rb.html +0 -137
- data/doc/rdoc/files/lib/ratch/fileutils_rb.html +0 -139
- data/doc/rdoc/files/lib/ratch/options_rb.html +0 -131
- data/doc/rdoc/files/lib/ratch/taskable_rb.html +0 -131
- data/doc/rdoc/files/lib/ratch/uploadutils_rb.html +0 -150
- data/doc/rdoc/fr_class_index.html +0 -48
- data/doc/rdoc/fr_file_index.html +0 -41
- data/doc/rdoc/fr_method_index.html +0 -133
- data/doc/rdoc/index.html +0 -24
- data/doc/rdoc/rdoc-style.css +0 -208
- data/doc/scrap/flexihead-flip.jpg +0 -0
- data/doc/scrap/flexihead.jpg +0 -0
- data/doc/scrap/head1.jpg +0 -0
- data/doc/scrap/ratch.jpg +0 -0
- data/doc/scrap/ratch1.png +0 -0
- data/doc/scrap/ratch2.jpg +0 -0
- data/doc/scrap/ratch3.png +0 -0
- data/doc/scrap/red-ratch.jpg +0 -0
- data/doc/scrap/redratchet.jpg +0 -0
- data/doc/scrap/ruby-kit/ruby.png +0 -0
- data/doc/scrap/scrap.red +0 -256
- data/doc/sitemap.yaml +0 -10
- data/doc/siteparts/index.red +0 -100
- data/doc/siteparts/layout.rhtml +0 -56
- data/doc/siteparts/tutorial.red +0 -578
- data/doc/style.css +0 -112
- data/doc/tutorial.html +0 -722
- data/lib/ratch/batch.rb +0 -488
- data/lib/ratch/support/setuputils.rb +0 -124
- data/lib/ratch/support/stage.rb +0 -292
- data/lib/ratch/toolset/ruby/rdoc +0 -88
- data/task/rdoc +0 -6
- data/work/old/batchfile.rb +0 -95
- data/work/project-old.rb +0 -67
- data/work/scrap/install +0 -89
- data/work/scrap/install.0 +0 -49
- data/work/scrap/install.1 +0 -63
- data/work/scrap/ludo +0 -25
- data/work/scrap/oldtaskable.rb +0 -573
- data/work/scrap/ratch.man +0 -39
- data/work/scrap/taskable-simple.rb +0 -42
- data/work/scrap/taskable.rb +0 -120
@@ -0,0 +1,226 @@
|
|
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? Better definition?
|
66
|
+
|
67
|
+
def batch_directory
|
68
|
+
@batch_directory ||= (
|
69
|
+
dir = call_directory.sub(root_directory + '/', '').split('/').first
|
70
|
+
File.join(root_directory, dir)
|
71
|
+
)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Current batch file, relative to the batch directory.
|
75
|
+
|
76
|
+
def batch_file
|
77
|
+
File.expand_path($0).sub(batch_directory + '/', '')
|
78
|
+
end
|
79
|
+
|
80
|
+
# Run batch file and cache result.
|
81
|
+
#
|
82
|
+
# Usually this can be taken care of by method_missing.
|
83
|
+
# But, in some cases, built in method names block batch
|
84
|
+
# calls, so you have to use #batch to invoke those.
|
85
|
+
|
86
|
+
def batch(batchfile, arguments=nil)
|
87
|
+
batch_cache[batchfile] ||= batch!(batchfile, arguments)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Lauch a batch file. Like #batch but not-cached.
|
91
|
+
# Run a batch file.
|
92
|
+
# TODO: How to handle arguments?
|
93
|
+
|
94
|
+
def batch!(batchfile, arguments=nil)
|
95
|
+
#BatchFile.new(batchfile).call # Old way with batch execution context object.
|
96
|
+
|
97
|
+
@main = nil # reset main task
|
98
|
+
|
99
|
+
script = File.read($0 = batchfile)
|
100
|
+
eval(script, TOPLEVEL_BINDING, $0)
|
101
|
+
|
102
|
+
#batch_file = File.expand_path($0).sub(batch_directory + '/', '')
|
103
|
+
#run(batch_file)
|
104
|
+
run_main #(batch_file)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Is a path a local batch directory?
|
108
|
+
|
109
|
+
def batch_directory?(path)
|
110
|
+
b = File.join(File.dirname($0), path.to_s)
|
111
|
+
b if FileTest.directory?(b)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Is a file a local batch file?
|
115
|
+
|
116
|
+
def batch?(path)
|
117
|
+
b = File.join(File.dirname($0), path.to_s)
|
118
|
+
b if FileTest.file?(b) && FileTest.executable?(b)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Is a batch run complete or in the process of being completed?
|
122
|
+
# Has the batch file been executed before?
|
123
|
+
|
124
|
+
def done?(batchfile)
|
125
|
+
batchfile == $0 || batch_cache.key?(batchfile)
|
126
|
+
end
|
127
|
+
|
128
|
+
# Batch cache, which prevents batch runs from re-executing.
|
129
|
+
|
130
|
+
def batch_cache
|
131
|
+
@batch_cache ||= {}
|
132
|
+
end
|
133
|
+
|
134
|
+
# If method is missing try to run an external task
|
135
|
+
# or binary by that name. If it is a binary, arguments
|
136
|
+
# translate into commandline parameters. For example:
|
137
|
+
#
|
138
|
+
# tar 'foo/', :x=>true, :v=>true, :z=>true, :f=>'foo.tar.gz'
|
139
|
+
#
|
140
|
+
# or
|
141
|
+
#
|
142
|
+
# tar '-xvzf', "foo.tar.gz", "foo/"
|
143
|
+
#
|
144
|
+
# becomes
|
145
|
+
#
|
146
|
+
# tar -x -v -z -f foo.tar.gz foo/
|
147
|
+
#
|
148
|
+
# If it is a task, it will be cached. Tasks only ever run once.
|
149
|
+
# To run them more than once you can manually execute them with #run.
|
150
|
+
# Likewise you can manually run and cache by calling #batch.
|
151
|
+
# This is good to know, b/c in some cases built in method names
|
152
|
+
# block task calls, so you have to #batch to invoke them.
|
153
|
+
|
154
|
+
def method_missing(sym,*args)
|
155
|
+
puts "method_missing: #{sym}" if debug?
|
156
|
+
#begin
|
157
|
+
launch(sym,*args)
|
158
|
+
#rescue ArgumentError
|
159
|
+
# super
|
160
|
+
#end
|
161
|
+
end
|
162
|
+
|
163
|
+
# TODO Better name!!! Better code.
|
164
|
+
|
165
|
+
def launch(name, *args)
|
166
|
+
name = name.to_s
|
167
|
+
force = name.chomp!('!')
|
168
|
+
|
169
|
+
# is this a batch directory?
|
170
|
+
if batch_directory?(name)
|
171
|
+
return Batch::Space.new(self, name)
|
172
|
+
end
|
173
|
+
|
174
|
+
params = args.to_params
|
175
|
+
|
176
|
+
# is this a batch file?
|
177
|
+
if bat = batch?(name)
|
178
|
+
if force
|
179
|
+
cmd = "./#{bat} #{params}"
|
180
|
+
puts "--> non-cached execution: #{cmd}" if trace?
|
181
|
+
return batch!(bat, args)
|
182
|
+
else
|
183
|
+
if done?(bat)
|
184
|
+
return nil unless bin?(name) # return cache?
|
185
|
+
else
|
186
|
+
cmd = "./#{bat} #{params}"
|
187
|
+
puts "--> cached execution: #{cmd}" if trace?
|
188
|
+
return batch(bat, args)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
# is this a bin file?
|
194
|
+
if bin = bin?(name)
|
195
|
+
cmd = "#{File.basename(bin)} #{params}"
|
196
|
+
return sh(cmd)
|
197
|
+
end
|
198
|
+
|
199
|
+
raise ArgumentError, "script not found -- #{name}"
|
200
|
+
end
|
201
|
+
|
202
|
+
end
|
203
|
+
|
204
|
+
# This is a type of functor, that allows for calling batch files
|
205
|
+
# that are in subdirectories using "dir.file" notation. Eg.
|
206
|
+
#
|
207
|
+
# svn.log
|
208
|
+
#
|
209
|
+
# could run the svn/log ratch file.
|
210
|
+
|
211
|
+
class Batch::Space
|
212
|
+
private *instance_methods.select{ |m| m !~ /^__/ }
|
213
|
+
|
214
|
+
def initialize(manager, directory)
|
215
|
+
@manager = manager
|
216
|
+
@directory = directory
|
217
|
+
end
|
218
|
+
|
219
|
+
def method_missing(sym, *args)
|
220
|
+
path = File.join(@directory, sym.to_s)
|
221
|
+
@manager.launch(path, *args)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|
226
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
# TITLE:
|
1
|
+
# = TITLE:
|
2
2
|
#
|
3
|
-
# Build
|
3
|
+
# Build DSL
|
4
4
|
#
|
5
|
-
# COPYING:
|
5
|
+
# = COPYING:
|
6
6
|
#
|
7
7
|
# Copyright (c) 2007 Psi T Corp.
|
8
8
|
#
|
@@ -22,8 +22,86 @@
|
|
22
22
|
# along with Ratch. If not, see <http://www.gnu.org/licenses/>.
|
23
23
|
|
24
24
|
module Ratch
|
25
|
+
module Dsl
|
25
26
|
|
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::File.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).
|
27
105
|
|
28
106
|
class Build
|
29
107
|
|
@@ -93,3 +171,4 @@ module Ratch
|
|
93
171
|
end
|
94
172
|
|
95
173
|
end
|
174
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
# TITLE:
|
1
|
+
# = TITLE:
|
2
2
|
#
|
3
|
-
#
|
3
|
+
# Console
|
4
4
|
#
|
5
|
-
# COPYING:
|
5
|
+
# = COPYING:
|
6
6
|
#
|
7
7
|
# Copyright (c) 2007 Psi T Corp.
|
8
8
|
#
|
@@ -22,8 +22,9 @@
|
|
22
22
|
# along with Ratch. If not, see <http://www.gnu.org/licenses/>.
|
23
23
|
|
24
24
|
module Ratch
|
25
|
+
module Dsl
|
25
26
|
|
26
|
-
module
|
27
|
+
module Console
|
27
28
|
|
28
29
|
# Convenient method to get simple console reply.
|
29
30
|
|
@@ -55,10 +56,17 @@ module Ratch
|
|
55
56
|
return inp.chomp
|
56
57
|
end
|
57
58
|
|
59
|
+
# Internal status report.
|
60
|
+
# Only output if dryrun or trace mode.
|
61
|
+
|
62
|
+
def status(message)
|
63
|
+
puts message if dryrun? or trace?
|
64
|
+
end
|
65
|
+
|
58
66
|
end
|
59
67
|
|
60
68
|
end
|
61
|
-
|
69
|
+
end
|
62
70
|
|
63
71
|
class Array
|
64
72
|
|
@@ -1,9 +1,8 @@
|
|
1
|
-
|
2
|
-
# TITLE:
|
1
|
+
# = TITLE:
|
3
2
|
#
|
4
|
-
#
|
3
|
+
# Email DSL
|
5
4
|
#
|
6
|
-
# COPYING:
|
5
|
+
# = COPYING:
|
7
6
|
#
|
8
7
|
# Copyright (c) 2007 Psi T Corp.
|
9
8
|
#
|
@@ -28,12 +27,10 @@ rescue LoadError
|
|
28
27
|
require 'net/smtp'
|
29
28
|
end
|
30
29
|
|
31
|
-
|
32
30
|
module Ratch
|
31
|
+
module Dsl
|
33
32
|
|
34
|
-
module
|
35
|
-
|
36
|
-
module_function
|
33
|
+
module Email
|
37
34
|
|
38
35
|
# Email function to easily send out an email.
|
39
36
|
#
|
@@ -45,24 +42,26 @@ module Ratch
|
|
45
42
|
# server Email server to route message.
|
46
43
|
# port Email server's port.
|
47
44
|
# domain Email server's domain name.
|
48
|
-
# account Email account name.
|
45
|
+
# account Email account name if needed.
|
46
|
+
# password Password for login..
|
49
47
|
# login Login type: plain, cram_md5 or login [plain].
|
50
48
|
# secure Uses TLS security, true or false? [false]
|
51
49
|
# message Mesage to send -or-
|
52
50
|
# file File that contains message.
|
53
|
-
#
|
54
|
-
# (Square brackets indicate defaults taken from Project information.
|
55
|
-
# if used via Project class.)
|
56
51
|
|
57
52
|
def email(message, settings)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
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
|
66
65
|
|
67
66
|
port ||= (secure ? 465 : 25)
|
68
67
|
account ||= mail_from
|
@@ -76,7 +75,7 @@ module Ratch
|
|
76
75
|
raise ArgumentError, "missing email field -- to" unless mail_to
|
77
76
|
raise ArgumentError, "missing email field -- from" unless mail_from
|
78
77
|
|
79
|
-
passwd
|
78
|
+
passwd ||= password(account)
|
80
79
|
|
81
80
|
mail_to = [mail_to].flatten.compact
|
82
81
|
|
@@ -103,10 +102,7 @@ module Ratch
|
|
103
102
|
end
|
104
103
|
end
|
105
104
|
|
106
|
-
#def password( account )
|
107
|
-
# @password || ENV['PASSWORD'] || ask("Password for #{account}: ")
|
108
|
-
#end
|
109
|
-
|
110
105
|
end
|
111
106
|
|
112
107
|
end
|
108
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
# TITLE:
|
1
|
+
# = TITLE:
|
2
2
|
#
|
3
|
-
#
|
3
|
+
# File DSL
|
4
4
|
#
|
5
|
-
# COPYING:
|
5
|
+
# = COPYING:
|
6
6
|
#
|
7
7
|
# Copyright (c) 2007 Psi T Corp.
|
8
8
|
#
|
@@ -25,22 +25,45 @@ require 'fileutils'
|
|
25
25
|
require 'facets/dir/multiglob'
|
26
26
|
require 'ratch/support/filetest'
|
27
27
|
|
28
|
+
|
28
29
|
module Ratch
|
30
|
+
module Dsl
|
29
31
|
|
30
|
-
module
|
32
|
+
module Filing
|
31
33
|
|
32
|
-
#
|
34
|
+
# Delegate access to FileUtils.
|
33
35
|
|
34
|
-
def
|
35
|
-
|
36
|
+
def fileutils
|
37
|
+
dryrun? ? ::FileUtils::DryRun : ::FileUtils
|
36
38
|
end
|
37
39
|
|
38
|
-
|
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
|
+
}
|
40
49
|
end
|
41
50
|
|
42
|
-
|
43
|
-
|
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)
|
44
67
|
end
|
45
68
|
|
46
69
|
# Read file.
|
@@ -59,45 +82,22 @@ module Ratch
|
|
59
82
|
end
|
60
83
|
end
|
61
84
|
|
62
|
-
|
63
|
-
# Add FileUtils Features #
|
64
|
-
##########################
|
65
|
-
|
66
|
-
::FileUtils.private_instance_methods(false).each do |meth|
|
67
|
-
next if meth =~ /^fu_/
|
68
|
-
module_eval %{
|
69
|
-
def #{meth}(*a,&b)
|
70
|
-
fileutils.#{meth}(*a,&b)
|
71
|
-
end
|
72
|
-
}
|
73
|
-
end
|
74
|
-
|
75
|
-
# Delegate access to FileUtils.
|
76
|
-
|
77
|
-
def fileutils
|
78
|
-
dryrun? ? ::FileUtils::DryRun : ::FileUtils
|
79
|
-
end
|
80
|
-
|
81
|
-
# Bonus FileUtils features.
|
85
|
+
# Assert that a path exists.
|
82
86
|
|
83
|
-
def
|
84
|
-
|
85
|
-
|
87
|
+
def exists?(path)
|
88
|
+
paths = Dir.glob(path)
|
89
|
+
paths.not_empty?
|
86
90
|
end
|
91
|
+
alias_method :exist?, :exists? ; module_function :exist?
|
92
|
+
alias_method :path?, :exists? ; module_function :path?
|
87
93
|
|
94
|
+
# Assert that a path exists.
|
88
95
|
|
89
|
-
|
90
|
-
|
91
|
-
#########################
|
92
|
-
|
93
|
-
FileTest.private_instance_methods(false).each do |meth|
|
94
|
-
next if meth =~ /^fu_/
|
95
|
-
module_eval %{
|
96
|
-
def #{meth}(*a,&b)
|
97
|
-
FileTest.#{meth}(*a,&b)
|
98
|
-
end
|
99
|
-
}
|
96
|
+
def exists!(*paths)
|
97
|
+
abort "path not found #{path}" unless paths.any?{|path| exists?(path)}
|
100
98
|
end
|
99
|
+
alias_method :exist!, :exists! ; module_function :exist!
|
100
|
+
alias_method :path!, :exists! ; module_function :path!
|
101
101
|
|
102
102
|
# Is a given path a regular file? If +path+ is a glob
|
103
103
|
# then checks to see if all matches are refular files.
|
@@ -145,22 +145,20 @@ module Ratch
|
|
145
145
|
# abort "fold not found #{path}" unless paths.any?{|path| fold?(path)}
|
146
146
|
# end
|
147
147
|
|
148
|
-
#
|
148
|
+
# Glob files.
|
149
149
|
|
150
|
-
def
|
151
|
-
|
152
|
-
paths.not_empty?
|
150
|
+
def glob(*args, &blk)
|
151
|
+
Dir.glob(*args, &blk)
|
153
152
|
end
|
154
|
-
alias_method :exist?, :exists? ; module_function :exist?
|
155
|
-
alias_method :path?, :exists? ; module_function :path?
|
156
153
|
|
157
|
-
|
154
|
+
def multiglob(*args, &blk)
|
155
|
+
Dir.multiglob(*args, &blk)
|
156
|
+
end
|
158
157
|
|
159
|
-
def
|
160
|
-
|
158
|
+
def multiglob_r(*args, &blk)
|
159
|
+
Dir.multiglob_r(*args, &blk)
|
161
160
|
end
|
162
|
-
|
163
|
-
alias_method :path!, :exists! ; module_function :path!
|
161
|
+
|
164
162
|
|
165
163
|
# # Is a file a task?
|
166
164
|
#
|
@@ -202,4 +200,6 @@ module Ratch
|
|
202
200
|
# end
|
203
201
|
|
204
202
|
end
|
203
|
+
|
204
|
+
end
|
205
205
|
end
|