inch 0.3.1.rc3 → 0.3.1.rc4

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: c7ebfc095c5dacd9a9b7e5c034e8ece4d04c62c0
4
- data.tar.gz: 9fc736421aac730436c60b90ce2c8fe524e6a7af
3
+ metadata.gz: e0e0ac12145f490c8344decf540c18bfde47cd80
4
+ data.tar.gz: 9bcb872f479818b9feac08c5d2db80303aee6ef5
5
5
  SHA512:
6
- metadata.gz: 4a9cebf6e1c4e435b68509c5e02b216ab99266d3e4bab7e7736eb5d3d5f216119426b0061e0280073c1b0c32aecf50f62925d6de4c75ea88ca551fa215880815
7
- data.tar.gz: 316deebcb7ed8bb2fcd9ba8ea90454b407b55b2c8f99435a1b6d97f63f34e876c12ab54c3385e0fdc8b92a86adf165ba6016846f5d7e8282123f2543ad641b17
6
+ metadata.gz: 65f3ce04102ade8753d5b1b7d0db2620f7a8087df58949fd9efe21c41ac54c27c82a4031885d913acbc9cd48353333ef36b1147d848f462a033cbb22162fcae1
7
+ data.tar.gz: acfdb32fe9cfb3a2301feef2110eedbf39ccfe6e4f78eb8e07dc2dffba2dd8f4e43601630c96b463b493a1c3a1453c2240c0072fb18b25bdedf27c2b133a9bfe
@@ -103,9 +103,9 @@ module Inch
103
103
  end
104
104
 
105
105
  def priority_arrows_gte(min_priority)
106
- Evaluation::PriorityRange.all.map do |range, str|
107
- str if range.min >= min_priority
108
- end.compact
106
+ Evaluation::PriorityRange.all.select do |priority_range|
107
+ priority_range.priorities.min >= min_priority
108
+ end
109
109
  end
110
110
 
111
111
  def grade_list(grade_symbol)
@@ -36,7 +36,7 @@ module Inch
36
36
  overridden_method_fullname
37
37
  parameters
38
38
  private?
39
- private_api_tag?
39
+ tagged_as_internal_api?
40
40
  private_tag?
41
41
  protected?
42
42
  public?
@@ -7,6 +7,10 @@ module Inch
7
7
  @text = text.to_s
8
8
  end
9
9
 
10
+ def describes_internal_api?
11
+ first_line =~ /^Internal\:\ .+/
12
+ end
13
+
10
14
  def empty?
11
15
  @text.strip.empty?
12
16
  end
@@ -32,11 +36,21 @@ module Inch
32
36
  end
33
37
 
34
38
  def mentions_return?
35
- @text.lines.to_a.last =~ /^Returns\ /
39
+ last_line =~ /^Returns\ /
36
40
  end
37
41
 
38
42
  def describes_return?
39
- @text.lines.to_a.last =~ /^Returns\ (\w+\s){2,}/
43
+ last_line =~ /^Returns\ (\w+\s){2,}/
44
+ end
45
+
46
+ private
47
+
48
+ def first_line
49
+ @first_line ||= @text.lines.to_a.first
50
+ end
51
+
52
+ def last_line
53
+ @last_line ||= @text.lines.to_a.last
40
54
  end
41
55
 
42
56
  def parse_code_examples
@@ -57,8 +71,6 @@ module Inch
57
71
  code_examples.delete_if(&:empty?).map(&:join)
58
72
  end
59
73
 
60
- private
61
-
62
74
  def mention_parameter_patterns(name)
63
75
  [
64
76
  "+#{name}+",
@@ -68,15 +68,9 @@ module Inch
68
68
  end
69
69
 
70
70
  # Returns all files declaring the object in the form of an Array of
71
- # Arrays containing the filename and the line number of their
72
- # declaration.
71
+ # Arrays containing the location of their declaration.
73
72
  #
74
- # @example
75
- # files # => [["lib/inch.rb", 3],
76
- # ["lib/inch/cli.rb", 1],
77
- # ["lib/inch/version.rb", 1],
78
- #
79
- # @return [Array<Array(String, Fixnum)>]
73
+ # @return [Array<CodeLocation>]
80
74
  def files
81
75
  object.files.map do |(filename, line_no)|
82
76
  CodeLocation.new(base_dir, filename, line_no)
@@ -202,8 +196,8 @@ module Inch
202
196
  @__private_tag
203
197
  end
204
198
 
205
- def private_api_tag?
206
- api_tag && api_tag.text == 'private'
199
+ def tagged_as_internal_api?
200
+ private_api_tag? || docstring.describes_internal_api?
207
201
  end
208
202
 
209
203
  def protected?
@@ -220,7 +214,7 @@ module Inch
220
214
 
221
215
  # @return [Boolean] +true+ if the object has no documentation at all
222
216
  def undocumented?
223
- docstring.empty? && tags.empty?
217
+ original_docstring.empty?
224
218
  end
225
219
 
226
220
  def unconsidered_tag_count
@@ -237,6 +231,14 @@ module Inch
237
231
  text.scan(/\b(#{Regexp.escape(name)})[^_0-9\!\?]/m).size > 1
238
232
  end
239
233
 
234
+ def original_docstring
235
+ object.docstring.all
236
+ end
237
+
238
+ def private_api_tag?
239
+ api_tag && api_tag.text == 'private'
240
+ end
241
+
240
242
  def tag(name)
241
243
  tags(name).first
242
244
  end
@@ -167,8 +167,8 @@ module Inch
167
167
  self[:private_tag?]
168
168
  end
169
169
 
170
- def private_api_tag?
171
- self[:private_api_tag?]
170
+ def tagged_as_internal_api?
171
+ self[:tagged_as_internal_api?]
172
172
  end
173
173
 
174
174
  def protected?
@@ -103,7 +103,7 @@ module Inch
103
103
  Role::Object::WithoutCodeExample => score_for(:code_example_single),
104
104
  Role::Object::Tagged => score_for_unconsidered_tags,
105
105
  Role::Object::TaggedAsAPI => nil,
106
- Role::Object::TaggedAsPrivateAPI => nil,
106
+ Role::Object::TaggedAsInternalAPI => nil,
107
107
  }
108
108
  end
109
109
 
@@ -41,7 +41,7 @@ module Inch
41
41
  end
42
42
 
43
43
  # Role assigned to objects explicitly or implicitly tagged to be part
44
- # of an API. If the API is 'private' TaggedAsPrivateAPI is assigned
44
+ # of an API. If the API is 'private'/'internal' TaggedAsInternalAPI is assigned
45
45
  # instead.
46
46
  class TaggedAsAPI < Base
47
47
  applicable_if :api_tag?
@@ -49,8 +49,8 @@ module Inch
49
49
 
50
50
  # Role assigned to objects explicitly or implicitly tagged to be part
51
51
  # of a private API.
52
- class TaggedAsPrivateAPI < Base
53
- applicable_if :private_api_tag?
52
+ class TaggedAsInternalAPI < Base
53
+ applicable_if :tagged_as_internal_api?
54
54
 
55
55
  def priority
56
56
  -5
@@ -1,3 +1,3 @@
1
1
  module Inch
2
- VERSION = "0.3.1.rc3"
2
+ VERSION = "0.3.1.rc4"
3
3
  end
@@ -98,4 +98,12 @@ module InchTest
98
98
  # @private
99
99
  def method_with_private_tag
100
100
  end
101
+
102
+ # @api private
103
+ def internal_api_with_yard
104
+ end
105
+
106
+ # Internal: Normalize the filename.
107
+ def internal_api_with_tomdoc
108
+ end
101
109
  end
@@ -10,7 +10,7 @@ describe ::Inch::CodeObject::Provider::YARD::Docstring do
10
10
 
11
11
  it "should notice things in tomdoc style docs" do
12
12
  text = <<-DOC
13
- Public: Detects the Language of the blob.
13
+ Internal: Detects the Language of the blob.
14
14
 
15
15
  param1 - String filename
16
16
  param2 - String blob data. A block also maybe passed in for lazy
@@ -21,6 +21,7 @@ param3 - Optional String mode (defaults to nil)
21
21
  Returns Language or nil.
22
22
  DOC
23
23
  docstring = described_class.new(text)
24
+ assert docstring.describes_internal_api?
24
25
  assert docstring.mentions_parameter?(:param1)
25
26
  assert docstring.mentions_parameter?(:param2)
26
27
  assert docstring.mentions_parameter?(:param3)
@@ -12,6 +12,14 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
12
12
  assert m.undocumented?
13
13
  end
14
14
 
15
+ def test_tagged_as_internal_api
16
+ %w( InchTest#internal_api_with_yard
17
+ InchTest#internal_api_with_tomdoc).each do |fullname|
18
+ m = @codebase.objects.find(fullname)
19
+ assert m.tagged_as_internal_api?
20
+ end
21
+ end
22
+
15
23
  def test_method_without_doc
16
24
  m = @codebase.objects.find("Foo::Bar#method_without_doc")
17
25
  refute m.has_doc?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1.rc3
4
+ version: 0.3.1.rc4
5
5
  platform: ruby
6
6
  authors:
7
7
  - René Föhring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-24 00:00:00.000000000 Z
11
+ date: 2014-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -290,7 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
290
  version: 1.3.1
291
291
  requirements: []
292
292
  rubyforge_project:
293
- rubygems_version: 2.2.2
293
+ rubygems_version: 2.2.0
294
294
  signing_key:
295
295
  specification_version: 4
296
296
  summary: Documentation measurement tool for Ruby