inch 0.4.4.rc2 → 0.4.4.rc3
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.
- checksums.yaml +4 -4
- data/lib/inch/code_object/provider/yard.rb +33 -0
- data/lib/inch/code_object/provider/yard/docstring.rb +0 -16
- data/lib/inch/code_object/provider/yard/object/method_object.rb +4 -3
- data/lib/inch/code_object/provider/yard/object/method_signature.rb +1 -1
- data/lib/inch/version.rb +1 -1
- data/test/fixtures/simple/lib/role_methods.rb +2 -0
- data/test/unit/code_object/proxy/method_object_test.rb +16 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 906e6d4610f4a1e6b81d26882e245c6b79080963
|
4
|
+
data.tar.gz: 5777392ea8de43a8536c7e223be7b2fbdf16af38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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
|
-
|
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
@@ -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
|