tomparse 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.index +2 -2
- data/.yardopts +8 -0
- data/HISTORY.md +26 -1
- data/README.md +92 -7
- data/lib/tomparse.rb +43 -482
- data/lib/tomparse.yml +68 -0
- data/lib/tomparse/argument.rb +69 -0
- data/lib/tomparse/option.rb +30 -0
- data/lib/tomparse/parse_error.rb +30 -0
- data/lib/tomparse/parser.rb +699 -0
- data/test/helper.rb +0 -20
- data/test/test_description.rb +54 -0
- data/test/test_prefixes.rb +3 -3
- data/test/test_signatures.rb +44 -25
- data/test/test_tags.rb +6 -4
- data/test/test_tomdoc.rb +3 -3
- data/test/test_yields.rb +17 -0
- metadata +12 -3
- data/.rubyrc +0 -19
data/test/helper.rb
CHANGED
@@ -1,25 +1,5 @@
|
|
1
|
-
#require 'microtest/testunit'
|
2
|
-
#require 'microtest/assertions'
|
3
|
-
#require 'test/fixtures/multiplex'
|
4
|
-
|
5
1
|
require 'citron'
|
6
2
|
require 'ae'
|
7
3
|
|
8
4
|
require 'tomparse'
|
9
5
|
|
10
|
-
#module TomParse
|
11
|
-
# class Test < ::Test::Unit::TestCase
|
12
|
-
# def self.test(name, &block)
|
13
|
-
# define_method("test_#{name.gsub(/\W/,'_')}", &block) if block
|
14
|
-
# end
|
15
|
-
#
|
16
|
-
# def default_test
|
17
|
-
# end
|
18
|
-
#
|
19
|
-
# def fixture(name)
|
20
|
-
# @fixtures ||= {}
|
21
|
-
# @fixtures[name] ||= File.read("test/fixtures/#{name}.rb")
|
22
|
-
# end
|
23
|
-
# end
|
24
|
-
#end
|
25
|
-
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
3
|
+
testcase "Description" do
|
4
|
+
|
5
|
+
context "description only" do
|
6
|
+
setup do
|
7
|
+
@comment = TomParse::TomDoc.new %{
|
8
|
+
# Has this initial paragraph.
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
test "correctly handles description only" do
|
13
|
+
@comment.description.assert == "Has this initial paragraph."
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "simple description with other things" do
|
18
|
+
setup do
|
19
|
+
@comment = TomParse::TomDoc.new %{
|
20
|
+
# Has this initial paragraph, that continues on to
|
21
|
+
# a new line.
|
22
|
+
#
|
23
|
+
# Examples
|
24
|
+
#
|
25
|
+
# foo('bar')
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
test "correctly handles description" do
|
30
|
+
@comment.description.assert == "Has this initial paragraph, that continues on to\na new line."
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "handles multiple paragraph descriptions" do
|
35
|
+
setup do
|
36
|
+
@comment = TomParse::TomDoc.new %{
|
37
|
+
# Has an initial paragraph.
|
38
|
+
#
|
39
|
+
# Has another paragraph in the description.
|
40
|
+
#
|
41
|
+
# Examples
|
42
|
+
#
|
43
|
+
# def multiplex(str, length)
|
44
|
+
# str * length
|
45
|
+
# end
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
test "correctly handles multiple paragraphs" do
|
50
|
+
@comment.description.assert == "Has an initial paragraph.\n\nHas another paragraph in the description."
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
data/test/test_prefixes.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative 'helper'
|
2
2
|
|
3
3
|
testcase "Prefixes" do
|
4
4
|
|
@@ -11,7 +11,7 @@ testcase "Prefixes" do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
test "internal?" do
|
14
|
-
|
14
|
+
@tomdoc.assert.internal?
|
15
15
|
end
|
16
16
|
|
17
17
|
test "description" do
|
@@ -29,7 +29,7 @@ testcase "Prefixes" do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
test "public?" do
|
32
|
-
|
32
|
+
@tomdoc.assert.public?
|
33
33
|
end
|
34
34
|
|
35
35
|
test "description" do
|
data/test/test_signatures.rb
CHANGED
@@ -1,36 +1,55 @@
|
|
1
|
-
|
1
|
+
require_relative 'helper'
|
2
2
|
|
3
3
|
testcase "Signatures" do
|
4
4
|
|
5
|
-
|
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
|
-
# Signature
|
12
|
-
#
|
13
|
-
# find_by_<field>[_and_<field>...](args)
|
14
|
-
#
|
15
|
-
# field - A field name.
|
16
|
-
}
|
17
|
-
end
|
5
|
+
context "singular term" do
|
18
6
|
|
19
|
-
|
20
|
-
|
21
|
-
|
7
|
+
setup do
|
8
|
+
@comment = TomParse::TomDoc.new %{
|
9
|
+
# Duplicate some text an abitrary number of times.
|
10
|
+
#
|
11
|
+
# Signature
|
12
|
+
#
|
13
|
+
# find(name)
|
14
|
+
# find(name=>pattern)
|
15
|
+
#
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
test "knows if the method has alternate signatures" do
|
20
|
+
@comment.signatures.size.assert == 2
|
21
|
+
@comment.signatures.first.assert == "find(name)"
|
22
|
+
@comment.signatures.last.assert == "find(name=>pattern)"
|
23
|
+
end
|
22
24
|
|
23
|
-
test "knows if the method has alternate signatures" do
|
24
|
-
@comment.signatures.size.assert == 1
|
25
|
-
@comment.signatures.first.assert == "find_by_<field>[_and_<field>...](args)"
|
26
25
|
end
|
27
26
|
|
28
|
-
|
29
|
-
|
27
|
+
context "plural term" do
|
28
|
+
|
29
|
+
setup do
|
30
|
+
@comment = TomParse::TomDoc.new %{
|
31
|
+
# Duplicate some text an abitrary number of times.
|
32
|
+
#
|
33
|
+
# Signatures
|
34
|
+
#
|
35
|
+
# find_by_<field>[_and_<field>...](args)
|
36
|
+
#
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
test "knows if the method has alternate signatures" do
|
41
|
+
@comment.signatures.size.assert == 1
|
42
|
+
@comment.signatures.first.assert == "find_by_<field>[_and_<field>...](args)"
|
43
|
+
end
|
30
44
|
|
31
|
-
arg = @comment.signature_fields.first
|
32
|
-
arg.name.assert == :field
|
33
|
-
arg.description.assert == "A field name."
|
34
45
|
end
|
35
46
|
|
47
|
+
#test "knows the fields associated with signatures" do
|
48
|
+
# @comment.signature_fields.size.assert == 1
|
49
|
+
#
|
50
|
+
# arg = @comment.signature_fields.first
|
51
|
+
# arg.name.assert == :field
|
52
|
+
# arg.description.assert == "A field name."
|
53
|
+
#end
|
54
|
+
|
36
55
|
end
|
data/test/test_tags.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative 'helper'
|
2
2
|
|
3
3
|
testcase "Tags" do
|
4
4
|
|
@@ -13,7 +13,8 @@ testcase "Tags" do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
test "tags has todo" do
|
16
|
-
|
16
|
+
@tomdoc.tags.size.assert == 1
|
17
|
+
@tomdoc.tags.assert.include? ['TODO', 'Something we have to do.']
|
17
18
|
end
|
18
19
|
|
19
20
|
end
|
@@ -24,12 +25,13 @@ testcase "Tags" do
|
|
24
25
|
@tomdoc = TomParse::TomDoc.new(<<-END)
|
25
26
|
# This is an example of tags.
|
26
27
|
#
|
27
|
-
#
|
28
|
+
# Foo: They can be anything really.
|
28
29
|
END
|
29
30
|
end
|
30
31
|
|
31
32
|
test "tags has foo" do
|
32
|
-
|
33
|
+
@tomdoc.tags.size.assert == 1
|
34
|
+
@tomdoc.tags.assert.include? ['Foo', 'They can be anything really.']
|
33
35
|
end
|
34
36
|
|
35
37
|
end
|
data/test/test_tomdoc.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative 'helper'
|
2
2
|
|
3
3
|
testcase TomParse::TomDoc do
|
4
4
|
|
@@ -14,8 +14,8 @@ testcase TomParse::TomDoc do
|
|
14
14
|
# reverse - An optional Boolean indicating
|
15
15
|
# whether to reverse the result text or not.
|
16
16
|
# options - Options (default: {})
|
17
|
-
#
|
18
|
-
#
|
17
|
+
# :insert_spaces - Whether to insert spaces
|
18
|
+
# :upcase - Convert the string to upper case
|
19
19
|
# blk - The block.
|
20
20
|
#
|
21
21
|
# Examples
|
data/test/test_yields.rb
ADDED
@@ -0,0 +1,17 @@
|
|
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
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tomparse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: citron
|
@@ -74,13 +74,20 @@ extra_rdoc_files:
|
|
74
74
|
- README.md
|
75
75
|
files:
|
76
76
|
- .index
|
77
|
-
- .
|
77
|
+
- .yardopts
|
78
|
+
- lib/tomparse/argument.rb
|
79
|
+
- lib/tomparse/option.rb
|
80
|
+
- lib/tomparse/parse_error.rb
|
81
|
+
- lib/tomparse/parser.rb
|
78
82
|
- lib/tomparse.rb
|
83
|
+
- lib/tomparse.yml
|
79
84
|
- test/helper.rb
|
85
|
+
- test/test_description.rb
|
80
86
|
- test/test_prefixes.rb
|
81
87
|
- test/test_signatures.rb
|
82
88
|
- test/test_tags.rb
|
83
89
|
- test/test_tomdoc.rb
|
90
|
+
- test/test_yields.rb
|
84
91
|
- HISTORY.md
|
85
92
|
- README.md
|
86
93
|
- LICENSE.txt
|
@@ -110,7 +117,9 @@ signing_key:
|
|
110
117
|
specification_version: 3
|
111
118
|
summary: TomDoc parser for Ruby
|
112
119
|
test_files:
|
120
|
+
- test/test_description.rb
|
113
121
|
- test/helper.rb
|
122
|
+
- test/test_yields.rb
|
114
123
|
- test/test_signatures.rb
|
115
124
|
- test/test_tags.rb
|
116
125
|
- test/test_tomdoc.rb
|
data/.rubyrc
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
config 'rubytest' do |run|
|
2
|
-
run.files << 'test/test_*.rb'
|
3
|
-
|
4
|
-
$:.unshift('test')
|
5
|
-
$:.unshift('lib')
|
6
|
-
end
|
7
|
-
|
8
|
-
config 'rubytest', :profile=>'coverage' do |run|
|
9
|
-
run.files << 'test/test_*.rb'
|
10
|
-
|
11
|
-
$:.unshift('test')
|
12
|
-
$:.unshift('lib')
|
13
|
-
|
14
|
-
require 'simplecov'
|
15
|
-
SimpleCov.start do
|
16
|
-
coverage_dir 'log/coverage'
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|