inch 0.4.3 → 0.4.4.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dab543a34157a4fe5467c6dbb51a94c112f29a83
4
- data.tar.gz: 674f4bd46b9f9b23b10bb5b8264f31019fb6d686
3
+ metadata.gz: f7dd851b019ec788a43552657ad1b35493956676
4
+ data.tar.gz: 3653aae1e38341b48df225a67b1334d6cb667c3b
5
5
  SHA512:
6
- metadata.gz: 6dc8d3ee59dceb8c04145f470820a28a6aff12d2c3462f893bdafc7b274b243bf6f1b12057606c91b2b0573dc0696334b46c993843d2048acc145a12765d8257
7
- data.tar.gz: 1270332e354f079ae12c9548d7f40f96b0c94c1debef1974c710ad80e7e03891bce603ef0fd4c6d89db8c19724b53d204d4e2f5f2c00f7a091453f6718ffdbbb
6
+ metadata.gz: edcdc37b91816acdd782a9f0a40d569bb9009ca0119d60fad5c1e0fdb6d2555e57f74a93fbb5b5cba409f19e601f2617b7eb07ff09100c68ceff756a12037842
7
+ data.tar.gz: 0e5d86540f4ef8cf5fe45ef76ce4bfda05159e56668114b00e0d2fd5066ddfab30ad664d6779e7cd80fe0fd5532b9bbfe043007072bc34bac20f53195797d0d3
@@ -49,6 +49,10 @@ module Inch
49
49
  last_line =~ /^Returns\ (\w+\s){2,}/
50
50
  end
51
51
 
52
+ def to_s
53
+ @text
54
+ end
55
+
52
56
  private
53
57
 
54
58
  def first_line
@@ -30,11 +30,11 @@ module Inch
30
30
  end
31
31
 
32
32
  def has_code_example?
33
- super || signatures.any? { |s| s.has_code_example? }
33
+ signatures.any? { |s| s.has_code_example? }
34
34
  end
35
35
 
36
36
  def has_doc?
37
- super && !implicit_docstring? || signatures.any? { |s| s.has_doc? }
37
+ signatures.any? { |s| s.has_doc? }
38
38
  end
39
39
 
40
40
  def method?
@@ -98,18 +98,6 @@ module Inch
98
98
 
99
99
  private
100
100
 
101
- # Returns +true+ if the docstring was generated by YARD
102
- def implicit_docstring?
103
- if getter?
104
- docstring == "Returns the value of attribute #{name}"
105
- elsif setter?
106
- basename = name.to_s.gsub(/(\=)$/, '')
107
- docstring == "Sets the attribute #{basename}"
108
- else
109
- false
110
- end
111
- end
112
-
113
101
  def overload_tags
114
102
  object.tags(:overload)
115
103
  end
@@ -5,7 +5,7 @@ module Inch
5
5
  module Object
6
6
  # Utility class to describe (overloaded) method signatures
7
7
  class MethodSignature < Struct.new(:method, :yard_tag)
8
- attr_reader :method, :yard_tag
8
+ attr_reader :method
9
9
 
10
10
  # @param method [Provider::YARD::Object::MethodObject]
11
11
  # @param method [::YARD::Tags::Tag,nil] if nil, the method's normal signature is used
@@ -15,23 +15,19 @@ module Inch
15
15
  end
16
16
 
17
17
  def all_signature_parameter_names
18
- if tag?
19
- yard_tag.parameters.map(&:first)
20
- else
21
- yard_object.parameters.map(&:first)
22
- end
18
+ relevant_object.parameters.map(&:first)
23
19
  end
24
20
 
25
21
  def has_code_example?
26
- if tag?
27
- !yard_tag.tags(:example).empty?
22
+ if docstring.contains_code_example?
23
+ true
28
24
  else
29
- !yard_object.tags(:example).empty?
25
+ !relevant_object.tags(:example).empty?
30
26
  end
31
27
  end
32
28
 
33
29
  def has_doc?
34
- !docstring.empty?
30
+ !docstring.empty? && !implicit_docstring?
35
31
  end
36
32
 
37
33
  def parameters
@@ -42,6 +38,9 @@ module Inch
42
38
  end
43
39
  end
44
40
 
41
+ # Returns the parameter with the given +name+.
42
+ # @param name [String,Symbol]
43
+ # @return [MethodParameterObject]
45
44
  def parameter(name)
46
45
  parameters.detect { |p| p.name == name.to_s }
47
46
  end
@@ -56,11 +55,7 @@ module Inch
56
55
  # Returns the actual signature of the method.
57
56
  # @return [String]
58
57
  def signature
59
- if tag?
60
- yard_tag.signature
61
- else
62
- yard_object.signature.gsub(/^(def\ )/, '')
63
- end
58
+ relevant_object.signature.gsub(/^(def\ )/, '')
64
59
  end
65
60
 
66
61
  private
@@ -73,10 +68,19 @@ module Inch
73
68
  end
74
69
 
75
70
  def docstring
76
- if tag?
77
- yard_tag.docstring
71
+ @docstring ||= Docstring.new(relevant_object.docstring)
72
+ end
73
+
74
+ # Returns +true+ if the docstring was generated by YARD
75
+ def implicit_docstring?
76
+ name = method.name
77
+ if method.getter?
78
+ docstring.to_s == "Returns the value of attribute #{name}"
79
+ elsif method.setter?
80
+ basename = name.to_s.gsub(/(\=)$/, '')
81
+ docstring.to_s == "Sets the attribute #{basename}"
78
82
  else
79
- yard_object.docstring
83
+ false
80
84
  end
81
85
  end
82
86
 
@@ -107,19 +111,11 @@ module Inch
107
111
  end
108
112
 
109
113
  def parameter_tags
110
- if tag?
111
- @yard_tag.tags(:param)
112
- else
113
- yard_object.tags(:param)
114
- end
115
- end
116
-
117
- def tag?
118
- !yard_tag.nil?
114
+ relevant_object.tags(:param)
119
115
  end
120
116
 
121
- def yard_object
122
- method.object
117
+ def relevant_object
118
+ @yard_tag || method.object
123
119
  end
124
120
  end
125
121
  end
data/lib/inch/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Inch
2
- VERSION = "0.4.3"
2
+ VERSION = "0.4.4.rc1"
3
3
  end
@@ -250,12 +250,14 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
250
250
  m = @objects.find("InchTest#attr_getset")
251
251
  assert m.getter?, "should be a getter"
252
252
  refute m.setter?
253
+ refute m.has_doc?
253
254
  end
254
255
 
255
256
  def test_attr_getset2
256
257
  m = @objects.find("InchTest#attr_getset=")
257
258
  refute m.getter?
258
259
  assert m.setter?, "should be a setter"
260
+ refute m.has_doc?
259
261
  end
260
262
 
261
263
  def test_splat_parameter_notation
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - René Föhring
@@ -315,9 +315,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
315
315
  version: '0'
316
316
  required_rubygems_version: !ruby/object:Gem::Requirement
317
317
  requirements:
318
- - - ">="
318
+ - - ">"
319
319
  - !ruby/object:Gem::Version
320
- version: '0'
320
+ version: 1.3.1
321
321
  requirements: []
322
322
  rubyforge_project:
323
323
  rubygems_version: 2.2.2