distil 0.14.4 → 0.14.5.a

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. data/VERSION +1 -1
  2. data/bin/distil +10 -0
  3. data/lib/distil/project.rb +10 -7
  4. data/lib/distil/source-file.rb +1 -1
  5. metadata +28 -164
  6. data/Buildfile +0 -33
  7. data/distil.gemspec +0 -783
  8. data/lib/distil/javascript-documentation-generator.rb +0 -49
  9. data/vendor/pdoc/LICENSE +0 -16
  10. data/vendor/pdoc/PDoc.tmbundle/Commands/Continue PDoc Comment.tmCommand +0 -39
  11. data/vendor/pdoc/PDoc.tmbundle/Macros/Collapse PDoc Blocks.tmMacro +0 -4084
  12. data/vendor/pdoc/PDoc.tmbundle/Macros/Expand PDoc Blocks.tmMacro +0 -1388
  13. data/vendor/pdoc/PDoc.tmbundle/Preferences/PDoc.tmPreferences +0 -50
  14. data/vendor/pdoc/PDoc.tmbundle/Snippets/class.tmSnippet +0 -24
  15. data/vendor/pdoc/PDoc.tmbundle/Snippets/constant.tmSnippet +0 -22
  16. data/vendor/pdoc/PDoc.tmbundle/Snippets/event.tmSnippet +0 -16
  17. data/vendor/pdoc/PDoc.tmbundle/Snippets/method.tmSnippet +0 -22
  18. data/vendor/pdoc/PDoc.tmbundle/Snippets/mixin.tmSnippet +0 -23
  19. data/vendor/pdoc/PDoc.tmbundle/Snippets/namespace.tmSnippet +0 -24
  20. data/vendor/pdoc/PDoc.tmbundle/Snippets/param.tmSnippet +0 -16
  21. data/vendor/pdoc/PDoc.tmbundle/Snippets/property.tmSnippet +0 -22
  22. data/vendor/pdoc/PDoc.tmbundle/Snippets/section.tmSnippet +0 -23
  23. data/vendor/pdoc/PDoc.tmbundle/Syntaxes/PDoc.tmLanguage +0 -33
  24. data/vendor/pdoc/PDoc.tmbundle/info.plist +0 -22
  25. data/vendor/pdoc/README.markdown +0 -34
  26. data/vendor/pdoc/Rakefile +0 -46
  27. data/vendor/pdoc/bin/pdoc +0 -58
  28. data/vendor/pdoc/lib/pdoc.rb +0 -32
  29. data/vendor/pdoc/lib/pdoc/error.rb +0 -4
  30. data/vendor/pdoc/lib/pdoc/generators.rb +0 -6
  31. data/vendor/pdoc/lib/pdoc/generators/abstract_generator.rb +0 -16
  32. data/vendor/pdoc/lib/pdoc/generators/html.rb +0 -8
  33. data/vendor/pdoc/lib/pdoc/generators/html/helpers.rb +0 -256
  34. data/vendor/pdoc/lib/pdoc/generators/html/page.rb +0 -71
  35. data/vendor/pdoc/lib/pdoc/generators/html/syntax_highlighter.rb +0 -41
  36. data/vendor/pdoc/lib/pdoc/generators/html/template.rb +0 -37
  37. data/vendor/pdoc/lib/pdoc/generators/html/website.rb +0 -194
  38. data/vendor/pdoc/lib/pdoc/generators/json.rb +0 -15
  39. data/vendor/pdoc/lib/pdoc/generators/pythonesque.rb +0 -105
  40. data/vendor/pdoc/lib/pdoc/models.rb +0 -47
  41. data/vendor/pdoc/lib/pdoc/models/argument.rb +0 -37
  42. data/vendor/pdoc/lib/pdoc/models/base.rb +0 -107
  43. data/vendor/pdoc/lib/pdoc/models/callable.rb +0 -19
  44. data/vendor/pdoc/lib/pdoc/models/class.rb +0 -28
  45. data/vendor/pdoc/lib/pdoc/models/class_method.rb +0 -18
  46. data/vendor/pdoc/lib/pdoc/models/class_property.rb +0 -9
  47. data/vendor/pdoc/lib/pdoc/models/constant.rb +0 -9
  48. data/vendor/pdoc/lib/pdoc/models/constructor.rb +0 -14
  49. data/vendor/pdoc/lib/pdoc/models/container.rb +0 -114
  50. data/vendor/pdoc/lib/pdoc/models/entity.rb +0 -54
  51. data/vendor/pdoc/lib/pdoc/models/instance_method.rb +0 -18
  52. data/vendor/pdoc/lib/pdoc/models/instance_property.rb +0 -9
  53. data/vendor/pdoc/lib/pdoc/models/mixin.rb +0 -10
  54. data/vendor/pdoc/lib/pdoc/models/namespace.rb +0 -10
  55. data/vendor/pdoc/lib/pdoc/models/root.rb +0 -27
  56. data/vendor/pdoc/lib/pdoc/models/section.rb +0 -19
  57. data/vendor/pdoc/lib/pdoc/models/signature.rb +0 -27
  58. data/vendor/pdoc/lib/pdoc/models/utility.rb +0 -11
  59. data/vendor/pdoc/lib/pdoc/parser.rb +0 -109
  60. data/vendor/pdoc/lib/pdoc/parser/argument_description_nodes.rb +0 -21
  61. data/vendor/pdoc/lib/pdoc/parser/basic_nodes.rb +0 -31
  62. data/vendor/pdoc/lib/pdoc/parser/description_nodes.rb +0 -42
  63. data/vendor/pdoc/lib/pdoc/parser/documentation_nodes.rb +0 -483
  64. data/vendor/pdoc/lib/pdoc/parser/ebnf_arguments_nodes.rb +0 -58
  65. data/vendor/pdoc/lib/pdoc/parser/ebnf_expression_nodes.rb +0 -227
  66. data/vendor/pdoc/lib/pdoc/parser/fragment.rb +0 -55
  67. data/vendor/pdoc/lib/pdoc/parser/section_content_nodes.rb +0 -19
  68. data/vendor/pdoc/lib/pdoc/parser/tags_nodes.rb +0 -14
  69. data/vendor/pdoc/lib/pdoc/parser/treetop_files/argument_description.treetop +0 -31
  70. data/vendor/pdoc/lib/pdoc/parser/treetop_files/basic.treetop +0 -41
  71. data/vendor/pdoc/lib/pdoc/parser/treetop_files/description.treetop +0 -7
  72. data/vendor/pdoc/lib/pdoc/parser/treetop_files/documentation.treetop +0 -75
  73. data/vendor/pdoc/lib/pdoc/parser/treetop_files/ebnf_arguments.treetop +0 -33
  74. data/vendor/pdoc/lib/pdoc/parser/treetop_files/ebnf_expression.treetop +0 -70
  75. data/vendor/pdoc/lib/pdoc/parser/treetop_files/ebnf_javascript.treetop +0 -54
  76. data/vendor/pdoc/lib/pdoc/parser/treetop_files/events.treetop +0 -17
  77. data/vendor/pdoc/lib/pdoc/parser/treetop_files/section_content.treetop +0 -8
  78. data/vendor/pdoc/lib/pdoc/parser/treetop_files/tags.treetop +0 -31
  79. data/vendor/pdoc/lib/pdoc/runner.rb +0 -110
  80. data/vendor/pdoc/lib/pdoc/treemaker.rb +0 -94
  81. data/vendor/pdoc/pdoc.gemspec +0 -31
  82. data/vendor/pdoc/templates/html/assets/images/pdoc/alias.png +0 -0
  83. data/vendor/pdoc/templates/html/assets/images/pdoc/class.png +0 -0
  84. data/vendor/pdoc/templates/html/assets/images/pdoc/class_deprecated.png +0 -0
  85. data/vendor/pdoc/templates/html/assets/images/pdoc/class_method.png +0 -0
  86. data/vendor/pdoc/templates/html/assets/images/pdoc/class_property.png +0 -0
  87. data/vendor/pdoc/templates/html/assets/images/pdoc/constant.png +0 -0
  88. data/vendor/pdoc/templates/html/assets/images/pdoc/constructor.png +0 -0
  89. data/vendor/pdoc/templates/html/assets/images/pdoc/deprecated.png +0 -0
  90. data/vendor/pdoc/templates/html/assets/images/pdoc/description.png +0 -0
  91. data/vendor/pdoc/templates/html/assets/images/pdoc/information.png +0 -0
  92. data/vendor/pdoc/templates/html/assets/images/pdoc/instance_method.png +0 -0
  93. data/vendor/pdoc/templates/html/assets/images/pdoc/instance_property.png +0 -0
  94. data/vendor/pdoc/templates/html/assets/images/pdoc/method.png +0 -0
  95. data/vendor/pdoc/templates/html/assets/images/pdoc/method_deprecated.png +0 -0
  96. data/vendor/pdoc/templates/html/assets/images/pdoc/mixin.png +0 -0
  97. data/vendor/pdoc/templates/html/assets/images/pdoc/namespace.png +0 -0
  98. data/vendor/pdoc/templates/html/assets/images/pdoc/property.png +0 -0
  99. data/vendor/pdoc/templates/html/assets/images/pdoc/related_to.png +0 -0
  100. data/vendor/pdoc/templates/html/assets/images/pdoc/search-background.png +0 -0
  101. data/vendor/pdoc/templates/html/assets/images/pdoc/section-background.png +0 -0
  102. data/vendor/pdoc/templates/html/assets/images/pdoc/section.png +0 -0
  103. data/vendor/pdoc/templates/html/assets/images/pdoc/selected-section-background.png +0 -0
  104. data/vendor/pdoc/templates/html/assets/images/pdoc/subclass.png +0 -0
  105. data/vendor/pdoc/templates/html/assets/images/pdoc/superclass.png +0 -0
  106. data/vendor/pdoc/templates/html/assets/images/pdoc/utility.png +0 -0
  107. data/vendor/pdoc/templates/html/assets/javascripts/pdoc/application.js +0 -478
  108. data/vendor/pdoc/templates/html/assets/javascripts/pdoc/prototype.js +0 -4874
  109. data/vendor/pdoc/templates/html/assets/javascripts/pdoc/tabs.js +0 -506
  110. data/vendor/pdoc/templates/html/assets/stylesheets/pdoc/api.css +0 -677
  111. data/vendor/pdoc/templates/html/assets/stylesheets/pdoc/pygments.css +0 -62
  112. data/vendor/pdoc/templates/html/helpers.rb +0 -35
  113. data/vendor/pdoc/templates/html/index.erb +0 -18
  114. data/vendor/pdoc/templates/html/item_index.js.erb +0 -6
  115. data/vendor/pdoc/templates/html/layout.erb +0 -67
  116. data/vendor/pdoc/templates/html/leaf.erb +0 -22
  117. data/vendor/pdoc/templates/html/node.erb +0 -30
  118. data/vendor/pdoc/templates/html/partials/class_relationships.erb +0 -19
  119. data/vendor/pdoc/templates/html/partials/classes.erb +0 -7
  120. data/vendor/pdoc/templates/html/partials/constructor.erb +0 -5
  121. data/vendor/pdoc/templates/html/partials/description.erb +0 -5
  122. data/vendor/pdoc/templates/html/partials/link_list.erb +0 -1
  123. data/vendor/pdoc/templates/html/partials/method_signatures.erb +0 -14
  124. data/vendor/pdoc/templates/html/partials/methodized_note.erb +0 -9
  125. data/vendor/pdoc/templates/html/partials/mixins.erb +0 -7
  126. data/vendor/pdoc/templates/html/partials/namespaces.erb +0 -7
  127. data/vendor/pdoc/templates/html/partials/related_utilities.erb +0 -5
  128. data/vendor/pdoc/templates/html/partials/relationships.erb +0 -11
  129. data/vendor/pdoc/templates/html/partials/short_description_list.erb +0 -7
  130. data/vendor/pdoc/templates/html/partials/title.erb +0 -22
  131. data/vendor/pdoc/templates/html/section.erb +0 -18
  132. data/vendor/pdoc/test/fixtures/ajax.js +0 -809
  133. data/vendor/pdoc/test/fixtures/prototype.js +0 -5789
  134. data/vendor/pdoc/test/fixtures/test.txt +0 -1
  135. data/vendor/pdoc/test/fixtures/text.txt +0 -13
  136. data/vendor/pdoc/test/unit/parser/argument_description_test.rb +0 -40
  137. data/vendor/pdoc/test/unit/parser/basic_test.rb +0 -55
  138. data/vendor/pdoc/test/unit/parser/description_test.rb +0 -34
  139. data/vendor/pdoc/test/unit/parser/documentation_test.rb +0 -520
  140. data/vendor/pdoc/test/unit/parser/ebnf_arguments_test.rb +0 -81
  141. data/vendor/pdoc/test/unit/parser/ebnf_expression_test.rb +0 -382
  142. data/vendor/pdoc/test/unit/parser/ebnf_javascript_test.rb +0 -37
  143. data/vendor/pdoc/test/unit/parser/events_test.rb +0 -27
  144. data/vendor/pdoc/test/unit/parser/section_content_test.rb +0 -44
  145. data/vendor/pdoc/test/unit/parser/tags_test.rb +0 -39
  146. data/vendor/pdoc/test/unit/parser/test_fragment.rb +0 -80
  147. data/vendor/pdoc/test/unit/parser_test_helper.rb +0 -62
  148. data/vendor/pdoc/test/unit/runner/basic_test.rb +0 -14
  149. data/vendor/pdoc/test/unit/templates/html_helpers_test.rb +0 -25
  150. data/vendor/pdoc/vendor/albino.rb +0 -122
  151. data/vendor/pdoc/website/html/documentation.html +0 -280
  152. data/vendor/pdoc/website/html/images/pdoc.jpg +0 -0
  153. data/vendor/pdoc/website/html/index.html +0 -84
  154. data/vendor/pdoc/website/html/stylesheets/main.css +0 -73
  155. data/vendor/pdoc/website/html/stylesheets/reset.css +0 -18
  156. data/vendor/pdoc/website/markdown/syntax.markdown +0 -226
  157. data/yuicompressor-2.4.6.zip +0 -0
@@ -1,81 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "parser_test_helper"))
2
-
3
- class ArgumentsTest < Test::Unit::TestCase
4
- include PDocTestHelper
5
- include EbnfArguments
6
-
7
- def setup
8
- @parser = EbnfArgumentsParser.new
9
- end
10
-
11
- def test_no_arguments
12
- assert_parsed " "
13
- assert_parsed ""
14
- assert_equal [], parse(" ").to_a.map(&:name)
15
- end
16
-
17
- def test_one_required_argument
18
- assert_parsed "content"
19
- assert_parsed "{ position: '(top|bottom|before|after)' }"
20
- assert_equal "content", parse("content").to_a.first.name
21
- assert_equal nil, parse("content").to_a.first.default_value
22
- assert !parse("content").to_a.first.optional?
23
- assert_equal "elements...", parse("elements...").to_a.first.name
24
- end
25
-
26
- def test_multiple_required_arguments
27
- assert_parsed "foo,bar"
28
- assert_parsed "foo , bar"
29
- assert_parsed "foo , bar"
30
- assert_equal ["foo", "bar"], parse("foo,bar").to_a.map(&:name)
31
- end
32
-
33
- def test_one_optional_argument
34
- assert_parsed "[content]"
35
- assert_parsed "[ content ]"
36
- assert_parsed "[{ position: '(top|bottom|before|after)' }]"
37
- assert_equal "content", parse("[content]").to_a.first.name
38
- assert_equal OptionalArgument, parse("[content]").to_a.first.class
39
- assert_equal nil, parse("[content]").to_a.first.default_value
40
- assert parse("[content]").to_a.first.optional?
41
- assert_equal "elements...", parse("[elements...]").to_a.first.name
42
- end
43
-
44
- def test_default_value
45
- assert_parsed "[content=foobar]"
46
- assert_parsed "[ content=foobar ]"
47
- assert_equal "content", parse("[content=foo]").to_a.first.name
48
- assert_equal "foo", parse("[content=foo]").to_a.first.default_value
49
- assert_equal "foo", parse("[content = foo]").to_a.first.default_value
50
- assert parse("[content]").to_a.first.optional?
51
- end
52
-
53
- def test_multiple_optional_arguments
54
- assert_parsed "[foo][,bar]"
55
- assert_parsed "[ foo ] [ , bar ]"
56
- assert_equal ["foo", "bar"], parse("[foo][,bar]").to_a.map(&:name)
57
- end
58
-
59
- def test_multiple_mixed_arguments
60
- assert_parsed "hello[,foo][,bar=43]"
61
- assert_parsed "hello [ , foo ] [ , bar=43 ]"
62
- assert_parsed "hello,world[,foo][,bar=43]"
63
- assert_parsed "hello , world [ , foo ] [ , bar=43 ]"
64
- assert_parsed "hello...[, world = foo]"
65
- assert_equal ["foo", "bar"], parse("[foo],bar").to_a.map(&:name)
66
- assert_equal "content", parse("hello[,content]").to_a.last.name
67
- assert_equal "content", parse("hello[,content=foo]").to_a.last.name
68
- assert_equal "foo", parse("hello[,content=foo]").to_a.last.default_value
69
- assert parse("hello[,content=foo]").to_a.last.optional?
70
- assert !parse("hello[,content=foo]").to_a.first.optional?
71
- end
72
-
73
- def test_nested_optional_arguments
74
- assert_parsed "hello[,foo[,bar]]"
75
- assert_parsed "hello [ , foo = 3 [ , bar = 43 ]]"
76
- assert_parsed "hello[,foo[,bar=43][,baz=26]]"
77
- assert_parsed "[length = 30[, suffix = '...']]"
78
- assert_equal ["foo", "bar"], parse("[foo[,bar]]").to_a.map(&:name)
79
- assert_equal ["hello", "foo", "bar", "baz"], parse("hello[,foo[,bar=43][,baz=26]]").to_a.map(&:name)
80
- end
81
- end
@@ -1,382 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "parser_test_helper"))
2
-
3
- class EbnfExpressionTest < Test::Unit::TestCase
4
- include PDocTestHelper
5
- include EbnfExpression
6
-
7
- def setup
8
- @parser = EbnfExpressionParser.new
9
- end
10
-
11
- def test_inspect
12
- ebnf = "Ajax.Responders.responders -> Array"
13
- assert_equal "#<EbnfExpression::KlassProperty @input=\"#{ebnf}\">", parse(ebnf).inspect
14
- end
15
-
16
- def test_instance_property
17
- ebnf = "Ajax.Response#responseJSON -> Array | Object | null"
18
- assert_parsed ebnf
19
- assert_equal InstanceProperty, parse(ebnf).class
20
- assert_equal "Ajax.Response", parse(ebnf).namespace
21
- assert_equal "responseJSON", parse(ebnf).name
22
- assert_equal "Ajax.Response#responseJSON", parse(ebnf).full_name
23
- assert_equal "Response", parse(ebnf).klass_name
24
- assert_equal "Array | Object | null", parse(ebnf).returns
25
- assert_equal ebnf, parse(ebnf).to_s
26
-
27
- ebnf = "a123#b456 -> Array | Object | null"
28
- assert_parsed ebnf
29
- assert_equal InstanceProperty, parse(ebnf).class
30
- assert_equal "a123", parse(ebnf).namespace
31
- assert_equal "b456", parse(ebnf).name
32
- assert_equal "a123#b456", parse(ebnf).full_name
33
- assert_equal "a123", parse(ebnf).klass_name
34
- assert_equal "Array | Object | null", parse(ebnf).returns
35
- assert_equal ebnf, parse(ebnf).to_s
36
- end
37
-
38
- def test_klass_property
39
- ebnf = "Ajax.Responders.responders -> Array"
40
- assert_parsed ebnf
41
- assert_equal KlassProperty, parse(ebnf).class
42
- assert_equal "Ajax.Responders", parse(ebnf).namespace
43
- assert_equal "responders", parse(ebnf).name
44
- assert_equal "Ajax.Responders.responders", parse(ebnf).full_name
45
- assert_equal "Responders", parse(ebnf).klass_name
46
- assert_equal "Array", parse(ebnf).returns
47
- assert_equal ebnf, parse(ebnf).to_s
48
-
49
- ebnf = "document.viewport.foo -> Bar"
50
- assert_parsed ebnf
51
- assert_equal KlassProperty, parse(ebnf).class
52
- assert_equal "document.viewport", parse(ebnf).namespace
53
- assert_equal "foo", parse(ebnf).name
54
- assert_equal "document.viewport.foo", parse(ebnf).full_name
55
- assert_equal "viewport", parse(ebnf).klass_name
56
- assert_equal "Bar", parse(ebnf).returns
57
- assert_equal ebnf, parse(ebnf).to_s
58
- end
59
-
60
- def test_utility
61
- ebnf = "$(element) -> Element | Array"
62
- assert_parsed ebnf
63
- assert_parsed "$$() -> Array"
64
- assert_parsed "$w() -> Array"
65
- assert_parsed "$A() -> Array"
66
- assert_equal Utility, parse(ebnf).class
67
- assert_equal "", parse(ebnf).namespace
68
- assert_equal "$", parse(ebnf).name
69
- assert_equal "$", parse(ebnf).full_name
70
- assert_equal nil, parse(ebnf).klass_name
71
- assert_equal %w[element], parse(ebnf).arguments.map(&:name)
72
- assert_equal "Element | Array", parse(ebnf).returns
73
- assert_equal ebnf, parse(ebnf).to_s
74
- end
75
-
76
- def test_klass_method
77
- ebnf = "Element.update(@element[,content]) -> Element"
78
- assert_parsed ebnf
79
- assert_equal KlassMethod, parse(ebnf).class
80
- assert_equal "Element", parse(ebnf).namespace
81
- assert_equal "update", parse(ebnf).name
82
- assert_equal "Element.update", parse(ebnf).full_name
83
- assert_equal "Element", parse(ebnf).klass_name
84
- assert_equal %w[element content], parse(ebnf).arguments.map(&:name)
85
- assert_equal "Element", parse(ebnf).returns
86
- assert_equal ebnf, parse(ebnf).to_s
87
-
88
- ebnf = "document.viewport.getWidth() -> Number"
89
- assert_parsed ebnf
90
- assert_equal KlassMethod, parse(ebnf).class
91
- assert_equal "document.viewport", parse(ebnf).namespace
92
- assert_equal "getWidth", parse(ebnf).name
93
- assert_equal "document.viewport.getWidth", parse(ebnf).full_name
94
- assert_equal "viewport", parse(ebnf).klass_name
95
- assert_equal [], parse(ebnf).arguments
96
- assert_equal "Number", parse(ebnf).returns
97
- assert_equal ebnf, parse(ebnf).to_s
98
- end
99
-
100
- def test_instance_method
101
- ebnf = "Element#update([content]) -> Element"
102
- assert_parsed ebnf
103
- assert_equal InstanceMethod, parse(ebnf).class
104
- assert_equal "Element", parse(ebnf).namespace
105
- assert_equal "update", parse(ebnf).name
106
- assert_equal "Element#update", parse(ebnf).full_name
107
- assert_equal "Element", parse(ebnf).klass_name
108
- assert_equal %w[content], parse(ebnf).arguments.map(&:name)
109
- assert_equal "Element", parse(ebnf).returns
110
- assert_equal ebnf, parse(ebnf).to_s
111
- end
112
-
113
- def test_constructors
114
- ebnf = "new Element(tagName[,attributes])"
115
- assert_parsed ebnf
116
- assert_equal Constructor, parse(ebnf).class
117
- assert_equal "Element", parse(ebnf).namespace
118
- assert_equal "new", parse(ebnf).name
119
- assert_equal "new Element", parse(ebnf).full_name
120
- assert_equal "Element", parse(ebnf).klass_name
121
- assert_equal %w[tagName attributes], parse(ebnf).arguments.map(&:name)
122
- assert_equal ebnf, parse(ebnf).to_s
123
-
124
- ebnf = "new Ajax.Request(url[,options])"
125
- assert_parsed ebnf
126
- assert_equal Constructor, parse(ebnf).class
127
- assert_equal "Ajax.Request", parse(ebnf).namespace
128
- assert_equal "new", parse(ebnf).name
129
- assert_equal "new Ajax.Request", parse(ebnf).full_name
130
- assert_equal "Request", parse(ebnf).klass_name
131
- assert_equal %w[url options], parse(ebnf).arguments.map(&:name)
132
- assert_equal ebnf, parse(ebnf).to_s
133
- end
134
-
135
-
136
- def test_klass
137
- ebnf = "class Ajax.Base"
138
- assert_parsed ebnf
139
- assert_equal Klass, parse(ebnf).class
140
- assert_equal "Ajax", parse(ebnf).namespace
141
- assert_equal "Base", parse(ebnf).name
142
- assert_equal "Ajax.Base", parse(ebnf).full_name
143
- assert_equal nil, parse(ebnf).klass_name
144
- assert_equal [], parse(ebnf).mixins
145
- assert_equal ebnf, parse(ebnf).to_s
146
-
147
- ebnf = "class Element"
148
- assert_parsed ebnf
149
- assert_equal Klass, parse(ebnf).class
150
- assert_equal "", parse(ebnf).namespace
151
- assert_equal "Element", parse(ebnf).name
152
- assert_equal "Element", parse(ebnf).full_name
153
- assert_equal nil, parse(ebnf).klass_name
154
- assert !parse(ebnf).subklass?
155
- assert_equal [], parse(ebnf).mixins
156
- assert_equal ebnf, parse(ebnf).to_s
157
-
158
- ebnf = "class Ajax.Request < Ajax.Base"
159
- assert_parsed ebnf
160
- assert_equal Klass, parse(ebnf).class
161
- assert_equal "Ajax", parse(ebnf).namespace
162
- assert_equal "Request", parse(ebnf).name
163
- assert_equal "Ajax.Request", parse(ebnf).full_name
164
- assert_equal nil, parse(ebnf).klass_name
165
- assert parse(ebnf).subklass?
166
- assert_equal "Base", parse(ebnf).superklass.name
167
- assert_equal "Ajax", parse(ebnf).superklass.namespace
168
- assert_equal [], parse(ebnf).mixins
169
- assert_equal ebnf, parse(ebnf).to_s
170
-
171
- ebnf = "class Array\n * includes Enumerable"
172
- assert_parsed ebnf
173
- assert_equal %w[Enumerable], parse(ebnf).mixins.map(&:name)
174
- assert_equal [""], parse(ebnf).mixins.map(&:namespace)
175
- assert_equal ebnf, parse(ebnf).to_s
176
-
177
- ebnf = "class Array\n * includes Enumerable, Foo.Comparable"
178
- assert_parsed ebnf
179
- assert_equal %w[Enumerable Comparable], parse(ebnf).mixins.map(&:name)
180
- assert_equal ["", "Foo"], parse(ebnf).mixins.map(&:namespace)
181
- assert_equal ebnf, parse(ebnf).to_s
182
- end
183
-
184
- def test_namespace
185
- ebnf = "Prototype.Browser"
186
- assert_parsed ebnf
187
- assert_equal Namespace, parse(ebnf).class
188
- assert_equal "Prototype", parse(ebnf).namespace
189
- assert_equal "Browser", parse(ebnf).name
190
- assert_equal "Prototype.Browser", parse(ebnf).full_name
191
- assert_equal nil, parse(ebnf).klass_name
192
- assert_equal [], parse(ebnf).mixins
193
- assert_equal ebnf, parse(ebnf).to_s
194
-
195
- ebnf = "Ajax"
196
- assert_parsed ebnf
197
- assert_equal Namespace, parse(ebnf).class
198
- assert_equal "", parse(ebnf).namespace
199
- assert_equal "Ajax", parse(ebnf).name
200
- assert_equal "Ajax", parse(ebnf).full_name
201
- assert_equal nil, parse(ebnf).klass_name
202
- assert_equal [], parse(ebnf).mixins
203
- assert_equal ebnf, parse(ebnf).to_s
204
-
205
- ebnf = "scripty2"
206
- assert_parsed ebnf
207
- assert_equal Namespace, parse(ebnf).class
208
- assert_equal "", parse(ebnf).namespace
209
- assert_equal "scripty2", parse(ebnf).name
210
- assert_equal "scripty2", parse(ebnf).full_name
211
- assert_equal nil, parse(ebnf).klass_name
212
- assert_equal [], parse(ebnf).mixins
213
- assert_equal ebnf, parse(ebnf).to_s
214
-
215
- ebnf = "Ajax\n * includes Enumerable"
216
- assert_parsed ebnf
217
- assert_equal Namespace, parse(ebnf).class
218
- assert_equal "", parse(ebnf).namespace
219
- assert_equal "Ajax", parse(ebnf).name
220
- assert_equal "Ajax", parse(ebnf).full_name
221
- assert_equal nil, parse(ebnf).klass_name
222
- assert_equal %w[Enumerable], parse(ebnf).mixins.map(&:name)
223
- assert_equal [""], parse(ebnf).mixins.map(&:namespace)
224
- assert_equal ebnf, parse(ebnf).to_s
225
-
226
- ebnf = "document"
227
- assert_parsed ebnf
228
- assert_equal Namespace, parse(ebnf).class
229
- assert_equal "", parse(ebnf).namespace
230
- assert_equal "document", parse(ebnf).name
231
- assert_equal "document", parse(ebnf).full_name
232
- assert_equal nil, parse(ebnf).klass_name
233
- assert_equal [], parse(ebnf).mixins
234
- assert_equal ebnf, parse(ebnf).to_s
235
-
236
- ebnf = "document.viewport"
237
- assert_parsed ebnf
238
- assert_equal Namespace, parse(ebnf).class
239
- assert_equal "document", parse(ebnf).namespace
240
- assert_equal "viewport", parse(ebnf).name
241
- assert_equal "document.viewport", parse(ebnf).full_name
242
- assert_equal nil, parse(ebnf).klass_name
243
- assert_equal [], parse(ebnf).mixins
244
- assert_equal ebnf, parse(ebnf).to_s
245
- end
246
-
247
- def test_mixin
248
- ebnf = "mixin Enumerable"
249
- assert_parsed ebnf
250
- assert_equal Mixin, parse(ebnf).class
251
- assert_equal "", parse(ebnf).namespace
252
- assert_equal "Enumerable", parse(ebnf).name
253
- assert_equal "Enumerable", parse(ebnf).full_name
254
- assert_equal ebnf, parse(ebnf).to_s
255
- end
256
-
257
- def test_constant
258
- ebnf = "Prototype.JSONFilter = /^\/\*-secure-([\s\S]*)\*\/\s*$/"
259
- assert_parsed ebnf
260
- assert_equal Constant, parse(ebnf).class
261
- assert_equal "Prototype", parse(ebnf).namespace
262
- assert_equal "JSONFilter", parse(ebnf).name
263
- assert_equal "Prototype.JSONFilter", parse(ebnf).full_name
264
- assert_equal "/^\/\*-secure-([\s\S]*)\*\/\s*$/", parse(ebnf).returns
265
- assert_equal ebnf, parse(ebnf).to_s
266
-
267
- ebnf = "s2.css.LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/"
268
- assert_parsed ebnf
269
- assert_equal Constant, parse(ebnf).class
270
- assert_equal "s2.css", parse(ebnf).namespace
271
- assert_equal "LENGTH", parse(ebnf).name
272
- assert_equal "s2.css.LENGTH", parse(ebnf).full_name
273
- assert_equal "/^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/", parse(ebnf).returns
274
- assert_equal ebnf, parse(ebnf).to_s
275
- end
276
-
277
- def test_no_arguments
278
- assert_parsed "Event#stop() -> a value"
279
- assert_parsed "Event#stop( ) -> a value"
280
- assert_equal [], parse("Event#stop() -> a value").arguments
281
- assert_equal [], parse("Event#stop( ) -> a value").arguments
282
- end
283
-
284
- def test_one_required_argument
285
- ebnf = "Event.stop(event) -> Event"
286
- ebnf_with_space = "Event.stop( event ) -> Event"
287
-
288
- assert_parsed ebnf
289
- assert_parsed ebnf_with_space
290
- assert_equal 1, parse(ebnf).arguments.length
291
- assert_equal 1, parse(ebnf_with_space).arguments.length
292
- assert_equal "event", parse(ebnf).arguments.first.name
293
- assert_equal nil, parse(ebnf).arguments.first.default_value
294
- assert_equal false, parse(ebnf).arguments.first.optional?
295
- end
296
-
297
- def test_multiple_required_arguments
298
- ebnf = "Event.findElement(event,selector) -> Event"
299
- ebnf_with_space = "Event.findElement( event , selector ) -> Event"
300
-
301
- assert_parsed ebnf
302
- assert_parsed ebnf_with_space
303
- assert_equal 2, parse(ebnf).arguments.length
304
- assert_equal 2, parse(ebnf_with_space).arguments.length
305
- assert_equal ["event", "selector"], parse(ebnf).arguments.map(&:name)
306
- assert_equal [nil, nil], parse(ebnf).arguments.map(&:default_value)
307
- assert_equal [false, false], parse(ebnf).arguments.map(&:optional?)
308
- end
309
-
310
- def test_one_optional_argument
311
- ebnf = "Element#update([content]) -> Element"
312
- ebnf_with_space = "Element#update( [ content ] ) -> Element"
313
-
314
- assert_parsed ebnf
315
- assert_parsed ebnf_with_space
316
- assert_equal 1, parse(ebnf).arguments.length
317
- assert_equal 1, parse(ebnf_with_space).arguments.length
318
- assert_equal "content", parse(ebnf).arguments.first.name
319
- assert_equal nil, parse(ebnf).arguments.first.default_value
320
- assert_equal true, parse(ebnf).arguments.first.optional?
321
- end
322
-
323
- def test_one_optional_argument_with_default_value
324
- ebnf = "Element#update([content='']) -> Element"
325
- ebnf_with_space = "Element#update( [ content='' ] ) -> Element"
326
-
327
- assert_parsed ebnf
328
- assert_parsed ebnf_with_space
329
- assert_equal 1, parse(ebnf).arguments.length
330
- assert_equal 1, parse(ebnf_with_space).arguments.length
331
- assert_equal "content", parse(ebnf).arguments.first.name
332
- assert_equal "''", parse(ebnf).arguments.first.default_value
333
- assert_equal true, parse(ebnf).arguments.first.optional?
334
- end
335
-
336
- def test_multiple_optional_arguments
337
- ebnf = "Element#down([selector][,index=0]) -> Element"
338
- ebnf_with_space = "Element#down( [ selector ] [ , index=0 ] ) -> Element"
339
-
340
- assert_parsed ebnf
341
- assert_parsed ebnf_with_space
342
- assert_equal 2, parse(ebnf).arguments.length
343
- assert_equal 2, parse(ebnf_with_space).arguments.length
344
- assert_equal ["selector", "index"], parse(ebnf).arguments.map(&:name)
345
- assert_equal [nil, "0"], parse(ebnf).arguments.map(&:default_value)
346
- assert_equal [true, true], parse(ebnf).arguments.map(&:optional?)
347
- end
348
-
349
- def test_multiple_mixed_arguments
350
- ebnf = "Element.down(element[,selector][,index=0]) -> Element"
351
- ebnf_with_space = "Element.down( element [ , selector ] [ , index=0 ] ) -> Element"
352
-
353
- assert_parsed ebnf
354
- assert_parsed ebnf_with_space
355
- assert_equal 3, parse(ebnf).arguments.length
356
- assert_equal 3, parse(ebnf_with_space).arguments.length
357
- assert_equal ["element", "selector", "index"], parse(ebnf).arguments.map(&:name)
358
- assert_equal [nil, nil, "0"], parse(ebnf).arguments.map(&:default_value)
359
- assert_equal [false, true, true], parse(ebnf).arguments.map(&:optional?)
360
- end
361
-
362
- def test_methodized_argument
363
- ebnf = "Element.down(@element[,selector][,index=0]) -> Element"
364
- ebnf_with_space = "Element.down( @element [ , selector ] [ , index=0 ] ) -> Element"
365
- ebnf2 = "Element.writeAttribute(@element, attribute[, value = true]) -> Element"
366
-
367
- assert_parsed ebnf
368
- assert_parsed ebnf_with_space
369
- assert parse(ebnf).methodized?
370
- assert parse(ebnf_with_space).methodized?
371
- assert !parse("Event#stop() -> a value").methodized?
372
- assert_equal 3, parse(ebnf).arguments.length
373
- assert_equal 3, parse(ebnf2).arguments.length
374
- assert_equal 3, parse(ebnf_with_space).arguments.length
375
- assert_equal ["element", "selector", "index"], parse(ebnf).arguments.map(&:name)
376
- assert_equal ['element', 'attribute', 'value'],parse(ebnf2).arguments.map(&:name)
377
- assert_equal [nil, nil, "0"], parse(ebnf).arguments.map(&:default_value)
378
- assert_equal [nil, nil, "true"], parse(ebnf2).arguments.map(&:default_value)
379
- assert_equal [false, true, true], parse(ebnf).arguments.map(&:optional?)
380
- assert_equal [false, false, true], parse(ebnf2).arguments.map(&:optional?)
381
- end
382
- end