reap 5.10.10 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (224) hide show
  1. data/COPYING +400 -8
  2. data/README +136 -75
  3. data/bin/reap +2 -2
  4. data/bin/rubytest +5 -0
  5. data/data/reap/scaffold/standard/COPYING +403 -0
  6. data/data/reap/scaffold/{ChangeLog → standard/ChangeLog} +0 -0
  7. data/data/reap/scaffold/standard/INSTALL +14 -0
  8. data/data/reap/scaffold/{ProjectInfo → standard/ProjectInfo} +23 -24
  9. data/data/reap/scaffold/standard/README +3 -0
  10. data/data/reap/scaffold/standard/Rakefile +10 -0
  11. data/{Rakefile → data/reap/scaffold/standard/TODO} +0 -0
  12. data/data/reap/scaffold/{setup.rb → standard/setup.rb} +287 -270
  13. data/data/reap/scaffold/subversion/trunk/COPYING +403 -0
  14. data/data/reap/scaffold/{INSTALL → subversion/trunk/ChangeLog} +0 -0
  15. data/data/reap/scaffold/subversion/trunk/INSTALL +14 -0
  16. data/data/reap/scaffold/subversion/trunk/ProjectInfo +76 -0
  17. data/data/reap/scaffold/subversion/trunk/README +3 -0
  18. data/data/reap/scaffold/subversion/trunk/Rakefile +10 -0
  19. data/data/reap/scaffold/{README → subversion/trunk/TODO} +0 -0
  20. data/data/reap/scaffold/subversion/trunk/setup.rb +1568 -0
  21. data/data/reap/setup.rb +1568 -0
  22. data/lib/reap/bin/reap.rb +176 -80
  23. data/lib/reap/bin/rubytest.rb +53 -0
  24. data/lib/reap/class/announce.rb +220 -0
  25. data/lib/reap/class/doap.rb +80 -0
  26. data/lib/reap/class/extest.rb +151 -0
  27. data/lib/reap/class/filer.rb +62 -0
  28. data/lib/reap/class/installer.rb +178 -0
  29. data/lib/reap/class/manifest.rb +72 -0
  30. data/lib/reap/class/package.rb +468 -0
  31. data/lib/reap/class/publish.rb +152 -0
  32. data/lib/reap/class/rdoc.rb +131 -0
  33. data/lib/reap/class/test.rb +269 -0
  34. data/lib/reap/projectinfo.rb +187 -30
  35. data/lib/reap/rake.rb +42 -0
  36. data/lib/reap/reap.rb +89 -0
  37. data/lib/reap/tasks.rb +672 -11
  38. data/lib/reap/taskutils.rb +122 -0
  39. data/sample/ProjectInfo +96 -0
  40. data/sample/Rakefile +9 -0
  41. data/sample/Reapfile +11 -0
  42. data/sample/task/demo.rb +15 -0
  43. data/setup.rb +287 -272
  44. metadata +99 -257
  45. data/ANN +0 -3
  46. data/ChangeLog +0 -25
  47. data/ProjectInfo +0 -65
  48. data/data/reap/scaffold/COPYING +0 -11
  49. data/data/reap/scaffold/Rakefile +0 -146
  50. data/data/reap/scaffold/Todo +0 -0
  51. data/dev/Rakefile +0 -60
  52. data/dev/composite_task.rb +0 -27
  53. data/dev/compositepublisher.rb +0 -24
  54. data/dev/ftptools.rb +0 -139
  55. data/dev/license-each.rb +0 -85
  56. data/dev/publisher.rb +0 -75
  57. data/dev/rubyforgepublisher.rb +0 -18
  58. data/dev/sshpublisher.rb +0 -47
  59. data/dev/suby-cvs.rb +0 -46
  60. data/dev/template.rb +0 -72
  61. data/lib/reap/lint.rb +0 -0
  62. data/lib/reap/readymade.rb +0 -21
  63. data/lib/reap/task.rb +0 -187
  64. data/lib/reap/task/announce.rb +0 -156
  65. data/lib/reap/task/fileperm.rb +0 -82
  66. data/lib/reap/task/info.rb +0 -20
  67. data/lib/reap/task/install.rb +0 -33
  68. data/lib/reap/task/noop.rb +0 -26
  69. data/lib/reap/task/package.rb +0 -204
  70. data/lib/reap/task/publish.rb +0 -49
  71. data/lib/reap/task/rdoc.rb +0 -82
  72. data/lib/reap/task/scaffold.rb +0 -114
  73. data/lib/reap/task/test.rb +0 -186
  74. data/lib/reap/task/testext.rb +0 -110
  75. data/lib/reap/task/webpublish.rb +0 -43
  76. data/lib/reap/test.rb +0 -138
  77. data/test/tc_reap.rb +0 -11
  78. data/web/ProjectInfo +0 -57
  79. data/web/images/appleboy.jpg +0 -0
  80. data/web/images/grape.jpg +0 -0
  81. data/web/index.html +0 -124
  82. data/web/rdoc/classes/Object.html +0 -121
  83. data/web/rdoc/classes/ProjectInfo.html +0 -207
  84. data/web/rdoc/classes/ProjectInfo.src/M000094.html +0 -18
  85. data/web/rdoc/classes/ProjectInfo.src/M000095.html +0 -24
  86. data/web/rdoc/classes/ProjectInfo.src/M000096.html +0 -22
  87. data/web/rdoc/classes/ProjectInfo.src/M000097.html +0 -21
  88. data/web/rdoc/classes/ProjectInfo.src/M000098.html +0 -18
  89. data/web/rdoc/classes/Reap.html +0 -248
  90. data/web/rdoc/classes/Reap.src/M000023.html +0 -16
  91. data/web/rdoc/classes/Reap.src/M000024.html +0 -21
  92. data/web/rdoc/classes/Reap.src/M000025.html +0 -16
  93. data/web/rdoc/classes/Reap.src/M000026.html +0 -21
  94. data/web/rdoc/classes/Reap/Announce.html +0 -262
  95. data/web/rdoc/classes/Reap/Announce.src/M000030.html +0 -18
  96. data/web/rdoc/classes/Reap/Announce.src/M000031.html +0 -114
  97. data/web/rdoc/classes/Reap/Announce.src/M000032.html +0 -46
  98. data/web/rdoc/classes/Reap/Info.html +0 -176
  99. data/web/rdoc/classes/Reap/Info.src/M000033.html +0 -18
  100. data/web/rdoc/classes/Reap/Info.src/M000034.html +0 -17
  101. data/web/rdoc/classes/Reap/Info.src/M000035.html +0 -18
  102. data/web/rdoc/classes/Reap/Install.html +0 -193
  103. data/web/rdoc/classes/Reap/Install.src/M000036.html +0 -18
  104. data/web/rdoc/classes/Reap/Install.src/M000037.html +0 -20
  105. data/web/rdoc/classes/Reap/Install.src/M000038.html +0 -26
  106. data/web/rdoc/classes/Reap/Noop.html +0 -192
  107. data/web/rdoc/classes/Reap/Noop.src/M000027.html +0 -18
  108. data/web/rdoc/classes/Reap/Noop.src/M000028.html +0 -17
  109. data/web/rdoc/classes/Reap/Noop.src/M000029.html +0 -18
  110. data/web/rdoc/classes/Reap/Package.html +0 -310
  111. data/web/rdoc/classes/Reap/Package.src/M000055.html +0 -18
  112. data/web/rdoc/classes/Reap/Package.src/M000056.html +0 -68
  113. data/web/rdoc/classes/Reap/Package.src/M000057.html +0 -84
  114. data/web/rdoc/classes/Reap/Package.src/M000058.html +0 -61
  115. data/web/rdoc/classes/Reap/Perm.html +0 -236
  116. data/web/rdoc/classes/Reap/Perm.src/M000078.html +0 -18
  117. data/web/rdoc/classes/Reap/Perm.src/M000079.html +0 -21
  118. data/web/rdoc/classes/Reap/Perm.src/M000080.html +0 -42
  119. data/web/rdoc/classes/Reap/Perm.src/M000081.html +0 -26
  120. data/web/rdoc/classes/Reap/Perm.src/M000082.html +0 -18
  121. data/web/rdoc/classes/Reap/Publish.html +0 -213
  122. data/web/rdoc/classes/Reap/Publish.src/M000070.html +0 -18
  123. data/web/rdoc/classes/Reap/Publish.src/M000071.html +0 -22
  124. data/web/rdoc/classes/Reap/Publish.src/M000072.html +0 -37
  125. data/web/rdoc/classes/Reap/RDoc.html +0 -218
  126. data/web/rdoc/classes/Reap/RDoc.src/M000059.html +0 -18
  127. data/web/rdoc/classes/Reap/RDoc.src/M000060.html +0 -24
  128. data/web/rdoc/classes/Reap/RDoc.src/M000061.html +0 -70
  129. data/web/rdoc/classes/Reap/Task.html +0 -396
  130. data/web/rdoc/classes/Reap/Task.src/M000039.html +0 -18
  131. data/web/rdoc/classes/Reap/Task.src/M000040.html +0 -16
  132. data/web/rdoc/classes/Reap/Task.src/M000041.html +0 -16
  133. data/web/rdoc/classes/Reap/Task.src/M000042.html +0 -16
  134. data/web/rdoc/classes/Reap/Task.src/M000043.html +0 -16
  135. data/web/rdoc/classes/Reap/Task.src/M000044.html +0 -22
  136. data/web/rdoc/classes/Reap/Task.src/M000045.html +0 -16
  137. data/web/rdoc/classes/Reap/Task.src/M000046.html +0 -16
  138. data/web/rdoc/classes/Reap/Task.src/M000047.html +0 -16
  139. data/web/rdoc/classes/Reap/Task.src/M000048.html +0 -16
  140. data/web/rdoc/classes/Reap/Task.src/M000049.html +0 -16
  141. data/web/rdoc/classes/Reap/Task.src/M000050.html +0 -27
  142. data/web/rdoc/classes/Reap/Task.src/M000051.html +0 -19
  143. data/web/rdoc/classes/Reap/Task.src/M000052.html +0 -18
  144. data/web/rdoc/classes/Reap/Task.src/M000053.html +0 -18
  145. data/web/rdoc/classes/Reap/Task.src/M000054.html +0 -19
  146. data/web/rdoc/classes/Reap/Test.html +0 -253
  147. data/web/rdoc/classes/Reap/Test.src/M000062.html +0 -18
  148. data/web/rdoc/classes/Reap/Test.src/M000063.html +0 -26
  149. data/web/rdoc/classes/Reap/Test.src/M000064.html +0 -77
  150. data/web/rdoc/classes/Reap/Test.src/M000065.html +0 -27
  151. data/web/rdoc/classes/Reap/Test.src/M000066.html +0 -50
  152. data/web/rdoc/classes/Reap/Test/TestResults.html +0 -205
  153. data/web/rdoc/classes/Reap/Test/TestResults.src/M000067.html +0 -21
  154. data/web/rdoc/classes/Reap/Test/TestResults.src/M000068.html +0 -21
  155. data/web/rdoc/classes/Reap/Test/TestResults.src/M000069.html +0 -23
  156. data/web/rdoc/classes/Reap/TestExt.html +0 -234
  157. data/web/rdoc/classes/Reap/TestExt.src/M000073.html +0 -18
  158. data/web/rdoc/classes/Reap/TestExt.src/M000074.html +0 -20
  159. data/web/rdoc/classes/Reap/TestExt.src/M000075.html +0 -49
  160. data/web/rdoc/classes/Reap/TestExt.src/M000076.html +0 -34
  161. data/web/rdoc/classes/Reap/TestExt.src/M000077.html +0 -27
  162. data/web/rdoc/classes/Reap/WebPublish.html +0 -213
  163. data/web/rdoc/classes/Reap/WebPublish.src/M000083.html +0 -18
  164. data/web/rdoc/classes/Reap/WebPublish.src/M000084.html +0 -21
  165. data/web/rdoc/classes/Reap/WebPublish.src/M000085.html +0 -32
  166. data/web/rdoc/classes/ReapCommand.html +0 -425
  167. data/web/rdoc/classes/ReapCommand.src/M000001.html +0 -16
  168. data/web/rdoc/classes/ReapCommand.src/M000003.html +0 -16
  169. data/web/rdoc/classes/ReapCommand.src/M000005.html +0 -16
  170. data/web/rdoc/classes/ReapCommand.src/M000007.html +0 -16
  171. data/web/rdoc/classes/ReapCommand.src/M000009.html +0 -16
  172. data/web/rdoc/classes/ReapCommand.src/M000011.html +0 -16
  173. data/web/rdoc/classes/ReapCommand.src/M000013.html +0 -18
  174. data/web/rdoc/classes/ReapCommand.src/M000014.html +0 -19
  175. data/web/rdoc/classes/ReapCommand.src/M000015.html +0 -19
  176. data/web/rdoc/classes/ReapCommand.src/M000016.html +0 -24
  177. data/web/rdoc/classes/ReapCommand.src/M000018.html +0 -29
  178. data/web/rdoc/classes/Scaffold.html +0 -211
  179. data/web/rdoc/classes/Scaffold.src/M000086.html +0 -16
  180. data/web/rdoc/classes/Scaffold.src/M000087.html +0 -28
  181. data/web/rdoc/classes/Scaffold.src/M000088.html +0 -32
  182. data/web/rdoc/classes/Scaffold.src/M000089.html +0 -18
  183. data/web/rdoc/classes/UnitTestKernel.html +0 -176
  184. data/web/rdoc/classes/UnitTestKernel.src/M000019.html +0 -18
  185. data/web/rdoc/classes/UnitTestKernel.src/M000020.html +0 -18
  186. data/web/rdoc/classes/UnitTestKernel.src/M000021.html +0 -22
  187. data/web/rdoc/classes/UnitTestKernel.src/M000022.html +0 -22
  188. data/web/rdoc/classes/UnitTesting.html +0 -165
  189. data/web/rdoc/classes/UnitTesting.src/M000090.html +0 -34
  190. data/web/rdoc/classes/UnitTesting.src/M000091.html +0 -18
  191. data/web/rdoc/classes/UnitTesting/Failure.html +0 -156
  192. data/web/rdoc/classes/UnitTesting/Failure.src/M000092.html +0 -18
  193. data/web/rdoc/classes/UnitTesting/Failure.src/M000093.html +0 -21
  194. data/web/rdoc/created.rid +0 -1
  195. data/web/rdoc/files/ANN.html +0 -107
  196. data/web/rdoc/files/COPYING.html +0 -119
  197. data/web/rdoc/files/ChangeLog.html +0 -144
  198. data/web/rdoc/files/ProjectInfo.html +0 -190
  199. data/web/rdoc/files/README.html +0 -274
  200. data/web/rdoc/files/Rakefile.html +0 -101
  201. data/web/rdoc/files/lib/reap/bin/reap_rb.html +0 -129
  202. data/web/rdoc/files/lib/reap/lint_rb.html +0 -101
  203. data/web/rdoc/files/lib/reap/projectinfo_rb.html +0 -110
  204. data/web/rdoc/files/lib/reap/readymade_rb.html +0 -123
  205. data/web/rdoc/files/lib/reap/task/announce_rb.html +0 -114
  206. data/web/rdoc/files/lib/reap/task/fileperm_rb.html +0 -108
  207. data/web/rdoc/files/lib/reap/task/info_rb.html +0 -108
  208. data/web/rdoc/files/lib/reap/task/install_rb.html +0 -108
  209. data/web/rdoc/files/lib/reap/task/noop_rb.html +0 -108
  210. data/web/rdoc/files/lib/reap/task/package_rb.html +0 -109
  211. data/web/rdoc/files/lib/reap/task/publish_rb.html +0 -108
  212. data/web/rdoc/files/lib/reap/task/rdoc_rb.html +0 -108
  213. data/web/rdoc/files/lib/reap/task/scaffold_rb.html +0 -107
  214. data/web/rdoc/files/lib/reap/task/test_rb.html +0 -110
  215. data/web/rdoc/files/lib/reap/task/testext_rb.html +0 -109
  216. data/web/rdoc/files/lib/reap/task/webpublish_rb.html +0 -108
  217. data/web/rdoc/files/lib/reap/task_rb.html +0 -120
  218. data/web/rdoc/files/lib/reap/tasks_rb.html +0 -116
  219. data/web/rdoc/files/lib/reap/test_rb.html +0 -109
  220. data/web/rdoc/fr_class_index.html +0 -47
  221. data/web/rdoc/fr_file_index.html +0 -51
  222. data/web/rdoc/fr_method_index.html +0 -124
  223. data/web/rdoc/index.html +0 -24
  224. data/web/rdoc/rdoc-style.css +0 -208
@@ -0,0 +1,152 @@
1
+ #--
2
+ # ___ _ _ _ _
3
+ # | _ \_ _| |__| (_)__| |_
4
+ # | _/ || | '_ \ | (_-< ' \
5
+ # |_| \_,_|_.__/_|_/__/_||_|
6
+ #
7
+ #++
8
+
9
+ require 'shellwords'
10
+
11
+ module Reap
12
+
13
+ # = Publish
14
+ #
15
+ # Publish documents to hosting service. Three means of
16
+ # publishing are current supported, ftp uploading, scp,
17
+ # and web convenience option that recognizes particular
18
+ # hosts (only RubyForge is currently supported).
19
+ #
20
+ # type Type of publishing, 'web', 'scp' or 'ftp'.
21
+ # host Host server, default is 'rubyforge.org'
22
+ # username Username for host.
23
+ # dir Directory of files to publish. Or,
24
+ # copy Files to publish using from and to.
25
+ # project Project name (used for Rubyforge)
26
+ #
27
+ # If the type is 'scp' or 'ftp' you will also need to provide
28
+ # the root directory parameter.
29
+ #
30
+ # root Document root directory at host.
31
+ #
32
+ # The dir parameter allows you to simply specify a local
33
+ # directory, the contents of which will be published to
34
+ # host's document root location (directory tree intact).
35
+ #
36
+ # If you need more control over which files to publish
37
+ # where, you can use the copy parameter instead. Provide
38
+ # an array of pattern strings in the form of "{from} {to}".
39
+ # If the desitination is the host's document root you do
40
+ # not need to specify the {to} part. For example:
41
+ #
42
+ # copy: [ 'web/*', 'doc/api/* doc/api' ]
43
+ #
44
+ # The first copies the files under your project's web directory
45
+ # to the host's document root. The second copies your projects
46
+ # doc/api files to the doc/api location on the host.
47
+ #
48
+ # When using the 'scp' type the internal template used for
49
+ # the outbound destination is 'username@host:root/'.
50
+
51
+ class Publish
52
+
53
+ include TaskUtils
54
+
55
+ attr_accessor :dir, :type, :host, :root, :project, :username, :copy
56
+
57
+ def initialize( pub )
58
+ @type = 'web'
59
+ @host = 'rubyforge.org'
60
+ @root = 'var/www/gforge-projects/'
61
+
62
+ super
63
+
64
+ @copy ||= [ "#{@dir}/*" ]
65
+ end
66
+
67
+ # Upload files to host.
68
+
69
+ def publish( target=nil, copy_from=nil, copy_to=nil )
70
+
71
+ return nil if target and target != @target
72
+
73
+ # setup
74
+ if copy_from
75
+ @copy = [ "#{copy_from} #{copy_to}".strip ]
76
+ end
77
+
78
+ # validate
79
+ unless @project
80
+ puts "Project not specified." ; return nil
81
+ end
82
+ unless @username
83
+ puts "Username not specified." ; return nil
84
+ end
85
+
86
+ # publish
87
+ puts "Reap is passing off publishing work..."
88
+
89
+ case @type
90
+ when 'web', 'www'
91
+ case @host
92
+ when 'rubyforge', 'rubyforge.org'
93
+ @host = "rubyforge.org"
94
+ @root = "/var/www/gforge-projects/#{@project}"
95
+ run_scp
96
+ else
97
+ puts %{Unrecognized publishing host '#{@host}'. Skipped.}
98
+ return nil
99
+ end
100
+ when 'scp'
101
+ run_scp
102
+ when 'ftp'
103
+ run_ftp
104
+ else
105
+ puts %{Unrecognized publishing type '#{@type}'. Skipped.}
106
+ return nil
107
+ end
108
+
109
+ end
110
+
111
+ private
112
+
113
+ # Use scp to upload files.
114
+ #--
115
+ # SHELL OUT! Need a net/ssh library to fix.
116
+ #++
117
+
118
+ def run_scp
119
+ @copy.each { |c|
120
+ from, to = *Shellwords.shellwords(c)
121
+ to = '' if to.nil?
122
+ to = to[1..-1] if to[0,1] == '/'
123
+ cmd = "scp -r #{from} #{@username}@#{@host}:#{@root}/#{to}"
124
+ sh( cmd )
125
+ }
126
+ end
127
+
128
+ # Use ftp to upload files.
129
+
130
+ def run_ftp
131
+ require 'net/ftp'
132
+ return if $PRETEND
133
+ Net::FTP.open( @host ) { |ftp|
134
+ ftp.login( @username )
135
+ ftp.chdir( @root )
136
+ @copy.each { |c|
137
+ from, to = *Shellwords.shellwords(c)
138
+ to = '' if to.nil?
139
+ to = to[1..-1] if to[0,1] == '/'
140
+ from.sub('*', '**/*') unless from =~ /\*\*/
141
+ files = FileList.new( from )
142
+ files.each { |f|
143
+ t = File.join( to, f.basename )
144
+ ftp.putbinaryfile( f, t, 1024 )
145
+ }
146
+ }
147
+ }
148
+ end
149
+
150
+ end
151
+
152
+ end #module Reap
@@ -0,0 +1,131 @@
1
+ #--
2
+ # ___ _
3
+ # | _ \__| |___ __
4
+ # | / _` / _ \/ _|
5
+ # |_|_\__,_\___/\__|
6
+ #
7
+ #++
8
+
9
+ module Reap
10
+
11
+ # = RDoc
12
+ #
13
+ # This class generates RDoc API documentation from source
14
+ # comments.
15
+ #
16
+ # title Project title to use in RDocs.
17
+ # dir Directory to store documentation [doc].
18
+ # main File to use as main page of RDocs.
19
+ # template Which RDoc template to use.
20
+ # include Files to include in RDocs.
21
+ # exclude Files to exclude from those.
22
+ # options Pass-thru extra options to RDoc command.
23
+ #
24
+
25
+ class RDoc # < Task
26
+
27
+ include TaskUtils
28
+
29
+ MUST_EXCLUDE = [ 'InstalledFiles', 'CVS/**/*', '_darcs/**/*' ]
30
+
31
+ # Note that ++dir++ is not offset by trunk.
32
+
33
+ attr_accessor :dir,
34
+ :main,
35
+ :title,
36
+ :template,
37
+ :trunk,
38
+ :include,
39
+ :exclude,
40
+ :options
41
+
42
+ def initialize( doc )
43
+ # set default values
44
+ @dir = 'doc'
45
+ @main = 'README'
46
+ #@title ||= master.title
47
+ @template = 'html' # 'jamis'
48
+ @include = [ 'A-Z*', 'lib/**/*', 'ext/**/*' ] #, @main ]
49
+ @exclude = [ 'demo/**/*', 'example/**/*', 'sample/**/*' ]
50
+ @options = ['--merge', '--all']
51
+
52
+ super
53
+
54
+ @include = [ @include, @main ].flatten
55
+ @exclude = [ @exclude ].flatten
56
+ @options = [ @options ].flatten
57
+ end
58
+
59
+ # Generate RDocs.
60
+
61
+ def generate
62
+ @rdoc_dir = File.expand_path(@dir)
63
+
64
+ if @trunk
65
+ Dir.chdir( @trunk ) { generate_rdocs }
66
+ else
67
+ generate_rdocs
68
+ end
69
+ end
70
+
71
+ alias_method :call, :generate
72
+
73
+ private
74
+
75
+ def generate_rdocs
76
+ # warn if main file doesn't exist
77
+ if !File.exists?(@main) or File.directory?(@main)
78
+ warn "WARNING! Specified RDoc Main file #{@main} not found."
79
+ @main = nil
80
+ end
81
+
82
+ if FileTest.directory?(@rdoc_dir)
83
+ q = "Directory '#{@dir}' already exists. Clobber?"
84
+ #until inp = $stdin.gets[0,1] ; sleep 1 ; end ; puts
85
+ inp = ask( q, 'yN' )
86
+ case inp.downcase
87
+ when 'y', 'yes', 'okay'
88
+ tell "Removing old directory '#{@rdoc_dir}'..."
89
+ FileUtils.rm_r(@rdoc_dir) unless $PRETEND
90
+ else
91
+ tell "Reap rdoc task canceled."
92
+ return nil
93
+ end
94
+ end
95
+
96
+ #rdoc_target = "#{@rdoc_dir}/index.html"
97
+
98
+ exc = []
99
+ (@exclude + MUST_EXCLUDE).each{ |e|
100
+ exc << e
101
+ exc |= Dir.glob(e+'/**/*')
102
+ }
103
+
104
+ inc = Dir.glob('[A-Z]*')
105
+ @include.each{ |i| inc |= Dir.glob(i) }
106
+ inc -= exc
107
+
108
+ inc = inc.select{ |f| File.file?(f) }
109
+
110
+ rdoc_files = inc
111
+ rdoc_files = '"' << rdoc_files.join('" "') << '"'
112
+
113
+ # build options string
114
+ build = []
115
+ build += @options
116
+ build << "--main '#{@main}'" if @main
117
+ build << "--title '#{@title}'" if @title
118
+ build << "-T '#{@template}'" if @template
119
+ rdoc_opts = build.join(' ')
120
+
121
+ #--
122
+ # SHELL OUT! Can RDoc be called from code?
123
+ #++
124
+
125
+ tell "Reap is shelling work out to RDoc..."
126
+ sh %{rdoc -o #{@rdoc_dir} #{rdoc_opts} #{rdoc_files}}
127
+ end
128
+
129
+ end
130
+
131
+ end #module Reap
@@ -0,0 +1,269 @@
1
+ #--
2
+ # _____ _
3
+ # |_ _|__ __| |_
4
+ # | |/ -_|_-< _|
5
+ # |_|\___/__/\__|
6
+ #
7
+ #++
8
+
9
+ #require 'test/unit'
10
+ require 'test/unit/ui/testrunnermediator'
11
+ require 'facet/string/tabto'
12
+ require 'facet/progressbar'
13
+
14
+ ::Test::Unit.run = true # don't run auto tests
15
+
16
+ module Reap
17
+
18
+ # == Test
19
+ #
20
+ # The Reap test class runs each test in it's own
21
+ # proccess, making for a more pure test facility.
22
+ # Reap runs each test in a separate proccess to aviod
23
+ # potential conflicts between scripts.
24
+ #
25
+ # files Test files (eg. test/tc_**/*.rb)
26
+ # Defaults to typcial selection.
27
+ #
28
+ # libs List of lookup directories to include in
29
+ # load path. './lib' is always included.
30
+ #
31
+ # live Flag to quickly deactive use of local libs.
32
+ # Test against installed files instead.
33
+ #
34
+ # requires List of any files to pre-require.
35
+ #
36
+ # NOTE This works well enough but it is a tad delicate.
37
+ # It actually marshals test results across stdout->stdin
38
+ # shell pipe. One consequence of this is that you can't
39
+ # send debug info to stdout in your tests (including #p and #puts).
40
+
41
+ class Test
42
+
43
+ include TaskUtils
44
+
45
+ attr_accessor :trunk, :files, :requires, :live, :libs
46
+
47
+ def initialize( tst )
48
+ #@trunk = 'trunk' if File.directory?('trunk')
49
+ @files = [ 'test/*/**/*.rb', 'test/**/tc*.rb', 'test/**/test*.rb', 'test/**/*test.rb' ]
50
+ @requires = []
51
+ @live = false
52
+ @libs = [] #['./lib']
53
+
54
+ super
55
+ end
56
+
57
+ # Start testing.
58
+
59
+ def test
60
+ if @trunk
61
+ Dir.chdir( @trunk ) { run_tests }
62
+ else
63
+ run_tests
64
+ end
65
+ end
66
+
67
+ alias_method :call, :test
68
+
69
+ private
70
+
71
+ # Run each test.
72
+
73
+ def run_tests
74
+ # interal use
75
+ @results = TestResults.new
76
+ @errors = []
77
+ @failures = []
78
+
79
+ # Get test files
80
+ test_libs = @libs.join(':')
81
+ test_files = FileList.new
82
+ test_files.include(*@files)
83
+ test_files.uniq!
84
+
85
+ if test_files.empty?
86
+ tell "No test files found."
87
+ return
88
+ end
89
+
90
+ #tell "Reap is passing off work to Ruby's Test Suite..."
91
+
92
+ pbar = Console::ProgressBar.new( 'Testing', test_files.size )
93
+
94
+ # Run tests
95
+ # (why arn't these unique to begin with?)
96
+ test_files.each do |test_file|
97
+ pbar.inc
98
+ #$stdout << '.'; $stdout.flush
99
+
100
+ if ! File.file?( test_file )
101
+ r = nil
102
+ else
103
+ r = fork_test( test_file )
104
+ end
105
+ unless r.passed?
106
+ @errors << r.instance_variable_get('@errors')
107
+ @failures << r.instance_variable_get('@failures')
108
+ end
109
+ @results << r
110
+
111
+ #ruby %{-r"test/unit" "#{f}"}
112
+ end
113
+
114
+ pbar.finish
115
+
116
+ # Don't know why empty arrays get in them yet, but...
117
+ @failures.reject! { |e| e == [] }
118
+ @errors.reject! { |e| e == [] }
119
+
120
+ # Display failures
121
+ puts
122
+ puts %{FAILURES:#{@failures.empty? ? ' []' : ''}}
123
+ @failures.reverse.each { |fails|
124
+ fails.reverse.each { |failure|
125
+ puts
126
+ puts %{ - test : #{failure.test_name}}
127
+ puts %{ location : #{failure.location}}
128
+ if failure.message.index("\n")
129
+ puts %{ message : >}
130
+ puts failure.message.tabto(6)
131
+ else
132
+ puts %{ message : #{failure.message}}
133
+ end
134
+ }
135
+ }
136
+
137
+ # Display errors
138
+ puts
139
+ puts %{ERRORS:#{@errors.empty? ? ' []' : ''}}
140
+ @errors.reverse.each { |errs|
141
+ errs.reverse.each { |err|
142
+ puts
143
+ puts %{ - test : #{err.test_name}}
144
+ puts %{ message : #{err.exception.message}}
145
+ puts %{ backtrace :}
146
+ err.exception.backtrace[0...-1].each { |bt| puts %Q{ - #{bt}} }
147
+ }
148
+ }
149
+
150
+ # Display final results
151
+ puts
152
+ puts @results
153
+ puts
154
+
155
+ # old way (don't work right)
156
+ #puts %Q{ ruby %{-I#{test_libs} -e0 -r"test/unit" \\\n#{test_reqs}#{test_opts}} } if $DEBUG
157
+ #ruby %{-I#{test_libs} -e0 -r"test/unit" \\\n#{test_reqs}#{test_opts}}
158
+ #ruby %{-e0 -r"test/unit" \\\n#{test_reqs}#{test_opts}}
159
+ end
160
+
161
+ private
162
+
163
+ # Runs a test.
164
+ #
165
+ # Currently send program output to null device.
166
+ # Could send to a logger in future version.
167
+
168
+ def fork_test( testfile )
169
+ src = ''
170
+
171
+ unless @live
172
+ l = File.join( Dir.pwd, 'lib' )
173
+ if File.directory?( l )
174
+ src << %{$:.unshift('#{l}')\n}
175
+ end
176
+ @libs.each { |r| src << %{$:.unshift('#{r}')\n} }
177
+ end
178
+
179
+ src << %{
180
+ #require 'test/unit'
181
+ require 'test/unit/collector'
182
+ require 'test/unit/collector/objectspace'
183
+ require 'test/unit/ui/testrunnermediator'
184
+ }
185
+
186
+ @requires.each do |fix|
187
+ src << %Q{
188
+ require '#{fix}'
189
+ }
190
+ end
191
+
192
+ src << %{
193
+ output = STDOUT.dup
194
+ STDOUT.reopen( PLATFORM =~ /mswin/ ? "NUL" : "/dev/null" )
195
+
196
+ load('#{testfile}')
197
+ tests = Test::Unit::Collector::ObjectSpace.new.collect
198
+ runner = Test::Unit::UI::TestRunnerMediator.new( tests )
199
+ result = runner.run_suite
200
+
201
+ begin
202
+ marshalled = Marshal.dump(result)
203
+ rescue TypeError => e
204
+ $stderr << "MARSHAL ERROR\n"
205
+ $stderr << "TEST: #{testfile}\n"
206
+ $stderr << "DATA:" << result.inspect
207
+ exit -1
208
+ end
209
+ output << marshalled
210
+
211
+ STDOUT.reopen(output)
212
+ output.close
213
+ }
214
+
215
+ result = IO.popen("ruby","w+") do |ruby|
216
+ ruby.puts src
217
+ ruby.close_write
218
+ ruby.read
219
+ end
220
+
221
+ p testfile if $VERBOSE
222
+
223
+ begin
224
+ marsh = Marshal.load(result)
225
+ rescue ArgumentError
226
+ $stderr << "\nCannot load marshalled test data.\n"
227
+ $stderr << result << "\n"
228
+ exit -1
229
+ end
230
+
231
+ return marsh
232
+ end
233
+
234
+ #
235
+ # Support class for collecting test results.
236
+ #
237
+
238
+ class TestResults
239
+
240
+ attr_reader :assertion_count, :run_count, :failure_count, :error_count
241
+
242
+ def initialize
243
+ @assertion_count = 0
244
+ @run_count = 0
245
+ @failure_count = 0
246
+ @error_count = 0
247
+ end
248
+
249
+ def <<( result )
250
+ @assertion_count += result.assertion_count
251
+ @run_count += result.run_count
252
+ @failure_count += result.failure_count
253
+ @error_count += result.error_count
254
+ end
255
+
256
+ def to_s
257
+ s = %{SUMMARY:\n\n}
258
+ s << %{ tests : #{@run_count}\n}
259
+ s << %{ assertions : #{@assertion_count}\n}
260
+ s << %{ failures : #{@failure_count}\n}
261
+ s << %{ errors : #{@error_count}\n}
262
+ s
263
+ end
264
+
265
+ end
266
+
267
+ end
268
+
269
+ end #module Reap