ratch 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. data/bin/ratch +60 -47
  2. data/bin/ratch-find +21 -0
  3. data/demo/{README → XR} +0 -0
  4. data/demo/task/stats +0 -2
  5. data/doc/images/clipboard.jpg +0 -0
  6. data/doc/images/clipboard2.png +0 -0
  7. data/doc/images/milles-tn.jpg +0 -0
  8. data/doc/images/mints.png +0 -0
  9. data/doc/images/ratch2.png +0 -0
  10. data/doc/images/ruby-sm.png +0 -0
  11. data/doc/images/silver.gif +0 -0
  12. data/doc/images/toolbox.jpg +0 -0
  13. data/doc/index.html +181 -0
  14. data/doc/notes/original.rb +308 -0
  15. data/doc/rdoc/classes/Array.html +194 -0
  16. data/doc/rdoc/classes/Dir.html +317 -0
  17. data/doc/rdoc/classes/Hash.html +217 -0
  18. data/doc/rdoc/classes/Ratch.html +201 -0
  19. data/doc/rdoc/classes/Ratch/ArgvUtils.html +173 -0
  20. data/doc/rdoc/classes/Ratch/ArgvUtils/Ext.html +285 -0
  21. data/doc/rdoc/classes/Ratch/BatchFile.html +207 -0
  22. data/doc/rdoc/classes/Ratch/BatchManager.html +250 -0
  23. data/doc/rdoc/classes/Ratch/BatchScript.html +127 -0
  24. data/doc/rdoc/classes/Ratch/Batchable.html +373 -0
  25. data/doc/rdoc/classes/Ratch/Build.html +321 -0
  26. data/doc/rdoc/classes/Ratch/BuildManager.html +319 -0
  27. data/doc/rdoc/classes/Ratch/Buildable.html +202 -0
  28. data/doc/rdoc/classes/Ratch/ConfigUtils.html +281 -0
  29. data/doc/rdoc/classes/Ratch/ConsoleUtils.html +189 -0
  30. data/doc/rdoc/classes/Ratch/EmailUtils.html +209 -0
  31. data/doc/rdoc/classes/Ratch/FileUtils.html +674 -0
  32. data/doc/rdoc/classes/Ratch/GeneralOptions.html +430 -0
  33. data/doc/rdoc/classes/Ratch/Task.html +201 -0
  34. data/doc/rdoc/classes/Ratch/TaskManager.html +330 -0
  35. data/doc/rdoc/classes/Ratch/Taskable.html +231 -0
  36. data/doc/rdoc/classes/Ratch/UploadUtils.html +566 -0
  37. data/doc/rdoc/created.rid +1 -0
  38. data/doc/rdoc/files/COPYING.html +1003 -0
  39. data/{demo/doc → doc}/rdoc/files/README.html +36 -5
  40. data/doc/rdoc/files/lib/ratch/argvutils_rb.html +131 -0
  41. data/doc/rdoc/files/lib/ratch/batch_rb.html +155 -0
  42. data/doc/rdoc/files/lib/ratch/batchable_rb.html +131 -0
  43. data/doc/rdoc/files/lib/ratch/batchfile_rb.html +148 -0
  44. data/doc/rdoc/files/lib/ratch/buildable_rb.html +131 -0
  45. data/doc/rdoc/files/lib/ratch/consoleutils_rb.html +131 -0
  46. data/{demo/doc/rdoc/files/lib/foo/foo_rb.html → doc/rdoc/files/lib/ratch/emailutils_rb.html} +35 -41
  47. data/doc/rdoc/files/lib/ratch/facets/multiglob_rb.html +137 -0
  48. data/doc/rdoc/files/lib/ratch/fileutils_rb.html +139 -0
  49. data/doc/rdoc/files/lib/ratch/options_rb.html +131 -0
  50. data/doc/rdoc/files/lib/ratch/taskable_rb.html +131 -0
  51. data/doc/rdoc/files/lib/ratch/uploadutils_rb.html +150 -0
  52. data/doc/rdoc/fr_class_index.html +48 -0
  53. data/doc/rdoc/fr_file_index.html +41 -0
  54. data/doc/rdoc/fr_method_index.html +133 -0
  55. data/{demo/doc → doc}/rdoc/index.html +1 -1
  56. data/{demo/doc → doc}/rdoc/rdoc-style.css +0 -0
  57. data/doc/scrap/flexihead-flip.jpg +0 -0
  58. data/doc/scrap/flexihead.jpg +0 -0
  59. data/doc/scrap/head1.jpg +0 -0
  60. data/doc/scrap/ratch.jpg +0 -0
  61. data/doc/scrap/ratch1.png +0 -0
  62. data/doc/scrap/ratch2.jpg +0 -0
  63. data/doc/scrap/ratch3.png +0 -0
  64. data/doc/scrap/red-ratch.jpg +0 -0
  65. data/doc/scrap/redratchet.jpg +0 -0
  66. data/doc/scrap/ruby-kit/ruby.png +0 -0
  67. data/doc/scrap/scrap.red +256 -0
  68. data/doc/sitemap.yaml +10 -0
  69. data/doc/siteparts/index.red +100 -0
  70. data/doc/siteparts/layout.rhtml +56 -0
  71. data/doc/siteparts/tutorial.red +578 -0
  72. data/doc/style.css +112 -0
  73. data/doc/tutorial.html +722 -0
  74. data/lib/ratch/batch.rb +417 -30
  75. data/lib/ratch/{argvutils.rb → batch/argvutils.rb} +27 -19
  76. data/lib/ratch/batch/build.rb +95 -0
  77. data/lib/ratch/{consoleutils.rb → batch/consoleutils.rb} +0 -0
  78. data/lib/ratch/{emailutils.rb → batch/emailutils.rb} +0 -0
  79. data/lib/ratch/{fileutils.rb → batch/fileutils.rb} +32 -32
  80. data/lib/ratch/{options.rb → batch/options.rb} +0 -0
  81. data/lib/ratch/batch/task.rb +43 -0
  82. data/lib/ratch/manager.rb +34 -0
  83. data/lib/ratch/project/information.rb +257 -0
  84. data/lib/ratch/project/package.rb +82 -0
  85. data/lib/ratch/project/project.rb +531 -0
  86. data/lib/ratch/project/release.rb +112 -0
  87. data/lib/ratch/support/filetest.rb +29 -0
  88. data/lib/ratch/support/setuputils.rb +124 -0
  89. data/lib/ratch/support/signiture.rb +252 -0
  90. data/lib/ratch/support/stage.rb +292 -0
  91. data/lib/ratch/toolset/ruby/pack/gem +85 -0
  92. data/lib/ratch/toolset/ruby/pack/tgz +85 -0
  93. data/lib/ratch/toolset/ruby/{crosstest → test/crosstest} +0 -0
  94. data/lib/ratch/toolset/ruby/{extest → test/extest} +0 -0
  95. data/lib/ratch/toolset/ruby/{isotest → test/isotest} +0 -0
  96. data/lib/ratch/toolset/ruby/{load → test/load} +0 -0
  97. data/lib/ratch/toolset/ruby/{loadtest → test/loadtest} +0 -0
  98. data/lib/ratch/toolset/ruby/{syntax → test/syntax} +0 -0
  99. data/lib/ratch/toolset/ruby/{test → test/test} +0 -0
  100. data/log/{history.rd → history} +6 -0
  101. data/log/{todo.rd → todo} +0 -0
  102. data/meta/MANIFEST +52 -36
  103. data/meta/ROLLRC +2 -0
  104. data/meta/icli.yaml +16 -0
  105. data/meta/{ratch-0.2.3.roll → project.yaml} +1 -7
  106. data/task/release +12 -0
  107. data/{lib/ratch → work/old}/batchfile.rb +0 -0
  108. data/work/project-old.rb +67 -0
  109. data/work/scrap/install +89 -0
  110. data/work/scrap/install.0 +49 -0
  111. data/work/scrap/install.1 +63 -0
  112. data/work/scrap/ludo +25 -0
  113. data/work/scrap/oldtaskable.rb +573 -0
  114. data/work/scrap/ratch.man +39 -0
  115. data/work/scrap/taskable-simple.rb +42 -0
  116. data/work/scrap/taskable.rb +120 -0
  117. metadata +170 -72
  118. data/demo/doc/rdoc/created.rid +0 -1
  119. data/demo/doc/rdoc/fr_class_index.html +0 -26
  120. data/demo/doc/rdoc/fr_file_index.html +0 -28
  121. data/demo/doc/rdoc/fr_method_index.html +0 -27
  122. data/demo/task/config.yaml +0 -2
  123. data/lib/ratch/batchable.rb +0 -169
  124. data/lib/ratch/buildable.rb +0 -182
  125. data/lib/ratch/configutils.rb +0 -132
  126. data/lib/ratch/facets/multiglob.rb +0 -160
  127. data/lib/ratch/taskable.rb +0 -152
  128. data/log/recent.rd +0 -8
  129. data/task/config.yaml +0 -10
@@ -0,0 +1,82 @@
1
+ # = TITLE:
2
+ #
3
+ # Package
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 'ratch/project/project'
25
+ require 'ratch/project/release'
26
+
27
+
28
+ module Ratch
29
+
30
+ # = Package Class
31
+ #
32
+ # Package class contains projectinformation but also
33
+ # release information such as current version and release date.
34
+ #
35
+ # Release information is delgated to the Release class via method_missing.
36
+
37
+ class Package < Project
38
+
39
+ def self.load
40
+ package = super
41
+ package.release = Release.load
42
+ package
43
+ end
44
+
45
+ def name
46
+ @name ||= release.name
47
+ end
48
+
49
+ # List of project files included in package.
50
+ #
51
+ # TODO: Read from MANIFEST ?
52
+
53
+ #attr_accessor :filelist
54
+
55
+ # Package format of this package (tar.gz, zip, gem, deb, etc.)
56
+ # For a package this is purely informational.
57
+
58
+ attr_accessor :format, :type
59
+
60
+ # Release information.
61
+
62
+ attr_accessor :release
63
+
64
+ # Delegate to release.
65
+
66
+ def method_missing(s, *a, &b)
67
+ if release.respond_to?(s)
68
+ release.send(s, *a, &b)
69
+ else
70
+ super
71
+ end
72
+ end
73
+
74
+ #
75
+
76
+ #validate "release isnt valid" do
77
+ # release.validate
78
+ #end
79
+
80
+ end
81
+
82
+ end
@@ -0,0 +1,531 @@
1
+ # = TITLE:
2
+ #
3
+ # Project
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 'facets/filelist'
25
+ require 'ratch/project/information'
26
+
27
+
28
+ module Ratch
29
+
30
+ # = Project class
31
+ #
32
+ # The Project class contains three sets of metadata. The first is the
33
+ # typical general information about a project --title, description, homepage, etc.
34
+ # This information is essentially static. Once set, it will probably never vary.
35
+ # The second is default packaging informaiton. These both come from the General base
36
+ # class. The third set is default build information, which may vary well for various
37
+ # packages types, as this information may need to be overridden for specific
38
+ # platform builds and package formats. This information describes how to
39
+ # pack this project into various packages. Hecne it does not belong to the Package
40
+ # class itself.
41
+ #
42
+ # General class is the base class of both the Project and Package classes.
43
+ # The class contains typical general information about a project/package, such
44
+ # as title, description, homepage, etc. This information is essentially static.
45
+ # Once set, it will probably will never vary. The class also contains *defaults*
46
+ # for package informaiton --information that is often static, but may vary
47
+ # for a partciular package platform or format. A good example is the platform
48
+ # attribute.
49
+
50
+ class Project < Information
51
+
52
+ PROJECT_FILE = '{,meta/}{project,package,index}{.yaml,.yml,}'
53
+
54
+ def self.load
55
+ location = Dir.pwd # ???
56
+ file = Dir.glob(PROJECT_FILE, File::FNM_CASEFOLD).first
57
+ if file
58
+ data = YAML::load(File.open(file))
59
+ new(location, data)
60
+ else
61
+ raise LoadError, "project file required -- #{PROJECT_FILE}"
62
+ end
63
+ end
64
+
65
+ # New Project.
66
+
67
+ def initialize(location, data={})
68
+ @location = location
69
+ super(data)
70
+ end
71
+
72
+ # Location is needed to calculate some conventional defaults.
73
+
74
+ attr_accessor :location
75
+
76
+
77
+ # General
78
+ #------------------------------------------------------------------------
79
+
80
+ # The title of the project (free-form, defaults to name).
81
+ attr_accessor :title do
82
+ @title || (
83
+ name if respond_to?(:name)
84
+ )
85
+ end
86
+
87
+ # Subtitle is limited to 60 characters.
88
+ attr_accessor :subtitle do
89
+ @subtitle.to_s[0..59]
90
+ end
91
+
92
+ # Brief one-line description of the package (Max 80 chars.)
93
+ attr_accessor :summary, :brief do
94
+ @summary.to_s[0..79]
95
+ end
96
+
97
+ # More detailed description of the package.
98
+ attr_accessor :description
99
+
100
+ # "Unix" name of the project/package.
101
+ attr_accessor :name
102
+
103
+ # "Unix" name of master project this "sub-project" may belong.
104
+ # (Default is the same as name).
105
+ attr_accessor :project do
106
+ @project || name
107
+ end
108
+
109
+ # The date the project was started.
110
+ attr_accessor :created
111
+
112
+ # Copyright notice.
113
+ attr_accessor :copyright do
114
+ @copyright || "Copyright (c) #{Time.now.strftime('%Y')} #{author}"
115
+ end
116
+
117
+ # Distribution License.
118
+ attr_accessor :license do
119
+ @license || 'GPLv3'
120
+ end
121
+
122
+ # Slogan or "trademark" phrase.
123
+ attr_accessor :slogan
124
+
125
+ # General one-word software category.
126
+ attr_accessor :category
127
+
128
+ # Author(s) of this project.
129
+ # (Usually in "name <email>" format.)
130
+ attr_accessor :author
131
+
132
+ # Contact(s) (defaults to authors).
133
+ # TODO Move to Variants?
134
+ attr_accessor :contact do
135
+ @contact || author
136
+ end
137
+
138
+ # Gerneral email address.
139
+ attr_accessor :email
140
+
141
+ # Official domain associated with this package.
142
+ attr_accessor :domain
143
+
144
+ # Project's homepage.
145
+ attr_accessor :homepage
146
+
147
+ # Project's development site.
148
+ attr_accessor :development, :devsite
149
+
150
+ # Internet address(es) to documentation pages.
151
+ attr_accessor :documentation, :docs
152
+
153
+ # Internet address(es) to downloadable packages.
154
+ attr_accessor :download
155
+
156
+ # Internet address for project wiki.
157
+ attr_accessor :wiki
158
+
159
+ # Project's mailing list.
160
+ attr_accessor :userlist, :mailinglist, :list
161
+
162
+ # Developer's mailing list.
163
+ attr_accessor :devlist do
164
+ @devlist || @userlist
165
+ end
166
+
167
+ # Returns a standard taguri id for the library and release.
168
+ def project_taguri
169
+ "tag:#{name}.#{domain},#{created}" # or released?
170
+ end
171
+
172
+
173
+ # # Version
174
+ # #------------------------------------------------------------------------
175
+ #
176
+ # # Version number (eg. '1.0.0').
177
+ # attr_accessor :version
178
+ #
179
+ # # Current version code name.
180
+ # attr_accessor :codename
181
+ #
182
+ # # Build number can br set to an arbitrar number, or if set to true,
183
+ # # it will defaults to a number based on current date-time.
184
+ #
185
+ # attr_accessor :buildno do
186
+ # @buildno = Time.now.strftime("%y%m%d%H%M") if TrueClass === @buildno
187
+ # @buildno
188
+ # end
189
+
190
+
191
+
192
+ # Content Classification
193
+ #------------------------------------------------------------------------
194
+
195
+ # Files in this package that are executables.
196
+ # These files must in the packages bin/ directory.
197
+ # If left blank all bin/ files are included.
198
+
199
+ attr_accessor :executable, :executables do
200
+ return [@executable].flatten.compact if @executable
201
+ exes = []
202
+ dir = File.join(location, 'bin')
203
+ if File.directory?(dir)
204
+ Dir.chdir(dir) do
205
+ exes = Dir.glob('*')
206
+ end
207
+ end
208
+ @executable = exes
209
+ end
210
+
211
+ # Library files in this package that are *public*.
212
+ # This is akin to load_path but specifies specific files
213
+ # that can be loaded from the outside --where as those
214
+ # not listed are considerd *private*.
215
+ #
216
+ # NOTE: This is not enforced --and may never be. It
217
+ # complicates library loading. Ie. how to distinguish public
218
+ # loading from external loading. But it something that can be
219
+ # consider more carfully in the future. For now it can serve
220
+ # as an optional reference.
221
+ attr_accessor :library, :libraries do
222
+ [@library || 'lib/**/*'].flatten
223
+ end
224
+
225
+ # Location(s) of executables.
226
+ attr_accessor :bin_path, :bin_paths
227
+
228
+ # Root location(s) of libraries (used by Rolls).
229
+ # If you plan to support Gems, this would be something like:
230
+ #
231
+ # 'lib/facets'
232
+ #
233
+ # If not, then the default ('lib') is nice b/c it means one less
234
+ # layer in your project heirarchy.
235
+ attr_accessor :lib_path, :lib_paths, :load_path, :load_paths do
236
+ [@lib_path || 'lib'].flatten
237
+ end
238
+
239
+ # Traditional load path (used by RubyGems).
240
+ # The default is 'lib', which is usually fine.
241
+ attr_accessor :gem_path, :gem_paths do
242
+ [@gem_path || 'lib'].flatten
243
+ end
244
+
245
+
246
+ # Security
247
+ #------------------------------------------------------------------------
248
+
249
+ # Encryption digest type used.
250
+ # (md5, sha1, sha128, sha256, sha512).
251
+ attr_accessor :digest do
252
+ @digest || 'md5'
253
+ end
254
+
255
+ # Public key file associated with this library. This is useful
256
+ # for security purposes especially remote loading. [pubkey.pem]
257
+ attr_accessor :public_key do
258
+ @public_key || 'pubkey.pem'
259
+ end
260
+
261
+ # Private key file associated with this library. This is useful
262
+ # for security purposes especially remote loading. [_privkey.pem]
263
+ attr_accessor :private_key
264
+ # @private_key || '_privkey.pem'
265
+ # end
266
+
267
+
268
+ # Source Management
269
+ #------------------------------------------------------------------------
270
+
271
+ # Specify which verison control system is being used.
272
+ # Sometimes this is autmatically detectable, but it
273
+ # is better to specify it.
274
+
275
+ # Specifices the type of revision control system used.
276
+ # darcs, svn, cvs, etc.
277
+ # Will try to determine which version control system is being used.
278
+ attr_accessor :scm do
279
+ return @scm unless @scm.nil?
280
+ @scm = if File.directory?('.svn')
281
+ 'svn'
282
+ elsif File.directory?('_darcs')
283
+ 'darcs'
284
+ else
285
+ false
286
+ end
287
+ end
288
+
289
+ # Files that are tracked under revision control.
290
+ # Default is all less standard exceptions.
291
+ # '+' and '-' prefixes can be used to augment the list
292
+ # rather than fully override it.
293
+ attr_accessor :track, :scm_files
294
+
295
+ # Internet address to source code repository.
296
+ # (http://, ftp://, etc.)
297
+ attr_accessor :repository, :repo
298
+
299
+ # Changelog file.
300
+ attr_accessor :changelog
301
+
302
+ # Manifest file. Defaults to 'MANIFEST'.
303
+ # (I like to put it in meta/MANIFEST, personally.)
304
+ attr_accessor :manifest do
305
+ @manifest ||= 'MANIFEST'
306
+ end
307
+
308
+
309
+ # Dependencies
310
+ #------------------------------------------------------------------------
311
+ # Package inter-relationship data. Generally refered to as package
312
+ # "dependencies", but also includes +recommendations+, +suggestions+,
313
+ # +replacements+, +provisions+, and +build-dependencies+, as well
314
+ # as a few other fields that set a package apart.
315
+ #------------------------------------------------------------------------
316
+
317
+ # What other packages *must* this package have in order to function.
318
+ attr_accessor :dependency, :dependencies do
319
+ @dependency || []
320
+ end
321
+
322
+ # What other packages *should* be used with this package.
323
+ attr_accessor :recommend, :recommends, :recommendations do
324
+ @recommend || []
325
+ end
326
+
327
+ # What other packages *could* be useful with this package.
328
+ attr_accessor :suggest, :suggests, :suggestions do
329
+ @suggest || []
330
+ end
331
+
332
+ # What other packages does this package conflict.
333
+ attr_accessor :conflict, :conflicts do
334
+ @conflict || []
335
+ end
336
+
337
+ # What other packages does this package replace.
338
+ attr_accessor :replace, :replaces, :replacements do
339
+ @replace || []
340
+ end
341
+
342
+ # What other package(s) does this package provide the same dependency fulfilment.
343
+ # For example, a package 'bar-plus' might fulfill the same dependency criteria
344
+ # as package 'bar', so 'bar-plus' is said to provide 'bar'.
345
+ attr_accessor :provide, :provides, :provisions do
346
+ @provide || []
347
+ end
348
+
349
+ # Abirtary information about what might be needed to use this package.
350
+ # This is strictly information for the end-user to consider.
351
+ # Eg. "Fast graphics card"
352
+ attr_accessor :requirement, :requirements do
353
+ @requirement || []
354
+ end
355
+
356
+ # What packages does this package need to build? (eg. 'rake', 'ratch', etc.)
357
+ attr_accessor :build_dependency, :build_dependencies do
358
+ @build_dependency || []
359
+ end
360
+
361
+ # Abirtary information about what might be needed to build this package.
362
+ attr_accessor :build_requirement, :build_requirements do
363
+ @build_requirement || []
364
+ end
365
+
366
+
367
+ # Packaging
368
+ #------------------------------------------------------------------------
369
+
370
+ # Platform. The default is nil, which is considered cross-platform.
371
+ # This tends to only change for special builds.
372
+ #
373
+ # TODO: if current?
374
+
375
+ attr_accessor :platform
376
+
377
+ # Architecture(s) this package can be run on: any, i386, i686, ppc, etc.
378
+ # This is strictly informational and is inteded to indicate the possiblities,
379
+ # not the particular platform this package runs on.
380
+
381
+ #attr_accessor :arch, :architecture do
382
+ # @arch || "any"
383
+ #end
384
+
385
+ # Script to run prior to build. No entry indicates no compilation.
386
+ attr_accessor :compile
387
+
388
+ # Packages that are intended to compile on install may need this. It is a list
389
+ # of "extension scripts" which generate Makefiles for use in compilation.
390
+ attr_accessor :extensions do
391
+ [@extensions || Dir.glob(File.join(location, 'ext/**/extconf.rb'))].flatten.compact
392
+ end
393
+
394
+ #
395
+ #validate "compile script not found" do
396
+ # compile ? File.file?(compile) : true
397
+ #end
398
+
399
+ # Package name. This defaults to name, but is here b/c it may
400
+ # vary under different packagings (deb vs. gem).
401
+ attr_accessor :package do
402
+ @package || (
403
+ name if respond_to?(:name)
404
+ )
405
+ end
406
+
407
+ # Generate documentation on installation?
408
+ attr_accessor :document
409
+
410
+ # Package name is in the form of +name-version+, or
411
+ # +name-version-arch+ if +arch+ is not 'any', 'all' or nil.
412
+ #
413
+ # TODO Not sure how this can work actually. What about
414
+ # multiple architectures?
415
+ def package_name
416
+ case platform
417
+ when 'any', 'all', nil
418
+ "#{package}-#{version}"
419
+ else
420
+ "#{package}-#{version}-#{platform}"
421
+ end
422
+ end
423
+
424
+
425
+ # Distribution
426
+ #------------------------------------------------------------------------
427
+
428
+ # Files to be distributed in a package. Defaults to all files.
429
+ # If an entry is a directory then all it's contents are also included.
430
+ # This along with @exclude@ and @ignore@ is used to generate a manifest.
431
+ attr_accessor :distribute, :include do
432
+ [@distribute || '**/*'].flatten.compact
433
+ end
434
+
435
+ # File to exclude from package. This is usually more useful than
436
+ # @distribute@, as it allows you to remove from all files, rather then
437
+ # explicitly designate everything to be included. Exlcusions have priority
438
+ # over dsitribute's inclusions. If an entry is a directory then all
439
+ # it's contents are also excluded.
440
+ attr_accessor :exclude do
441
+ [@exclude].flatten.compact
442
+ end
443
+
444
+ # Files to generally ignore, mainly used for manifest collection. Ignore
445
+ # has priority over @exclude@ and @distribute@.
446
+ attr_accessor :ignore do
447
+ @ignore || %w{ **/.svn _darcs .config .installed }
448
+ end
449
+
450
+ # Add version tiers to package? If true a package's lib/ and ext/ files
451
+ # will be wrapped in a version folder. (This is specialized transfer rule.)
452
+ #attr_accessor :tier
453
+
454
+ # Manifest file.
455
+ #def manifest
456
+ # @manifest #||= Manifest.open
457
+ #end
458
+
459
+ # Set manifest file, which will load it.
460
+ #def manifest=(file)
461
+ # @manifest = file
462
+ # @filelist = File.read_list(file) #Manifest.open(file)
463
+ # return file
464
+ #end
465
+
466
+ # List of file included in a package. This is generated using
467
+ # @distribute@, @exlude@ and @ignore@.
468
+ def filelist
469
+ @filelist ||= collect_files(true)
470
+ end
471
+
472
+ # Validate that the files in the manifest actually exist.
473
+ #def validate_manifest
474
+ # missing = []
475
+ # filelist.each do |f|
476
+ # missing << f unless File.exist?(f)
477
+ # end
478
+ # unless missing.empty?
479
+ # raise ValidationError, "manifest lists non-existent files -- " + missing.join(" ")
480
+ # end
481
+ #end
482
+
483
+ private
484
+
485
+ # Collect distribution files.
486
+
487
+ def collect_files(with_dirs=false)
488
+ files = FileList.new
489
+
490
+ Dir.chdir(location) do
491
+ files.include(*distribute)
492
+ files.exclude(*exclude)
493
+ files.exclude(*ignore)
494
+ end
495
+
496
+ files = files.to_a
497
+
498
+ # TODO: is there a way to do this with FileList?
499
+ unless with_dirs
500
+ files = files.select{ |f| !File.directory?(f) }
501
+ end
502
+
503
+ return files
504
+ end
505
+
506
+
507
+ # Validation
508
+ #------------------------------------------------------------------------
509
+
510
+ public
511
+
512
+ #
513
+ validate "location is required" do
514
+ location
515
+ end
516
+
517
+ #
518
+ validate "executables do not exist" do
519
+ exes = []
520
+ dir = File.join(location, 'bin')
521
+ if File.directory?(dir)
522
+ Dir.chdir(dir) do
523
+ exes = Dir.glob('*')
524
+ end
525
+ end
526
+ (executables - exes).empty?
527
+ end
528
+
529
+ end
530
+
531
+ end