tomparse 0.4.2 → 0.5.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.
- checksums.yaml +7 -0
- data/HISTORY.md +18 -1
- data/README.md +33 -46
- data/lib/tomparse/argument.rb +1 -1
- data/lib/tomparse/parser.rb +8 -8
- data/lib/tomparse/version.rb +4 -0
- data/lib/tomparse.rb +5 -1
- metadata +52 -72
- data/.index +0 -67
- data/.yardopts +0 -8
- data/lib/tomparse.yml +0 -67
- data/test/helper.rb +0 -13
- data/test/test_arguments.rb +0 -217
- data/test/test_description.rb +0 -54
- data/test/test_examples.rb +0 -124
- data/test/test_prefixes.rb +0 -42
- data/test/test_signatures.rb +0 -55
- data/test/test_tags.rb +0 -40
- data/test/test_tomdoc.rb +0 -217
- data/test/test_yields.rb +0 -17
data/test/test_tomdoc.rb
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
require_relative 'helper'
|
|
2
|
-
|
|
3
|
-
testcase TomParse::TomDoc do
|
|
4
|
-
|
|
5
|
-
context "general parsing" do
|
|
6
|
-
|
|
7
|
-
setup do
|
|
8
|
-
@comment = TomParse::TomDoc.new %{
|
|
9
|
-
# Duplicate some text an abitrary number of times.
|
|
10
|
-
#
|
|
11
|
-
# text - The String to be duplicated.
|
|
12
|
-
# count - The Integer number of times to
|
|
13
|
-
# duplicate the text.
|
|
14
|
-
# reverse - An optional Boolean indicating
|
|
15
|
-
# whether to reverse the result text or not.
|
|
16
|
-
# options - Options (default: {})
|
|
17
|
-
# :insert_spaces - Whether to insert spaces
|
|
18
|
-
# :upcase - Convert the string to upper case
|
|
19
|
-
# blk - The block.
|
|
20
|
-
#
|
|
21
|
-
# Examples
|
|
22
|
-
# multiplex('Tom', 4)
|
|
23
|
-
# # => 'TomTomTomTom'
|
|
24
|
-
#
|
|
25
|
-
# multiplex('Bo', 2)
|
|
26
|
-
# # => 'BoBo'
|
|
27
|
-
#
|
|
28
|
-
# multiplex('Chris', -1)
|
|
29
|
-
# # => nil
|
|
30
|
-
#
|
|
31
|
-
# Returns the duplicated String when the count is > 1.
|
|
32
|
-
# Returns the atomic mass of the element as a Float. The value is in
|
|
33
|
-
# unified atomic mass units.
|
|
34
|
-
# Returns nil when the count is < 1.
|
|
35
|
-
# Raises ExpectedString if the first argument is not a String.
|
|
36
|
-
# Raises ExpectedInteger if the second argument is not an Integer.
|
|
37
|
-
}
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
test "parses a description" do
|
|
41
|
-
@comment.description.assert == "Duplicate some text an abitrary number of times."
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
test "parses args" do
|
|
45
|
-
@comment.args.size.assert == 5
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
test "know a hash arg's options" do
|
|
49
|
-
@comment.args[3].options.size.assert == 2
|
|
50
|
-
@comment.args[3].options.first.name.assert == :':insert_spaces'
|
|
51
|
-
@comment.args[3].options[1].name.assert == :':upcase'
|
|
52
|
-
@comment.args[3].options.first.description.assert == 'Whether to insert spaces'
|
|
53
|
-
@comment.args[3].options[1].description.assert == 'Convert the string to upper case'
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
test "knows an arg's name" do
|
|
57
|
-
@comment.args.first.name.assert == :text
|
|
58
|
-
@comment.args[1].name.assert == :count
|
|
59
|
-
@comment.args[2].name.assert == :reverse
|
|
60
|
-
@comment.args[3].name.assert == :options
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
test "knows an arg's description" do
|
|
64
|
-
@comment.args[1].description.assert == 'The Integer number of times to duplicate the text.'
|
|
65
|
-
|
|
66
|
-
reverse = 'An optional Boolean indicating whether to reverse the'
|
|
67
|
-
reverse << ' result text or not.'
|
|
68
|
-
@comment.args[2].description.assert == reverse
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
test "knows an arg's optionality" do
|
|
72
|
-
refute @comment.args.first.optional?
|
|
73
|
-
assert @comment.args[2].optional?
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
test "knows how many examples there are" do
|
|
77
|
-
@comment.examples.size.assert == 3
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
test "knows each example" do
|
|
81
|
-
@comment.examples[1].to_s.assert == "multiplex('Bo', 2)\n# => 'BoBo'"
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
test "knows how many return examples there are" do
|
|
85
|
-
@comment.returns.size.assert == 3
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
test "knows if the method raises anything" do
|
|
89
|
-
@comment.raises.size.assert == 2
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
test "knows each return example" do
|
|
93
|
-
rtn = @comment.returns.first.to_s
|
|
94
|
-
rtn.assert == "Returns the duplicated String when the count is > 1."
|
|
95
|
-
|
|
96
|
-
string = ''
|
|
97
|
-
string << "Returns the atomic mass of the element as a Float. "
|
|
98
|
-
string << "The value is in unified atomic mass units."
|
|
99
|
-
@comment.returns[1].to_s.assert == string
|
|
100
|
-
|
|
101
|
-
@comment.returns[2].to_s.assert == "Returns nil when the count is < 1."
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
context "handles multiple paragraph descriptions" do
|
|
107
|
-
setup do
|
|
108
|
-
@comment = TomParse::TomDoc.new %{
|
|
109
|
-
# Has an initial paragraph.
|
|
110
|
-
#
|
|
111
|
-
# Has another paragraph in the description.
|
|
112
|
-
#
|
|
113
|
-
# Examples
|
|
114
|
-
#
|
|
115
|
-
# def multiplex(str, length)
|
|
116
|
-
# str * length
|
|
117
|
-
# end
|
|
118
|
-
}
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
test "correctly handles multiple paragraphs" do
|
|
122
|
-
@comment.description.assert == "Has an initial paragraph.\n\nHas another paragraph in the description."
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
context "handles whitespace in examples" do
|
|
127
|
-
setup do
|
|
128
|
-
@comment = TomParse::TomDoc.new %{
|
|
129
|
-
# Duplicate some text an abitrary number of times.
|
|
130
|
-
#
|
|
131
|
-
# Examples
|
|
132
|
-
#
|
|
133
|
-
# def multiplex(str, length)
|
|
134
|
-
# str * length
|
|
135
|
-
# end
|
|
136
|
-
}
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
test "correctly handles whitespace with examples" do
|
|
140
|
-
eg = @comment.examples[0].to_s
|
|
141
|
-
eg.assert == "def multiplex(str, length)\n str * length\nend"
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
context "without arguments or examples" do
|
|
146
|
-
|
|
147
|
-
setup do
|
|
148
|
-
@comment = TomParse::TomDoc.new %{
|
|
149
|
-
# Duplicate some text an abitrary number of times.
|
|
150
|
-
#
|
|
151
|
-
# Returns the duplicated String.
|
|
152
|
-
}
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
test "knows what to do when there are no args" do
|
|
156
|
-
@comment.args.size.assert == 0
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
test "knows what to do when there are no examples" do
|
|
160
|
-
@comment.examples.size.assert == 0
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
test "knows what to do when there are no return examples" do
|
|
164
|
-
@comment.examples.size.assert == 0
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
context "invalid documentation" do
|
|
171
|
-
|
|
172
|
-
setup do
|
|
173
|
-
@comment = TomParse::TomDoc.new %{
|
|
174
|
-
# Duplicate some text an abitrary number of times.
|
|
175
|
-
#
|
|
176
|
-
# Examples
|
|
177
|
-
#
|
|
178
|
-
# multiplex('Tom', 4)
|
|
179
|
-
# # => 'TomTomTomTom'
|
|
180
|
-
#
|
|
181
|
-
# multiplex('Bo', 2)
|
|
182
|
-
# # => 'BoBo'
|
|
183
|
-
}
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
test "knows when TomDoc is invalid" do
|
|
187
|
-
expect TomParse::ParseError do
|
|
188
|
-
@comment.validate
|
|
189
|
-
end
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
context "without comment marker" do
|
|
196
|
-
|
|
197
|
-
setup do
|
|
198
|
-
@comment = TomParse::TomDoc.new %{
|
|
199
|
-
Duplicate some text an abitrary number of times.
|
|
200
|
-
|
|
201
|
-
Yields the Integer index of the iteration.
|
|
202
|
-
|
|
203
|
-
Signature
|
|
204
|
-
|
|
205
|
-
find_by_<field>[_and_<field>...](args)
|
|
206
|
-
|
|
207
|
-
field - A field name.
|
|
208
|
-
}
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
test "can handle comments without comment marker" do
|
|
212
|
-
@comment.description.assert == "Duplicate some text an abitrary number of times."
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
end
|
data/test/test_yields.rb
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
require_relative 'helper'
|
|
2
|
-
|
|
3
|
-
testcase "Yields" do
|
|
4
|
-
|
|
5
|
-
setup do
|
|
6
|
-
@comment = TomParse::TomDoc.new %{
|
|
7
|
-
# Duplicate some text an abitrary number of times.
|
|
8
|
-
#
|
|
9
|
-
# Yields the Integer index of the iteration.
|
|
10
|
-
}
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
test "knows what the method yields" do
|
|
14
|
-
@comment.yields.assert == "Yields the Integer index of the iteration."
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
end
|