proutils 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.
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/README ADDED
@@ -0,0 +1,78 @@
1
+ = ProUtils
2
+
3
+ ProUtils is a collect of handy command line tools. You can think of it as
4
+ supplements to the ubinqutous GNU CoreUtils.
5
+
6
+ ProUtils consits of the following tools:
7
+
8
+ === Mint
9
+
10
+ Mint is a managed copy tool. It makes it easy to recreate folder layouts,
11
+ project scaffolding, and of course update files.
12
+
13
+ Mint is managed copy tool. It's especailly useful for managing
14
+ project scaffolding, and comes with some pre-built Ruby project
15
+ templates. This is an early version, but it's based on some older code
16
+ that worked well. Future plans will add plugin support for dynamic
17
+ scaffolds.
18
+
19
+
20
+ === Xact
21
+
22
+ Script Ginsu! Xact (formerly Exacto) is a text extraction utility.
23
+ It is useful for extractng any identifiable section of
24
+ of text. It is also very useful for running comment-embedded
25
+ tests, examples and/or benchmarks from source scripts.
26
+
27
+
28
+ === rTar
29
+
30
+ rTar is a package format based on tar. But it follows a structural pattern
31
+ of recursion to allow efficent cherry picking of data from within an archive.
32
+
33
+
34
+ === iCli
35
+
36
+ Command the Web! iCli provides a command-line Interface to World Wide Web.
37
+ In particular, it makes it easy to interface with gforge-based development
38
+ sites like Rubyforge.
39
+
40
+ Underthe hood, iCli is a web-scrapping toolkit base on the
41
+ HttpClient library.
42
+
43
+ === How does it differ from the Seattle.rb's 'rubyforge'?
44
+
45
+ * It is designed to be extensible to support other sites.
46
+ * It does not store project data in hidden home directory.
47
+ Instead it looks up all needed information on the fly.
48
+
49
+
50
+
51
+ == Status
52
+
53
+ This is an early release. Basic functionality is in place. Better documentation
54
+ and command line help will be available in coming releases.
55
+
56
+
57
+ == Install
58
+
59
+ $ gem install proutils
60
+
61
+ or to install manually
62
+
63
+ $ tar -xzf protuils-0.2.0.tgz
64
+ $ cd proutils-0.2.0
65
+ $ sudo task/setup
66
+
67
+
68
+ == Acknowlegments
69
+
70
+ iCli is based on Ara T. Howards' original rubyforge.rb script.
71
+
72
+
73
+ == License
74
+
75
+ ProUtils Copyright (c) 2006, 2007 Thomas Sawyer, Psi T. Corp.
76
+
77
+ ProUtils is ditributed under the terms of the GPL3 license.
78
+
data/RELEASE ADDED
@@ -0,0 +1,7 @@
1
+ ProUtils
2
+
3
+ http://proutils.rubyforge.org
4
+
5
+ ProUtils is a collection of useful command-line
6
+ utilities which includes icli, mint, rtar and xact.
7
+
data/TODO ADDED
@@ -0,0 +1,4 @@
1
+ = TODO List
2
+
3
+ * Add web extraction option.
4
+
data/bin/icli ADDED
@@ -0,0 +1,278 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'yaml'
4
+ require 'facets/arguments'
5
+ require 'proutils/icli/abstract_host'
6
+
7
+ module ICli
8
+
9
+ class Command
10
+
11
+ def self.start
12
+ new.run
13
+ end
14
+
15
+ def initialize()
16
+ @command_arguments, @command_options = *Console::Arguments.parameters
17
+
18
+ @config_options = file_options(@command_options['use'])
19
+
20
+ parse_general_options(@command_options)
21
+
22
+ @host = @command_arguments.shift
23
+ @command = @command_arguments.shift
24
+
25
+ @host_options = @config_options[@host].merge(:dryrun=>@dryrun, :trace=>@trace)
26
+ @command_options = @command_options.merge(@config_options[@host][@command] || {})
27
+ end
28
+
29
+ def run
30
+ host = host_class(@host).new(@host_options)
31
+ if host.commands.include?(@command)
32
+ host.send(@command, @command_options) # TODO Add command_arguments?
33
+ else
34
+ puts "Unknown command -- #{@command}"
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def parse_general_options(options)
41
+ @dryrun = %w{dryrun dry-run noharm}.any?{ |o| options.delete(o) }
42
+ @trace = %w{trace}.any?{ |o| options.delete(o) }
43
+ end
44
+
45
+ def dryrun? ; @dryrun ; end
46
+ def trace? ; @trace ; end
47
+
48
+ # Print help usage to stadout.
49
+ def help
50
+ puts DATA.read
51
+ end
52
+
53
+ #
54
+ def host_class(name)
55
+ ICli.factory(name)
56
+ end
57
+
58
+ def file_options(fname=nil)
59
+ file = config_file(fname)
60
+ if file
61
+ YAML::load(File.open(file))
62
+ elsif fname
63
+ raise ArgumentError, "Parameter file not found -- #{fname}" unless file
64
+ else
65
+ {}
66
+ end
67
+ end
68
+
69
+ def config_file(fname=nil)
70
+ if fname
71
+ Dir.glob("#{fname}{.yaml,.yml,}").first
72
+ else
73
+ Dir.glob("{meta/icli,.icli}{.yaml,.yml,}").first
74
+ end
75
+ end
76
+
77
+ # #
78
+ #
79
+ # def config_load(section=nil)
80
+ # if file = config_file
81
+ # options = YAML::load(File.open(file))
82
+ # else
83
+ # options = {}
84
+ # end
85
+ # # merge in the selected section
86
+ # if section
87
+ # options.merge!(options[section.to_s] || {})
88
+ # end
89
+ # # remove subsections (should we bother?)
90
+ # options = options.delete_if{ |k,v| Hash === v }
91
+ # # return
92
+ # return options
93
+ # end
94
+
95
+
96
+ end
97
+ end
98
+
99
+ ICli::Command.start
100
+
101
+ =begin
102
+
103
+ class CommonOptions < Console::Command::Options
104
+ attr_accessor :host,
105
+ :domain,
106
+ :username
107
+ end
108
+
109
+ class ReleaseOptions < CommonOptions
110
+ attr_accessor :store, # Package folder.
111
+ :files, # Files to release.
112
+ :package, # Package name.
113
+ :version, # Package version.
114
+ :release, # Release name. Defaults to +version+.
115
+ :date, # Release Date. Defaults to +Time.now+.
116
+ :processor, # Processor type. Deafults to +Any+.
117
+ :changelog, # ChangeLog file.
118
+ :notelog, # Notes file.
119
+ :is_public # Is this release public?
120
+ end
121
+
122
+ class PublishOptions < CommonOptions
123
+ attr_accessor :root # directory with website files
124
+ end
125
+
126
+ class AnnounceOptions < CommonOptions
127
+ attr_accessor :subject,
128
+ :message
129
+ end
130
+
131
+ #
132
+
133
+ options :publish, PublishOptions
134
+ options :release, ReleaseOptions
135
+ options :announce, AnnounceOptions
136
+ options :touch, CommonOptions
137
+
138
+ # Publish
139
+ #
140
+ # root directory with website files
141
+
142
+ def publish
143
+ options = config_load('publish')
144
+
145
+ # merge in any commandline options
146
+ options.merge!(PublishOptions.parse.to_h)
147
+
148
+ name = options['host'] || options['domain']
149
+ host = host_class(name).new(options)
150
+
151
+ host.publish(options)
152
+ end
153
+
154
+ # Release options. This is a hash of options:
155
+ #
156
+ # store Location of packages.
157
+ # version Package version.
158
+ # files Files to release. (defaults to source/package-version.*)
159
+ # package Package name (defaults to +project+).
160
+ # release Release name (defaults to +version+).
161
+ # date Release Date (defaults to to +Time.now+).
162
+ # processor Processor type (deafults to +Any+).
163
+ # changelog ChangeLog file.
164
+ # notelog Notes file.
165
+ # is_public Is this release public?
166
+ #
167
+
168
+ def release
169
+ options = config_load('release')
170
+
171
+ # merge in any commandline options
172
+ options.merge!(@options.to_h) #(ReleaseOptions.parse.to_h)
173
+
174
+ #options = {}
175
+ #options.update info.gather('rubyforge')
176
+ #options.update info.gather('release')
177
+ #options.update info.select('version', 'changelog', 'notelog', 'processor'=>'arch')
178
+ #options['files'] = Dir[File.join(info.package_store,"*#{options['version']}.*")]
179
+
180
+ store = options['store']
181
+ name = options['package']
182
+ vers = options['version']
183
+
184
+ options['files'] ||= Dir[File.join(store,"#{name}-#{ver}.*")]
185
+
186
+ name = options['host'] || options['domain']
187
+ host = host_class(name).new(options)
188
+
189
+ host.release(options)
190
+ end
191
+
192
+ # Annouce to news.
193
+
194
+ def announce
195
+ options = config_load('announce')
196
+
197
+ # merge in any commandline options
198
+ options.merge!(AnnounceOptions.parse.to_h)
199
+
200
+ name = options['host'] || options['domain']
201
+ host = host_class(name).new(options)
202
+
203
+ host.announce(options)
204
+ end
205
+
206
+ # Test connection. Simply login and logout.
207
+
208
+ def touch
209
+ options = config_load
210
+
211
+ # merge in any commandline options
212
+ options.merge!(@options.to_h) #(CommonOptions.parse.to_h)
213
+
214
+ name = options['host'] || options['domain']
215
+ host = host_class(name).new(options)
216
+
217
+ host.touch
218
+ end
219
+
220
+
221
+ # Default action (no subcommand)
222
+
223
+ alias_method :default, :help
224
+
225
+
226
+ # def start
227
+ # config = File.file?(CONFIG_FILE) ? YAML::load(f) : {}
228
+ # section = (@args[0] || 'all').to_s.downcase
229
+ #
230
+ # if section == 'all'
231
+ # config.each do |name, settings|
232
+ # settings.update(@keys)
233
+ # press(settings)
234
+ # end
235
+ # else
236
+ # settings = config[section]
237
+ # settings.update(@keys)
238
+ # press(settings)
239
+ # end
240
+ # end*/
241
+ =end
242
+
243
+
244
+ __END__
245
+
246
+ Forge v0.2.0
247
+
248
+ Usage: forge <command> <options>
249
+
250
+ Commands:
251
+
252
+ touch
253
+ Test connection. This simply attempts to login and logout.
254
+
255
+ release
256
+ Release a package.
257
+
258
+ announce
259
+ Make an announcement via news.
260
+
261
+ publish
262
+ Publish website files.
263
+
264
+ Common Options:
265
+
266
+ --host
267
+ The host name (eg. rubyforge). If LaForge supports the
268
+ host name then a specialized adatapter will be used.
269
+
270
+ --domain
271
+ The domain name of the host. If the host is not build in
272
+ you can supply the domain name instead of the host name.
273
+ The generic GForge adapter will be used.
274
+
275
+ --username
276
+ Your username on the host.
277
+
278
+ For more information, http://proutils.rubyforge.org.
data/bin/mint ADDED
@@ -0,0 +1,139 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'getoptlong'
4
+ require 'proutils/mint/copier'
5
+
6
+ module Mint
7
+
8
+ # Scaffolding Console Command
9
+
10
+ class Command
11
+
12
+ # Start command.
13
+
14
+ def self.start
15
+ new.start
16
+ end
17
+
18
+ # New scaffolding command.
19
+
20
+ def initialize
21
+ @options = {}
22
+ @cmd = 'copy' # default command
23
+
24
+ opts = GetoptLong.new(
25
+ ['--source', '-s', GetoptLong::NO_ARGUMENT],
26
+ ['--dryrun', '--noharm', '-n', GetoptLong::NO_ARGUMENT],
27
+ ['--skip', GetoptLong::NO_ARGUMENT],
28
+ ['--replace', GetoptLong::NO_ARGUMENT],
29
+ ['--help', '-h', GetoptLong::NO_ARGUMENT]
30
+ )
31
+
32
+ opts.each do |k,v|
33
+ case k
34
+ when '--dryrun'
35
+ @options[:dryrun] = true
36
+ when '--safe'
37
+ @options[:skip] = true
38
+ when '--replace'
39
+ @options[:force] = true
40
+ when '--help'
41
+ @cmd = 'help'
42
+ when '--source'
43
+ @options[:special] = true
44
+ end
45
+ end
46
+
47
+ end
48
+
49
+ # Start execution.
50
+
51
+ def start
52
+ send(@cmd)
53
+ end
54
+
55
+ # Copy scaffolding.
56
+
57
+ def copy
58
+ #if @source
59
+ # src = Mint.lookup(ARGV[0])
60
+ # dst = ARGV[1] || '.'
61
+ #else
62
+ src = ARGV[0]
63
+ dst = ARGV[1] || '.'
64
+ #end
65
+
66
+ if src
67
+ Copier.new(src, dst, @options).copy
68
+ else
69
+ puts "Unrecognized source, '#{src}'."
70
+ exit 0
71
+ end
72
+ end
73
+
74
+ # Get help.
75
+
76
+ def help
77
+ $stdout << DATA.read
78
+ exit -1
79
+ end
80
+
81
+ #
82
+
83
+ def __DIR__
84
+ File.dirname(__FILE__)
85
+ end
86
+ end
87
+
88
+ end
89
+
90
+ Mint::Command.start
91
+
92
+
93
+ __END__
94
+ Mint v0.2.0
95
+ Usage: mint [-s] <source-path> [destination]
96
+
97
+ Opitons:
98
+
99
+ -s --source
100
+ Source path starts in mint paths.
101
+
102
+ --skip
103
+ Skip all duplicates.
104
+
105
+ --replace
106
+ Replace all duplicates.
107
+
108
+ --svn (NOT IMPLEMTENTED YET)
109
+ Create subversion branches/ tags/ trunk/
110
+ directories at the top level.
111
+
112
+ -n --noharm --dryrun
113
+ Only pretend to create files.
114
+
115
+ --help
116
+ Display's this help information.
117
+
118
+ Built-in Sources:
119
+
120
+ website Start a website.
121
+
122
+ ruby Create a standard ruby project layout.
123
+
124
+ Examples:
125
+
126
+ To copy a directory:
127
+ $ mint ~/pictures ~/copy_of_pictures/
128
+
129
+ To copy a selection of files:
130
+ $ mint ~/pictures/*.jpg ~/copy_of_pictures/
131
+
132
+ To scaffold a new ruby project in the current directory.
133
+ $ mint -s ruby .
134
+
135
+ To scaffold a new website to a new directory.
136
+ $ mint -s website mysite/
137
+
138
+ To copy a single file, for instance:
139
+ $ mint -s ruby/meta/name-1.0.0.roll meta/
data/bin/rtar ADDED
@@ -0,0 +1,69 @@
1
+
2
+ require 'facet/command'
3
+ require 'proutils/rtar'
4
+
5
+ # Rock command line interface.
6
+ #
7
+ class Rock::Command < Console::Command
8
+
9
+ def __pack( file )
10
+ @mode, @file = :pack, file
11
+ end
12
+
13
+ def __unpack( file )
14
+ @mode, @file = :unpack, file
15
+ end
16
+ alias_method :_x, :__unpack
17
+
18
+ def __list( file )
19
+ @mode, @file = :list, file
20
+ end
21
+
22
+ def __verbose
23
+ $VERBOSE = true
24
+ end
25
+ alias_method :_v, :__verbose
26
+
27
+ def __force
28
+ $FORCE = true
29
+ end
30
+ alias_method :_f, :__force
31
+
32
+ def __help
33
+ @mode = nil
34
+ end
35
+
36
+ # main routine
37
+
38
+ def default
39
+ $VERBOSE ||= false
40
+ $FORCE ||= false
41
+
42
+ case @mode
43
+ when :pack
44
+ rpkg = Rock::Package.new
45
+ rpkg.pack( @file )
46
+ when :unpack
47
+ rpkg = Rock::Package.new
48
+ rpkg.unpack( @file )
49
+ when :list
50
+ rpkg = Rock::Package.new
51
+ rpkg.list( @file )
52
+ else
53
+ puts HELP
54
+ end
55
+
56
+ if nil.status?
57
+ puts Rock::Errors.__send__(*nil.status)
58
+ end
59
+ end
60
+
61
+ VERSION = '0.4.0'
62
+
63
+ HELP = <<-END
64
+ rock v#{VERSION}
65
+ END
66
+
67
+ end
68
+
69
+ Rock::Command.execute
data/bin/xact ADDED
@@ -0,0 +1,121 @@
1
+ #! /usr/bin/ruby
2
+
3
+ require 'getoptlong'
4
+ require 'proutils/xact/extract'
5
+
6
+ module Xact
7
+
8
+ #
9
+ # Extract commandline interface.
10
+ #
11
+
12
+ class Command
13
+
14
+ def self.run
15
+ new.run
16
+ end
17
+
18
+ #
19
+
20
+ attr_reader :file, :start, :stop, :repeat, :style
21
+
22
+ #
23
+
24
+ def initialize
25
+ opts = GetoptLong.new(
26
+ [ '--help' , GetoptLong::NO_ARGUMENT ],
27
+ [ '--repeat', '-r' , GetoptLong::NO_ARGUMENT ],
28
+ [ '--unxml', '-x' , GetoptLong::NO_ARGUMENT ],
29
+ [ '--style', '-s' , GetoptLong::REQUIRED_ARGUMENT ]
30
+ )
31
+
32
+ repeat = nil
33
+ style = nil
34
+ unxml = nil
35
+
36
+ opts.each do |opt, arg|
37
+ case opt
38
+ when '--help'
39
+ help
40
+ exit 0
41
+ when '--repeat'
42
+ repeat = true
43
+ when '--style'
44
+ style = arg
45
+ when '--unxml'
46
+ unxml = true
47
+ end
48
+ end
49
+
50
+ file = ARGV.shift
51
+ start = ARGV.shift
52
+ stop = ARGV.shift
53
+
54
+ # if i = argv.index('-h')
55
+ # handle = argv[i+1].strip
56
+ # argv[i+1,1] = nil
57
+ # argv.delete('-h')
58
+ # else
59
+ # handle = 'test'
60
+ # end
61
+ #
62
+ # file = argv.pop
63
+
64
+ unless file && File.file?(file)
65
+ puts "No such file -- '#{file}'."
66
+ exit 0
67
+ end
68
+
69
+ @file = file
70
+ @start = start
71
+ @stop = stop
72
+ @repeat = repeat
73
+ @style = style
74
+ @unxml = unxml
75
+ end
76
+
77
+ #
78
+
79
+ def extractor
80
+ @extractor ||= Extractor.new(@file, :unxml => @unxml)
81
+ end
82
+
83
+ # Extract and display.
84
+
85
+ def run
86
+ r = case style
87
+ when 'ruby'
88
+ extractor.extract_ruby_block_comment(start||'test')
89
+ when 'rubymethod'
90
+ extractor.extract_ruby_method_comment(start)
91
+ else
92
+ if stop
93
+ extractor.extract_block(start, stop)
94
+ else
95
+ extractor.extract_pattern(start)
96
+ end
97
+ end
98
+ text, offset = *r
99
+ $stdout << text
100
+ end
101
+
102
+ # # Extract the code.
103
+ #
104
+ # def exact
105
+ # return *@exacto.extract_block(handle)
106
+ # end
107
+
108
+ # Show help.
109
+
110
+ def help
111
+ puts "USAGE: xact [options...] <file> [pattern] [end-pattern]"
112
+ puts " --help This help ionformation."
113
+ puts " -r --repeat Repeat for every occurance."
114
+ puts " --style Use built-in style."
115
+ end
116
+
117
+ end
118
+
119
+ end
120
+
121
+ Xact::Command.run
@@ -0,0 +1,4 @@
1
+
2
+ def scaffold_directory
3
+ File.join(Config::CONFIG['datadir'], 'cherry', 'architect', 'scaffold')
4
+ end