inch 0.4.10 → 0.5.0.rc1

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.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2 -11
  3. data/Gemfile +2 -5
  4. data/README.md +1 -1
  5. data/Rakefile +2 -2
  6. data/bin/inch +3 -3
  7. data/config/defaults.rb +0 -7
  8. data/inch.gemspec +7 -7
  9. data/lib/inch.rb +9 -9
  10. data/lib/inch/api.rb +10 -10
  11. data/lib/inch/api/compare.rb +2 -2
  12. data/lib/inch/api/compare/code_objects.rb +3 -2
  13. data/lib/inch/api/compare/codebases.rb +1 -1
  14. data/lib/inch/api/diff.rb +10 -7
  15. data/lib/inch/api/filter.rb +1 -1
  16. data/lib/inch/api/get.rb +1 -1
  17. data/lib/inch/api/options/base.rb +4 -4
  18. data/lib/inch/api/options/filter.rb +4 -0
  19. data/lib/inch/api/options/suggest.rb +5 -1
  20. data/lib/inch/api/stats.rb +1 -0
  21. data/lib/inch/api/suggest.rb +10 -9
  22. data/lib/inch/cli.rb +6 -6
  23. data/lib/inch/cli/arguments.rb +2 -2
  24. data/lib/inch/cli/command.rb +15 -15
  25. data/lib/inch/cli/command/base.rb +4 -4
  26. data/lib/inch/cli/command/console.rb +5 -5
  27. data/lib/inch/cli/command/diff.rb +8 -7
  28. data/lib/inch/cli/command/inspect.rb +4 -5
  29. data/lib/inch/cli/command/list.rb +4 -4
  30. data/lib/inch/cli/command/options/base.rb +8 -8
  31. data/lib/inch/cli/command/options/base_list.rb +5 -9
  32. data/lib/inch/cli/command/options/console.rb +3 -4
  33. data/lib/inch/cli/command/options/diff.rb +6 -8
  34. data/lib/inch/cli/command/options/inspect.rb +2 -2
  35. data/lib/inch/cli/command/options/list.rb +2 -3
  36. data/lib/inch/cli/command/options/show.rb +2 -2
  37. data/lib/inch/cli/command/options/stats.rb +1 -2
  38. data/lib/inch/cli/command/options/suggest.rb +3 -6
  39. data/lib/inch/cli/command/output/base.rb +6 -4
  40. data/lib/inch/cli/command/output/console.rb +5 -4
  41. data/lib/inch/cli/command/output/diff.rb +6 -6
  42. data/lib/inch/cli/command/output/inspect.rb +8 -6
  43. data/lib/inch/cli/command/output/list.rb +1 -0
  44. data/lib/inch/cli/command/output/show.rb +5 -4
  45. data/lib/inch/cli/command/output/stats.rb +21 -21
  46. data/lib/inch/cli/command/output/suggest.rb +27 -30
  47. data/lib/inch/cli/command/show.rb +4 -4
  48. data/lib/inch/cli/command/stats.rb +4 -4
  49. data/lib/inch/cli/command/suggest.rb +6 -6
  50. data/lib/inch/cli/command_parser.rb +5 -6
  51. data/lib/inch/cli/sparkline_helper.rb +6 -6
  52. data/lib/inch/cli/trace_helper.rb +1 -1
  53. data/lib/inch/cli/yardopts_helper.rb +3 -4
  54. data/lib/inch/code_object.rb +3 -3
  55. data/lib/inch/code_object/converter.rb +8 -6
  56. data/lib/inch/code_object/provider.rb +1 -1
  57. data/lib/inch/code_object/provider/yard.rb +12 -10
  58. data/lib/inch/code_object/provider/yard/docstring.rb +19 -51
  59. data/lib/inch/code_object/provider/yard/nodoc_helper.rb +4 -4
  60. data/lib/inch/code_object/provider/yard/object.rb +10 -12
  61. data/lib/inch/code_object/provider/yard/object/base.rb +27 -48
  62. data/lib/inch/code_object/provider/yard/object/method_object.rb +10 -47
  63. data/lib/inch/code_object/provider/yard/object/method_parameter_object.rb +6 -10
  64. data/lib/inch/code_object/provider/yard/object/method_signature.rb +8 -12
  65. data/lib/inch/code_object/provider/yard/object/namespace_object.rb +4 -1
  66. data/lib/inch/code_object/provider/yard/parser.rb +3 -3
  67. data/lib/inch/code_object/proxy.rb +9 -10
  68. data/lib/inch/code_object/proxy/base.rb +10 -12
  69. data/lib/inch/code_object/proxy/method_object.rb +2 -3
  70. data/lib/inch/code_object/proxy/method_parameter_object.rb +3 -5
  71. data/lib/inch/codebase.rb +5 -4
  72. data/lib/inch/codebase/objects_filter.rb +4 -2
  73. data/lib/inch/codebase/serializer.rb +3 -3
  74. data/lib/inch/config.rb +2 -2
  75. data/lib/inch/config/base.rb +1 -0
  76. data/lib/inch/config/codebase.rb +4 -4
  77. data/lib/inch/core_ext.rb +1 -1
  78. data/lib/inch/core_ext/string.rb +1 -1
  79. data/lib/inch/evaluation.rb +15 -16
  80. data/lib/inch/evaluation/file.rb +1 -1
  81. data/lib/inch/evaluation/grade_list.rb +2 -2
  82. data/lib/inch/evaluation/object_schema.rb +1 -1
  83. data/lib/inch/evaluation/proxy.rb +7 -8
  84. data/lib/inch/evaluation/proxy/base.rb +10 -13
  85. data/lib/inch/evaluation/proxy/constant_object.rb +1 -1
  86. data/lib/inch/evaluation/proxy/method_object.rb +5 -12
  87. data/lib/inch/evaluation/proxy/module_object.rb +1 -1
  88. data/lib/inch/evaluation/proxy/namespace_object.rb +1 -1
  89. data/lib/inch/evaluation/role/base.rb +1 -1
  90. data/lib/inch/evaluation/role/method.rb +2 -2
  91. data/lib/inch/evaluation/role/method_parameter.rb +1 -2
  92. data/lib/inch/evaluation/role/object.rb +2 -2
  93. data/lib/inch/rake.rb +2 -2
  94. data/lib/inch/rake/suggest.rb +2 -3
  95. data/lib/inch/utils/shell_helper.rb +1 -1
  96. data/lib/inch/utils/ui.rb +5 -5
  97. data/lib/inch/utils/weighted_list.rb +3 -2
  98. data/lib/inch/version.rb +1 -1
  99. data/test/fixtures/simple/lib/broken.rb +7 -35
  100. data/test/fixtures/simple/lib/foo.rb +1 -22
  101. data/test/integration/api/compare/codebases.rb +1 -1
  102. data/test/integration/cli/command/console_test.rb +5 -5
  103. data/test/integration/cli/command/inspect_test.rb +5 -4
  104. data/test/integration/cli/command/list_test.rb +4 -3
  105. data/test/integration/cli/command/show_test.rb +4 -4
  106. data/test/integration/cli/command/stats_test.rb +2 -2
  107. data/test/integration/cli/command/suggest_test.rb +10 -10
  108. data/test/integration/stats_options_test.rb +3 -3
  109. data/test/integration/visibility_options_test.rb +13 -13
  110. data/test/shared/base_list.rb +3 -4
  111. data/test/test_helper.rb +6 -16
  112. data/test/unit/api/filter_test.rb +7 -7
  113. data/test/unit/api/get_test.rb +1 -1
  114. data/test/unit/api/list_test.rb +1 -1
  115. data/test/unit/api/options/base_test.rb +3 -3
  116. data/test/unit/api/stats_test.rb +1 -1
  117. data/test/unit/api/suggest_test.rb +3 -3
  118. data/test/unit/cli/arguments_test.rb +1 -1
  119. data/test/unit/cli/command/base_test.rb +1 -1
  120. data/test/unit/cli/command/options/base_list_test.rb +2 -2
  121. data/test/unit/cli/command/options/base_object_test.rb +1 -1
  122. data/test/unit/cli/command/options/base_test.rb +1 -1
  123. data/test/unit/cli/command_parser_test.rb +2 -2
  124. data/test/unit/cli/trace_helper_test.rb +1 -1
  125. data/test/unit/cli/yardopts_helper_test.rb +3 -4
  126. data/test/unit/code_object/converter_test.rb +1 -1
  127. data/test/unit/code_object/provider/yard/docstring_test.rb +28 -106
  128. data/test/unit/code_object/provider/yard/nodoc_helper_test.rb +5 -6
  129. data/test/unit/code_object/provider/yard/object/method_object_test.rb +10 -20
  130. data/test/unit/code_object/provider/yard_test.rb +4 -4
  131. data/test/unit/code_object/provider_test.rb +1 -1
  132. data/test/unit/code_object/proxy/method_object_test.rb +262 -382
  133. data/test/unit/code_object/proxy_test.rb +1 -1
  134. data/test/unit/codebase/objects_test.rb +2 -2
  135. data/test/unit/codebase/proxy_test.rb +1 -1
  136. data/test/unit/config/codebase_test.rb +1 -1
  137. data/test/unit/evaluation/role/base_test.rb +2 -2
  138. data/test/unit/utils/ui_test.rb +4 -4
  139. data/test/unit/utils/weighted_list_test.rb +4 -7
  140. metadata +4 -14
  141. data/.rubocop.yml +0 -15
  142. data/.rubocop_todo.yml +0 -94
  143. data/lib/inch/code_object/provider/yard/object/class_variable_object.rb +0 -12
  144. data/lib/inch/code_object/proxy/class_variable_object.rb +0 -8
  145. data/lib/inch/evaluation/proxy/class_variable_object.rb +0 -19
  146. data/lib/inch/evaluation/role/class_variable.rb +0 -55
  147. data/test/fixtures/simple/lib/broken_ruby_2_0_features.rb +0 -7
  148. data/test/fixtures/simple/lib/directives.rb +0 -8
@@ -3,6 +3,6 @@ module Inch
3
3
  end
4
4
  end
5
5
 
6
- require "inch/code_object/converter"
7
- require "inch/code_object/provider"
8
- require "inch/code_object/proxy"
6
+ require 'inch/code_object/converter'
7
+ require 'inch/code_object/provider'
8
+ require 'inch/code_object/proxy'
@@ -52,7 +52,7 @@ module Inch
52
52
  unconsidered_tag_count
53
53
  undocumented?
54
54
  visibility
55
- ).map(&:to_sym)
55
+ ).map(&:to_sym)
56
56
 
57
57
  PARAMETER_ATTRIBUTES = %w(
58
58
  name
@@ -62,7 +62,7 @@ module Inch
62
62
  splat?
63
63
  typed?
64
64
  wrongly_mentioned?
65
- ).map(&:to_sym)
65
+ ).map(&:to_sym)
66
66
 
67
67
  # Returns an attributes Hash for a given code object
68
68
  #
@@ -71,14 +71,16 @@ module Inch
71
71
  def self.to_hash(o)
72
72
  attributes = {}
73
73
  OBJECT_ATTRIBUTES.each do |name|
74
- next unless o.respond_to?(name)
75
- attributes[name] = o.public_send(name)
74
+ if o.respond_to?(name)
75
+ attributes[name] = o.public_send(name)
76
+ end
76
77
  end
77
78
  attributes[:parameters] = o.parameters.map do |parameter|
78
79
  hash = {}
79
80
  PARAMETER_ATTRIBUTES.each do |pname|
80
- next unless parameter.respond_to?(pname)
81
- hash[pname] = parameter.public_send(pname)
81
+ if parameter.respond_to?(pname)
82
+ hash[pname] = parameter.public_send(pname)
83
+ end
82
84
  end
83
85
  hash
84
86
  end
@@ -33,4 +33,4 @@ module Inch
33
33
  end
34
34
  end
35
35
 
36
- require "inch/code_object/provider/yard"
36
+ require 'inch/code_object/provider/yard'
@@ -3,6 +3,7 @@ module Inch
3
3
  module Provider
4
4
  # Parses the source tree (using YARD)
5
5
  module YARD
6
+
6
7
  # Returns +true+ if the docstring was generated by YARD
7
8
  #
8
9
  # @param docstring [Docstring,String]
@@ -12,7 +13,7 @@ module Inch
12
13
  if method.getter?
13
14
  docstring.to_s == "Returns the value of attribute #{name}"
14
15
  elsif method.setter?
15
- basename = name.to_s.gsub(/(\=)$/, "")
16
+ basename = name.to_s.gsub(/(\=)$/, '')
16
17
  docstring.to_s == "Sets the attribute #{basename}"
17
18
  else
18
19
  false
@@ -26,11 +27,11 @@ module Inch
26
27
  def self.implicit_tag?(tag, method)
27
28
  name = method.name
28
29
  if method.getter?
29
- tag.tag_name == "return" &&
30
+ tag.tag_name == 'return' &&
30
31
  tag.text == "the current value of #{name}"
31
32
  elsif method.setter?
32
- tag.tag_name == "return" &&
33
- tag.text == "the newly set value"
33
+ tag.tag_name == 'return' &&
34
+ tag.text == 'the newly set value'
34
35
  else
35
36
  false
36
37
  end
@@ -39,17 +40,18 @@ module Inch
39
40
  def self.parse(dir, config = Inch::Config.codebase)
40
41
  Parser.parse(dir, config)
41
42
  end
43
+
42
44
  end
43
45
  end
44
46
  end
45
47
  end
46
48
 
47
- require "logger"
48
- require "yard"
49
+ require 'logger'
50
+ require 'yard'
49
51
 
50
52
  log.level = ::Logger::UNKNOWN # basically disable YARD's logging
51
53
 
52
- require "inch/code_object/provider/yard/parser"
53
- require "inch/code_object/provider/yard/docstring"
54
- require "inch/code_object/provider/yard/nodoc_helper"
55
- require "inch/code_object/provider/yard/object"
54
+ require 'inch/code_object/provider/yard/parser'
55
+ require 'inch/code_object/provider/yard/docstring'
56
+ require 'inch/code_object/provider/yard/nodoc_helper'
57
+ require 'inch/code_object/provider/yard/object'
@@ -42,16 +42,11 @@ module Inch
42
42
  end
43
43
 
44
44
  def mentions_return?
45
- last_lines.any? do |line|
46
- line =~ /^#{tomdoc_modifiers}Returns\ /
47
- end
45
+ last_line =~ /^Returns\ /
48
46
  end
49
47
 
50
48
  def describes_return?
51
- last_lines.any? do |line|
52
- line =~ /^#{tomdoc_modifiers}Returns\ (\w+\s){2,}/i ||
53
- line =~ /^#{tomdoc_modifiers}Returns\ (nil|nothing)\.*/i
54
- end
49
+ last_line =~ /^Returns\ (\w+\s){2,}/
55
50
  end
56
51
 
57
52
  def to_s
@@ -64,28 +59,18 @@ module Inch
64
59
  @first_line ||= @text.lines.to_a.first
65
60
  end
66
61
 
67
- # Returns the last lines of the docstring.
68
- # @return [Array<String>] the last line and, if the last line(s) is
69
- # indented, the last unindented line
70
- def last_lines
71
- @last_lines ||= begin
72
- list = []
73
- @text.lines.to_a.reverse.each do |line|
74
- list << line
75
- break if line =~ /^\S/
76
- end
77
- list.reverse
78
- end
62
+ def last_line
63
+ @last_line ||= @text.lines.to_a.last
79
64
  end
80
65
 
81
66
  def parse_code_examples
82
67
  code_examples = []
83
68
  example = nil
84
- @text.lines.each do |line|
85
- if line =~ /^\s*+$/
69
+ @text.lines.each_with_index do |line, index|
70
+ if line =~/^\s*+$/
86
71
  code_examples << example if example
87
72
  example = []
88
- elsif line =~ /^\ {2,}\S+/
73
+ elsif line =~/^\ {2,}\S+/
89
74
  example << line if example
90
75
  else
91
76
  code_examples << example if example
@@ -96,34 +81,22 @@ module Inch
96
81
  code_examples.delete_if(&:empty?).map(&:join)
97
82
  end
98
83
 
99
- # Returns patterns in which method parameters are mentioned
100
- # in inline docs.
101
- #
102
- # @param name [String] the name of the method parameter
103
- # @return [Array<Regexp>]
104
84
  def mention_parameter_patterns(name)
105
- escaped_name = Regexp.escape(name)
106
- type = /<[^>]+>/
107
85
  [
108
- escaped_name,
109
- /#{escaped_name}#{type}/ # matches "param1<String,nil>"
110
- ].map do |expr|
111
- [
112
- /#{expr}\:\:/, # param1::
113
- /\+#{expr}\+/, # +param1+
114
- /\+#{expr}\+\:\:/, # +param1+::
115
- /<tt>#{expr}<\/tt>/, # <tt>param1</tt>
116
- /<tt>#{expr}<\/tt>\:\:/, # <tt>param1</tt>::
117
- /^#{expr}\ \-\ / # param1 -
118
- ]
119
- end.flatten
86
+ "+#{name}+",
87
+ "+#{name}+::",
88
+ "<tt>#{name}</tt>",
89
+ "<tt>#{name}</tt>::",
90
+ "#{name}::",
91
+ /^#{Regexp.escape(name)}\ \-\ /
92
+ ]
120
93
  end
121
94
 
122
95
  def describe_parameter_extra_regexps(name)
123
96
  [
124
97
  "#{name}::",
125
98
  "+#{name}+::",
126
- "<tt>#{name}</tt>::"
99
+ "<tt>#{name}</tt>::",
127
100
  ].map do |pattern|
128
101
  r = pattern.is_a?(Regexp) ? pattern : Regexp.escape(pattern)
129
102
  /#{r}\n\ {2,}.+/m
@@ -131,11 +104,10 @@ module Inch
131
104
  end
132
105
 
133
106
  def describe_parameter_regexps(name)
134
- same_line_regexps =
135
- mention_parameter_patterns(name).map do |pattern|
136
- r = pattern.is_a?(Regexp) ? pattern : Regexp.escape(pattern)
137
- /^#{r}\s?\S+/
138
- end
107
+ same_line_regexps = mention_parameter_patterns(name).map do |pattern|
108
+ r = pattern.is_a?(Regexp) ? pattern : Regexp.escape(pattern)
109
+ /^#{r}\s?\S+/
110
+ end
139
111
  same_line_regexps + describe_parameter_extra_regexps(name)
140
112
  end
141
113
 
@@ -149,10 +121,6 @@ module Inch
149
121
  end
150
122
  end
151
123
  end
152
-
153
- def tomdoc_modifiers
154
- /((Public|Private|Internal)\:\ )*/
155
- end
156
124
  end
157
125
  end
158
126
  end
@@ -3,6 +3,7 @@ module Inch
3
3
  module Provider
4
4
  module YARD
5
5
  module NodocHelper
6
+
6
7
  # Returns true if the code object is somehow marked not to be
7
8
  # documented.
8
9
  #
@@ -80,11 +81,10 @@ module Inch
80
81
  # @return [String]
81
82
  def get_line_no(filename, line_number)
82
83
  f = File.open(filename)
83
- line_number.times { f.gets }
84
- result = $_ # LAST_READ_LINE
84
+ line_number.times{f.gets}
85
+ result = $_
85
86
  f.close
86
- result.encode("UTF-8", "binary",
87
- invalid: :replace, undef: :replace, replace: "")
87
+ result.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
88
88
  end
89
89
  end
90
90
  end
@@ -16,11 +16,10 @@ module Inch
16
16
  # @return [Provider::YARD::Object]
17
17
  def for(yard_object)
18
18
  @cache ||= {}
19
- if (proxy_object = @cache[cache_key(yard_object)])
19
+ if proxy_object = @cache[cache_key(yard_object)]
20
20
  proxy_object
21
21
  else
22
- @cache[cache_key(yard_object)] =
23
- class_for(yard_object).new(yard_object)
22
+ @cache[cache_key(yard_object)] = class_for(yard_object).new(yard_object)
24
23
  end
25
24
  end
26
25
 
@@ -31,7 +30,7 @@ module Inch
31
30
  # @param yard_object [YARD::CodeObject]
32
31
  # @return [Class]
33
32
  def class_for(yard_object)
34
- class_name = yard_object.class.to_s.split("::").last
33
+ class_name = yard_object.class.to_s.split('::').last
35
34
  const_get(class_name)
36
35
  rescue NameError
37
36
  Base
@@ -51,11 +50,10 @@ module Inch
51
50
  end
52
51
  end
53
52
 
54
- require "inch/code_object/provider/yard/object/base"
55
- require "inch/code_object/provider/yard/object/namespace_object"
56
- require "inch/code_object/provider/yard/object/class_object"
57
- require "inch/code_object/provider/yard/object/class_variable_object"
58
- require "inch/code_object/provider/yard/object/constant_object"
59
- require "inch/code_object/provider/yard/object/method_object"
60
- require "inch/code_object/provider/yard/object/method_parameter_object"
61
- require "inch/code_object/provider/yard/object/module_object"
53
+ require 'inch/code_object/provider/yard/object/base'
54
+ require 'inch/code_object/provider/yard/object/namespace_object'
55
+ require 'inch/code_object/provider/yard/object/class_object'
56
+ require 'inch/code_object/provider/yard/object/constant_object'
57
+ require 'inch/code_object/provider/yard/object/method_object'
58
+ require 'inch/code_object/provider/yard/object/method_parameter_object'
59
+ require 'inch/code_object/provider/yard/object/module_object'
@@ -1,4 +1,4 @@
1
- require "forwardable"
1
+ require 'forwardable'
2
2
 
3
3
  module Inch
4
4
  module CodeObject
@@ -21,17 +21,14 @@ module Inch
21
21
  AUTO_GENERATED_TAG_NAMES = %w(raise yield)
22
22
 
23
23
  # convenient shortcuts to (YARD) code object
24
- def_delegators :object,
25
- :type, :namespace, :source, :source_type, :group,
26
- :dynamic, :visibility
24
+ def_delegators :object, :type, :namespace, :source, :source_type, :group, :dynamic, :visibility
27
25
 
28
- # @param object [YARD::CodeObjects::Base] the actual (YARD) code
29
- # object
26
+ # @param object [YARD::CodeObjects::Base] the actual (YARD) code object
30
27
  def initialize(object)
31
28
  @object = object
32
- @api_tag = __api_tag
33
- @parent = __parent
34
- @private_tag = __private_tag
29
+ @__api_tag = __api_tag
30
+ @__parent = __parent
31
+ @__private_tag = __private_tag
35
32
  end
36
33
 
37
34
  # Returns the fullname of the object that the current object
@@ -48,18 +45,18 @@ module Inch
48
45
  !api_tag.nil?
49
46
  end
50
47
 
51
- attr_reader :api_tag
48
+ def api_tag
49
+ @__api_tag
50
+ end
52
51
 
53
52
  # To be overridden
54
53
  # @see Proxy::NamespaceObject
55
- # @return [CodeObject::Proxy::Base,nil] the child inside the current
56
- # object or +nil+
57
- def child(_name)
54
+ # @return [CodeObject::Proxy::Base,nil] the child inside the current object or +nil+
55
+ def child(name)
58
56
  nil
59
57
  end
60
58
 
61
- # @return [Array,nil] the full names of the children of the current
62
- # object
59
+ # @return [Array,nil] the full names of the children of the current object
63
60
  def children_fullnames
64
61
  []
65
62
  end
@@ -70,29 +67,8 @@ module Inch
70
67
  []
71
68
  end
72
69
 
73
- RUBY_CORE = %w(
74
- Array Bignum BasicObject Object Module Class Complex NilClass
75
- Numeric String Float Fiber FiberError Continuation Dir File
76
- Encoding Enumerator StopIteration Enumerator::Generator
77
- Enumerator::Yielder Exception SystemExit SignalException Interrupt
78
- StandardError TypeError ArgumentError IndexError KeyError
79
- RangeError ScriptError SyntaxError LoadError NotImplementedError
80
- NameError NoMethodError RuntimeError SecurityError NoMemoryError
81
- EncodingError SystemCallError Encoding::CompatibilityError
82
- File::Stat IO Hash ENV IOError EOFError ARGF RubyVM
83
- RubyVM::InstructionSequence Math::DomainError ZeroDivisionError
84
- FloatDomainError Integer Fixnum Data TrueClass FalseClass Mutex
85
- Thread Proc LocalJumpError SystemStackError Method UnboundMethod
86
- Binding Process::Status Random Range Rational RegexpError Regexp
87
- MatchData Symbol Struct ThreadGroup ThreadError Time
88
- Encoding::UndefinedConversionError
89
- Encoding::InvalidByteSequenceError
90
- Encoding::ConverterNotFoundError Encoding::Converter RubyVM::Env
91
-
92
- Comparable Kernel File::Constants Enumerable Errno FileTest GC
93
- ObjectSpace GC::Profiler IO::WaitReadable IO::WaitWritable Marshal
94
- Math Process Process::UID Process::GID Process::Sys Signal
95
- )
70
+ RUBY_CORE = %w(Array Bignum BasicObject Object Module Class Complex NilClass Numeric String Float Fiber FiberError Continuation Dir File Encoding Enumerator StopIteration Enumerator::Generator Enumerator::Yielder Exception SystemExit SignalException Interrupt StandardError TypeError ArgumentError IndexError KeyError RangeError ScriptError SyntaxError LoadError NotImplementedError NameError NoMethodError RuntimeError SecurityError NoMemoryError EncodingError SystemCallError Encoding::CompatibilityError File::Stat IO Hash ENV IOError EOFError ARGF RubyVM RubyVM::InstructionSequence Math::DomainError ZeroDivisionError FloatDomainError Integer Fixnum Data TrueClass FalseClass Mutex Thread Proc LocalJumpError SystemStackError Method UnboundMethod Binding Process::Status Random Range Rational RegexpError Regexp MatchData Symbol Struct ThreadGroup ThreadError Time Encoding::UndefinedConversionError Encoding::InvalidByteSequenceError Encoding::ConverterNotFoundError Encoding::Converter RubyVM::Env) +
71
+ %w(Comparable Kernel File::Constants Enumerable Errno FileTest GC ObjectSpace GC::Profiler IO::WaitReadable IO::WaitWritable Marshal Math Process Process::UID Process::GID Process::Sys Signal)
96
72
  def core?
97
73
  RUBY_CORE.include?(name.to_s)
98
74
  end
@@ -116,8 +92,7 @@ module Inch
116
92
  []
117
93
  end
118
94
 
119
- # CodeLocation is a utility class to find declarations of objects in
120
- # files
95
+ # CodeLocation is a utility class to find declarations of objects in files
121
96
  class CodeLocation < Struct.new(:base_dir, :relative_path, :line_no)
122
97
  def filename
123
98
  File.join(base_dir, relative_path)
@@ -157,9 +132,9 @@ module Inch
157
132
  if tags(:example).size > 1 || docstring.code_examples.size > 1
158
133
  true
159
134
  else
160
- if (tag = tag(:example))
135
+ if tag = tag(:example)
161
136
  multi_code_examples?(tag.text)
162
- elsif (text = docstring.code_examples.first)
137
+ elsif text = docstring.code_examples.first
163
138
  multi_code_examples?(text)
164
139
  else
165
140
  false
@@ -211,7 +186,9 @@ module Inch
211
186
  end
212
187
 
213
188
  # @return [Array,nil] the parent of the current object or +nil+
214
- attr_reader :parent
189
+ def parent
190
+ @__parent
191
+ end
215
192
 
216
193
  def __parent
217
194
  YARD::Object.for(object.parent) if object.parent
@@ -251,7 +228,7 @@ module Inch
251
228
  end
252
229
 
253
230
  def inspect
254
- "#<#{self.class}: #{fullname}>"
231
+ "#<#{self.class.to_s}: #{fullname}>"
255
232
  end
256
233
 
257
234
  protected
@@ -266,10 +243,12 @@ module Inch
266
243
  !private_tag.nil?
267
244
  end
268
245
 
269
- attr_reader :private_tag
246
+ def private_tag
247
+ @__private_tag
248
+ end
270
249
 
271
250
  def private_api_tag?
272
- api_tag && api_tag.text == "private"
251
+ api_tag && api_tag.text == 'private'
273
252
  end
274
253
 
275
254
  def tag(name)
@@ -290,12 +269,12 @@ module Inch
290
269
  @unconsidered_tags ||= tags.reject do |tag|
291
270
  auto_generated_tag?(tag) ||
292
271
  CONSIDERED_YARD_TAGS.include?(tag.tag_name)
293
- end
272
+ end
294
273
  end
295
274
 
296
275
  def __depth(i = 0)
297
276
  if parent
298
- parent.__depth(i + 1)
277
+ parent.__depth(i+1)
299
278
  else
300
279
  i
301
280
  end