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.
- data/CHANGES +17 -0
- data/COPYING +674 -0
- data/README +78 -0
- data/RELEASE +7 -0
- data/TODO +4 -0
- data/bin/icli +278 -0
- data/bin/mint +139 -0
- data/bin/rtar +69 -0
- data/bin/xact +121 -0
- data/data/mint/cherry/_scaffold.rb +4 -0
- data/data/mint/roll/name-1.0.0.roll +26 -0
- data/data/mint/ruby/README +17 -0
- data/data/mint/ruby/README.first +10 -0
- data/data/mint/ruby/README.license +403 -0
- data/data/mint/ruby/meta/MANIFEST +2 -0
- data/data/mint/ruby/meta/name-1.0.0.roll +26 -0
- data/data/mint/ruby/script/finish_scaffold +8 -0
- data/data/mint/ruby/script/setup +1600 -0
- data/data/mint/website/css/clean.css +5 -0
- data/data/mint/website/index.html +0 -0
- data/demo/demo_rtar/Lorem_ipsum.txt +233 -0
- data/demo/demo_rtar/lib/demo_rock/tryme.rb +2 -0
- data/demo/demo_rtar/meta/data +6 -0
- data/demo/demo_rtar/web/index.html +13 -0
- data/demo/demo_rtar/web/rocklobster.jpg +0 -0
- data/demo/mint/loremipsum.txt +9 -0
- data/demo/mint/tryme.rb +33 -0
- data/lib/proutils/icli/abstract_host.rb +71 -0
- data/lib/proutils/icli/gforge.rb +668 -0
- data/lib/proutils/icli/rubyforge.rb +26 -0
- data/lib/proutils/icli/tool.rb +128 -0
- data/lib/proutils/icli/uploadutils.rb +410 -0
- data/lib/proutils/mint/copier.rb +324 -0
- data/lib/proutils/mint/fileutils.rb +47 -0
- data/lib/proutils/mint/help.txt +0 -0
- data/lib/proutils/rtar/rtar.rb +309 -0
- data/lib/proutils/rtar/vendor/archive/tar/minitar/command.rb +814 -0
- data/lib/proutils/rtar/vendor/archive/tar/minitar.rb +979 -0
- data/lib/proutils/xact/extract.rb +211 -0
- data/lib/proutils/xact/save.rb +151 -0
- data/meta/MANIFEST +100 -0
- data/meta/config.yaml +12 -0
- data/meta/icli.yaml +16 -0
- data/meta/project.yaml +27 -0
- data/meta/proutils.roll +3 -0
- data/test/fixture.rb +6 -0
- data/test/lib/test_exacto.rb +54 -0
- data/work/ANN +14 -0
- data/work/icli/icli +223 -0
- data/work/icli/rake.rb +82 -0
- data/work/icli/utils/consoleutils.rb +67 -0
- data/work/icli/utils/emailutils.rb +85 -0
- data/work/icli/utils/fileutils.rb +47 -0
- data/work/mint/command-old.rb +48 -0
- data/work/mint/lazyfile.rb +97 -0
- data/work/mint/part.rb +316 -0
- data/work/mint/scaffold-old.rb +420 -0
- data/work/rtar/index.html +68 -0
- data/work/rtar/old-index.html +63 -0
- data/work/xact/xact-ginsu +5 -0
- data/work/xact/xact-ruby.rb +155 -0
- 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
data/meta/icli.yaml
ADDED
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
|
+
|
data/meta/proutils.roll
ADDED
@@ -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
|
+
|