bahuvrihi-tap 0.10.4 → 0.10.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/bin/rap +112 -0
  2. data/bin/tap +21 -10
  3. data/cmd/destroy.rb +1 -1
  4. data/cmd/generate.rb +1 -1
  5. data/cmd/run.rb +4 -48
  6. data/cmd/server.rb +3 -1
  7. data/lib/tap/constants.rb +1 -1
  8. data/lib/tap/env.rb +37 -39
  9. data/lib/tap/exe.rb +59 -29
  10. data/lib/tap/generator/base.rb +1 -1
  11. data/lib/tap/generator/generators/config/templates/doc.erb +1 -1
  12. data/lib/tap/generator/generators/file_task/templates/test.erb +1 -1
  13. data/lib/tap/generator/generators/root/templates/README +0 -0
  14. data/lib/tap/generator/generators/root/templates/gemspec +3 -4
  15. data/lib/tap/generator/generators/root/templates/tapfile +3 -3
  16. data/lib/tap/parser.rb +35 -0
  17. data/lib/tap/patches/optparse/summarize.rb +62 -0
  18. data/lib/tap/root.rb +24 -18
  19. data/lib/tap/support/class_configuration.rb +1 -1
  20. data/lib/tap/support/configurable_class.rb +3 -1
  21. data/lib/tap/support/configuration.rb +19 -0
  22. data/lib/tap/support/constant.rb +14 -2
  23. data/lib/tap/support/declarations.rb +33 -39
  24. data/lib/tap/support/dependable.rb +21 -2
  25. data/lib/tap/support/gems.rb +4 -30
  26. data/lib/tap/support/gems/rack.rb +14 -11
  27. data/lib/tap/support/lazy_attributes.rb +1 -1
  28. data/lib/tap/support/lazydoc.rb +257 -340
  29. data/lib/tap/support/lazydoc/comment.rb +499 -0
  30. data/lib/tap/support/lazydoc/config.rb +17 -0
  31. data/lib/tap/support/lazydoc/declaration.rb +20 -0
  32. data/lib/tap/support/lazydoc/document.rb +118 -0
  33. data/lib/tap/support/lazydoc/method.rb +24 -0
  34. data/lib/tap/support/manifest.rb +33 -4
  35. data/lib/tap/support/validation.rb +56 -0
  36. data/lib/tap/task.rb +46 -44
  37. data/lib/tap/tasks/dump.rb +15 -10
  38. data/lib/tap/tasks/load.rb +25 -0
  39. data/lib/tap/tasks/rake.rb +2 -2
  40. data/lib/tap/test.rb +55 -36
  41. data/lib/tap/test/file_methods.rb +204 -178
  42. data/lib/tap/test/file_methods_class.rb +4 -18
  43. data/lib/tap/test/script_methods.rb +76 -90
  44. data/lib/tap/test/script_methods/regexp_escape.rb +92 -0
  45. data/lib/tap/test/script_methods/script_test.rb +4 -2
  46. data/lib/tap/test/subset_methods.rb +46 -49
  47. data/lib/tap/test/subset_methods_class.rb +17 -54
  48. data/lib/tap/test/tap_methods.rb +1 -5
  49. data/lib/tap/test/utils.rb +142 -32
  50. metadata +12 -3
  51. data/lib/tap/support/command_line.rb +0 -55
  52. data/lib/tap/support/comment.rb +0 -270
@@ -1,270 +0,0 @@
1
- require 'strscan'
2
-
3
- module Tap
4
- module Support
5
- # Comment represents a comment parsed by Lazydoc.
6
- class Comment
7
-
8
- class << self
9
-
10
- # Parses the input string into a comment, stopping at end_regexp
11
- # or the first non-comment line. Also parses the next non-comment
12
- # lines as the comment subject. Takes a string or a StringScanner
13
- # and returns the new comment.
14
- #
15
- # comment_string = %Q{
16
- # # comments spanning multiple
17
- # # lines are collected
18
- # #
19
- # # while indented lines
20
- # # are preserved individually
21
- # #
22
- # this is the subject line
23
- #
24
- # # this line is not parsed as it
25
- # # is after a non-comment line
26
- # }
27
- #
28
- # c = Comment.parse(comment_string)
29
- # c.lines
30
- # # => [
31
- # # ['comments spanning multiple', 'lines are collected'],
32
- # # [''],
33
- # # [' while indented lines'],
34
- # # [' are preserved individually'],
35
- # # [''],
36
- # # []]
37
- # c.subject # => "this is the subject line"
38
- #
39
- def parse(str, parse_subject=true) # :yields: fragment
40
- scanner = case str
41
- when StringScanner then str
42
- when String then StringScanner.new(str)
43
- else raise TypeError, "can't convert #{str.class} into StringScanner or String"
44
- end
45
-
46
- comment = Comment.new
47
- while scanner.scan(/\r?\n?[ \t]*#[ \t]?(([ \t]*).*?)\r?$/)
48
- fragment = scanner[1]
49
- indent = scanner[2]
50
-
51
- # collect continuous description line
52
- # fragments and join into a single line
53
- if block_given? && yield(fragment)
54
- # break on comment if the description end is reached
55
- parse_subject = false
56
- break
57
- else
58
- categorize(fragment, indent) {|f| comment.push(f) }
59
- end
60
- end
61
-
62
- if parse_subject
63
- scanner.skip(/\s+/)
64
- unless scanner.peek(1) == '#'
65
- comment.subject = scanner.scan(/.+?$/)
66
- comment.subject.strip! unless comment.subject == nil
67
- end
68
- end
69
-
70
- comment
71
- end
72
-
73
- # Scans the line checking if it is a comment. If so, scan
74
- # yields the parse fragments to the block which correspond
75
- # to the type of comment input (continuation, indent, etc).
76
- # Returns true if the line is a comment, false otherwise.
77
- #
78
- # Scan may be used to build a comment from an array of lines:
79
- #
80
- # lines = [
81
- # "# comments spanning multiple",
82
- # "# lines are collected",
83
- # "#",
84
- # "# while indented lines",
85
- # "# are preserved individually",
86
- # "# ",
87
- # "not a comment line",
88
- # "# skipped since the loop breaks",
89
- # "# at the first non-comment line"]
90
- #
91
- # c = Comment.new
92
- # lines.each do |line|
93
- # break unless Comment.scan(line) do |fragment|
94
- # # c.unshift will also work if building in reverse
95
- # c.push(fragment)
96
- # end
97
- # end
98
- #
99
- # c.lines
100
- # # => [
101
- # # ['comments spanning multiple', 'lines are collected'],
102
- # # [''],
103
- # # [' while indented lines'],
104
- # # [' are preserved individually'],
105
- # # [''],
106
- # # []]
107
- #
108
- def scan(line) # :yields: fragment
109
- return false unless line =~ /^[ \t]*#[ \t]?(([ \t]*).*?)\r?$/
110
- categorize($1, $2) do |fragment|
111
- yield(fragment)
112
- end
113
- true
114
- end
115
-
116
- def wrap(lines, cols=80, tabsize=2)
117
- lines = lines.split(/\r?\n/) unless lines.kind_of?(Array)
118
-
119
- lines.collect do |line|
120
- line = line.gsub(/\t/, " " * tabsize) unless tabsize == nil
121
-
122
- if line.strip.empty?
123
- line
124
- else
125
- # wrapping algorithm is slightly modified from
126
- # http://blog.macromates.com/2006/wrapping-text-with-regular-expressions/
127
- line.gsub(/(.{1,#{cols}})( +|$\r?\n?)|(.{1,#{cols}})/, "\\1\\3\n").split(/\s*\n/)
128
- end
129
- end.flatten
130
- end
131
-
132
- private
133
-
134
- def categorize(fragment, indent)
135
- case
136
- when fragment == indent
137
- # empty comment line
138
- yield [""]
139
- yield []
140
- when indent.empty?
141
- # continuation line
142
- yield fragment.rstrip
143
- else
144
- # indented line
145
- yield [fragment.rstrip]
146
- yield []
147
- end
148
- end
149
- end
150
-
151
- # An array of line fragment arrays.
152
- attr_reader :lines
153
-
154
- # The next non-comment line after the comment ends.
155
- # This is the line that would receive the comment
156
- # in RDoc documentation.
157
- attr_accessor :subject
158
-
159
- # Returns the line number for the subject line, if known.
160
- attr_accessor :line_number
161
-
162
- def initialize(line_number=nil)
163
- @lines = []
164
- @subject = nil
165
- @line_number = line_number
166
- end
167
-
168
- # Pushes the fragment onto the last line array. If fragment is an
169
- # array itself, then fragment will be pushed onto lines.
170
- #
171
- # c = Comment.new
172
- # c.push "some line"
173
- # c.push "fragments"
174
- # c.push ["a", "whole", "new line"]
175
- # c.lines # => [["some line", "fragments"], ["a", "whole", "new line"]]
176
- #
177
- def push(fragment)
178
- lines << [] if lines.empty?
179
-
180
- case fragment
181
- when Array
182
- if lines[-1].empty?
183
- lines[-1] = fragment
184
- else
185
- lines.push fragment
186
- end
187
- else
188
- lines[-1].push fragment
189
- end
190
- end
191
-
192
- # Alias for push.
193
- def <<(fragment)
194
- push(fragment)
195
- end
196
-
197
- # Unshifts the fragment to the first line array. If fragment is an
198
- # array itself, then fragment will be unshifted onto lines.
199
- #
200
- # c = Comment.new
201
- # c.unshift "some line"
202
- # c.unshift "fragments"
203
- # c.unshift ["a", "whole", "new line"]
204
- # c.lines # => [["a", "whole", "new line"], ["fragments", "some line"]]
205
- #
206
- def unshift(fragment)
207
- lines << [] if lines.empty?
208
-
209
- case fragment
210
- when Array
211
- if lines[0].empty?
212
- lines[0] = fragment
213
- else
214
- lines.unshift fragment
215
- end
216
- else
217
- lines[0].unshift fragment
218
- end
219
- end
220
-
221
- def prepend(comment_line)
222
- Comment.scan(comment_line) {|f| unshift(f) }
223
- end
224
-
225
- def append(comment_line)
226
- Comment.scan(comment_line) {|f| push(f) }
227
- end
228
-
229
- # Removes leading and trailing lines that are empty ([])
230
- # or whitespace (['']). Returns self.
231
- def trim
232
- lines.shift while !lines.empty? && (lines[0].empty? || lines[0].join.strip.empty?)
233
- lines.pop while !lines.empty? && (lines[-1].empty? || lines[-1].join.strip.empty?)
234
- self
235
- end
236
-
237
- # True if there are no fragments in self.
238
- def empty?
239
- !lines.find {|array| !array.empty?}
240
- end
241
-
242
- def wrap(cols=80, tabsize=2, line_sep="\n", fragment_sep=" ", strip=true)
243
- resolved_lines = Comment.wrap(to_s(fragment_sep, nil, strip), cols, tabsize)
244
- line_sep ? resolved_lines.join(line_sep) : resolved_lines
245
- end
246
-
247
- # Returns lines as a string where line fragments are joined by
248
- # fragment_sep and lines are joined by line_sep.
249
- def to_s(fragment_sep=" ", line_sep="\n", strip=true)
250
- resolved_lines = lines.collect {|line| line.join(fragment_sep)}
251
-
252
- # strip leading an trailing whitespace lines
253
- if strip
254
- resolved_lines.shift while !resolved_lines.empty? && resolved_lines[0].empty?
255
- resolved_lines.pop while !resolved_lines.empty? && resolved_lines[-1].empty?
256
- end
257
-
258
- line_sep ? resolved_lines.join(line_sep) : resolved_lines
259
- end
260
-
261
- def ==(another)
262
- another.kind_of?(Comment) &&
263
- self.line_number == another.line_number &&
264
- self.subject == another.subject &&
265
- self.lines == another.lines
266
- end
267
-
268
- end
269
- end
270
- end