sidekiq-statsd 0.1.0 → 0.1.1

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.
Files changed (41) hide show
  1. data/.yardopts +1 -1
  2. data/README.md +8 -4
  3. data/lib/sidekiq/statsd/client.rb +10 -10
  4. data/lib/sidekiq/statsd/server_middleware.rb +8 -9
  5. data/lib/sidekiq/statsd/version.rb +1 -1
  6. data/spec/sidekiq/statsd/client_spec.rb +6 -6
  7. data/spec/spec_helper.rb +1 -0
  8. data/vendor/ruby/1.9.1/bin/yard +1 -1
  9. data/vendor/ruby/1.9.1/bin/yardoc +1 -1
  10. data/vendor/ruby/1.9.1/bin/yri +1 -1
  11. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/lib/yard/tags/default_factory.rb +176 -0
  12. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/lib/yard/tags/default_tag.rb +12 -0
  13. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/lib/yard/tags/directives.rb +595 -0
  14. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/lib/yard/tags/library.rb +630 -0
  15. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/lib/yard/tags/option_tag.rb +12 -0
  16. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/lib/yard/tags/overload_tag.rb +65 -0
  17. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/lib/yard/tags/ref_tag.rb +7 -0
  18. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/lib/yard/tags/ref_tag_list.rb +27 -0
  19. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/lib/yard/tags/tag.rb +57 -0
  20. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/lib/yard/tags/tag_format_error.rb +6 -0
  21. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/spec/tags/default_factory_spec.rb +152 -0
  22. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/spec/tags/default_tag_spec.rb +11 -0
  23. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/spec/tags/directives_spec.rb +436 -0
  24. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/spec/tags/library_spec.rb +34 -0
  25. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/spec/tags/overload_tag_spec.rb +53 -0
  26. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/spec/tags/ref_tag_list_spec.rb +53 -0
  27. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/templates/default/tags/html/example.erb +11 -0
  28. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/templates/default/tags/html/index.erb +3 -0
  29. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/templates/default/tags/html/option.erb +24 -0
  30. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/templates/default/tags/html/overload.erb +14 -0
  31. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/templates/default/tags/html/see.erb +8 -0
  32. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/templates/default/tags/html/tag.erb +20 -0
  33. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/templates/default/tags/setup.rb +55 -0
  34. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/templates/default/tags/text/example.erb +12 -0
  35. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/templates/default/tags/text/index.erb +1 -0
  36. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/templates/default/tags/text/option.erb +20 -0
  37. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/templates/default/tags/text/overload.erb +19 -0
  38. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/templates/default/tags/text/see.erb +11 -0
  39. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/templates/default/tags/text/tag.erb +13 -0
  40. data/vendor/ruby/1.9.1/gems/yard-0.8.6.1/templates/guide/tags/html/setup.rb +8 -0
  41. metadata +34 -4
@@ -0,0 +1,436 @@
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
+
3
+ def tag_parse(content, object = nil, handler = nil)
4
+ @parser = DocstringParser.new
5
+ @parser.parse(content, object, handler)
6
+ @parser
7
+ end
8
+
9
+ describe YARD::Tags::ParseDirective do
10
+ describe '#call' do
11
+ after { Registry.clear }
12
+
13
+ it "should parse if handler=nil but use file=(stdin)" do
14
+ tag_parse %{@!parse
15
+ # Docstring here
16
+ def foo; end
17
+ }
18
+ Registry.at('#foo').docstring.should == "Docstring here"
19
+ Registry.at('#foo').file.should == '(stdin)'
20
+ end
21
+
22
+ it "should allow parser type to be specified in type" do
23
+ tag_parse %{@!parse [c]
24
+ void Init_Foo() {
25
+ rb_define_method(rb_cMyClass, "foo", foo, 1);
26
+ }
27
+ }
28
+ Registry.at('MyClass#foo').should_not be_nil
29
+ end
30
+
31
+ it "should parse code in context of current handler" do
32
+ src = <<-eof
33
+ class A
34
+ # @!parse
35
+ # def foo; end
36
+ eval "def foo; end"
37
+ end
38
+ eof
39
+ parser = Parser::SourceParser.new
40
+ parser.file = "myfile.rb"
41
+ parser.parse(StringIO.new(src))
42
+ Registry.at('A#foo').file.should == 'myfile.rb'
43
+ end
44
+ end
45
+ end
46
+
47
+ describe YARD::Tags::GroupDirective do
48
+ describe '#call' do
49
+ it "should do nothing if handler=nil" do
50
+ tag_parse("@!group foo")
51
+ end
52
+
53
+ it "should set group value in parser state (with handler)" do
54
+ handler = OpenStruct.new(:extra_state => OpenStruct.new)
55
+ tag_parse("@!group foo", nil, handler)
56
+ handler.extra_state.group.should == 'foo'
57
+ end
58
+ end
59
+ end
60
+
61
+ describe YARD::Tags::EndGroupDirective do
62
+ describe '#call' do
63
+ it "should do nothing if handler=nil" do
64
+ tag_parse("@!endgroup foo")
65
+ end
66
+
67
+ it "should set group value in parser state (with handler)" do
68
+ handler = OpenStruct.new(:extra_state => OpenStruct.new(:group => "foo"))
69
+ tag_parse("@!endgroup", nil, handler)
70
+ handler.extra_state.group.should be_nil
71
+ end
72
+ end
73
+ end
74
+
75
+ describe YARD::Tags::MacroDirective do
76
+ def handler
77
+ OpenStruct.new(:call_params => %w(a b c),
78
+ :caller_method => 'foo',
79
+ :scope => :instance, :visibility => :public,
80
+ :namespace => P('Foo::Bar'),
81
+ :statement => OpenStruct.new(:source => 'foo :a, :b, :c'))
82
+ end
83
+
84
+ after(:all) { Registry.clear }
85
+
86
+ describe '#call' do
87
+ it "should define new macro when [new] is provided" do
88
+ tag_parse("@!macro [new] foo\n foo")
89
+ CodeObjects::MacroObject.find('foo').macro_data.should == 'foo'
90
+ end
91
+
92
+ it "should define new macro if text block is provided" do
93
+ tag_parse("@!macro bar\n bar")
94
+ CodeObjects::MacroObject.find('bar').macro_data.should == 'bar'
95
+ end
96
+
97
+ it "should expand macros and return #expanded_text to tag parser" do
98
+ tag_parse("@!macro [new] foo\n foo")
99
+ tag_parse("@!macro foo").text.should == 'foo'
100
+ end
101
+
102
+ it "should not expand new macro if docstring is unattached" do
103
+ tag_parse("@!macro [new] foo\n foo").text.should_not == 'foo'
104
+ end
105
+
106
+ it "should expand new anonymous macro even if docstring is unattached" do
107
+ tag_parse("@!macro\n foo").text.should == 'foo'
108
+ end
109
+
110
+ it "should allow multiple macros to be expanded" do
111
+ tag_parse("@!macro [new] foo\n foo")
112
+ tag_parse("@!macro bar\n bar")
113
+ tag_parse("@!macro foo\n@!macro bar").text.should == "foo\nbar"
114
+ end
115
+
116
+ it "should allow anonymous macros" do
117
+ tag_parse("@!macro\n a b c", nil, handler)
118
+ @parser.text.should == 'a b c'
119
+ end
120
+
121
+ it "should expand call_params and caller_method using $N when handler is provided" do
122
+ tag_parse("@!macro\n $1 $2 $3", nil, handler)
123
+ @parser.text.should == 'a b c'
124
+ end
125
+
126
+ it "should attach macro to method if one exists" do
127
+ tag_parse("@!macro [attach] attached\n $1 $2 $3", nil, handler)
128
+ macro = CodeObjects::MacroObject.find('attached')
129
+ macro.method_object.should == P('Foo::Bar.foo')
130
+ end
131
+
132
+ it "should not expand new attached macro if defined on class method" do
133
+ baz = CodeObjects::MethodObject.new(P('Foo::Bar'), :baz, :class)
134
+ baz.visibility.should == :public
135
+ tag_parse("@!macro [attach] attached2\n @!visibility private", baz, handler)
136
+ macro = CodeObjects::MacroObject.find('attached2')
137
+ macro.method_object.should == P('Foo::Bar.baz')
138
+ baz.visibility.should == :public
139
+ end
140
+
141
+ it "should expand macro if defined on class method and there is no data block" do
142
+ tag_parse("@!macro [new] attached3\n expanded_data")
143
+ baz = CodeObjects::MethodObject.new(P('Foo::Bar'), :baz, :class)
144
+ doc = DocstringParser.new.parse('@!macro attached3', baz, handler).to_docstring
145
+ doc.should == 'expanded_data'
146
+ end
147
+
148
+ it "should not attempt to expand macro values if handler = nil" do
149
+ tag_parse("@!macro [attach] xyz\n $1 $2 $3")
150
+ end
151
+ end
152
+ end
153
+
154
+ describe YARD::Tags::MethodDirective do
155
+ describe '#call' do
156
+ after { Registry.clear }
157
+
158
+ it "should use entire docstring if no indented data is found" do
159
+ YARD.parse_string <<-eof
160
+ class Foo
161
+ # @!method foo
162
+ # @!method bar
163
+ # @!scope class
164
+ end
165
+ eof
166
+ Registry.at('Foo.foo').should be_a(CodeObjects::MethodObject)
167
+ Registry.at('Foo.bar').should be_a(CodeObjects::MethodObject)
168
+ end
169
+
170
+ it "should handle indented block text in @!method" do
171
+ YARD.parse_string <<-eof
172
+ # @!method foo(a)
173
+ # Docstring here
174
+ # @return [String] the foo
175
+ # Ignore this
176
+ # @param [String] a
177
+ eof
178
+ foo = Registry.at('#foo')
179
+ foo.docstring.should == "Docstring here"
180
+ foo.docstring.tag(:return).should_not be_nil
181
+ foo.tag(:param).should be_nil
182
+ end
183
+
184
+ it "should execute directives on object in indented block" do
185
+ YARD.parse_string <<-eof
186
+ class Foo
187
+ # @!method foo(a)
188
+ # @!scope class
189
+ # @!visibility private
190
+ # @!method bar
191
+ # Hello
192
+ # Ignore this
193
+ end
194
+ eof
195
+ foo = Registry.at('Foo.foo')
196
+ foo.visibility.should == :private
197
+ bar = Registry.at('Foo#bar')
198
+ bar.visibility.should == :public
199
+ end
200
+
201
+ it "should be able to define multiple @methods in docstring" do
202
+ YARD.parse_string <<-eof
203
+ class Foo
204
+ # @!method foo1
205
+ # Docstring1
206
+ # @!method foo2
207
+ # Docstring2
208
+ # @!method foo3
209
+ # @!scope class
210
+ # Docstring3
211
+ end
212
+ eof
213
+ foo1 = Registry.at('Foo#foo1')
214
+ foo2 = Registry.at('Foo#foo2')
215
+ foo3 = Registry.at('Foo.foo3')
216
+ foo1.docstring.should == 'Docstring1'
217
+ foo2.docstring.should == 'Docstring2'
218
+ foo3.docstring.should == 'Docstring3'
219
+ end
220
+
221
+ it "should define the method inside namespace if attached to namespace object" do
222
+ YARD.parse_string <<-eof
223
+ module Foo
224
+ # @!method foo
225
+ # Docstring1
226
+ # @!method bar
227
+ # Docstring2
228
+ class Bar
229
+ end
230
+ end
231
+ eof
232
+ Registry.at('Foo::Bar#foo').docstring.should == 'Docstring1'
233
+ Registry.at('Foo::Bar#bar').docstring.should == 'Docstring2'
234
+ end
235
+
236
+ it "should set scope to class if signature has 'self.' prefix" do
237
+ YARD.parse_string <<-eof
238
+ # @!method self.foo
239
+ # @!method self. bar
240
+ # @!method self.baz()
241
+ class Foo
242
+ end
243
+ eof
244
+ %w(foo bar baz).each do |name|
245
+ Registry.at("Foo.#{name}").should be_a(CodeObjects::MethodObject)
246
+ end
247
+ end
248
+
249
+ it "should define parameters from signature" do
250
+ YARD.parse_string <<-eof
251
+ # @!method foo(a, b, c = nil)
252
+ eof
253
+ Registry.at('#foo').parameters.should == [['a', nil], ['b', nil], ['c', 'nil']]
254
+ end
255
+
256
+ it "should be able to define method with module scope (module function)" do
257
+ YARD.parse_string <<-eof
258
+ # @!method foo
259
+ # @!scope module
260
+ # This is a docstring
261
+ # @return [Boolean] whether this is true
262
+ class Foo
263
+ end
264
+ eof
265
+ foo_c = Registry.at('Foo.foo')
266
+ foo_i = Registry.at('Foo#foo')
267
+ foo_c.should_not be_nil
268
+ foo_i.should_not be_nil
269
+ foo_c.should be_module_function
270
+ foo_c.docstring.should == foo_i.docstring
271
+ foo_c.tag(:return).text.should == foo_i.tag(:return).text
272
+ end
273
+ end
274
+ end
275
+
276
+ describe YARD::Tags::AttributeDirective do
277
+ describe '#call' do
278
+ after { Registry.clear }
279
+
280
+ it "should use entire docstring if no indented data is found" do
281
+ YARD.parse_string <<-eof
282
+ class Foo
283
+ # @!attribute foo
284
+ # @!attribute bar
285
+ # @!scope class
286
+ end
287
+ eof
288
+ Registry.at('Foo.foo').should be_reader
289
+ Registry.at('Foo.bar').should be_reader
290
+ end
291
+
292
+ it "should handle indented block in @!attribute" do
293
+ YARD.parse_string <<-eof
294
+ # @!attribute foo
295
+ # Docstring here
296
+ # @return [String] the foo
297
+ # Ignore this
298
+ # @param [String] a
299
+ eof
300
+ foo = Registry.at('#foo')
301
+ foo.is_attribute?.should == true
302
+ foo.docstring.should == "Docstring here"
303
+ foo.docstring.tag(:return).should_not be_nil
304
+ foo.tag(:param).should be_nil
305
+ end
306
+
307
+ it "should be able to define multiple @attributes in docstring" do
308
+ YARD.parse_string <<-eof
309
+ class Foo
310
+ # @!attribute [r] foo1
311
+ # Docstring1
312
+ # @!attribute [w] foo2
313
+ # Docstring2
314
+ # @!attribute foo3
315
+ # @!scope class
316
+ # Docstring3
317
+ end
318
+ eof
319
+ foo1 = Registry.at('Foo#foo1')
320
+ foo2 = Registry.at('Foo#foo2=')
321
+ foo3 = Registry.at('Foo.foo3')
322
+ foo4 = Registry.at('Foo.foo3=')
323
+ foo1.should be_reader
324
+ foo2.should be_writer
325
+ foo3.should be_reader
326
+ foo1.docstring.should == 'Docstring1'
327
+ foo2.docstring.should == 'Docstring2'
328
+ foo3.docstring.should == 'Docstring3'
329
+ foo4.should be_writer
330
+ foo1.attr_info[:write].should be_nil
331
+ foo2.attr_info[:read].should be_nil
332
+ end
333
+
334
+ it "should define the attr inside namespace if attached to namespace object" do
335
+ YARD.parse_string <<-eof
336
+ module Foo
337
+ # @!attribute [r] foo
338
+ # @!attribute [r] bar
339
+ class Bar
340
+ end
341
+ end
342
+ eof
343
+ Registry.at('Foo::Bar#foo').should be_reader
344
+ Registry.at('Foo::Bar#bar').should be_reader
345
+ end
346
+ end
347
+
348
+ it "should set scope to class if signature has 'self.' prefix" do
349
+ YARD.parse_string <<-eof
350
+ # @!attribute self.foo
351
+ # @!attribute self. bar
352
+ # @!attribute self.baz
353
+ class Foo
354
+ end
355
+ eof
356
+ %w(foo bar baz).each do |name|
357
+ Registry.at("Foo.#{name}").should be_reader
358
+ end
359
+ end
360
+ end
361
+
362
+ describe YARD::Tags::ScopeDirective do
363
+ describe '#call' do
364
+ after { Registry.clear }
365
+
366
+ it "should set state on tag parser if object = nil" do
367
+ tag_parse("@!scope class")
368
+ @parser.state.scope.should == :class
369
+ end
370
+
371
+ it "should set state on tag parser if object is namespace" do
372
+ object = CodeObjects::ClassObject.new(:root, 'Foo')
373
+ tag_parse("@!scope class", object)
374
+ object[:scope].should be_nil
375
+ @parser.state.scope.should == :class
376
+ end
377
+
378
+ it "should set scope on object if object is a method object" do
379
+ object = CodeObjects::MethodObject.new(:root, 'foo')
380
+ tag_parse("@!scope class", object)
381
+ object.scope.should == :class
382
+ end
383
+
384
+ %w(class instance module).each do |type|
385
+ it "should allow #{type} as value" do
386
+ tag_parse("@!scope #{type}")
387
+ @parser.state.scope.should == type.to_sym
388
+ end
389
+ end
390
+
391
+ %w(invalid foo FOO CLASS INSTANCE).each do |type|
392
+ it "should not allow #{type} as value" do
393
+ tag_parse("@!scope #{type}")
394
+ @parser.state.scope.should be_nil
395
+ end
396
+ end
397
+ end
398
+ end
399
+
400
+ describe YARD::Tags::VisibilityDirective do
401
+ describe '#call' do
402
+ after { Registry.clear }
403
+
404
+ it "should set visibility on tag parser if object = nil" do
405
+ tag_parse("@!visibility private")
406
+ @parser.state.visibility.should == :private
407
+ end
408
+
409
+ it "should set state on tag parser if object is namespace" do
410
+ object = CodeObjects::ClassObject.new(:root, 'Foo')
411
+ tag_parse("@!visibility protected", object)
412
+ object.visibility.should == :protected
413
+ @parser.state.visibility.should be_nil
414
+ end
415
+
416
+ it "should set visibility on object if object is a method object" do
417
+ object = CodeObjects::MethodObject.new(:root, 'foo')
418
+ tag_parse("@!visibility private", object)
419
+ object.visibility.should == :private
420
+ end
421
+
422
+ %w(public private protected).each do |type|
423
+ it "should allow #{type} as value" do
424
+ tag_parse("@!visibility #{type}")
425
+ @parser.state.visibility.should == type.to_sym
426
+ end
427
+ end
428
+
429
+ %w(invalid foo FOO PRIVATE INSTANCE).each do |type|
430
+ it "should not allow #{type} as value" do
431
+ tag_parse("@!visibility #{type}")
432
+ @parser.state.visibility.should be_nil
433
+ end
434
+ end
435
+ end
436
+ end
@@ -0,0 +1,34 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe YARD::Tags::Library do
4
+ def tag(docstring)
5
+ Docstring.new(docstring).tags.first
6
+ end
7
+
8
+ describe '#see_tag' do
9
+ it "should take a URL" do
10
+ tag("@see http://example.com").name.should == "http://example.com"
11
+ end
12
+
13
+ it "should take an object path" do
14
+ tag("@see String#reverse").name.should == "String#reverse"
15
+ end
16
+
17
+ it "should take a description after the url/object" do
18
+ tag = tag("@see http://example.com An Example Site")
19
+ tag.name.should == "http://example.com"
20
+ tag.text.should == "An Example Site"
21
+ end
22
+ end
23
+
24
+ describe '.define_tag' do
25
+ it "should allow defining tags with '.' in the name (x.y.z defines method x_y_z)" do
26
+ Tags::Library.define_tag("foo", 'x.y.z')
27
+ Tags::Library.define_tag("foo2", 'x.y.zz', Tags::OverloadTag)
28
+ Tags::Library.instance.method(:x_y_z_tag).should_not be_nil
29
+ Tags::Library.instance.method(:x_y_zz_tag).should_not be_nil
30
+ tag('@x.y.z foo bar').text.should == 'foo bar'
31
+ tag('@x.y.zz foo(bar)').signature.should == 'foo(bar)'
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,53 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe YARD::Tags::OverloadTag do
4
+ before do
5
+ @tag = Tags::OverloadTag.new(:overload, <<-'eof')
6
+ def bar(a, b = 1, &block)
7
+ Hello world
8
+ @param a [String]
9
+ @return [String]
10
+ eof
11
+ end
12
+
13
+ it "should parse the first line as a method signature" do
14
+ @tag.signature.should == "def bar(a, b = 1, &block)"
15
+ @tag.parameters.should == [['a', nil], ['b', "1"], ['&block', nil]]
16
+ end
17
+
18
+ it "should parse the rest of the text as a new Docstring" do
19
+ @tag.docstring.should be_instance_of(Docstring)
20
+ @tag.docstring.should == "Hello world"
21
+ end
22
+
23
+ it "should set Docstring's object after #object= is called" do
24
+ m = mock(:object)
25
+ @tag.object = m
26
+ @tag.docstring.object.should == m
27
+ end
28
+
29
+ it "should respond to #tag, #tags and #has_tag?" do
30
+ @tag.object = mock(:object)
31
+ @tag.tags.size.should == 2
32
+ @tag.tag(:param).name.should == "a"
33
+ @tag.has_tag?(:return).should == true
34
+ end
35
+
36
+ it "should not be a CodeObjects::Base when not hooked up to an object" do
37
+ @tag.object = nil
38
+ @tag.is_a?(CodeObjects::Base).should == false
39
+ end
40
+
41
+ it "should be a CodeObjects::Base when hooked up to an object" do
42
+ @tag.object = mock(:object)
43
+ @tag.object.should_receive(:is_a?).at_least(3).times.with(CodeObjects::Base).and_return(true)
44
+ @tag.is_a?(CodeObjects::Base).should == true
45
+ @tag.kind_of?(CodeObjects::Base).should == true
46
+ (CodeObjects::Base === @tag).should == true
47
+ end
48
+
49
+ it "should not parse 'def' out of method name" do
50
+ tag = Tags::OverloadTag.new(:overload, "default")
51
+ tag.signature.should == "default"
52
+ end
53
+ end
@@ -0,0 +1,53 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe YARD::Tags::RefTagList do
4
+ before { YARD::Registry.clear }
5
+
6
+ it "should accept symbol or string as owner's path and convert it into a proxy" do
7
+ t = Tags::RefTagList.new('author', :String)
8
+ t.owner.should == P(:String)
9
+ end
10
+
11
+ it "should accept proxy object as owner" do
12
+ t = Tags::RefTagList.new('author', P(:String))
13
+ t.owner.should == P(:String)
14
+ end
15
+
16
+ it "should return tags from a proxy object" do
17
+ o = CodeObjects::ClassObject.new(:root, :String)
18
+ t = Tags::Tag.new(:author, 'foo')
19
+ o.docstring.add_tag(t)
20
+
21
+ ref = Tags::RefTagList.new('author', :String)
22
+ ref.tags.should == [t]
23
+ ref.tags.first.text.should == 'foo'
24
+ end
25
+
26
+ it "should return named tags from a proxy object" do
27
+ o = CodeObjects::ClassObject.new(:root, :String)
28
+ p1 = Tags::Tag.new(:param, 'bar1', nil, 'foo')
29
+ p2 = Tags::Tag.new(:param, 'bar2', nil, 'foo')
30
+ p3 = Tags::Tag.new(:param, 'bar3', nil, 'bar')
31
+ t1 = Tags::Tag.new(:return, 'blah')
32
+ o.docstring.add_tag(p1, t1, p2, p3)
33
+
34
+ ref = Tags::RefTagList.new('param', :String, 'foo')
35
+ ref.tags.should == [p1, p2]
36
+ ref.tags.first.text.should == 'bar1'
37
+ end
38
+
39
+ it "all tags should respond to #owner and be a RefTag" do
40
+ o = CodeObjects::ClassObject.new(:root, :String)
41
+ p1 = Tags::Tag.new(:param, 'bar1', nil, 'foo')
42
+ p2 = Tags::Tag.new(:param, 'bar2', nil, 'foo')
43
+ p3 = Tags::Tag.new(:param, 'bar3', nil, 'bar')
44
+ t1 = Tags::Tag.new(:return, 'blah')
45
+ o.docstring.add_tag(p1, t1, p2, p3)
46
+
47
+ ref = Tags::RefTagList.new('param', :String)
48
+ ref.tags.each do |t|
49
+ t.should be_kind_of(Tags::RefTag)
50
+ t.owner.should == o
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,11 @@
1
+ <% if object.has_tag?(:example) %>
2
+ <div class="examples">
3
+ <p class="tag_title">Examples:</p>
4
+ <% object.tags(:example).each do |tag| %>
5
+ <% unless tag.name.empty? %>
6
+ <p class="example_title"><%= htmlify_line(tag.name) %></p>
7
+ <% end %>
8
+ <pre class="example code"><code><%= html_syntax_highlight(tag.text) %></code></pre>
9
+ <% end %>
10
+ </div>
11
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <div class="tags">
2
+ <%= yieldall %>
3
+ </div>
@@ -0,0 +1,24 @@
1
+ <% if object.has_tag?(:option) %>
2
+ <% object.parameters.each do |param, default| %>
3
+ <% tags = object.tags(:option).select {|x| x.name.to_s == param.to_s } %>
4
+ <% next if tags.empty? %>
5
+ <p class="tag_title">Options Hash (<tt><%= param %></tt>):</p>
6
+ <ul class="option">
7
+ <% for tag in tags %>
8
+ <li>
9
+ <span class="name"><%= tag.pair.name %></span>
10
+ <span class="type"><%= format_types(tag.pair.types || ['Object']) %></span>
11
+ <span class="default">
12
+ <% if tag.pair.defaults %>
13
+ &mdash; default:
14
+ <%= tag.pair.defaults.map {|t| "<tt>#{h t}</tt>" }.join(", ") %>
15
+ <% end %>
16
+ </span>
17
+ <% if tag.pair.text && tag.pair.text =~ /\S/ %>
18
+ &mdash; <%= htmlify_line(tag.pair.text) %>
19
+ <% end %>
20
+ </li>
21
+ <% end %>
22
+ </ul>
23
+ <% end %>
24
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <% if object.tags(:overload).size == 1 %>
2
+ <%= yieldall :object => object.tag(:overload) %>
3
+ <% elsif object.has_tag?(:overload) && object.tags(:overload).any? {|o| !o.docstring.blank? } %>
4
+ <p class="tag_title">Overloads:</p>
5
+ <ul class="overload">
6
+ <% object.tags(:overload).each do |overload| %>
7
+ <% next if overload.docstring.blank? %>
8
+ <li class="overload_item">
9
+ <span class="signature"><%= signature(overload, false, false) %></span>
10
+ <%= yieldall :object => overload %>
11
+ </li>
12
+ <% end %>
13
+ </ul>
14
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <% if object.has_tag?(:see) %>
2
+ <p class="tag_title">See Also:</p>
3
+ <ul class="see">
4
+ <% for tag in object.tags(:see) %>
5
+ <li><%= linkify(tag.name, tag.text) %></li>
6
+ <% end %>
7
+ </ul>
8
+ <% end %>
@@ -0,0 +1,20 @@
1
+ <p class="tag_title"><%= @label ? @label : YARD::Tags::Library.labels[@name] %>:</p>
2
+ <ul class="<%= @name %>">
3
+ <% object.tags(@name).each do |tag| %>
4
+ <li>
5
+ <% unless @no_names %>
6
+ <span class='name'><%= h tag.name %></span>
7
+ <% end %>
8
+ <% unless @no_types %>
9
+ <span class='type'><%= format_types(tag.types) %></span>
10
+ <% end %>
11
+ <% if @name == :param && (o=object.parameters.assoc(tag.name.to_s)) && o[1] %>
12
+ <em class="default">(defaults to: <tt><%= h o[1] %></tt>)</em>
13
+ <% end %>
14
+ <% if tag.text && !tag.text.empty? %>
15
+ <% unless (@no_types || tag.types.nil? || tag.types.empty?) && @no_names %>&mdash;<% end %>
16
+ <%= htmlify_line(tag.text) %>
17
+ <% end %>
18
+ </li>
19
+ <% end %>
20
+ </ul>