inch 0.4.4.rc2 → 0.4.4.rc3

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: 939665081ef1fae175405f3e47c6aab33b96449a
4
- data.tar.gz: 384311683a56411b6408f0206af6e5428c828d04
3
+ metadata.gz: 906e6d4610f4a1e6b81d26882e245c6b79080963
4
+ data.tar.gz: 5777392ea8de43a8536c7e223be7b2fbdf16af38
5
5
  SHA512:
6
- metadata.gz: 38867d8c71272f70cc7195cc2e65a1830b0cd63a88738ee23bc1cc04d4a5ee90e28ecdfb511f442655708841a1cb747919c4adec8596a194daee63cfb4f8e241
7
- data.tar.gz: dc096ab206cc711c66203426303b5e44aff321dbcf849a7579da4ba91db842b1fc320c88206de44858a3aaa3ee9527a2bb6a3b823f3fe598097ac89102276c10
6
+ metadata.gz: 0e7375a37a7d8166fb730f61c7bf2fcf935d2919d463342c4327d9f2a47911086ebe1bcc007787a64c79f94a48c158178165483d880f884fe672bc16a7015267
7
+ data.tar.gz: 18d13d4469bdfcc1beff48798a6aeacb5e9b2eda677e9a766b32eb3ec5fee6ad6a0c4a7dad1c67e5335914c897044a7a3870c524230f576707b4728402f39e02
@@ -4,6 +4,39 @@ module Inch
4
4
  # Parses the source tree (using YARD)
5
5
  module YARD
6
6
 
7
+ # Returns +true+ if the docstring was generated by YARD
8
+ #
9
+ # @param docstring [Docstring,String]
10
+ # @param method [MethodObject]
11
+ def self.implicit_docstring?(docstring, method)
12
+ name = method.name
13
+ if method.getter?
14
+ docstring.to_s == "Returns the value of attribute #{name}"
15
+ elsif method.setter?
16
+ basename = name.to_s.gsub(/(\=)$/, '')
17
+ docstring.to_s == "Sets the attribute #{basename}"
18
+ else
19
+ false
20
+ end
21
+ end
22
+
23
+ # Returns +true+ if the tag was generated by YARD
24
+ #
25
+ # @param tag [::YARD::Tag]
26
+ # @param method [MethodObject]
27
+ def self.implicit_tag?(tag, method)
28
+ name = method.name
29
+ if method.getter?
30
+ tag.tag_name == 'return' &&
31
+ tag.text == "the current value of #{name}"
32
+ elsif method.setter?
33
+ tag.tag_name == 'return' &&
34
+ tag.text == 'the newly set value'
35
+ else
36
+ false
37
+ end
38
+ end
39
+
7
40
  def self.parse(dir, config = Inch::Config.codebase)
8
41
  Parser.parse(dir, config)
9
42
  end
@@ -3,22 +3,6 @@ module Inch
3
3
  module Provider
4
4
  module YARD
5
5
  class Docstring
6
- # Returns +true+ if the docstring was generated by YARD
7
- #
8
- # @param docstring [Docstring,String]
9
- # @param method [MethodObject]
10
- def self.implicit?(docstring, method)
11
- name = method.name
12
- if method.getter?
13
- docstring.to_s == "Returns the value of attribute #{name}"
14
- elsif method.setter?
15
- basename = name.to_s.gsub(/(\=)$/, '')
16
- docstring.to_s == "Sets the attribute #{basename}"
17
- else
18
- false
19
- end
20
- end
21
-
22
6
  def initialize(text)
23
7
  @text = text.to_s
24
8
  end
@@ -64,11 +64,12 @@ module Inch
64
64
  end
65
65
 
66
66
  def return_mentioned?
67
- !return_tags.empty? || docstring.mentions_return? && !implicit_docstring?
67
+ return_tags.any? { |t| !t.types.empty? && !YARD.implicit_tag?(t, self) } ||
68
+ docstring.mentions_return? && !implicit_docstring?
68
69
  end
69
70
 
70
71
  def return_described?
71
- return_tags.any? { |t| !t.text.empty? } ||
72
+ return_tags.any? { |t| !t.text.empty? && !YARD.implicit_tag?(t, self) } ||
72
73
  docstring.describes_return? && !implicit_docstring?
73
74
  end
74
75
 
@@ -100,7 +101,7 @@ module Inch
100
101
 
101
102
  # Returns +true+ if the docstring was generated by YARD
102
103
  def implicit_docstring?
103
- Docstring.implicit?(docstring, self)
104
+ YARD.implicit_docstring?(docstring, self)
104
105
  end
105
106
 
106
107
  def overload_tags
@@ -70,7 +70,7 @@ module Inch
70
70
 
71
71
  # Returns +true+ if the docstring was generated by YARD
72
72
  def implicit_docstring?
73
- Docstring.implicit?(docstring, method)
73
+ YARD.implicit_docstring?(docstring, method)
74
74
  end
75
75
 
76
76
  # Returns how the given parameter is noted in the method's
data/lib/inch/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Inch
2
- VERSION = "0.4.4.rc2"
2
+ VERSION = "0.4.4.rc3"
3
3
  end
@@ -2,6 +2,8 @@ def root_method
2
2
  end
3
3
 
4
4
  module InchTest
5
+ StructGetSet = Struct.new(:struct_getset)
6
+
5
7
  attr_accessor :attr_getset
6
8
 
7
9
  def manual_getset
@@ -272,6 +272,22 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
272
272
  assert_equal 0, m.score
273
273
  end
274
274
 
275
+ def test_struct_getset
276
+ m = @objects.find("InchTest::StructGetSet#struct_getset")
277
+ assert m.getter?, "should be a getter"
278
+ refute m.setter?
279
+ refute m.has_doc?
280
+ assert_equal 0, m.score
281
+ end
282
+
283
+ def test_struct_getset2
284
+ m = @objects.find("InchTest::StructGetSet#struct_getset=")
285
+ refute m.getter?
286
+ assert m.setter?, "should be a setter"
287
+ refute m.has_doc?
288
+ assert_equal 0, m.score
289
+ end
290
+
275
291
  def test_splat_parameter_notation
276
292
  # it should assign the same score whether the parameter is
277
293
  # described with or without the splat (*) operator
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.4.rc2
4
+ version: 0.4.4.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - René Föhring