ratch 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/ratch +60 -47
- data/bin/ratch-find +21 -0
- data/demo/{README → XR} +0 -0
- data/demo/task/stats +0 -2
- data/doc/images/clipboard.jpg +0 -0
- data/doc/images/clipboard2.png +0 -0
- data/doc/images/milles-tn.jpg +0 -0
- data/doc/images/mints.png +0 -0
- data/doc/images/ratch2.png +0 -0
- data/doc/images/ruby-sm.png +0 -0
- data/doc/images/silver.gif +0 -0
- data/doc/images/toolbox.jpg +0 -0
- data/doc/index.html +181 -0
- data/doc/notes/original.rb +308 -0
- data/doc/rdoc/classes/Array.html +194 -0
- data/doc/rdoc/classes/Dir.html +317 -0
- data/doc/rdoc/classes/Hash.html +217 -0
- data/doc/rdoc/classes/Ratch.html +201 -0
- data/doc/rdoc/classes/Ratch/ArgvUtils.html +173 -0
- data/doc/rdoc/classes/Ratch/ArgvUtils/Ext.html +285 -0
- data/doc/rdoc/classes/Ratch/BatchFile.html +207 -0
- data/doc/rdoc/classes/Ratch/BatchManager.html +250 -0
- data/doc/rdoc/classes/Ratch/BatchScript.html +127 -0
- data/doc/rdoc/classes/Ratch/Batchable.html +373 -0
- data/doc/rdoc/classes/Ratch/Build.html +321 -0
- data/doc/rdoc/classes/Ratch/BuildManager.html +319 -0
- data/doc/rdoc/classes/Ratch/Buildable.html +202 -0
- data/doc/rdoc/classes/Ratch/ConfigUtils.html +281 -0
- data/doc/rdoc/classes/Ratch/ConsoleUtils.html +189 -0
- data/doc/rdoc/classes/Ratch/EmailUtils.html +209 -0
- data/doc/rdoc/classes/Ratch/FileUtils.html +674 -0
- data/doc/rdoc/classes/Ratch/GeneralOptions.html +430 -0
- data/doc/rdoc/classes/Ratch/Task.html +201 -0
- data/doc/rdoc/classes/Ratch/TaskManager.html +330 -0
- data/doc/rdoc/classes/Ratch/Taskable.html +231 -0
- data/doc/rdoc/classes/Ratch/UploadUtils.html +566 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/COPYING.html +1003 -0
- data/{demo/doc → doc}/rdoc/files/README.html +36 -5
- data/doc/rdoc/files/lib/ratch/argvutils_rb.html +131 -0
- data/doc/rdoc/files/lib/ratch/batch_rb.html +155 -0
- data/doc/rdoc/files/lib/ratch/batchable_rb.html +131 -0
- data/doc/rdoc/files/lib/ratch/batchfile_rb.html +148 -0
- data/doc/rdoc/files/lib/ratch/buildable_rb.html +131 -0
- data/doc/rdoc/files/lib/ratch/consoleutils_rb.html +131 -0
- data/{demo/doc/rdoc/files/lib/foo/foo_rb.html → doc/rdoc/files/lib/ratch/emailutils_rb.html} +35 -41
- data/doc/rdoc/files/lib/ratch/facets/multiglob_rb.html +137 -0
- data/doc/rdoc/files/lib/ratch/fileutils_rb.html +139 -0
- data/doc/rdoc/files/lib/ratch/options_rb.html +131 -0
- data/doc/rdoc/files/lib/ratch/taskable_rb.html +131 -0
- data/doc/rdoc/files/lib/ratch/uploadutils_rb.html +150 -0
- data/doc/rdoc/fr_class_index.html +48 -0
- data/doc/rdoc/fr_file_index.html +41 -0
- data/doc/rdoc/fr_method_index.html +133 -0
- data/{demo/doc → doc}/rdoc/index.html +1 -1
- data/{demo/doc → doc}/rdoc/rdoc-style.css +0 -0
- data/doc/scrap/flexihead-flip.jpg +0 -0
- data/doc/scrap/flexihead.jpg +0 -0
- data/doc/scrap/head1.jpg +0 -0
- data/doc/scrap/ratch.jpg +0 -0
- data/doc/scrap/ratch1.png +0 -0
- data/doc/scrap/ratch2.jpg +0 -0
- data/doc/scrap/ratch3.png +0 -0
- data/doc/scrap/red-ratch.jpg +0 -0
- data/doc/scrap/redratchet.jpg +0 -0
- data/doc/scrap/ruby-kit/ruby.png +0 -0
- data/doc/scrap/scrap.red +256 -0
- data/doc/sitemap.yaml +10 -0
- data/doc/siteparts/index.red +100 -0
- data/doc/siteparts/layout.rhtml +56 -0
- data/doc/siteparts/tutorial.red +578 -0
- data/doc/style.css +112 -0
- data/doc/tutorial.html +722 -0
- data/lib/ratch/batch.rb +417 -30
- data/lib/ratch/{argvutils.rb → batch/argvutils.rb} +27 -19
- data/lib/ratch/batch/build.rb +95 -0
- data/lib/ratch/{consoleutils.rb → batch/consoleutils.rb} +0 -0
- data/lib/ratch/{emailutils.rb → batch/emailutils.rb} +0 -0
- data/lib/ratch/{fileutils.rb → batch/fileutils.rb} +32 -32
- data/lib/ratch/{options.rb → batch/options.rb} +0 -0
- data/lib/ratch/batch/task.rb +43 -0
- data/lib/ratch/manager.rb +34 -0
- data/lib/ratch/project/information.rb +257 -0
- data/lib/ratch/project/package.rb +82 -0
- data/lib/ratch/project/project.rb +531 -0
- data/lib/ratch/project/release.rb +112 -0
- data/lib/ratch/support/filetest.rb +29 -0
- data/lib/ratch/support/setuputils.rb +124 -0
- data/lib/ratch/support/signiture.rb +252 -0
- data/lib/ratch/support/stage.rb +292 -0
- data/lib/ratch/toolset/ruby/pack/gem +85 -0
- data/lib/ratch/toolset/ruby/pack/tgz +85 -0
- data/lib/ratch/toolset/ruby/{crosstest → test/crosstest} +0 -0
- data/lib/ratch/toolset/ruby/{extest → test/extest} +0 -0
- data/lib/ratch/toolset/ruby/{isotest → test/isotest} +0 -0
- data/lib/ratch/toolset/ruby/{load → test/load} +0 -0
- data/lib/ratch/toolset/ruby/{loadtest → test/loadtest} +0 -0
- data/lib/ratch/toolset/ruby/{syntax → test/syntax} +0 -0
- data/lib/ratch/toolset/ruby/{test → test/test} +0 -0
- data/log/{history.rd → history} +6 -0
- data/log/{todo.rd → todo} +0 -0
- data/meta/MANIFEST +52 -36
- data/meta/ROLLRC +2 -0
- data/meta/icli.yaml +16 -0
- data/meta/{ratch-0.2.3.roll → project.yaml} +1 -7
- data/task/release +12 -0
- data/{lib/ratch → work/old}/batchfile.rb +0 -0
- data/work/project-old.rb +67 -0
- data/work/scrap/install +89 -0
- data/work/scrap/install.0 +49 -0
- data/work/scrap/install.1 +63 -0
- data/work/scrap/ludo +25 -0
- data/work/scrap/oldtaskable.rb +573 -0
- data/work/scrap/ratch.man +39 -0
- data/work/scrap/taskable-simple.rb +42 -0
- data/work/scrap/taskable.rb +120 -0
- metadata +170 -72
- data/demo/doc/rdoc/created.rid +0 -1
- data/demo/doc/rdoc/fr_class_index.html +0 -26
- data/demo/doc/rdoc/fr_file_index.html +0 -28
- data/demo/doc/rdoc/fr_method_index.html +0 -27
- data/demo/task/config.yaml +0 -2
- data/lib/ratch/batchable.rb +0 -169
- data/lib/ratch/buildable.rb +0 -182
- data/lib/ratch/configutils.rb +0 -132
- data/lib/ratch/facets/multiglob.rb +0 -160
- data/lib/ratch/taskable.rb +0 -152
- data/log/recent.rd +0 -8
- data/task/config.yaml +0 -10
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
# = TITLE:
|
|
2
|
+
#
|
|
3
|
+
# Build
|
|
4
|
+
#
|
|
5
|
+
# = COPYING:
|
|
6
|
+
#
|
|
7
|
+
# Copyright (c) 2007 Psi T Corp.
|
|
8
|
+
#
|
|
9
|
+
# This file is part of the ProUtils' Box program.
|
|
10
|
+
#
|
|
11
|
+
# Box 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
|
+
# Box 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 Box. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
+
|
|
24
|
+
require 'fileutils'
|
|
25
|
+
require 'facets/string/lchomp'
|
|
26
|
+
require 'facets/hash/rekey'
|
|
27
|
+
require 'facets/hash/slice'
|
|
28
|
+
|
|
29
|
+
require 'box/buildutils'
|
|
30
|
+
|
|
31
|
+
module Box
|
|
32
|
+
|
|
33
|
+
# Error when attempting to overwrite prexisting package.
|
|
34
|
+
# Presently this is triggered by the existance of the stage
|
|
35
|
+
# directory, not any specific package file.
|
|
36
|
+
|
|
37
|
+
class OverwriteError < Exception
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Build packages for a given platform. It servers as the basis
|
|
41
|
+
# of all package building for Box. It does this by first staging
|
|
42
|
+
# the package, ie. hard linking it to the store location,
|
|
43
|
+
# then it generates each package format from it.
|
|
44
|
+
|
|
45
|
+
class Build
|
|
46
|
+
|
|
47
|
+
include BuildUtils
|
|
48
|
+
|
|
49
|
+
attr_reader :location
|
|
50
|
+
|
|
51
|
+
attr_reader :project
|
|
52
|
+
|
|
53
|
+
attr_reader :release
|
|
54
|
+
|
|
55
|
+
#attr_reader :build
|
|
56
|
+
|
|
57
|
+
# General options. These are parsed and then passed on to the per-format builders.
|
|
58
|
+
# TODO: Fully enforce the dryrun and force options.
|
|
59
|
+
attr_reader :options
|
|
60
|
+
|
|
61
|
+
# Whether to include all files, not just manifests.
|
|
62
|
+
#attr_reader :all
|
|
63
|
+
|
|
64
|
+
# New package builder.
|
|
65
|
+
#
|
|
66
|
+
# INPUT:
|
|
67
|
+
# location Project location
|
|
68
|
+
# project Project metadata
|
|
69
|
+
# release Release metadata, eg. version number.
|
|
70
|
+
# build Build data hash. This generally differs b/c of platform binary builds.
|
|
71
|
+
# options Overrides and runtime options.
|
|
72
|
+
#
|
|
73
|
+
# Options can be
|
|
74
|
+
# types/formats Override build specified types
|
|
75
|
+
# store Override build specified store
|
|
76
|
+
# force Force build (overwrite old build of same name)
|
|
77
|
+
# dryrun Dry-run mode (NOT YET FULLY ENFORCED!)
|
|
78
|
+
|
|
79
|
+
def initialize(location, project, release, build, options={})
|
|
80
|
+
@location = location
|
|
81
|
+
|
|
82
|
+
# per-build project
|
|
83
|
+
project = project.clone
|
|
84
|
+
project.update(build)
|
|
85
|
+
|
|
86
|
+
@project = project
|
|
87
|
+
@release = release
|
|
88
|
+
@options = options
|
|
89
|
+
|
|
90
|
+
assert_valid
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
#
|
|
94
|
+
|
|
95
|
+
def assert_valid
|
|
96
|
+
raise "missing location" unless location
|
|
97
|
+
raise "missing project" unless project
|
|
98
|
+
raise "missing release" unless release
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
#
|
|
102
|
+
|
|
103
|
+
def package
|
|
104
|
+
@package ||= (
|
|
105
|
+
package = project.instance_data
|
|
106
|
+
#package.update(build)
|
|
107
|
+
package[:release] = release
|
|
108
|
+
package[:filelist] = project.filelist
|
|
109
|
+
#package.rekey!
|
|
110
|
+
Package.new(location, package)
|
|
111
|
+
)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Force otherwise protected operations.
|
|
115
|
+
|
|
116
|
+
def force? ; @options[:force] ; end
|
|
117
|
+
|
|
118
|
+
# Dryrun mode? (NOT FULLY ENFORCED YET)
|
|
119
|
+
|
|
120
|
+
def dryrun? ; @options[:dryrun] ; end
|
|
121
|
+
|
|
122
|
+
# Which package formats to create.
|
|
123
|
+
|
|
124
|
+
def formats
|
|
125
|
+
@formats ||= (
|
|
126
|
+
[project.formats].flatten.collect{ |f| f.to_s.downcase.lchomp('.') }
|
|
127
|
+
)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Where to store the created package(s).
|
|
131
|
+
|
|
132
|
+
def store
|
|
133
|
+
@project.store
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# # Template for stage directory name. Defaults to "%s-%s" for name-version or
|
|
137
|
+
# # "%s-%s-%s for name-version-platform."
|
|
138
|
+
# #
|
|
139
|
+
# def stage_name
|
|
140
|
+
# #@stage_name ||= project.stage_name
|
|
141
|
+
# end
|
|
142
|
+
|
|
143
|
+
# Where to stage the build.
|
|
144
|
+
|
|
145
|
+
def stage_directory
|
|
146
|
+
@stage_directory ||= File.join(store, stage_name)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Create package(s).
|
|
150
|
+
|
|
151
|
+
def generate
|
|
152
|
+
generate_extensions
|
|
153
|
+
generate_stage
|
|
154
|
+
generate_manifest
|
|
155
|
+
generate_packages
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Compile binary extensions -- shell out to compile script if given.
|
|
159
|
+
# This is used when creating binary packages.
|
|
160
|
+
|
|
161
|
+
def generate_extensions
|
|
162
|
+
compile = project.compile
|
|
163
|
+
return unless compile
|
|
164
|
+
#begin
|
|
165
|
+
sh compile
|
|
166
|
+
#rescue
|
|
167
|
+
#end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Prepare stage.
|
|
171
|
+
|
|
172
|
+
def generate_stage
|
|
173
|
+
return stage_directory if dryrun? # Don't link to stage if dryrun.
|
|
174
|
+
|
|
175
|
+
clear_stage
|
|
176
|
+
mkdir_p(stage_directory) #dir = File.expand_path(stage)
|
|
177
|
+
|
|
178
|
+
# TODO Dryrun test here or before folder creation?
|
|
179
|
+
files.each do |f| # Link files into staging area.
|
|
180
|
+
file = File.join(stage_directory, f)
|
|
181
|
+
if File.directory?(f)
|
|
182
|
+
mkdir_p(file)
|
|
183
|
+
else
|
|
184
|
+
unless File.exist?(file) and File.mtime(file) >= File.mtime(f)
|
|
185
|
+
ln(f, file) #safe_ln ?
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
return stage_directory
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
# Clear old stage, if any.
|
|
193
|
+
|
|
194
|
+
def clear_stage
|
|
195
|
+
if File.directory?(stage_directory) # Ensure existance of staging area
|
|
196
|
+
raise(OverwriteError, stage_directory) unless force?
|
|
197
|
+
rm_r(stage_directory)
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# TODO Build manifest
|
|
202
|
+
|
|
203
|
+
def generate_manifest
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# Build packages.
|
|
207
|
+
# TODO Move this to Manager ?
|
|
208
|
+
|
|
209
|
+
def generate_packages
|
|
210
|
+
package_files = formats.collect do |format|
|
|
211
|
+
#format = clean_type(format)
|
|
212
|
+
say '' if format == 'gem' # FIXME This is here b/c Gems outputs on it's own.
|
|
213
|
+
file = create_package(format)
|
|
214
|
+
unless dryrun? or (format == 'gem')
|
|
215
|
+
report_package_built(format, file) if file
|
|
216
|
+
end
|
|
217
|
+
file
|
|
218
|
+
end
|
|
219
|
+
report_packaging_complete(package_files.size)
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
# Create package.
|
|
223
|
+
|
|
224
|
+
def create_package(type)
|
|
225
|
+
package.format = type
|
|
226
|
+
|
|
227
|
+
builder_class = FormatBuilder.registry[type]
|
|
228
|
+
builder = builder_class.new(package, stage_directory, options)
|
|
229
|
+
file = builder.build
|
|
230
|
+
|
|
231
|
+
transfer(file) unless dryrun?
|
|
232
|
+
|
|
233
|
+
return file
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
# Stage name.
|
|
237
|
+
|
|
238
|
+
def stage_name
|
|
239
|
+
name = package.name
|
|
240
|
+
p name
|
|
241
|
+
version = package.version
|
|
242
|
+
platform = package.platform #arch
|
|
243
|
+
buildno = package.buildno
|
|
244
|
+
|
|
245
|
+
if project.stage
|
|
246
|
+
template = project.stage
|
|
247
|
+
else
|
|
248
|
+
template = platform ? "%s-%s-%s" : "%s-%s"
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
if buildno # TODO Make this better.
|
|
252
|
+
buildno = Time.now.strftime("%H*60+%M")
|
|
253
|
+
version = "#{version}.#{buildno}"
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
template % [ name, version, platform ]
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
# Files to be included in package.
|
|
260
|
+
|
|
261
|
+
def files
|
|
262
|
+
project.filelist #+ [package.manifest_file]
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
# Transfer package file to storage location.
|
|
266
|
+
|
|
267
|
+
def transfer(file)
|
|
268
|
+
dest = File.join(store, File.basename(file)) # move to store, unless already there
|
|
269
|
+
dest = File.expand_path(dest)
|
|
270
|
+
mv(file, store) unless file == dest
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
# Report that a package has been built.
|
|
274
|
+
|
|
275
|
+
def report_package_built(type, file)
|
|
276
|
+
r = ''
|
|
277
|
+
r << "\n Successfully built #{type}"
|
|
278
|
+
r << "\n Name: #{package.name}"
|
|
279
|
+
r << "\n Version: #{package.version}"
|
|
280
|
+
r << "\n File: #{File.basename(file)}"
|
|
281
|
+
say r
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
# Report that packaging is complete.
|
|
285
|
+
|
|
286
|
+
def report_packaging_complete(size)
|
|
287
|
+
say "\nSuccessfully built #{size} packages at #{store}/."
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env ratch
|
|
2
|
+
|
|
3
|
+
# generate gem package
|
|
4
|
+
|
|
5
|
+
begin
|
|
6
|
+
require 'rubygems/specification'
|
|
7
|
+
Gem::manage_gems
|
|
8
|
+
rescue LoadError
|
|
9
|
+
raise LoadError, "RubyGems is not installed?"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
require 'ratch/project/package'
|
|
13
|
+
|
|
14
|
+
#
|
|
15
|
+
|
|
16
|
+
main 'pack/gem' do
|
|
17
|
+
# load config (TODO)
|
|
18
|
+
#source = Dir.pwd
|
|
19
|
+
store = 'pkg'
|
|
20
|
+
package = Ratch::Package.load
|
|
21
|
+
#status "Creating RubyGem(s)"
|
|
22
|
+
file = nil
|
|
23
|
+
#cd(source) do
|
|
24
|
+
#status "vi #{metadata.name}.gemspec"
|
|
25
|
+
builder = ::Gem::Builder.new(gemspec(package))
|
|
26
|
+
#status "gem build #{package.name}"
|
|
27
|
+
unless dryrun?
|
|
28
|
+
file = builder.build
|
|
29
|
+
file = File.expand_path(file)
|
|
30
|
+
end
|
|
31
|
+
#end
|
|
32
|
+
transfer(file, store)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Create Gem::Specification.
|
|
36
|
+
|
|
37
|
+
def gemspec(package)
|
|
38
|
+
distribute = package.filelist
|
|
39
|
+
#distribute = Dir.multiglob_with_default( '**/*', distribute )
|
|
40
|
+
|
|
41
|
+
::Gem::Specification.new do |spec|
|
|
42
|
+
spec.name = package.name
|
|
43
|
+
spec.version = package.version
|
|
44
|
+
spec.summary = package.brief
|
|
45
|
+
spec.description = package.description
|
|
46
|
+
spec.author = package.author
|
|
47
|
+
spec.email = package.email
|
|
48
|
+
spec.rubyforge_project = package.development if /rubyforge.org/ =~ package.development
|
|
49
|
+
spec.homepage = package.homepage
|
|
50
|
+
|
|
51
|
+
# Platform: ruby, mswin32, i586-linux, powerpc-darwin, current
|
|
52
|
+
spec.platform = 'ruby' # TODO current support!
|
|
53
|
+
|
|
54
|
+
spec.require_paths = [package.gem_path].flatten.reverse
|
|
55
|
+
|
|
56
|
+
#if package.platform != 'ruby'
|
|
57
|
+
# spec.require_paths.concat(spec.require_paths.collect{ |d| File.join(d, platform) })
|
|
58
|
+
#end
|
|
59
|
+
|
|
60
|
+
spec.bindir = "bin"
|
|
61
|
+
spec.executables = package.executables
|
|
62
|
+
spec.requirements = package.requirements
|
|
63
|
+
spec.has_rdoc = package.document
|
|
64
|
+
|
|
65
|
+
if package.dependencies
|
|
66
|
+
package.dependencies.each do |d,v|
|
|
67
|
+
spec.add_dependency(*[d,v].compact)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
spec.extensions = package.compile
|
|
72
|
+
|
|
73
|
+
spec.files = distribute
|
|
74
|
+
|
|
75
|
+
spec.test_files = distribute.select{ |f| f =~ /^test\// } # TODO make test_files configurable
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Transfer package file to storage location.
|
|
80
|
+
|
|
81
|
+
def transfer(file, store)
|
|
82
|
+
dest = File.join(store, File.basename(file)) # move to store, unless already there
|
|
83
|
+
dest = File.expand_path(dest)
|
|
84
|
+
mv(file, store) unless file == dest
|
|
85
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env ratch
|
|
2
|
+
|
|
3
|
+
# generate gem package
|
|
4
|
+
|
|
5
|
+
begin
|
|
6
|
+
require 'rubygems/specification'
|
|
7
|
+
Gem::manage_gems
|
|
8
|
+
rescue LoadError
|
|
9
|
+
raise LoadError, "RubyGems is not installed?"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
require 'ratch/project/package'
|
|
13
|
+
|
|
14
|
+
#
|
|
15
|
+
|
|
16
|
+
main 'pack/gem' do
|
|
17
|
+
# load config (TODO)
|
|
18
|
+
#source = Dir.pwd
|
|
19
|
+
store = 'pkg'
|
|
20
|
+
package = Ratch::Package.load
|
|
21
|
+
#status "Creating RubyGem(s)"
|
|
22
|
+
file = nil
|
|
23
|
+
#cd(source) do
|
|
24
|
+
#status "vi #{metadata.name}.gemspec"
|
|
25
|
+
builder = ::Gem::Builder.new(gemspec(package))
|
|
26
|
+
#status "gem build #{package.name}"
|
|
27
|
+
unless dryrun?
|
|
28
|
+
file = builder.build
|
|
29
|
+
file = File.expand_path(file)
|
|
30
|
+
end
|
|
31
|
+
#end
|
|
32
|
+
transfer(file, store)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Create Gem::Specification.
|
|
36
|
+
|
|
37
|
+
def gemspec(package)
|
|
38
|
+
distribute = package.filelist
|
|
39
|
+
#distribute = Dir.multiglob_with_default( '**/*', distribute )
|
|
40
|
+
|
|
41
|
+
::Gem::Specification.new do |spec|
|
|
42
|
+
spec.name = package.name
|
|
43
|
+
spec.version = package.version
|
|
44
|
+
spec.summary = package.brief
|
|
45
|
+
spec.description = package.description
|
|
46
|
+
spec.author = package.author
|
|
47
|
+
spec.email = package.email
|
|
48
|
+
spec.rubyforge_project = package.development if /rubyforge.org/ =~ package.development
|
|
49
|
+
spec.homepage = package.homepage
|
|
50
|
+
|
|
51
|
+
# Platform: ruby, mswin32, i586-linux, powerpc-darwin, current
|
|
52
|
+
spec.platform = 'ruby' # TODO current support!
|
|
53
|
+
|
|
54
|
+
spec.require_paths = [package.gem_path].flatten.reverse
|
|
55
|
+
|
|
56
|
+
#if package.platform != 'ruby'
|
|
57
|
+
# spec.require_paths.concat(spec.require_paths.collect{ |d| File.join(d, platform) })
|
|
58
|
+
#end
|
|
59
|
+
|
|
60
|
+
spec.bindir = "bin"
|
|
61
|
+
spec.executables = package.executables
|
|
62
|
+
spec.requirements = package.requirements
|
|
63
|
+
spec.has_rdoc = package.document
|
|
64
|
+
|
|
65
|
+
if package.dependencies
|
|
66
|
+
package.dependencies.each do |d,v|
|
|
67
|
+
spec.add_dependency(*[d,v].compact)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
spec.extensions = package.compile
|
|
72
|
+
|
|
73
|
+
spec.files = distribute
|
|
74
|
+
|
|
75
|
+
spec.test_files = distribute.select{ |f| f =~ /^test\// } # TODO make test_files configurable
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Transfer package file to storage location.
|
|
80
|
+
|
|
81
|
+
def transfer(file, store)
|
|
82
|
+
dest = File.join(store, File.basename(file)) # move to store, unless already there
|
|
83
|
+
dest = File.expand_path(dest)
|
|
84
|
+
mv(file, store) unless file == dest
|
|
85
|
+
end
|