ratch 1.1.0 → 1.2.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 (86) hide show
  1. data/.ruby +99 -0
  2. data/COPYING +203 -21
  3. data/History.rdoc +35 -0
  4. data/License.txt +204 -0
  5. data/README.rdoc +113 -0
  6. data/Version +1 -0
  7. data/bin/ludo +16 -0
  8. data/bin/ratch +1 -8
  9. data/lib/ratch.rb +28 -0
  10. data/lib/ratch.yml +99 -0
  11. data/lib/ratch/batch.rb +500 -0
  12. data/lib/ratch/console.rb +199 -0
  13. data/lib/ratch/core_ext.rb +1 -4
  14. data/lib/ratch/core_ext/facets.rb +15 -1
  15. data/lib/ratch/core_ext/filetest.rb +29 -0
  16. data/lib/ratch/core_ext/{string.rb → to_actual_filename.rb} +0 -23
  17. data/lib/ratch/core_ext/to_console.rb +30 -12
  18. data/lib/ratch/core_ext/{object.rb → to_yamlfrag.rb} +1 -0
  19. data/lib/ratch/core_ext/unfold_paragraphs.rb +27 -0
  20. data/lib/ratch/file_list.rb +411 -0
  21. data/lib/ratch/script.rb +99 -5
  22. data/lib/ratch/script/help.rb +84 -0
  23. data/lib/ratch/shell.rb +783 -0
  24. data/lib/ratch/system.rb +15 -0
  25. data/lib/ratch/utils/cli.rb +49 -0
  26. data/lib/ratch/utils/config.rb +52 -0
  27. data/lib/ratch/{emailer.rb → utils/email.rb} +43 -6
  28. data/lib/ratch/utils/ftp.rb +134 -0
  29. data/lib/ratch/utils/pom.rb +22 -0
  30. data/lib/ratch/utils/rdoc.rb +48 -0
  31. data/lib/ratch/utils/tar.rb +88 -0
  32. data/lib/ratch/utils/xdg.rb +39 -0
  33. data/lib/ratch/utils/zlib.rb +54 -0
  34. data/spec/01_shell.rdoc +198 -0
  35. data/spec/02_script.rdoc +34 -0
  36. data/spec/03_batch.rdoc +71 -0
  37. data/spec/04_system.rdoc +3 -0
  38. data/spec/applique/array.rb +8 -0
  39. data/spec/applique/setup.rb +20 -0
  40. data/test/case_batch.rb +63 -0
  41. data/test/case_shell.rb +46 -0
  42. data/test/core_ext/case_pathname.rb +361 -0
  43. data/test/helper.rb +4 -0
  44. data/test/utils/case_cli.rb +6 -0
  45. data/test/utils/case_config.rb +12 -0
  46. data/test/utils/case_email.rb +10 -0
  47. data/test/utils/case_ftp.rb +6 -0
  48. data/test/utils/case_pom.rb +17 -0
  49. data/test/utils/case_rdoc.rb +23 -0
  50. data/test/utils/case_tar.rb +6 -0
  51. data/test/utils/case_zlib.rb +11 -0
  52. data/test/utils/fixtures/pom_sample/Profile +4 -0
  53. data/test/utils/fixtures/rdoc_sample/README.rdoc +4 -0
  54. data/test/utils/fixtures/rdoc_sample/lib/rdoc_sample/rdoc_sample.rb +9 -0
  55. metadata +139 -82
  56. data/HISTORY +0 -6
  57. data/MANIFEST +0 -53
  58. data/NEWS +0 -12
  59. data/README +0 -87
  60. data/VERSION +0 -1
  61. data/demo/tryme-task.ratch +0 -12
  62. data/demo/tryme1.ratch +0 -6
  63. data/doc/log/basic_stats/index.html +0 -39
  64. data/doc/log/notes.xml +0 -18
  65. data/doc/log/stats.log +0 -14
  66. data/doc/log/syntax.log +0 -0
  67. data/doc/log/testunit.log +0 -156
  68. data/lib/ratch/commandline.rb +0 -16
  69. data/lib/ratch/core_ext/pathname.rb +0 -38
  70. data/lib/ratch/dsl.rb +0 -420
  71. data/lib/ratch/index.rb +0 -4
  72. data/lib/ratch/io.rb +0 -116
  73. data/lib/ratch/plugin.rb +0 -65
  74. data/lib/ratch/service.rb +0 -33
  75. data/lib/ratch/task.rb +0 -249
  76. data/lib/ratch/task2.rb +0 -298
  77. data/meta/abstract +0 -4
  78. data/meta/author +0 -1
  79. data/meta/contact +0 -1
  80. data/meta/homepage +0 -1
  81. data/meta/name +0 -1
  82. data/meta/requires +0 -4
  83. data/meta/summary +0 -1
  84. data/test/README +0 -1
  85. data/test/test_helper.rb +0 -4
  86. data/test/test_task.rb +0 -46
data/VERSION DELETED
@@ -1 +0,0 @@
1
- ratch 1.1.0 stable (2008-11-22)
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ratch
2
-
3
- task :hello do
4
- puts "Hello"
5
- end
6
-
7
- task :world => [:hello] do
8
- puts "World"
9
- end
10
-
11
- run :world
12
-
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ratch
2
-
3
- puts "Hello World"
4
-
5
- p commandline
6
-
@@ -1,39 +0,0 @@
1
-
2
- <html>
3
- <head>
4
- <title>Ratch Code Statistics</title>
5
- <style>
6
- h2{margin: 5px 0;}
7
- table{width: 95%;}
8
- th{background: #dcc;}
9
- td{padding: 5px;}
10
- .basic_stats{margin: 0 auto; width: 800px;}
11
- </style>
12
- <link rel="stylesheet" type="text/css" href="stats.css"/>
13
- </head>
14
- <body>
15
- <div class="basic_stats">
16
- <h1>Ratch -- Basic Code Statistics</h1>
17
- <table class="counts" border="1">
18
- <tr><th colspan="9"><h2>Counts</h2></th></tr>
19
- <tr><th>TYPE</th><th>Total</th><th>Code</th><th>-%-</th><th>Docs</th><th>-%-</th><th>Blank</th><th>-%-</th><th>Files</th></tr>
20
- <tr><th>Source</th><td>1669</td><td>731</td><td>43%</td><td>635</td><td>38%</td><td>303</td><td>18%</td><td>17</td></tr>
21
- <tr><th>Test</th><td>50</td><td>30</td><td>1%</td><td>3</td><td>0%</td><td>17</td><td>1%</td><td>2</td></tr>
22
- <tr><th>Total</th><td>1719</td><td>761</td><td>44%</td><td>638</td><td>37%</td><td>320</td><td>18%</td><td>19</td></tr>
23
- </table>
24
- <br/>
25
- <table class="ratios" border="1">
26
- <tr><th colspan="6"><h2>Ratios</h2></th></tr>
27
- <tr><th>x:1</th><th>Code</th><th>Docs</th><th>Blank</th><th>Test</th><th>Total</th></tr>
28
- <tr><th>Code</th><td> 1.0</td><td> 1.2</td><td> 2.4</td><td> 14.6</td><td> 0.4</td></tr>
29
- <tr><th>Docs</th><td> 0.9</td><td> 1.0</td><td> 2.1</td><td> 12.7</td><td> 0.4</td></tr>
30
- <tr><th>Blank</th><td> 0.4</td><td> 0.5</td><td> 1.0</td><td> 6.1</td><td> 0.2</td></tr>
31
- <tr><th>Test</th><td> 0.1</td><td> 0.1</td><td> 0.2</td><td> 1.0</td><td> 0.0</td></tr>
32
- <tr><th>Total</th><td> 2.3</td><td> 2.6</td><td> 5.5</td><td> 33.4</td><td> 1.0</td></tr>
33
- </table>
34
- <br/>
35
- <div class="date">Sun Nov 23 14:09:41 -0500 2008</div>
36
- </div>
37
- </body>
38
- </html>
39
-
@@ -1,18 +0,0 @@
1
- <notes>
2
- <set label="FIXME">
3
- <file src="lib/ratch/emailer.rb">
4
- <note line="154" type="FIXME">FIXME: Does not hide password.</note>
5
- </file>
6
- </set>
7
- <set label="TODO">
8
- <file src="lib/ratch/dsl.rb">
9
- <note line="97" type="TODO">TODO: DEPRECATE #sh in favor of #shell (?)</note>
10
- <note line="115" type="TODO">TODO: Replace these with Folio when Folio&apos;s is as capable.</note>
11
- <note line="178" type="TODO">TODO: Deprecate these?</note>
12
- <note line="406" type="TODO">TODO: Put this in FileTest instead?</note>
13
- </file>
14
- <file src="lib/ratch/plugin.rb">
15
- <note line="57" type="TODO">TODO: Allow this to be optional? How?</note>
16
- </file>
17
- </set>
18
- </notes>
@@ -1,14 +0,0 @@
1
- Ratch Statistics
2
- Mon Aug 18 15:10:07 -0400 2008
3
-
4
- TYPE Total Code -%- Docs -%- Blank -%- Files
5
- Source 1703 820 48% 572 33% 311 18% 18
6
- Test 50 30 1% 3 0% 17 0% 2
7
- Total 1753 850 48% 575 32% 328 18% 20
8
-
9
- RATIO Code Docs Blank Test Total
10
- Code 1.0 1.4 2.6 16.4 -
11
- Docs - 1.0 1.8 11.4 -
12
- Blank - - 1.0 6.2 -
13
- Test - - - 1.0 -
14
- Total 2.1 3.0 5.5 34.1 1.0
File without changes
@@ -1,156 +0,0 @@
1
- Loaded suite [test/test_helper.rb, test/test_task.rb]
2
- Started
3
- ..
4
- Finished in 0.001091 seconds.
5
-
6
- 2 tests, 2 assertions, 0 failures, 0 errors
7
- Loaded suite [test/test_helper.rb, test/test_task.rb]
8
- Started
9
- ..
10
- Finished in 0.000625 seconds.
11
-
12
- 2 tests, 2 assertions, 0 failures, 0 errors
13
- Loaded suite [test/test_helper.rb, test/test_task.rb]
14
- Started
15
- ..
16
- Finished in 0.001007 seconds.
17
-
18
- 2 tests, 2 assertions, 0 failures, 0 errors
19
- Loaded suite [test/test_helper.rb, test/test_task.rb]
20
- Started
21
- ..
22
- Finished in 0.000613 seconds.
23
-
24
- 2 tests, 2 assertions, 0 failures, 0 errors
25
- Loaded suite [test/test_helper.rb, test/test_task.rb]
26
- Started
27
- ..
28
- Finished in 0.000791 seconds.
29
-
30
- 2 tests, 2 assertions, 0 failures, 0 errors
31
- Loaded suite [test/test_helper.rb, test/test_task.rb]
32
- Started
33
- ..
34
- Finished in 0.000624 seconds.
35
-
36
- 2 tests, 2 assertions, 0 failures, 0 errors
37
- Loaded suite [test/test_helper.rb, test/test_task.rb]
38
- Started
39
- ..
40
- Finished in 0.000694 seconds.
41
-
42
- 2 tests, 2 assertions, 0 failures, 0 errors
43
- Loaded suite [test/test_helper.rb, test/test_task.rb]
44
- Started
45
- ..
46
- Finished in 0.00107 seconds.
47
-
48
- 2 tests, 2 assertions, 0 failures, 0 errors
49
- Loaded suite [test/test_helper.rb, test/test_task.rb]
50
- Started
51
- ..
52
- Finished in 0.00084 seconds.
53
-
54
- 2 tests, 2 assertions, 0 failures, 0 errors
55
- Loaded suite [test/test_helper.rb, test/test_task.rb]
56
- Started
57
- ..
58
- Finished in 0.000842 seconds.
59
-
60
- 2 tests, 2 assertions, 0 failures, 0 errors
61
- Loaded suite [test/test_helper.rb, test/test_task.rb]
62
- Started
63
- ..
64
- Finished in 0.000838 seconds.
65
-
66
- 2 tests, 2 assertions, 0 failures, 0 errors
67
- Loaded suite [test/test_helper.rb, test/test_task.rb]
68
- Started
69
- ..
70
- Finished in 0.000672 seconds.
71
-
72
- 2 tests, 2 assertions, 0 failures, 0 errors
73
- Loaded suite [test/test_helper.rb, test/test_task.rb]
74
- Started
75
- ..
76
- Finished in 0.000864 seconds.
77
-
78
- 2 tests, 2 assertions, 0 failures, 0 errors
79
- Loaded suite [test/test_helper.rb, test/test_task.rb]
80
- Started
81
- ..
82
- Finished in 0.001295 seconds.
83
-
84
- 2 tests, 2 assertions, 0 failures, 0 errors
85
- Loaded suite [test/test_helper.rb, test/test_task.rb]
86
- Started
87
- ..
88
- Finished in 0.000868 seconds.
89
-
90
- 2 tests, 2 assertions, 0 failures, 0 errors
91
- Loaded suite [test/test_helper.rb, test/test_task.rb]
92
- Started
93
- ..
94
- Finished in 0.000871 seconds.
95
-
96
- 2 tests, 2 assertions, 0 failures, 0 errors
97
- Loaded suite [test/test_helper.rb, test/test_task.rb]
98
- Started
99
- ..
100
- Finished in 0.000838 seconds.
101
-
102
- 2 tests, 2 assertions, 0 failures, 0 errors
103
- Loaded suite [test/test_helper.rb, test/test_task.rb]
104
- Started
105
- ..
106
- Finished in 0.000866 seconds.
107
-
108
- 2 tests, 2 assertions, 0 failures, 0 errors
109
- Loaded suite [test/test_helper.rb, test/test_task.rb]
110
- Started
111
- ..
112
- Finished in 0.001105 seconds.
113
-
114
- 2 tests, 2 assertions, 0 failures, 0 errors
115
- Loaded suite [test/test_helper.rb, test/test_task.rb]
116
- Started
117
- ..
118
- Finished in 0.00067 seconds.
119
-
120
- 2 tests, 2 assertions, 0 failures, 0 errors
121
- Loaded suite [test/test_helper.rb, test/test_task.rb]
122
- Started
123
- ..
124
- Finished in 0.000891 seconds.
125
-
126
- 2 tests, 2 assertions, 0 failures, 0 errors
127
- Loaded suite [test/test_helper.rb, test/test_task.rb]
128
- Started
129
- ..
130
- Finished in 0.000872 seconds.
131
-
132
- 2 tests, 2 assertions, 0 failures, 0 errors
133
- Loaded suite [test/test_helper.rb, test/test_task.rb]
134
- Started
135
- ..
136
- Finished in 0.000836 seconds.
137
-
138
- 2 tests, 2 assertions, 0 failures, 0 errors
139
- Loaded suite [test/test_helper.rb, test/test_task.rb]
140
- Started
141
- ..
142
- Finished in 0.000735 seconds.
143
-
144
- 2 tests, 2 assertions, 0 failures, 0 errors
145
- Loaded suite [test/test_helper.rb, test/test_task.rb]
146
- Started
147
- ..
148
- Finished in 0.000644 seconds.
149
-
150
- 2 tests, 2 assertions, 0 failures, 0 errors
151
- Loaded suite [test/test_helper.rb, test/test_task.rb]
152
- Started
153
- ..
154
- Finished in 0.000666 seconds.
155
-
156
- 2 tests, 2 assertions, 0 failures, 0 errors
@@ -1,16 +0,0 @@
1
- require 'clio/commandline'
2
-
3
- module Ratch
4
-
5
- class Commandline < Clio::Commandline
6
- opt('--help' , "display help")
7
- opt('--trace' , "trace execution")
8
- opt('--debug' , "debug mode")
9
- opt('--pretend -p' , "no disk writes")
10
- opt('--quiet -q' , "run silently")
11
- opt('--verbose' , "extra output")
12
- opt('--force' , "force operations")
13
- end
14
-
15
- end
16
-
@@ -1,38 +0,0 @@
1
- require 'facets/pathname'
2
-
3
- class Pathname
4
-
5
- # Like directory? but return self if true, otherwise nil.
6
- def dir?
7
- directory? ? self : nil
8
- end
9
-
10
- # Already in Facets
11
- #
12
- # def glob(*opts)
13
- # flags = 0
14
- # opts.each do |opt|
15
- # case opt when Symbol, String
16
- # flags += File.const_get("FNM_#{opt}".upcase)
17
- # else
18
- # flags += opt
19
- # end
20
- # end
21
- # self.class.glob(self.to_s, flags).collect{ |path| self.class.new(path) }
22
- # end
23
- #
24
- # #
25
- # def first(*opts)
26
- # flags = 0
27
- # opts.each do |opt|
28
- # case opt when Symbol, String
29
- # flags += File.const_get("FNM_#{opt}".upcase)
30
- # else
31
- # flags += opt
32
- # end
33
- # end
34
- # file = self.class.glob(self.to_s, flags).first
35
- # file ? self.class.new(file) : nil
36
- # end
37
-
38
- end
@@ -1,420 +0,0 @@
1
- require 'yaml'
2
- require 'rbconfig' # replace with facets/rbsystem?
3
- require 'fileutils'
4
-
5
- require 'ratch/core_ext'
6
- require 'ratch/index'
7
- require 'ratch/io'
8
- require 'ratch/commandline'
9
- require 'ratch/emailer'
10
-
11
- require 'ratch/task'
12
-
13
- require 'facets/platform'
14
-
15
- require 'folio'
16
-
17
- #require 'facets/openhash'
18
- #require 'facets/argvector'
19
-
20
-
21
- module Ratch
22
-
23
- # = Ratch DSL
24
- #
25
- # The DSL class is the heart of Ratch, it provides all the convenece methods
26
- # that make Ratch so convenient for writing Ruby-based batch script.
27
- #
28
- class DSL < Module
29
-
30
- #
31
- def initialize(ioc={})
32
- include Taskable
33
- include Taskable::Dsl
34
-
35
- extend self
36
-
37
- @cli = ioc[:cli] || Commandline.new
38
- @io = ioc[:io] || IO.new(@cli)
39
-
40
- mode = {
41
- :dryrun => @cli.dryrun?,
42
- :verbose => @cli.verbose?
43
- #:noop => ?
44
- }
45
-
46
- @fio = ioc[:fio] || Folio::Shell.new(mode)
47
- end
48
-
49
- # Delagate input/output routines to Ratch::IO object.
50
- attr :io
51
-
52
- # Delagate file operations to Folio::Shell.
53
- attr :fio
54
-
55
- # Delagate commandline settings to Ratch::Commandline object.
56
- attr :cli
57
-
58
- alias_method :commandline, :cli
59
-
60
- # DEPRECATE!
61
- alias_method :command, :cli
62
-
63
- #
64
- #def commandline
65
- # #@commandline ||= ArgVector.new(ARGV)
66
- # @commandline
67
- #end
68
-
69
- def force? ; cli.force? ; end
70
- def trace? ; cli.trace? ; end
71
- def debug? ; cli.debug? ; end
72
- def pretend? ; cli.pretend? ; end
73
- def dryrun? ; cli.pretend? ; end
74
- def quiet? ; cli.quiet? ; end
75
- def verbose? ; cli.verbose? ; end
76
-
77
- # Current platform.
78
- def current_platform
79
- Platform.local.to_s
80
- end
81
-
82
- # Shell runner.
83
- def shell(cmd)
84
- if dryrun?
85
- puts cmd
86
- true
87
- else
88
- puts "--> system call: #{cmd}" if trace?
89
- if quiet?
90
- silently{ system(cmd) }
91
- else
92
- system(cmd)
93
- end
94
- end
95
- end
96
-
97
- # TODO: DEPRECATE #sh in favor of #shell (?)
98
- alias_method :sh, :shell
99
-
100
- # Delegate to Filio::Shell.
101
- def method_missing(s, *a, &b)
102
- if @fio.respond_to?(s)
103
- @fio.__send__(s, *a, &b)
104
- else
105
- super
106
- end
107
- end
108
-
109
- # Provides convenient starting points in the file system.
110
- #
111
- # root #=> #<Pathname:/>
112
- # home #=> #<Pathname:/home/jimmy>
113
- # work #=> #<Pathname:/home/jimmy/Documents>
114
- #
115
- # TODO: Replace these with Folio when Folio's is as capable.
116
-
117
- # Current root path.
118
- def root(*args)
119
- Pathname['/', *args]
120
- end
121
-
122
- # Current home path.
123
- def home(*args)
124
- Pathname['~', *args].expand_path
125
- end
126
-
127
- # Current working path.
128
- def work(*args)
129
- Pathname['.', *args]
130
- end
131
-
132
- alias_method :pwd, :work
133
-
134
- # Bonus FileUtils features.
135
- #def cd(*a,&b)
136
- # puts "cd #{a}" if dryrun? or trace?
137
- # fileutils.chdir(*a,&b)
138
- #end
139
-
140
- # Read file.
141
- def file_read(path)
142
- File.read(path)
143
- end
144
-
145
- # Write file.
146
- def file_write(path, text)
147
- if dryrun?
148
- puts "write #{path}"
149
- else
150
- File.open(path, 'w'){ |f| f << text }
151
- end
152
- end
153
-
154
- # Assert that a path exists.
155
- def exists?(path)
156
- paths = Dir.glob(path)
157
- paths.not_empty?
158
- end
159
- alias_method :exist?, :exists? #; module_function :exist?
160
- alias_method :path?, :exists? #; module_function :path?
161
-
162
- # Is a given path a regular file? If +path+ is a glob
163
- # then checks to see if all matches are refular files.
164
- def file?(path)
165
- paths = Dir.glob(path)
166
- paths.not_empty? && paths.all?{ |f| FileTest.file?(f) }
167
- end
168
-
169
- # Is a given path a directory? If +path+ is a glob
170
- # checks to see if all matches are directories.
171
- def dir?(path)
172
- paths = Dir.glob(path)
173
- paths.not_empty? && paths.all?{ |f| FileTest.directory?(f) }
174
- end
175
- alias_method :directory?, :dir? #; module_function :directory?
176
-
177
-
178
- # TODO: Deprecate these?
179
-
180
- # Assert that a path exists.
181
- def exists!(*paths)
182
- abort "path not found #{path}" unless paths.any?{|path| exists?(path)}
183
- end
184
- alias_method :exist!, :exists! #; module_function :exist!
185
- alias_method :path!, :exists! #; module_function :path!
186
-
187
- # Assert that a given path is a file.
188
- def file!(*paths)
189
- abort "file not found #{path}" unless paths.any?{|path| file?(path)}
190
- end
191
-
192
- # Assert that a given path is a directory.
193
- def dir!(*paths)
194
- paths.each do |path|
195
- abort "Directory not found: '#{path}'." unless dir?(path)
196
- end
197
- end
198
- alias_method :directory!, :dir! #; module_function :directory!
199
-
200
-
201
- # Load configuration data from a file.
202
- # Results are cached and and empty Hash is
203
- # returned if the file is not found.
204
- #
205
- # Since they are YAML files, they can optionally
206
- # end with '.yaml' or '.yml'.
207
- def configuration(file)
208
- @configuration ||= {}
209
- @configuration[file] ||= (
210
- begin
211
- configuration!(file)
212
- rescue LoadError
213
- Hash.new{ |h,k| h[k] = {} }
214
- end
215
- )
216
- end
217
-
218
- # Load configuration data from a file.
219
- # The "bang" version will raise an error
220
- # if file is not found. It also does not
221
- # cache the results.
222
- #
223
- # Since they are YAML files, they can optionally
224
- # end with '.yaml' or '.yml'.
225
- def configuration!(file)
226
- @configuration ||= {}
227
- patt = file + "{.yml,.yaml,}"
228
- path = Dir.glob(patt, File::FNM_CASEFOLD).find{ |f| File.file?(f) }
229
- if path
230
- # The || {} is in case the file is empty.
231
- data = YAML::load(File.open(path)) || {}
232
- @configuration[file] = data
233
- else
234
- raise LoadError, "Missing file -- #{path}"
235
- end
236
- end
237
-
238
- #
239
- #
240
- def naming_policy(*policies)
241
- if policies.empty?
242
- @naming_policy ||= ['down', 'ext']
243
- else
244
- @naming_policy = policies
245
- end
246
- end
247
-
248
- #
249
- #
250
- def apply_naming_policy(name, ext)
251
- naming_policy.each do |policy|
252
- case policy.to_s
253
- when /^low/, /^down/
254
- name = name.downcase
255
- when /^up/
256
- name = name.upcase
257
- when /^cap/
258
- name = name.capitalize
259
- when /^ext/
260
- name = name + ".#{ext}"
261
- end
262
- end
263
- name
264
- end
265
-
266
- # Email function to easily send out an email.
267
- #
268
- # Settings:
269
- #
270
- # subject Subject of email message.
271
- # from Message FROM address [email].
272
- # to Email address to send announcemnt.
273
- # server Email server to route message.
274
- # port Email server's port.
275
- # domain Email server's domain name.
276
- # account Email account name if needed.
277
- # password Password for login..
278
- # login Login type: plain, cram_md5 or login [plain].
279
- # secure Uses TLS security, true or false? [false]
280
- # message Mesage to send -or-
281
- # file File that contains message.
282
- #
283
- def email(options)
284
- emailer = Emailer.new(options.rekey)
285
- success = emailer.email
286
- if Exception === success
287
- puts "Email failed: #{success.message}."
288
- else
289
- puts "Email sent successfully to #{success.join(';')}."
290
- end
291
- end
292
-
293
-
294
- # Internal status report.
295
- # Only output if dryrun or trace mode.
296
- def status(message)
297
- io.status(message)
298
- end
299
-
300
- # Convenient method to get simple console reply.
301
- def ask(question, answers=nil)
302
- io.ask(question, answers)
303
- end
304
-
305
- # Ask for a password. (FIXME: only for unix so far)
306
- def password(prompt=nil)
307
- io.password(prompt)
308
- end
309
-
310
- end
311
-
312
- end
313
-
314
-
315
-
316
-
317
-
318
-
319
-
320
- # Delegate file system routines to FileUtils or FileUtils::DryRun,
321
- # depending on dryrun mode.
322
- #def fileutils
323
- # dryrun? ? ::FileUtils::DryRun : ::FileUtils
324
- #end
325
-
326
- # Add FileUtils Features
327
- #::FileUtils.private_instance_methods(false).each do |meth|
328
- # next if meth =~ /^fu_/
329
- # module_eval %{
330
- # def #{meth}(*a,&b)
331
- # fileutils.#{meth}(*a,&b)
332
- # end
333
- # }
334
- #end
335
-
336
- # Add FileTest Features
337
- #::FileTest.private_instance_methods(false).each do |meth|
338
- # next if meth =~ /^fu_/
339
- # module_eval %{
340
- # def #{meth}(*a,&b)
341
- # FileTest.#{meth}(*a,&b)
342
- # end
343
- # }
344
- #end
345
-
346
- # # Delegate access to ZipUtils.
347
- # #
348
- # def ziputils
349
- # dryrun? ? ::ZipUtils::DryRun : ::ZipUtils
350
- # end
351
-
352
- # # Compress directory.
353
- # #
354
- # def compress(format, folder, file=nil, options={})
355
- # case format.to_s.downcase
356
- # when 'zip'
357
- # ziputils.zip(folder, file, options)
358
- # when 'tgz'
359
- # ziputils.tgz(folder, file, options)
360
- # when 'tbz', 'bzip'
361
- # ziputils.tar_bzip(folder, file, options)
362
- # else
363
- # raise ArguementError, "unsupported compression format -- #{format}"
364
- # end
365
- # end
366
-
367
- # # Create a zip file of a directory.
368
- # #
369
- # def zip(folder, file=nil, options={})
370
- # ziputils.zip(folder, file, options)
371
- # end
372
-
373
- # # Create a tar.bz2 file of a directory.
374
- # #
375
- # def tar_bzip(folder, file=nil, options={})
376
- # ziputils.tar_bzip(folder, file, options)
377
- # end
378
-
379
- # # Create a tgz file of a directory.
380
- # #
381
- # def tar_gzip(folder, file=nil, options={})
382
- # ziputils.tar_gzip(folder, file, options)
383
- # end
384
- # alias_method :tgz, :tar_gzip
385
-
386
- # Glob files.
387
- #def glob(*args, &blk)
388
- # Dir.glob(*args, &blk)
389
- #end
390
-
391
- # Multiglob files.
392
- #def multiglob(*args, &blk)
393
- # Dir.multiglob(*args, &blk)
394
- #end
395
-
396
- # Multiglob recursive.
397
- #def multiglob_r(*args, &blk)
398
- # Dir.multiglob_r(*args, &blk)
399
- #end
400
-
401
- =begin
402
- # Does a path need updating, based on given +sources+?
403
- # This compares mtimes of give paths. Returns false
404
- # if the path needs to be updated.
405
- #
406
- # TODO: Put this in FileTest instead?
407
-
408
- def out_of_date?(path, *sources)
409
- return true unless File.exist?(path)
410
-
411
- sources = sources.collect{ |source| Dir.glob(source) }.flatten
412
- mtimes = sources.collect{ |file| File.mtime(file) }
413
-
414
- return true if mtimes.empty? # TODO: This the way to go here?
415
-
416
- File.mtime(path) < mtimes.max
417
- end
418
- =end
419
-
420
-