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
@@ -0,0 +1,211 @@
1
+ # Title:
2
+ # Xacto
3
+ #
4
+ # Synopsis:
5
+ # Extractor is a tool for extracting code from embedded comment blocks.
6
+ #
7
+ # COPYRIGHT:
8
+ # Copyright (c) 2006,2007 Thomas Sawyer & Tyler Rick
9
+ #
10
+ # LICENSE:
11
+ # Distributed under the Ruby/GPL dual license.
12
+ #
13
+ # Authors:
14
+ # - Thomas Sawyer
15
+ # - Tyler Rick
16
+ #
17
+ # Todo:
18
+ # - Should extract_block handle more than the first matching block?
19
+ # - How can we handle embedded code in stadard comments? Eg. #
20
+ # - Should this code be wrapped in toplevel Ratchets module?
21
+
22
+ require 'fileutils'
23
+ require 'open-uri'
24
+ require 'facets/string/tabs' # for margin
25
+
26
+ module Xact
27
+
28
+ # Text Extraction class.
29
+
30
+ class Extractor
31
+
32
+ attr :file
33
+ attr :options
34
+
35
+ alias_method :uri, :file
36
+
37
+ # New extractor.
38
+
39
+ def initialize(file, options={})
40
+ @file = file
41
+ @options = options
42
+ end
43
+
44
+ # Read file.
45
+
46
+ def raw
47
+ @raw ||= open(@file) # File.read(@file)
48
+ end
49
+
50
+ #
51
+
52
+ def text
53
+ if options[:unxml]
54
+ @text = raw.gsub!(/\<(*.?)\>/, '')
55
+ else
56
+ @text = raw
57
+ end
58
+ end
59
+
60
+
61
+ # Extract Pattern.
62
+
63
+ def extract_pattern(pattern)
64
+ pattern = Regexp.new(pattern)
65
+
66
+ md = pattern.match(text)
67
+ if clip = md ? md[1] : nil
68
+ offset = text[0...md.begin(1)].count("\n")
69
+ return clip, offset
70
+ else
71
+ raise "Pattern not found -- #{pattern}"
72
+ return nil, nil
73
+ end
74
+ end
75
+
76
+ # Extract Block.
77
+
78
+ def extract_block(start, stop)
79
+ start = Regexp.new(start)
80
+ stop = Regexp.new(stop)
81
+
82
+ md_start = start.match(text)
83
+ if md_start
84
+ md_stop = stop.match(text[md_start.end(0)..-1])
85
+ if md_stop
86
+ clip = text[md_start.end(0)...(md_stop.begin(0)+md_start.end(0))]
87
+ else
88
+ raise "Pattern not found -- #{stop}"
89
+ return nil, nil
90
+ end
91
+ offset = text[0...md_start.begin(0)].count("\n") #?
92
+ return clip, offset
93
+ else
94
+ raise "Pattern not found -- #{start}"
95
+ return nil, nil
96
+ end
97
+ end
98
+
99
+ #################
100
+ # Ruby Specific #
101
+ #################
102
+
103
+ # Returns a Ruby comment block with a given handle.
104
+
105
+ def extract_ruby_block_comment(handle)
106
+ b = Regexp.escape(handle)
107
+ if b == ''
108
+ pattern = /^=begin.*?\n(.*?)\n=end/mi
109
+ else
110
+ pattern = /^=begin[ \t]+#{b}.*?\n(.*?)\n=end/mi
111
+ end
112
+ extract_pattern(pattern)
113
+ end
114
+
115
+ # Returns a Ruby method comment.
116
+
117
+ def extract_ruby_method_comment(meth) #=nil )
118
+ #if meth
119
+ regexp = Regexp.escape(meth)
120
+ pattern = /(\A\s*\#.*?^\s*def #{regexp}/mi
121
+ extract_pattern(pattern)
122
+ #else
123
+ # prog.scan /^\s*\#/mi
124
+ # md = pattern_inline_all.match( prog )
125
+ #end
126
+ end
127
+
128
+ # # Extract the matching comment block.
129
+ #
130
+ # def extract_block( handle='test' )
131
+ # text = File.read(file)
132
+ # md = pattern_block(handle).match(text)
133
+ # code = md ? md[1] : nil
134
+ # unless code
135
+ # puts "Code block not found -- #{handle}"
136
+ # exit 0 #return nil
137
+ # end
138
+ # offset = text[0...md.begin(1)].count("\n")
139
+ # return code, offset
140
+ # end
141
+ #
142
+ # # Returns the comment inline regexp to match against.
143
+ #
144
+ # def pattern_inline( mark )
145
+ # m = Regexp.escape(mark)
146
+ # /(\A\s*\#.*?^\s*def #{m}/mi
147
+ # end
148
+ #
149
+ # def extract_inline( fname, mark=nil )
150
+ # prog = File.read( file )
151
+ # if mark
152
+ # md = pattern_inline(mark).match( prog )
153
+ # else
154
+ # prog.scan /^\s*\#/mi
155
+ # md = pattern_inline_all.match( prog )
156
+ # end
157
+ # end
158
+
159
+ end
160
+
161
+ end
162
+
163
+
164
+
165
+ # _____ _
166
+ # |_ _|__ ___| |_
167
+ # | |/ _ \/ __| __|
168
+ # | | __/\__ \ |_
169
+ # |_|\___||___/\__|
170
+ #
171
+ =begin test
172
+
173
+ require 'test/unit'
174
+
175
+ class ExtractorTest < Test::Unit::TestCase
176
+
177
+ def exacto_knife
178
+ @knife ||= Extractor.new('/dev/null')
179
+ end
180
+
181
+ def build_pattern_block(block, code)
182
+ exacto_knife.pattern_block(block).match(code)
183
+ end
184
+
185
+ # Usual case.
186
+
187
+ def test_pattern_block
188
+ assert_equal "require 'foo'\nfoo", build_pattern_block('test', "=begin test\nrequire 'foo'\nfoo\n=end")[1]
189
+ end
190
+
191
+ # Some tests for when the block is empty ('') -- should it act as a wildcard and match *any* block,
192
+ # or should Extractor::Command#initialize complain about that.
193
+
194
+ def test_pattern_block_no_handle
195
+ assert_equal "require 'foo'\nfoo", build_pattern_block('', "=begin\nrequire 'foo'\nfoo\n=end")[1]
196
+ end
197
+
198
+ def test_pattern_block_no_handle_given
199
+ assert_equal "require 'foo'\nfoo", build_pattern_block('', "=begin test\nrequire 'foo'\nfoo\n=end")[1]
200
+ end
201
+
202
+ # Yes, I know, as a side-effect of this regexp change, it will also match some invalid "blocks", like =beginblah. But that
203
+ # seems like a nonissue, given that the Ruby parser would reject that syntax anyway.
204
+
205
+ def test_pattern_block_side_effects
206
+ assert_equal "require 'foo'\nfoo", build_pattern_block('', "=beginblah\nrequire 'foo'\nfoo\n=end")[1]
207
+ end
208
+
209
+ end
210
+
211
+ =end
@@ -0,0 +1,151 @@
1
+ # Title:
2
+ # Xacto
3
+ #
4
+ # Synopsis:
5
+ # Extractor is a tool for extracting code from embedded comment blocks.
6
+ #
7
+ # COPYRIGHT:
8
+ # Copyright (c) 2006,2007 Thomas Sawyer & Tyler Rick
9
+ #
10
+ # LICENSE:
11
+ # Distributed under the Ruby/GPL dual license.
12
+ #
13
+ # Authors:
14
+ # - Thomas Sawyer
15
+ # - Tyler Rick
16
+ #
17
+ # Todo:
18
+ # - Should extract_block handle more than the first matching block?
19
+ # - How can we handle embedded code in stadard comments? Eg. #
20
+ # - Should this code be wrapped in toplevel Ratchets module?
21
+
22
+ require 'fileutils'
23
+ require 'facets/string/tabs' # for margin
24
+
25
+ module Xact
26
+
27
+ #
28
+
29
+ module ExtractAndSave
30
+
31
+ extend self
32
+
33
+ # Extract unit tests. This task scans every package script
34
+ # looking for sections of the form:
35
+ #
36
+ # =begin test
37
+ # ...
38
+ # =end
39
+ #
40
+ # With appropriate headers, it copies these sections to files
41
+ # in your project's test/ dir, which then can be run using the
42
+ # Ratchet test task. The exact directory layout of the files to
43
+ # be tested is reflected in the test directory. You can then
44
+ # use project.rb's test task to run the tests.
45
+ #
46
+ # files Files to extract ['lib/**/*.rb']
47
+ # output Test directory ['test/']
48
+ #
49
+
50
+ def test_extract(files=nil)
51
+ output = 'test/embedded' # Don't think output should be setable.
52
+
53
+ files = files || 'lib/**/*.rb'
54
+ files = 'lib/**/*.rb' if TrueClass == files
55
+ files = [files].flatten.compact
56
+
57
+ filelist = files.collect{ |f| Dir.glob(f) }
58
+ filelist.flatten!
59
+ if filelist.empty?
60
+ puts "No scripts found from which to extract tests."
61
+ return
62
+ end
63
+
64
+ FileUtils.mkdir_p(output) unless File.directory?(output)
65
+
66
+ #vrunner = VerbosityRunner.new("Extracting", verbosity?)
67
+ #vrunner.setup(filelist.size)
68
+
69
+ filelist.each do |file|
70
+ #vrunner.prepare(file)
71
+
72
+ testing = extract_test_from_file( file )
73
+ if testing.strip.empty?
74
+ status = "[NONE]"
75
+ else
76
+ complete_test = create_test(testing, file)
77
+ libpath = File.dirname(file)
78
+ testfile = "test_" + File.basename(file)
79
+ fp = File.join(output, libpath, testfile)
80
+ unless File.directory?( File.dirname(fp))
81
+ FileUtils.mkdir_p(File.dirname(fp))
82
+ end
83
+ File.open(fp, "w"){ |fw| fw << complete_test }
84
+ status = "[TEST]"
85
+ end
86
+
87
+ #vrunner.complete(file, status)
88
+ end
89
+
90
+ #vrunner.finish(
91
+ # :normal => "#{filelist.size} files had tests extracted.",
92
+ # :check => false
93
+ #)
94
+ end
95
+
96
+ private
97
+
98
+ # Extract test from a file's testing comments.
99
+
100
+ def extract_test_from_file( file )
101
+ return nil if ! File.file?( file )
102
+ tests = ""; inside = false
103
+ fstr = File.read( file )
104
+ fstr.split(/\n/).each do |l|
105
+ if l =~ /^=begin[ ]*test/i
106
+ tests << "\n"
107
+ inside = true
108
+ next
109
+ elsif inside and l =~ /^=[ ]*end/
110
+ inside = false
111
+ next
112
+ end
113
+ if inside
114
+ tests << l << "\n"
115
+ end
116
+ end
117
+ tests
118
+ end
119
+
120
+ # Generate the test.
121
+
122
+ def create_test( 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
+ `# Project.rb Test Extraction
140
+ `#
141
+ `
142
+ `#{reqf}
143
+ `
144
+ HERE
145
+ teststr << testing << "\n"
146
+ teststr
147
+ end
148
+
149
+ end
150
+
151
+ end
data/meta/MANIFEST ADDED
@@ -0,0 +1,100 @@
1
+ # -x pkg -x doc -x work
2
+ CHANGES
3
+ COPYING
4
+ README
5
+ RELEASE
6
+ TODO
7
+ bin
8
+ bin/icli
9
+ bin/mint
10
+ bin/rtar
11
+ bin/xact
12
+ data
13
+ data/mint
14
+ data/mint/cherry
15
+ data/mint/cherry/_scaffold.rb
16
+ data/mint/roll
17
+ data/mint/roll/name-1.0.0.roll
18
+ data/mint/ruby
19
+ data/mint/ruby/README
20
+ data/mint/ruby/README.first
21
+ data/mint/ruby/README.license
22
+ data/mint/ruby/bin
23
+ data/mint/ruby/data
24
+ data/mint/ruby/doc
25
+ data/mint/ruby/doc/index.html
26
+ data/mint/ruby/doc/log
27
+ data/mint/ruby/doc/log/ChangeLog
28
+ data/mint/ruby/doc/log/TODO
29
+ data/mint/ruby/doc/note
30
+ data/mint/ruby/ext
31
+ data/mint/ruby/lib
32
+ data/mint/ruby/meta
33
+ data/mint/ruby/meta/MANIFEST
34
+ data/mint/ruby/meta/name-1.0.0.roll
35
+ data/mint/ruby/script
36
+ data/mint/ruby/script/finish_scaffold
37
+ data/mint/ruby/script/setup
38
+ data/mint/ruby/test
39
+ data/mint/website
40
+ data/mint/website/css
41
+ data/mint/website/css/clean.css
42
+ data/mint/website/img
43
+ data/mint/website/index.html
44
+ demo
45
+ demo/demo_rtar
46
+ demo/demo_rtar/Lorem_ipsum.txt
47
+ demo/demo_rtar/lib
48
+ demo/demo_rtar/lib/demo_rock
49
+ demo/demo_rtar/lib/demo_rock/tryme.rb
50
+ demo/demo_rtar/meta
51
+ demo/demo_rtar/meta/data
52
+ demo/demo_rtar/web
53
+ demo/demo_rtar/web/index.html
54
+ demo/demo_rtar/web/rocklobster.jpg
55
+ demo/mint
56
+ demo/mint/loremipsum.txt
57
+ demo/mint/tryme.rb
58
+ lib
59
+ lib/proutils
60
+ lib/proutils/icli
61
+ lib/proutils/icli/abstract_host.rb
62
+ lib/proutils/icli/gforge.rb
63
+ lib/proutils/icli/rubyforge.rb
64
+ lib/proutils/icli/tool.rb
65
+ lib/proutils/icli/uploadutils.rb
66
+ lib/proutils/mint
67
+ lib/proutils/mint/copier.rb
68
+ lib/proutils/mint/fileutils.rb
69
+ lib/proutils/mint/help.txt
70
+ lib/proutils/rtar
71
+ lib/proutils/rtar/rtar.rb
72
+ lib/proutils/rtar/vendor
73
+ lib/proutils/rtar/vendor/archive
74
+ lib/proutils/rtar/vendor/archive/tar
75
+ lib/proutils/rtar/vendor/archive/tar/minitar
76
+ lib/proutils/rtar/vendor/archive/tar/minitar/command.rb
77
+ lib/proutils/rtar/vendor/archive/tar/minitar.rb
78
+ lib/proutils/xact
79
+ lib/proutils/xact/extract.rb
80
+ lib/proutils/xact/save.rb
81
+ meta
82
+ meta/MANIFEST
83
+ meta/config.yaml
84
+ meta/icli.yaml
85
+ meta/project.yaml
86
+ meta/proutils.roll
87
+ task
88
+ task/changelog
89
+ task/clobber
90
+ task/clobber/package
91
+ task/prepare
92
+ task/publish
93
+ task/rdoc
94
+ task/release
95
+ task/setup
96
+ task/test
97
+ test
98
+ test/fixture.rb
99
+ test/lib
100
+ test/lib/test_exacto.rb
data/meta/config.yaml ADDED
@@ -0,0 +1,12 @@
1
+ ---
2
+
3
+ rdoc:
4
+ title: ProUtils
5
+ main: README
6
+ template: jamis
7
+ options: [ '--all', '--inline-source' ]
8
+ exclude:
9
+ - lib/proutils/rtar/vendor
10
+
11
+ publish:
12
+ project: proutils
data/meta/icli.yaml ADDED
@@ -0,0 +1,16 @@
1
+ ---
2
+ rubyforge:
3
+ project : proutils
4
+ username : transami
5
+
6
+ release:
7
+ store : pkg
8
+ package : proutils
9
+ notelog : RELEASE
10
+ changelog : CHANGES
11
+
12
+ publish: {}
13
+
14
+ announce:
15
+ message: README
16
+
data/meta/project.yaml ADDED
@@ -0,0 +1,27 @@
1
+ title : ProUtils
2
+ summary : Ruby Recursive Archival Format
3
+ description: >
4
+ ProUtils is a collect of handy command line tools. Think of it as a
5
+ supplement to the ubinqutous GNU CoreUtils.
6
+
7
+ author : Trans <transfire at gmail.com>
8
+ homepage : "http://proutils.rubyforge.org"
9
+ download : "https://rubyforge.org/frs/?group_id=4411"
10
+ maillist : proutils-talk@rubyforge.org
11
+ repository : "http://proutils.rubyforge.org/svn/"
12
+ created : "2006-05-09"
13
+
14
+ dependency:
15
+ - [ facets , '> 2.2.0']
16
+ - [ httpclient, '> 2.0.0' ]
17
+
18
+ executables:
19
+ - icli
20
+ - mint
21
+ - rtar
22
+ - xact
23
+ # - exrb
24
+
25
+ exclude : [ doc, task, pkg ]
26
+ document : true
27
+
@@ -0,0 +1,3 @@
1
+ proutils 0.3.0 beta 2007-12-17
2
+ lib/proutils
3
+
data/test/fixture.rb ADDED
@@ -0,0 +1,6 @@
1
+
2
+ =begin test
3
+ puts "here"
4
+ =end
5
+
6
+
@@ -0,0 +1,54 @@
1
+ # _____ _
2
+ # |_ _|__ ___| |_
3
+ # | |/ _ \/ __| __|
4
+ # | | __/\__ \ |_
5
+ # |_|\___||___/\__|
6
+ #
7
+ # for lib/exacto.rb
8
+ #
9
+ # Extracted Fri Feb 23 00:03:20 EST 2007
10
+ # Project.rb Test Extraction
11
+ #
12
+
13
+ require 'exacto.rb'
14
+
15
+
16
+ require 'test/unit'
17
+
18
+ class ExactoTest < Test::Unit::TestCase
19
+
20
+ def exacto_knife
21
+ @knife ||= Exacto.new('/dev/null')
22
+ end
23
+
24
+ def build_pattern_block(block, code)
25
+ exacto_knife.pattern_block(block).match(code)
26
+ end
27
+
28
+ # Usual case.
29
+
30
+ def test_pattern_block
31
+ assert_equal "require 'foo'\nfoo", build_pattern_block('test', "=begin test\nrequire 'foo'\nfoo\n=end")[1]
32
+ end
33
+
34
+ # Some tests for when the block is empty ('') -- should it act as a wildcard and match *any* block,
35
+ # or should Exacto::Command#initialize complain about that.
36
+
37
+ def test_pattern_block_no_handle
38
+ assert_equal "require 'foo'\nfoo", build_pattern_block('', "=begin\nrequire 'foo'\nfoo\n=end")[1]
39
+ end
40
+
41
+ def test_pattern_block_no_handle_given
42
+ assert_equal "require 'foo'\nfoo", build_pattern_block('', "=begin test\nrequire 'foo'\nfoo\n=end")[1]
43
+ end
44
+
45
+ # Yes, I know, as a side-effect of this regexp change, it will also match some invalid "blocks", like =beginblah. But that
46
+ # seems like a nonissue, given that the Ruby parser would reject that syntax anyway.
47
+
48
+ def test_pattern_block_side_effects
49
+ assert_equal "require 'foo'\nfoo", build_pattern_block('', "=beginblah\nrequire 'foo'\nfoo\n=end")[1]
50
+ end
51
+
52
+ end
53
+
54
+
data/work/ANN ADDED
@@ -0,0 +1,14 @@
1
+ ______ __
2
+ / ____/ __ ____ _____/ /_ ___
3
+ / __/ \ / / __ `/ ___/ __/ __ \
4
+ / /__ > </ /_/ / /__/ /_/ /_/ /
5
+ /_____/_/ \_\__,_/\___/\__/\____/ v.$version
6
+
7
+ $description
8
+
9
+ $homepage
10
+
11
+ $news
12
+
13
+ $slogan
14
+