proutils 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/CHANGES +17 -0
  2. data/COPYING +674 -0
  3. data/README +78 -0
  4. data/RELEASE +7 -0
  5. data/TODO +4 -0
  6. data/bin/icli +278 -0
  7. data/bin/mint +139 -0
  8. data/bin/rtar +69 -0
  9. data/bin/xact +121 -0
  10. data/data/mint/cherry/_scaffold.rb +4 -0
  11. data/data/mint/roll/name-1.0.0.roll +26 -0
  12. data/data/mint/ruby/README +17 -0
  13. data/data/mint/ruby/README.first +10 -0
  14. data/data/mint/ruby/README.license +403 -0
  15. data/data/mint/ruby/meta/MANIFEST +2 -0
  16. data/data/mint/ruby/meta/name-1.0.0.roll +26 -0
  17. data/data/mint/ruby/script/finish_scaffold +8 -0
  18. data/data/mint/ruby/script/setup +1600 -0
  19. data/data/mint/website/css/clean.css +5 -0
  20. data/data/mint/website/index.html +0 -0
  21. data/demo/demo_rtar/Lorem_ipsum.txt +233 -0
  22. data/demo/demo_rtar/lib/demo_rock/tryme.rb +2 -0
  23. data/demo/demo_rtar/meta/data +6 -0
  24. data/demo/demo_rtar/web/index.html +13 -0
  25. data/demo/demo_rtar/web/rocklobster.jpg +0 -0
  26. data/demo/mint/loremipsum.txt +9 -0
  27. data/demo/mint/tryme.rb +33 -0
  28. data/lib/proutils/icli/abstract_host.rb +71 -0
  29. data/lib/proutils/icli/gforge.rb +668 -0
  30. data/lib/proutils/icli/rubyforge.rb +26 -0
  31. data/lib/proutils/icli/tool.rb +128 -0
  32. data/lib/proutils/icli/uploadutils.rb +410 -0
  33. data/lib/proutils/mint/copier.rb +324 -0
  34. data/lib/proutils/mint/fileutils.rb +47 -0
  35. data/lib/proutils/mint/help.txt +0 -0
  36. data/lib/proutils/rtar/rtar.rb +309 -0
  37. data/lib/proutils/rtar/vendor/archive/tar/minitar/command.rb +814 -0
  38. data/lib/proutils/rtar/vendor/archive/tar/minitar.rb +979 -0
  39. data/lib/proutils/xact/extract.rb +211 -0
  40. data/lib/proutils/xact/save.rb +151 -0
  41. data/meta/MANIFEST +100 -0
  42. data/meta/config.yaml +12 -0
  43. data/meta/icli.yaml +16 -0
  44. data/meta/project.yaml +27 -0
  45. data/meta/proutils.roll +3 -0
  46. data/test/fixture.rb +6 -0
  47. data/test/lib/test_exacto.rb +54 -0
  48. data/work/ANN +14 -0
  49. data/work/icli/icli +223 -0
  50. data/work/icli/rake.rb +82 -0
  51. data/work/icli/utils/consoleutils.rb +67 -0
  52. data/work/icli/utils/emailutils.rb +85 -0
  53. data/work/icli/utils/fileutils.rb +47 -0
  54. data/work/mint/command-old.rb +48 -0
  55. data/work/mint/lazyfile.rb +97 -0
  56. data/work/mint/part.rb +316 -0
  57. data/work/mint/scaffold-old.rb +420 -0
  58. data/work/rtar/index.html +68 -0
  59. data/work/rtar/old-index.html +63 -0
  60. data/work/xact/xact-ginsu +5 -0
  61. data/work/xact/xact-ruby.rb +155 -0
  62. metadata +178 -0
data/work/mint/part.rb ADDED
@@ -0,0 +1,316 @@
1
+ # = scaffold.rb
2
+ #
3
+ # TODO Generalize scaffolding for arbitrary parts (?)
4
+
5
+ require 'rbconfig'
6
+ require 'tmpdir'
7
+ #require 'open-uri'
8
+
9
+ #require 'ratchets/utility/compress'
10
+ require 'facets/core/array/to_path.rb'
11
+
12
+ require 'project/buildutils'
13
+
14
+ class Project
15
+
16
+ # The Scaffold module provides a means for building up new
17
+ # project layout, including all the typical standard
18
+ # directories and files, or other pre-packaged project parts.
19
+ #
20
+ # New project layouts are automatically built to standard
21
+ # specifications and can be wrapped in additional subversion
22
+ # and/or website layers.
23
+ #
24
+ # Project parts can be retrived from remote sources and will
25
+ # be automitacally decompressed and merged into the project.
26
+ # If a scaffold.rb file is included in the parts package then
27
+ # conditional building can take place.
28
+ #
29
+ # WARNING! This is a very new feature and should be used with
30
+ # the expectaton that it is not 100% bug-free, and will certainly
31
+ # warrent design changes in the future.
32
+
33
+ class Scaffolding < Toolset
34
+
35
+ # Create a new conventional project layout.
36
+ #
37
+ # Generates a project directory layout within the current
38
+ # directory. The scaffolding includes all the standard
39
+ # features such as directories lib/ bin/ doc/
40
+ # and files such as README.
41
+ #
42
+ # To use this task you need to first create an new empty
43
+ # directory and change into it. This command will not
44
+ # create a new project directory for you. As a safegaurd,
45
+ # this command will not generate scaffolding in a directory
46
+ # with files already present, unless you use the -f (force)
47
+ # option.
48
+ #
49
+ # You can specify a subversion layout by setting +svn+ to
50
+ # true. You can also specify a web layout via the by setting
51
+ # +web+ to true.
52
+
53
+ def new( opts={} )
54
+ opts = opts.to_options
55
+
56
+ if project_content? and not opts.force
57
+ puts "Directory already has content. Use -f option to force new scaffolding."
58
+ return
59
+ end
60
+
61
+ # change 'standard' to 'ruby' in case other languages may
62
+ # be supported in future?
63
+ type = opts.type || 'standard'
64
+ web = opts.web
65
+ svn = opts.svn || opts.subversion
66
+
67
+ type = 'standard' if type == 'std'
68
+
69
+ if file = project_file?
70
+ file = File.expand_path(file)
71
+ else
72
+ file = form()
73
+ file = File.expand_path(file)
74
+ if ENV['EDITOR']
75
+ system "#{ENV['EDITOR']} #{file}"
76
+ end
77
+ end
78
+
79
+ proj = YAML::load(File.open(file))
80
+
81
+ # set scaffolding dir
82
+ dir = File.join( datadir, 'scaffolds' )
83
+
84
+ if web
85
+ from = File.join(dir, 'website', '.')
86
+ cp_r(from, '.')
87
+ cd('src')
88
+ end
89
+
90
+ if svn
91
+ mkdir_p('branches')
92
+ mkdir_p('tags')
93
+ mkdir_p('trunk')
94
+ cd('trunk')
95
+ end
96
+
97
+ # copies standard project layout from Ratchets' data dir
98
+ from = File.join(dir, 'standard', '.')
99
+ cp_r(from, '.')
100
+
101
+ # if project use project info to improve scaffolding
102
+ if proj
103
+ mkdir_p("lib/#{proj['name']}")
104
+ mkdir_p("data/#{proj['name']}")
105
+
106
+ #unless project.dryrun?
107
+ # bdir = Dir.pwd
108
+ # bdir.sub!(File.dirname(file) + '/','')
109
+ # File.open(file,'a') do |f|
110
+ # f << "basedir: #{bdir}"
111
+ # end
112
+ #end
113
+
114
+ # move project file to source folder if differnt
115
+ mv(file,'.') unless Dir.pwd == File.dirname(file)
116
+ else
117
+ # create project information file
118
+ form
119
+ end
120
+
121
+ puts "Project ready."
122
+ end
123
+
124
+ # Create a project part.
125
+
126
+ def part( opts )
127
+ puts "part system not yet implmented"
128
+ end
129
+
130
+ # Creates a ProjectInfo file in the current directory.
131
+ # It will not overwrite a ProjectInfo file if one is already
132
+ # present. The file can be named ProjectInfo, PROJECT or
133
+ # project.yaml.
134
+
135
+ def form( opts={} )
136
+ opts = opts.to_options
137
+
138
+ name = opts.name || 'ProjectInfo'
139
+
140
+ if name !~ /project(info)?(.yaml|.yml)?/i
141
+ raise ArgumentError, "not a recognized project information file name"
142
+ end
143
+
144
+ f = nil
145
+ files = Dir.glob("{[Pp]roject,PROJECT}{INFO,[Ii]nfo,.yml,.yaml,}")
146
+ if f = files[0]
147
+ puts "Project file '#{f}' already exists."
148
+ return
149
+ end
150
+
151
+ file = File.join(datadir, 'scaffolds', 'project.yaml')
152
+ install(file, name)
153
+
154
+ unless opts.noharm
155
+ File.open(name,'a') do |f|
156
+ date = Time.now.strftime("%Y-%m-%d")
157
+ f << "created: #{date}"
158
+ end
159
+ end
160
+
161
+ unless opts.quiet
162
+ puts "Created '#{name}'."
163
+ puts "Please edit to suit your project."
164
+ end
165
+
166
+ return name
167
+ end
168
+
169
+ private
170
+
171
+ # Is there a project information file?
172
+
173
+ def project_file?
174
+ f = nil
175
+ files = Dir.glob("{[Pp]roject,PROJECT}{INFO,[Ii]nfo,.yml,.yaml,}")
176
+ return files[0]
177
+ end
178
+
179
+ # Project contains content?
180
+
181
+ def project_content?
182
+ content = Dir.entries('.') - ['.', '..']
183
+ content -= [project_file?]
184
+ return !content.empty?
185
+ end
186
+
187
+ end # end Scaffolding
188
+
189
+ end # class Project
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+ # def seed( keys, &yld )
200
+ # keys = (keys||yld).to_openobject
201
+ #
202
+ # name = keys.name
203
+ # type = keys.type
204
+ # site = keys.site
205
+ # meta = keys.meta
206
+ # web = keys.web
207
+ #
208
+ # raise ArgumentError, "missing field -- name or type" unless name
209
+ #
210
+ # if site
211
+ # url = File.join(site, name)
212
+ # scaffold(url, keys)
213
+ # else
214
+ # case name.to_s.downcase
215
+ # when 'std', 'standard', 'svn', 'subversion'
216
+ # new_project(keys)
217
+ # when 'project', 'projectinfo', 'project.yaml', 'project.yml'
218
+ # projectinfo_template(name, meta)
219
+ # #when 'setup', 'setup.rb'
220
+ # # setup_rb
221
+ # else
222
+ # url = File.join( Ratchets.datadir, 'scaffolding', name )
223
+ # scaffold(url, keys)
224
+ # end
225
+ # end
226
+ # end
227
+ #
228
+ # private
229
+
230
+
231
+ # def new_project( keys, &yld )
232
+ # keys = (keys||yld).to_openobject
233
+ #
234
+ # type = keys.type || keys.name
235
+ # meta = keys.meta
236
+ # web = keys.web
237
+ #
238
+ # raise ArgumentError, "Must supply new project type." unless type
239
+ #
240
+ # content = Dir.entries('.') - [ '.', '..' ]
241
+ # if not content.empty? and not project.force?
242
+ # puts "Directory already has content. Use -f option to force new scaffolding."
243
+ # return nil
244
+ # end
245
+ #
246
+ # local_store = File.join( Ratchets.datadir, 'scaffolding' )
247
+ #
248
+ # type = 'standard' if type == 'std'
249
+ # type = 'subversion' if type == 'svn'
250
+ #
251
+ # if web
252
+ # from = File.join( local_store, 'website', '.' )
253
+ # FileUtils.cp_r( from, '.' )
254
+ # Dir.chdir( 'src' )
255
+ # end
256
+ #
257
+ # if type == 'subversion' or type == 'svn'
258
+ # mkdir_p( 'branches' )
259
+ # mkdir_p( 'tags' )
260
+ # mkdir_p( 'trunk' )
261
+ # Dir.chdir( 'trunk' )
262
+ # end
263
+ #
264
+ # # copies typical project layout
265
+ # from = File.join( local_store, 'standard', '.' )
266
+ # FileUtils.cp_r( from, '.' )
267
+ #
268
+ # # create project.yaml template.
269
+ # projectinfo_template(nil,meta)
270
+ #
271
+ # puts "Project ready."
272
+ # end
273
+
274
+ =begin
275
+ # Generate pre-built targets in project's target folder.
276
+
277
+ def targets( keys, &yld ) #( folder, targets=nil )
278
+ keys = (keys||yld).to_openobject
279
+
280
+ folder = keys.folder || 'script'
281
+ targets = keys.targets || keys.target
282
+
283
+ match = File.join(File.dirname(__FILE__), 'targets', '*')
284
+ files = Dir.glob(match)
285
+ names = files.collect{ |f| File.basename(f).chomp('.rb') }
286
+ cross = Hash[*names.zip(files).flatten]
287
+
288
+ case targets
289
+ when String
290
+ targets = targets.split(',')
291
+ when Array
292
+ targets = [targets].flatten
293
+ else
294
+ targets = names
295
+ end
296
+
297
+ # only specific targets that exist?
298
+ #targets = (AUTOTARGETS & targets)
299
+
300
+ unless (diff=(targets-names)).empty?
301
+ puts "project: unknown targets " + diff.join(',')
302
+ return
303
+ end
304
+
305
+ mkdir_p(folder)
306
+ targets.each do |name|
307
+ file1 = cross[name]
308
+ file2 = File.join(folder, name)
309
+ unless (File.exist?(file2) or project.dryrun?)
310
+ install(file1, file2, :mode=>0754)
311
+ end
312
+ end
313
+
314
+ return folder
315
+ end
316
+ =end