sidekiq-statsd 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
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,65 @@
1
+ module YARD
2
+ module Tags
3
+ class OverloadTag < Tag
4
+ attr_reader :signature, :parameters, :docstring
5
+
6
+ def initialize(tag_name, text)
7
+ super(tag_name, nil)
8
+ parse_tag(text)
9
+ parse_signature
10
+ end
11
+
12
+ def tag(name) docstring.tag(name) end
13
+ def tags(name = nil) docstring.tags(name) end
14
+ def has_tag?(name) docstring.has_tag?(name) end
15
+
16
+ def object=(value)
17
+ super(value)
18
+ docstring.object = value
19
+ end
20
+
21
+ def name(prefix = false)
22
+ return @name unless prefix
23
+ object.scope == :class ? @name.to_s : "#{object.send(:sep)}#{@name}"
24
+ end
25
+
26
+ def method_missing(*args, &block)
27
+ object.send(*args, &block)
28
+ end
29
+
30
+ def type
31
+ object.type
32
+ end
33
+
34
+ def is_a?(other)
35
+ object.is_a?(other) || self.class >= other.class || false
36
+ end
37
+ alias kind_of? is_a?
38
+
39
+ private
40
+
41
+ def parse_tag(text)
42
+ @signature, text = *text.split(/\r?\n/, 2)
43
+ @signature.strip!
44
+ text ||= ""
45
+ numspaces = text[/\A(\s*)/, 1].length
46
+ text.gsub!(/^[ \t]{#{numspaces}}/, '')
47
+ text.strip!
48
+ @docstring = Docstring.new(text, nil)
49
+ end
50
+
51
+ def parse_signature
52
+ if signature =~ /^(?:def\s)?\s*(#{CodeObjects::METHODMATCH})(?:(?:\s+|\s*\()(.*)(?:\)\s*$)?)?/m
53
+ meth, args = $1, $2
54
+ meth.gsub!(/\s+/,'')
55
+ # FIXME refactor this code to not make use of the Handlers::Base class (tokval_list should be moved)
56
+ toks = YARD::Parser::Ruby::Legacy::TokenList.new(args)
57
+ args = YARD::Handlers::Ruby::Legacy::Base.new(nil, nil).send(:tokval_list, toks, :all)
58
+ args.map! {|a| k, v = *a.split('=', 2); [k.strip.to_s, (v ? v.strip : nil)] } if args
59
+ @name = meth.to_sym
60
+ @parameters = args
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,7 @@
1
+ module YARD
2
+ module Tags
3
+ module RefTag
4
+ attr_accessor :owner
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ module YARD
2
+ module Tags
3
+ class RefTagList
4
+ attr_accessor :owner, :tag_name, :name
5
+
6
+ def initialize(tag_name, owner, name = nil)
7
+ @owner = CodeObjects::Proxy === owner ? owner : P(owner)
8
+ @tag_name = tag_name.to_s
9
+ @name = name
10
+ end
11
+
12
+ def tags
13
+ if owner.is_a?(CodeObjects::Base)
14
+ o = owner.tags(tag_name)
15
+ o = o.select {|t| t.name.to_s == name.to_s } if name
16
+ o.each do |t|
17
+ t.extend(RefTag)
18
+ t.owner = owner
19
+ end
20
+ o
21
+ else
22
+ []
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,57 @@
1
+ module YARD
2
+ module Tags
3
+ # Represents a metadata tag value (+@tag+). Tags can have any combination of
4
+ # {#types}, {#name} and {#text}, or none of the above.
5
+ #
6
+ # @example Programmatic tag creation
7
+ # # The following docstring syntax:
8
+ # # @param [String, nil] arg an argument
9
+ # #
10
+ # # is equivalent to:
11
+ # Tag.new(:param, 'an argument', ['String', 'nil'], 'arg')
12
+ class Tag
13
+ # @return [String] the name of the tag
14
+ attr_accessor :tag_name
15
+
16
+ # @return [String] the tag text associated with the tag
17
+ # @return [nil] if no tag text is supplied
18
+ attr_accessor :text
19
+
20
+ # @return [Array<String>] a list of types associated with the tag
21
+ # @return [nil] if no types are associated with the tag
22
+ attr_accessor :types
23
+
24
+ # @return [String] a name associated with the tag
25
+ attr_accessor :name
26
+
27
+ # @return [CodeObjects::Base] the associated object
28
+ attr_accessor :object
29
+
30
+ # Creates a new tag object with a tag name and text. Optionally, formally declared types
31
+ # and a key name can be specified.
32
+ #
33
+ # Types are mainly for meta tags that rely on type information, such as +param+, +return+, etc.
34
+ #
35
+ # Key names are for tags that declare meta data for a specific key or name, such as +param+,
36
+ # +raise+, etc.
37
+ #
38
+ # @param [#to_s] tag_name the tag name to create the tag for
39
+ # @param [String] text the descriptive text for this tag
40
+ # @param [Array<String>] types optional type list of formally declared types
41
+ # for the tag
42
+ # @param [String] name optional key name which the tag refers to
43
+ def initialize(tag_name, text, types = nil, name = nil)
44
+ @tag_name, @text, @name, @types = tag_name.to_s, text, name, (types ? [types].flatten.compact : nil)
45
+ end
46
+
47
+ # Convenience method to access the first type specified. This should mainly
48
+ # be used for tags that only specify one type.
49
+ #
50
+ # @return [String] the first of the list of specified types
51
+ # @see #types
52
+ def type
53
+ types.first
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,6 @@
1
+ module YARD
2
+ module Tags
3
+ class TagFormatError < Exception
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,152 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe YARD::Tags::DefaultFactory do
4
+ before { @f = YARD::Tags::DefaultFactory.new }
5
+
6
+ describe '#parse_tag' do
7
+ it "should not have trailing whitespace on a regular freeform tag" do
8
+ @f.parse_tag('api', 'private ').text.should == "private"
9
+ end
10
+ end
11
+
12
+ describe '#extract_types_and_name_from_text' do
13
+ def parse_types(types)
14
+ @f.send(:extract_types_and_name_from_text, types)
15
+ end
16
+
17
+ it "should handle one type" do
18
+ parse_types('[A]').should == [nil, ['A'], ""]
19
+ end
20
+
21
+ it "should handle a list of types" do
22
+ parse_types('[A, B, C]').should == [nil, ['A', 'B', 'C'], ""]
23
+ end
24
+
25
+ it "should handle ducktypes" do
26
+ parse_types('[#foo]').should == [nil, ['#foo'], '']
27
+ end
28
+
29
+ %w(#foo= #<< #<=> #>> #== #=== Array<#<=>> Array<#==>).each do |meth|
30
+ it "should handle ducktypes with special method name #{meth}" do
31
+ parse_types("[#{meth}]").should == [nil, [meth], '']
32
+ end
33
+ end
34
+
35
+ it "should only parse #ducktypes inside brackets" do
36
+ parse_types("#ducktype").should == [nil, nil, '#ducktype']
37
+ end
38
+
39
+ it "should return the text before and after the type list" do
40
+ parse_types(' b <String> description').should == ['b', ['String'], 'description']
41
+ parse_types('b c <String> description (test)').should == [nil, nil, 'b c <String> description (test)']
42
+ end
43
+
44
+ it "should handle a complex list of types" do
45
+ v = parse_types(' [Test, Array<String, Hash, C>, String]')
46
+ v.should include(["Test", "Array<String, Hash, C>", "String"])
47
+ end
48
+
49
+ it "should handle any of the following start/end delimiting chars: (), <>, {}, []" do
50
+ a = parse_types('[a,b,c]')
51
+ b = parse_types('<a,b,c>')
52
+ c = parse_types('(a,b,c)')
53
+ d = parse_types('{a,b,c}')
54
+ a.should == b
55
+ b.should == c
56
+ c.should == d
57
+ a.should include(['a','b','c'])
58
+ end
59
+
60
+ it "should return the text before the type list as the last element" do
61
+ parse_types('b[x, y, z]').should == ['b', ['x', 'y', 'z'], '']
62
+ parse_types(' ! <x>').should == ["!", ['x'], '']
63
+ end
64
+
65
+ it "should return text unparsed if there is no type list" do
66
+ parse_types('').should == [nil, nil, '']
67
+ parse_types('[]').should == [nil, nil, '[]']
68
+ end
69
+
70
+ it "should allow A => B syntax" do
71
+ v = parse_types(' [Test, Array<String, Hash{A => {B => C}}, C>, String]')
72
+ v.should include(["Test", "Array<String, Hash{A => {B => C}}, C>", "String"])
73
+ end
74
+ end
75
+
76
+ describe '#parse_tag_with_types' do
77
+ def parse_types(text)
78
+ @f.send(:parse_tag_with_types, 'test', text)
79
+ end
80
+
81
+ it "should parse given types and description" do
82
+ YARD::Tags::Tag.should_receive(:new).with("test", "description", ["x", "y", "z"])
83
+ parse_types(' [x, y, z] description')
84
+ end
85
+
86
+ it "should parse given types only" do
87
+ YARD::Tags::Tag.should_receive(:new).with("test", "", ["x", "y", "z"])
88
+ parse_types(' [x, y, z] ')
89
+ end
90
+
91
+ it "should allow type list to be omitted" do
92
+ YARD::Tags::Tag.should_receive(:new).with('test', 'description', nil)
93
+ parse_types(' description ')
94
+ end
95
+
96
+ it "should raise an error if a name is specified before type list" do
97
+ lambda { parse_types('b<String> desc') }.should raise_error(YARD::Tags::TagFormatError, 'cannot specify a name before type list for \'@test\'')
98
+ end
99
+ end
100
+
101
+ describe '#parse_tag_with_types_name_and_default' do
102
+ def parse_types(text)
103
+ @f.send(:parse_tag_with_types_name_and_default, 'test', text)
104
+ end
105
+
106
+ it "should parse a standard type list with name before types (no default)" do
107
+ YARD::Tags::DefaultTag.should_receive(:new).with("test", "description", ["x", "y", "z"], 'NAME', nil)
108
+ parse_types('NAME [x, y, z] description')
109
+ end
110
+
111
+ it "should parse a standard type list with name after types (no default)" do
112
+ YARD::Tags::DefaultTag.should_receive(:new).with("test", "description", ["x", "y", "z"], 'NAME', nil)
113
+ parse_types(' [x, y, z] NAME description')
114
+ end
115
+
116
+ it "should parse a tag definition with name, typelist and default" do
117
+ YARD::Tags::DefaultTag.should_receive(:new).with("test", "description", ["x", "y", "z"], 'NAME', ['default', 'values'])
118
+ parse_types(' [x, y, z] NAME (default, values) description')
119
+ end
120
+
121
+ it "should parse a tag definition with name, typelist and default when name is before type list" do
122
+ YARD::Tags::DefaultTag.should_receive(:new).with("test", "description", ["x", "y", "z"], 'NAME', ['default', 'values'])
123
+ parse_types(' NAME [x, y, z] (default, values) description')
124
+ end
125
+
126
+ it "should allow typelist to be omitted" do
127
+ YARD::Tags::DefaultTag.should_receive(:new).with("test", "description", nil, 'NAME', ['default', 'values'])
128
+ parse_types(' NAME (default, values) description')
129
+ end
130
+ end
131
+
132
+ describe '#parse_tag_with_options' do
133
+ def parse_options(text)
134
+ @f.parse_tag_with_options('option', text)
135
+ end
136
+
137
+ it "should have a name before tag info" do
138
+ t = parse_options("xyz key [Types] (default) description")
139
+ t.tag_name.should == 'option'
140
+ t.name.should == 'xyz'
141
+ end
142
+
143
+ it "should parse the rest of the tag like DefaultTag" do
144
+ t = parse_options("xyz key [Types] (default) description")
145
+ t.pair.should be_instance_of(Tags::DefaultTag)
146
+ t.pair.types.should == ["Types"]
147
+ t.pair.name.should == "key"
148
+ t.pair.defaults.should == ["default"]
149
+ t.pair.text.should == "description"
150
+ end
151
+ end
152
+ end
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe YARD::Tags::DefaultTag do
4
+ it "should create a tag with defaults" do
5
+ o = YARD::Tags::DefaultTag.new('tagname', 'desc', ['types'], 'name', ['defaults'])
6
+ o.defaults.should == ['defaults']
7
+ o.tag_name.should == 'tagname'
8
+ o.name.should == 'name'
9
+ o.types.should == ['types']
10
+ end
11
+ end