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,80 @@
1
+
2
+ module Reap
3
+
4
+ # = Doap
5
+
6
+ class Doap
7
+
8
+ include TaskUtils
9
+
10
+ attr_accessor :dir
11
+
12
+ attr_accessor :title,
13
+ :name,
14
+ :created,
15
+ :summary,
16
+ :description,
17
+ :maintainer,
18
+ :email,
19
+ :homepage,
20
+ :wiki
21
+
22
+ def initalize( prj )
23
+ super
24
+
25
+ @dir ||= '.'
26
+ end
27
+
28
+ def call
29
+ write( generate )
30
+ puts "DOAP file created at '#{File.join( @dir, "doap.xml" )}'."
31
+ end
32
+
33
+ # Generate a doap file.
34
+
35
+ def generate
36
+ x = ''
37
+ x << %{
38
+ |<Project xmlns="http://usefulinc.com/ns/doap#"\n
39
+ | xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n
40
+ | xmlns:foaf="http://xmlns.com/foaf/0.1/">
41
+ | <name>#{@title}</name>
42
+ | <shortname>#{@name}</shortname>
43
+ | <homepage rdf:resource="#{@homepage}" />
44
+ | <wiki rdf:resource="#{@wiki}" />
45
+ | <created>#{@created}</created>
46
+ | <shortdesc xml:lang="en">
47
+ }.margin
48
+ x << "\n" << @summary.word_wrap(50).indent(6)
49
+ x << %{
50
+ | </shortdesc>
51
+ | <description xml:lang="en">
52
+ }.margin
53
+ x << "\n" << @description.word_wrap(50).indent(6)
54
+ x << %{
55
+ | </description>
56
+ | <maintainer>
57
+ | <foaf:Person>
58
+ | <foaf:name>#{@maintainer}</foaf:name>
59
+ | <foaf:email>#{@email}</foaf:name>
60
+ | <foaf:homepage rdf:resource="#{@homepage}" />
61
+ | </foaf:Person>
62
+ | </maintainer>
63
+ | </Project>
64
+ }.margin
65
+
66
+ return x
67
+ end
68
+
69
+ private
70
+
71
+ # Write the doap file.
72
+
73
+ def write( doap )
74
+ file = File.join( @dir, "doap.xml" )
75
+ File.open( file, 'w' ) { |f| f << doap }
76
+ end
77
+
78
+ end
79
+
80
+ end #module Reap
@@ -0,0 +1,151 @@
1
+ #--
2
+ # _____ _ ___ _
3
+ # |_ _|__ __| |_ | __|_ _| |_
4
+ # | |/ -_|_-< _| | _|\ \ / _|_
5
+ # |_|\___/__/\__| |___/_\_\\__(_)
6
+ #
7
+ #++
8
+
9
+ require 'facet/string/margin'
10
+ require 'facet/progressbar'
11
+ require 'facet/filelist.rb' unless defined?( FileList )
12
+
13
+ module Reap
14
+
15
+ # = Test Extraction
16
+ #
17
+ # This task scans every package script looking for sections of the form:
18
+ #
19
+ # =begin test
20
+ # ...
21
+ # =end
22
+ #
23
+ # With appropriate headers, it copies these sections to files in your
24
+ # project's test/ dir, which then can be run using the Reap test task.
25
+ # The exact directory layout of the files to be tested is reflected in
26
+ # the test directory. You can then use Reap's test task to run the tests.
27
+ #
28
+ # Specific Settings:
29
+ #
30
+ # dir Specify the test directory. Default is 'test'.
31
+ # files Specify files to extract. Default is 'lib/**/*.rb'.
32
+ #
33
+
34
+ class ExTest
35
+
36
+ include TaskUtils
37
+
38
+ attr_accessor :dir, :trunk, :files, :options
39
+
40
+ def initialize( tst )
41
+ @dir = 'test'
42
+ #@trunk = 'trunk' if File.directory?('trunk')
43
+ @files = [ 'lib/**/*.rb' ]
44
+ @options = {}
45
+
46
+ super
47
+
48
+ @files = [ @files ].flatten
49
+ end
50
+
51
+ # Extract tests.
52
+
53
+ def extract
54
+ if @trunk
55
+ Dir.chdir( @trunk ) { extract_tests }
56
+ else
57
+ extract_tests
58
+ end
59
+ end
60
+
61
+ alias_method :call, :extract
62
+
63
+ private
64
+
65
+ def extract_tests
66
+ #test_libs = @libs.join(':')
67
+ filelist = FileList.new
68
+ filelist.include(*@files)
69
+ if filelist.empty?
70
+ tell "No script files found."
71
+ return
72
+ end
73
+ #tell "Reap is scanning and copying embedded tests..."
74
+ if @dir.strip.empty?
75
+ tell "Test directory must be specified. Aborting."
76
+ return # TODO use #abort or sepcial method to do a nice exit?
77
+ end
78
+ unless File.directory?( @dir )
79
+ tell "Test directory doesn't exist: #{File.expand_path( @dir )}"
80
+ return
81
+ end
82
+ pbar = Console::ProgressBar.new( 'Extracting', filelist.size )
83
+ filelist.each { |file|
84
+ pbar.inc
85
+ testing = extract_from_file( file )
86
+ unless testing.strip.empty?
87
+ complete_test = create( testing, file )
88
+ libpath = File.dirname( file )
89
+ testfile = "test_" + File.basename( file )
90
+ fp = File.join( dir, libpath, testfile )
91
+ unless File.directory?( File.dirname( fp ) )
92
+ FileUtils.mkdir_p( File.dirname(fp) )
93
+ end
94
+ File.open( fp, "w" ) { |fw| fw << complete_test }
95
+ end
96
+ }
97
+ pbar.finish
98
+ end
99
+
100
+ private
101
+
102
+ def extract_from_file( file )
103
+ return nil if ! File.file?( file )
104
+ tests = ""; inside = false
105
+ fstr = File.read( file )
106
+ fstr.split(/\n/).each do |l|
107
+ if l =~ /^=begin[ ]*test/i
108
+ tests << "\n"
109
+ inside = true
110
+ next
111
+ elsif inside and l =~ /^=[ ]*end/
112
+ inside = false
113
+ next
114
+ end
115
+ if inside
116
+ tests << l << "\n"
117
+ end
118
+ end
119
+ tests
120
+ end
121
+
122
+ def create( testing, file )
123
+ fp = file.split(/[\/]/)
124
+ if fp[0] == 'lib'
125
+ reqf = "require '#{fp[1..-1].join('/')}'"
126
+ else
127
+ reqf = ''
128
+ end
129
+ teststr = <<-HERE.margin
130
+ `# _____ _
131
+ `# |_ _|__ ___| |_
132
+ `# | |/ _ \\/ __| __|
133
+ `# | | __/\\__ \\ |_
134
+ `# |_|\\___||___/\\__|
135
+ `#
136
+ `# for #{file}
137
+ `#
138
+ `# Extracted #{Time.now}
139
+ `# Unit Tools Reap Test Extractor
140
+ `#
141
+ `
142
+ `#{reqf}
143
+ `
144
+ HERE
145
+ teststr << testing << "\n"
146
+ teststr
147
+ end
148
+
149
+ end
150
+
151
+ end #module Reap
@@ -0,0 +1,62 @@
1
+ #--
2
+ #++
3
+
4
+ #require 'digest/md5'
5
+
6
+ module Reap
7
+
8
+ # = Filer
9
+ #
10
+ #
11
+
12
+ class Filer
13
+
14
+ include TaskUtils
15
+
16
+ attr_accessor :source
17
+
18
+ def initialize( name, source, &build )
19
+ @name = name
20
+ @source = [source].flatten
21
+ @build = build
22
+ end
23
+
24
+ # Is this file task needed? Yes if it doesn't exist, or if its time
25
+ # stamp is out of date.
26
+ def needed?
27
+ return true unless ::File.exist?( @name )
28
+ return true if out_of_date?( timestamp( @name ) )
29
+ false
30
+ end
31
+
32
+ # Check timestamp.
33
+ def timestamp( name )
34
+ if ::File.exist?( name.to_s )
35
+ ::File.mtime( name.to_s )
36
+ else
37
+ Time::EARLY # TODO replace with Facets' -Infinity class (?)
38
+ end
39
+ end
40
+
41
+ # Are there any sources with a later time than the given timestamp?
42
+ def out_of_date?( stamp )
43
+ @source.any? { |n| timestamp(n) > stamp }
44
+ end
45
+
46
+ # Build file.
47
+
48
+ def build
49
+ @build.call if needed?
50
+ end
51
+
52
+ alias_method :call, :build
53
+
54
+ private
55
+
56
+ #def salt( file )
57
+ # Digest::MD5.new( File.read( file ) ).hexdigest
58
+ #end
59
+
60
+ end
61
+
62
+ end #module Reap
@@ -0,0 +1,178 @@
1
+ require 'rbconfig'
2
+ require 'fileutils'
3
+
4
+ module Reap
5
+
6
+ # = Installer
7
+ #
8
+ # The Installer class generates a specialized install.rb
9
+ # script specifically for your project. It currently
10
+ # does not support c/c++ ext/ compilation.
11
+
12
+ class Installer
13
+
14
+ include TaskUtils
15
+
16
+ def self.config(name)
17
+ # XXX use pathname
18
+ prefix = Regexp.quote(Config::CONFIG["prefix"])
19
+ exec_prefix = Regexp.quote(Config::CONFIG["exec_prefix"])
20
+ Config::CONFIG[name].gsub(/\A\/?(#{prefix}|#{exec_prefix})\/?/, '')
21
+ end
22
+
23
+ KINDS = [
24
+ :bin, :lib, :ext, :data, :conf, :doc
25
+ ]
26
+
27
+ SITE_DIRS = {
28
+ :bin => config("bindir"),
29
+ :lib => config("sitelibdir"),
30
+ :ext => config("sitearchdir"),
31
+ :data => config("datadir"),
32
+ :conf => config("sysconfdir"),
33
+ :doc => File.join(config("datadir"), "doc"),
34
+ }
35
+
36
+ VEND_DIRS = {
37
+ :bin => config("bindir"),
38
+ :lib => config("rubylibdir"),
39
+ :ext => config("archdir"),
40
+ :data => config("datadir"),
41
+ :conf => config("sysconfdir"),
42
+ :doc => File.join(config("datadir"), "doc"),
43
+ }
44
+
45
+ MODES = {
46
+ :bin => 0755,
47
+ :lib => 0644,
48
+ :ext => 0755, # was: 0555,
49
+ :data => 0644,
50
+ :conf => 0644,
51
+ :doc => 0644,
52
+ }
53
+
54
+ attr_accessor :trunk, :template, :options
55
+
56
+ def initialize( ins )
57
+ super
58
+ @trunk = '.' unless @trunk
59
+ @spec = parse( @template )
60
+ @transfer = Hash.new { |h,k| h[k] = [] }
61
+ end
62
+
63
+ #--
64
+ # TODO use shellwords
65
+ #++
66
+ def parse( spec )
67
+ lines = spec.strip.split("\n")
68
+ lines.each { |line|
69
+ words = line.strip.split(/\s+/)
70
+ send( *words )
71
+ }
72
+ end
73
+
74
+ # substitute variables
75
+ def vsub( str )
76
+ return nil if str.nil?
77
+ str = str.gsub( '$version', @options[:version].to_s )
78
+ str = str.gsub( '$name', @options[:name].to_s )
79
+ str
80
+ end
81
+
82
+ # Return the installation directory.
83
+ def dir( kind, mode=:site )
84
+ case mode
85
+ when :site
86
+ SITE_DIRS[ kind ]
87
+ when :vendor
88
+ VEND_DIRS[ kind ]
89
+ else
90
+ raise ArgumentError, "unknown mode -- #{mode}"
91
+ end
92
+ end
93
+
94
+ # Return installation prefix.
95
+ def prefix( kind )
96
+ Config::CONFIG["prefix"]
97
+ end
98
+
99
+ #--
100
+ # DSL methods for setting installation spec.
101
+ #++
102
+
103
+ # Setup a lib installation transfer.
104
+ def lib( from, glob, to )
105
+ to = '' if to == '.'
106
+ @transfer[:lib] << { :from=>vsub(from), :glob=>vsub(glob), :to=>vsub(to) }
107
+ end
108
+
109
+ # Setup a bin installation transfer.
110
+ def bin( from, glob, to )
111
+ to = '' if to == '.'
112
+ @transfer[:bin] << { :from=>vsub(from), :glob=>vsub(glob), :to=>vsub(to) }
113
+ end
114
+
115
+ # Compile script and write to install file (install.rb).
116
+
117
+ def compile_and_write
118
+ script = ""
119
+ script << "# INSTALL SCRIPT\n"
120
+ script << "# Generated by Reap\n"
121
+ script << "# #{Time.now}\n"
122
+ script << "\n"
123
+ script << compile
124
+ script << "\n"
125
+ script << "# END"
126
+
127
+ write( script )
128
+ end
129
+
130
+ alias_method :call, :compile_and_write
131
+
132
+ private
133
+
134
+ # Compile installation instructions.
135
+
136
+ def compile
137
+ mkdirp = []
138
+ script = ''
139
+ Dir.chdir( @trunk ) do
140
+ KINDS.each { |kind|
141
+ @transfer[kind].each { |trans|
142
+ next unless File.directory?( trans[:from] )
143
+ files = []
144
+ Dir.chdir( trans[:from] ) {
145
+ files = Dir.glob( trans[:glob] ).reject { |f| File.directory?( f ) }
146
+ }
147
+ files.each { |file|
148
+ f = File.join( trans[:from], file )
149
+ t = File.join( prefix(kind), dir(kind), trans[:to], file )
150
+ m = MODES[kind]
151
+ d = File.dirname(t)
152
+ unless mkdirp.include?(d)
153
+ script << "mkdir_p '%s'\n" % d
154
+ mkdirp << d
155
+ end
156
+ script << "install '%s', '%s', :mode=>%o\n" % [ f, t, m ]
157
+ }
158
+ }
159
+ }
160
+ end
161
+ script
162
+ end
163
+
164
+ def write( script )
165
+ install_file = File.join( @trunk, 'install.rb' )
166
+ if File.file?( install_file )
167
+ script_template = File.read( install_file )
168
+ script = script_template.gsub(/\# INSTALL SCRIPT.*\# END/, script)
169
+ end
170
+ File.open( install_file, 'w+' ) do |f|
171
+ f << script
172
+ end
173
+ end
174
+ end
175
+
176
+ end
177
+
178
+ end #module Reap