inch 0.4.6 → 0.4.7
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/.rubocop.yml +15 -0
- data/.rubocop_todo.yml +113 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +5 -2
- data/README.md +2 -2
- data/Rakefile +2 -2
- data/bin/inch +3 -2
- data/config/defaults.rb +7 -0
- data/inch.gemspec +7 -7
- data/lib/inch.rb +9 -10
- data/lib/inch/api.rb +10 -10
- data/lib/inch/api/compare.rb +2 -2
- data/lib/inch/api/compare/code_objects.rb +2 -3
- data/lib/inch/api/compare/codebases.rb +1 -1
- data/lib/inch/api/diff.rb +6 -9
- data/lib/inch/api/options/base.rb +4 -4
- data/lib/inch/api/options/suggest.rb +1 -1
- data/lib/inch/api/stats.rb +0 -1
- data/lib/inch/api/suggest.rb +8 -9
- data/lib/inch/cli.rb +6 -6
- data/lib/inch/cli/command.rb +15 -15
- data/lib/inch/cli/command/base.rb +2 -2
- data/lib/inch/cli/command/console.rb +5 -5
- data/lib/inch/cli/command/diff.rb +7 -8
- data/lib/inch/cli/command/inspect.rb +5 -4
- data/lib/inch/cli/command/list.rb +4 -4
- data/lib/inch/cli/command/options/base.rb +8 -8
- data/lib/inch/cli/command/options/base_list.rb +9 -5
- data/lib/inch/cli/command/options/console.rb +4 -3
- data/lib/inch/cli/command/options/diff.rb +6 -4
- data/lib/inch/cli/command/options/inspect.rb +2 -2
- data/lib/inch/cli/command/options/list.rb +4 -3
- data/lib/inch/cli/command/options/show.rb +2 -2
- data/lib/inch/cli/command/options/stats.rb +2 -1
- data/lib/inch/cli/command/options/suggest.rb +6 -3
- data/lib/inch/cli/command/output/base.rb +2 -4
- data/lib/inch/cli/command/output/console.rb +4 -5
- data/lib/inch/cli/command/output/diff.rb +6 -6
- data/lib/inch/cli/command/output/inspect.rb +6 -8
- data/lib/inch/cli/command/output/list.rb +0 -1
- data/lib/inch/cli/command/output/show.rb +4 -5
- data/lib/inch/cli/command/output/stats.rb +21 -21
- data/lib/inch/cli/command/output/suggest.rb +28 -26
- data/lib/inch/cli/command/show.rb +4 -4
- data/lib/inch/cli/command/stats.rb +4 -4
- data/lib/inch/cli/command/suggest.rb +6 -6
- data/lib/inch/cli/command_parser.rb +6 -5
- data/lib/inch/cli/sparkline_helper.rb +2 -2
- data/lib/inch/cli/trace_helper.rb +1 -1
- data/lib/inch/cli/yardopts_helper.rb +4 -3
- data/lib/inch/code_object.rb +3 -3
- data/lib/inch/code_object/converter.rb +6 -8
- data/lib/inch/code_object/provider.rb +1 -1
- data/lib/inch/code_object/provider/yard.rb +10 -12
- data/lib/inch/code_object/provider/yard/docstring.rb +53 -21
- data/lib/inch/code_object/provider/yard/nodoc_helper.rb +3 -3
- data/lib/inch/code_object/provider/yard/object.rb +11 -9
- data/lib/inch/code_object/provider/yard/object/base.rb +33 -9
- data/lib/inch/code_object/provider/yard/object/class_variable_object.rb +12 -0
- data/lib/inch/code_object/provider/yard/object/method_object.rb +36 -11
- data/lib/inch/code_object/provider/yard/object/method_parameter_object.rb +2 -2
- data/lib/inch/code_object/provider/yard/object/method_signature.rb +11 -8
- data/lib/inch/code_object/provider/yard/object/namespace_object.rb +1 -4
- data/lib/inch/code_object/provider/yard/parser.rb +2 -2
- data/lib/inch/code_object/proxy.rb +10 -9
- data/lib/inch/code_object/proxy/base.rb +8 -8
- data/lib/inch/code_object/proxy/class_variable_object.rb +8 -0
- data/lib/inch/code_object/proxy/method_object.rb +3 -2
- data/lib/inch/code_object/proxy/method_parameter_object.rb +1 -1
- data/lib/inch/codebase.rb +4 -5
- data/lib/inch/codebase/objects_filter.rb +2 -4
- data/lib/inch/codebase/serializer.rb +3 -3
- data/lib/inch/config.rb +2 -2
- data/lib/inch/config/base.rb +0 -1
- data/lib/inch/config/codebase.rb +3 -3
- data/lib/inch/core_ext.rb +1 -1
- data/lib/inch/core_ext/string.rb +1 -1
- data/lib/inch/evaluation.rb +16 -15
- data/lib/inch/evaluation/grade_list.rb +2 -2
- data/lib/inch/evaluation/object_schema.rb +1 -1
- data/lib/inch/evaluation/proxy.rb +8 -7
- data/lib/inch/evaluation/proxy/base.rb +12 -7
- data/lib/inch/evaluation/proxy/class_variable_object.rb +19 -0
- data/lib/inch/evaluation/proxy/constant_object.rb +1 -1
- data/lib/inch/evaluation/proxy/method_object.rb +12 -5
- data/lib/inch/evaluation/proxy/module_object.rb +1 -1
- data/lib/inch/evaluation/proxy/namespace_object.rb +1 -1
- data/lib/inch/evaluation/role/base.rb +1 -1
- data/lib/inch/evaluation/role/class_variable.rb +55 -0
- data/lib/inch/evaluation/role/method.rb +0 -1
- data/lib/inch/evaluation/role/method_parameter.rb +2 -1
- data/lib/inch/evaluation/role/object.rb +2 -2
- data/lib/inch/rake.rb +2 -2
- data/lib/inch/rake/suggest.rb +2 -2
- data/lib/inch/utils/shell_helper.rb +1 -1
- data/lib/inch/utils/ui.rb +5 -5
- data/lib/inch/utils/weighted_list.rb +2 -3
- data/lib/inch/version.rb +1 -1
- data/test/fixtures/simple/lib/broken.rb +35 -7
- data/test/fixtures/simple/lib/broken_ruby_2_0_features.rb +7 -0
- data/test/fixtures/simple/lib/directives.rb +8 -0
- data/test/fixtures/simple/lib/foo.rb +17 -0
- data/test/integration/api/compare/codebases.rb +1 -1
- data/test/integration/cli/command/console_test.rb +5 -5
- data/test/integration/cli/command/inspect_test.rb +4 -5
- data/test/integration/cli/command/list_test.rb +3 -4
- data/test/integration/cli/command/show_test.rb +4 -4
- data/test/integration/cli/command/stats_test.rb +2 -2
- data/test/integration/cli/command/suggest_test.rb +7 -7
- data/test/integration/stats_options_test.rb +3 -3
- data/test/integration/visibility_options_test.rb +13 -13
- data/test/shared/base_list.rb +4 -3
- data/test/test_helper.rb +16 -5
- data/test/unit/api/filter_test.rb +7 -7
- data/test/unit/api/get_test.rb +1 -1
- data/test/unit/api/list_test.rb +1 -1
- data/test/unit/api/options/base_test.rb +3 -3
- data/test/unit/api/stats_test.rb +1 -1
- data/test/unit/api/suggest_test.rb +3 -3
- data/test/unit/cli/arguments_test.rb +1 -1
- data/test/unit/cli/command/base_test.rb +1 -1
- data/test/unit/cli/command/options/base_list_test.rb +2 -2
- data/test/unit/cli/command/options/base_object_test.rb +1 -1
- data/test/unit/cli/command/options/base_test.rb +1 -1
- data/test/unit/cli/command_parser_test.rb +2 -2
- data/test/unit/cli/trace_helper_test.rb +1 -1
- data/test/unit/cli/yardopts_helper_test.rb +4 -3
- data/test/unit/code_object/converter_test.rb +1 -1
- data/test/unit/code_object/provider/yard/docstring_test.rb +105 -28
- data/test/unit/code_object/provider/yard/nodoc_helper_test.rb +5 -5
- data/test/unit/code_object/provider/yard/object/method_object_test.rb +20 -10
- data/test/unit/code_object/provider/yard_test.rb +4 -4
- data/test/unit/code_object/provider_test.rb +1 -1
- data/test/unit/code_object/proxy/method_object_test.rb +366 -262
- data/test/unit/code_object/proxy_test.rb +1 -1
- data/test/unit/codebase/objects_test.rb +2 -2
- data/test/unit/codebase/proxy_test.rb +1 -1
- data/test/unit/config/codebase_test.rb +1 -1
- data/test/unit/evaluation/role/base_test.rb +1 -1
- data/test/unit/utils/ui_test.rb +4 -4
- data/test/unit/utils/weighted_list_test.rb +7 -4
- metadata +12 -2
@@ -67,7 +67,7 @@ module Inch
|
|
67
67
|
if @method.docstring.describes_parameter?(name)
|
68
68
|
true
|
69
69
|
else
|
70
|
-
unsplatted = name.gsub(/^[\&\*]/,
|
70
|
+
unsplatted = name.gsub(/^[\&\*]/, "")
|
71
71
|
@method.docstring.describes_parameter?(unsplatted)
|
72
72
|
end
|
73
73
|
end
|
@@ -76,7 +76,7 @@ module Inch
|
|
76
76
|
if @method.docstring.mentions_parameter?(name)
|
77
77
|
true
|
78
78
|
else
|
79
|
-
unsplatted = name.gsub(/^[\&\*]/,
|
79
|
+
unsplatted = name.gsub(/^[\&\*]/, "")
|
80
80
|
@method.docstring.mentions_parameter?(unsplatted)
|
81
81
|
end
|
82
82
|
end
|
@@ -8,11 +8,12 @@ module Inch
|
|
8
8
|
attr_reader :method, :docstring
|
9
9
|
|
10
10
|
# @param method [Provider::YARD::Object::MethodObject]
|
11
|
-
# @param
|
11
|
+
# @param yard_tag [::YARD::Tags::Tag,nil] if nil, the method's normal signature is used
|
12
12
|
def initialize(method, yard_tag = nil)
|
13
13
|
@method = method
|
14
14
|
@yard_tag = yard_tag
|
15
|
-
@docstring =
|
15
|
+
@docstring =
|
16
|
+
Provider::YARD::Docstring.new(relevant_object.docstring)
|
16
17
|
end
|
17
18
|
|
18
19
|
def all_signature_parameter_names
|
@@ -43,26 +44,28 @@ module Inch
|
|
43
44
|
# @param name [String,Symbol]
|
44
45
|
# @return [MethodParameterObject]
|
45
46
|
def parameter(name)
|
46
|
-
parameters.
|
47
|
+
parameters.find { |p| p.name == name.to_s }
|
47
48
|
end
|
48
49
|
|
49
50
|
# Returns +true+ if the other signature is identical to self
|
50
51
|
# @param other [MethodSignature]
|
51
52
|
# @return [Boolean]
|
52
53
|
def same?(other)
|
53
|
-
all_signature_parameter_names ==
|
54
|
+
all_signature_parameter_names ==
|
55
|
+
other.all_signature_parameter_names
|
54
56
|
end
|
55
57
|
|
56
58
|
# Returns the actual signature of the method.
|
57
59
|
# @return [String]
|
58
60
|
def signature
|
59
|
-
relevant_object.signature.gsub(/^(def\ )/,
|
61
|
+
relevant_object.signature.gsub(/^(def\ )/, "")
|
60
62
|
end
|
61
63
|
|
62
64
|
private
|
63
65
|
|
64
66
|
def all_parameter_names
|
65
|
-
all_names = all_signature_parameter_names +
|
67
|
+
all_names = all_signature_parameter_names +
|
68
|
+
parameter_tags.map(&:name)
|
66
69
|
all_names.map do |name|
|
67
70
|
normalize_parameter_name(name) if name
|
68
71
|
end.compact.uniq
|
@@ -90,11 +93,11 @@ module Inch
|
|
90
93
|
# @param name [String] parameter name
|
91
94
|
# @return [String]
|
92
95
|
def normalize_parameter_name(name)
|
93
|
-
name.gsub(/[\&\*\$\[\]]/,
|
96
|
+
name.gsub(/[\&\*\$\[\]]/, "")
|
94
97
|
end
|
95
98
|
|
96
99
|
def parameter_tag(param_name)
|
97
|
-
parameter_tags.
|
100
|
+
parameter_tags.find do |tag|
|
98
101
|
tag.name == param_name
|
99
102
|
end
|
100
103
|
end
|
@@ -28,9 +28,7 @@ module Inch
|
|
28
28
|
|
29
29
|
# called by MethodObject#getter?
|
30
30
|
def child(name)
|
31
|
-
if children
|
32
|
-
children.detect { |child| child.name == name }
|
33
|
-
end
|
31
|
+
children.find { |child| child.name == name } if children
|
34
32
|
end
|
35
33
|
|
36
34
|
def children
|
@@ -38,7 +36,6 @@ module Inch
|
|
38
36
|
YARD::Object.for(o)
|
39
37
|
end
|
40
38
|
end
|
41
|
-
|
42
39
|
end
|
43
40
|
end
|
44
41
|
end
|
@@ -11,7 +11,7 @@ module Inch
|
|
11
11
|
# @see #parse
|
12
12
|
# @return [CodeObject::Provider::YARD::Parser] the instance that ran
|
13
13
|
def self.parse(*args)
|
14
|
-
parser =
|
14
|
+
parser = new
|
15
15
|
parser.parse(*args)
|
16
16
|
parser
|
17
17
|
end
|
@@ -46,7 +46,7 @@ module Inch
|
|
46
46
|
object.base_dir = dir
|
47
47
|
|
48
48
|
object.aliases_fullnames.each do |fullname|
|
49
|
-
_alias = objects.
|
49
|
+
_alias = objects.find { |o| o.fullname == fullname }
|
50
50
|
_alias.aliased_object_fullname = object.fullname
|
51
51
|
end
|
52
52
|
end
|
@@ -11,7 +11,7 @@ module Inch
|
|
11
11
|
# @return [CodeObject::Proxy::Base]
|
12
12
|
def for(code_object)
|
13
13
|
attributes = Converter.to_hash(code_object)
|
14
|
-
|
14
|
+
class_for(code_object).new(attributes)
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
@@ -21,7 +21,7 @@ module Inch
|
|
21
21
|
# @param code_object [YARD::CodeObject]
|
22
22
|
# @return [Class]
|
23
23
|
def class_for(code_object)
|
24
|
-
class_name = code_object.class.to_s.split(
|
24
|
+
class_name = code_object.class.to_s.split("::").last
|
25
25
|
const_get(class_name)
|
26
26
|
end
|
27
27
|
end
|
@@ -29,10 +29,11 @@ module Inch
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
require
|
33
|
-
require
|
34
|
-
require
|
35
|
-
require
|
36
|
-
require
|
37
|
-
require
|
38
|
-
require
|
32
|
+
require "inch/code_object/proxy/base"
|
33
|
+
require "inch/code_object/proxy/namespace_object"
|
34
|
+
require "inch/code_object/proxy/class_object"
|
35
|
+
require "inch/code_object/proxy/class_variable_object"
|
36
|
+
require "inch/code_object/proxy/constant_object"
|
37
|
+
require "inch/code_object/proxy/method_object"
|
38
|
+
require "inch/code_object/proxy/method_parameter_object"
|
39
|
+
require "inch/code_object/proxy/module_object"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "forwardable"
|
2
2
|
|
3
3
|
module Inch
|
4
4
|
module CodeObject
|
@@ -42,9 +42,9 @@ module Inch
|
|
42
42
|
|
43
43
|
# @return [Symbol]
|
44
44
|
def grade
|
45
|
-
@grade ||= Evaluation.new_grade_lists.
|
46
|
-
|
47
|
-
|
45
|
+
@grade ||= Evaluation.new_grade_lists.find do |range|
|
46
|
+
range.scores.include?(score)
|
47
|
+
end.grade
|
48
48
|
end
|
49
49
|
|
50
50
|
# @return [Boolean] if the current object is an alias for something else
|
@@ -54,7 +54,7 @@ module Inch
|
|
54
54
|
|
55
55
|
# @return [CodeObject::Proxy::Base] the object the current object is an alias of
|
56
56
|
def aliased_object
|
57
|
-
object_lookup.find(
|
57
|
+
object_lookup.find(self[:aliased_object_fullname])
|
58
58
|
end
|
59
59
|
|
60
60
|
# @return [Boolean] +true+ if the object has an @api tag
|
@@ -172,7 +172,7 @@ module Inch
|
|
172
172
|
|
173
173
|
# @return [CodeObject::Proxy::Base,nil] the parent of the current object or +nil+
|
174
174
|
def parent
|
175
|
-
object_lookup.find(
|
175
|
+
object_lookup.find(self[:parent_fullname])
|
176
176
|
end
|
177
177
|
|
178
178
|
def private?
|
@@ -205,7 +205,7 @@ module Inch
|
|
205
205
|
end
|
206
206
|
|
207
207
|
def type
|
208
|
-
self.class.to_s.gsub(/Object$/,
|
208
|
+
self.class.to_s.gsub(/Object$/, "")
|
209
209
|
end
|
210
210
|
|
211
211
|
# @return [Boolean] +true+ if the object has no documentation at all
|
@@ -233,7 +233,7 @@ module Inch
|
|
233
233
|
end
|
234
234
|
|
235
235
|
def inspect
|
236
|
-
"#<#{self.class
|
236
|
+
"#<#{self.class}: #{fullname}>"
|
237
237
|
end
|
238
238
|
end
|
239
239
|
end
|
@@ -36,7 +36,7 @@ module Inch
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def parameter(name)
|
39
|
-
parameters.
|
39
|
+
parameters.find { |p| p.name == name.to_s }
|
40
40
|
end
|
41
41
|
|
42
42
|
def parameters
|
@@ -50,7 +50,8 @@ module Inch
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def overridden_method
|
53
|
-
@overridden_method ||=
|
53
|
+
@overridden_method ||=
|
54
|
+
object_lookup.find(self[:overridden_method_fullname])
|
54
55
|
end
|
55
56
|
|
56
57
|
def return_mentioned?
|
data/lib/inch/codebase.rb
CHANGED
@@ -15,8 +15,7 @@ module Inch
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
|
18
|
+
require "inch/codebase/proxy"
|
19
|
+
require "inch/codebase/objects"
|
20
|
+
require "inch/codebase/objects_filter"
|
21
|
+
require "inch/codebase/serializer"
|
@@ -41,16 +41,14 @@ module Inch
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def filter_depth
|
44
|
-
if options.depth
|
45
|
-
@list = @list.select { |o| o.depth <= options.depth }
|
46
|
-
end
|
44
|
+
@list = @list.select { |o| o.depth <= options.depth } if options.depth
|
47
45
|
end
|
48
46
|
|
49
47
|
def filter_visibility
|
50
48
|
@list = @list.select do |o|
|
51
49
|
options.visibility.include?(o.visibility)
|
52
50
|
end
|
53
|
-
|
51
|
+
unless options.visibility.include?(:private)
|
54
52
|
@list = @list.reject do |o|
|
55
53
|
o.tagged_as_private?
|
56
54
|
end
|
@@ -9,12 +9,12 @@ module Inch
|
|
9
9
|
|
10
10
|
def self.save(codebase, filename)
|
11
11
|
content = Marshal.dump(codebase)
|
12
|
-
FileUtils.mkdir_p(
|
13
|
-
File.open(filename,
|
12
|
+
FileUtils.mkdir_p(File.dirname(filename))
|
13
|
+
File.open(filename, "wb") { |file| file.write(content) }
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.load(filename)
|
17
|
-
codebase = Marshal.load(
|
17
|
+
codebase = Marshal.load(File.binread(filename))
|
18
18
|
codebase.objects.each do |object|
|
19
19
|
object.object_lookup = codebase.objects
|
20
20
|
end
|
data/lib/inch/config.rb
CHANGED
data/lib/inch/config/base.rb
CHANGED
data/lib/inch/config/codebase.rb
CHANGED
@@ -57,9 +57,9 @@ module Inch
|
|
57
57
|
|
58
58
|
def update_files(files)
|
59
59
|
return if files.nil?
|
60
|
-
|
61
|
-
|
60
|
+
@included_files = expand_files(files["included"]) if files["included"]
|
61
|
+
@excluded_files = expand_files(files["excluded"]) if files["excluded"]
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
65
|
-
end
|
65
|
+
end
|
data/lib/inch/core_ext.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require "inch/core_ext/string"
|
data/lib/inch/core_ext/string.rb
CHANGED
data/lib/inch/evaluation.rb
CHANGED
@@ -9,26 +9,27 @@ module Inch
|
|
9
9
|
private
|
10
10
|
|
11
11
|
def self.class_for(code_object)
|
12
|
-
class_name = code_object.class.to_s.split(
|
12
|
+
class_name = code_object.class.to_s.split("::").last
|
13
13
|
const_get(class_name)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
require
|
18
|
+
require "inch/utils/read_write_methods"
|
19
19
|
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
20
|
+
require "inch/evaluation/file"
|
21
|
+
require "inch/evaluation/grade"
|
22
|
+
require "inch/evaluation/grade_list"
|
23
|
+
require "inch/evaluation/object_schema"
|
24
|
+
require "inch/evaluation/priority_range"
|
25
25
|
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
29
|
-
require
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
26
|
+
require "inch/evaluation/role/base"
|
27
|
+
require "inch/evaluation/role/missing"
|
28
|
+
require "inch/evaluation/role/object"
|
29
|
+
require "inch/evaluation/role/method"
|
30
|
+
require "inch/evaluation/role/method_parameter"
|
31
|
+
require "inch/evaluation/role/namespace"
|
32
|
+
require "inch/evaluation/role/constant"
|
33
|
+
require "inch/evaluation/role/class_variable"
|
33
34
|
|
34
|
-
require
|
35
|
+
require "inch/evaluation/proxy"
|
@@ -6,8 +6,8 @@ module Inch
|
|
6
6
|
class GradeList < Struct.new(:grade)
|
7
7
|
extend Forwardable
|
8
8
|
|
9
|
-
def_delegators :grade,
|
10
|
-
|
9
|
+
def_delegators :grade,
|
10
|
+
:scores, :label, :color, :bg_color, :to_s, :to_sym
|
11
11
|
|
12
12
|
# Returns code_objects that received a score with the defined +scores+
|
13
13
|
attr_reader :objects
|
@@ -10,16 +10,17 @@ module Inch
|
|
10
10
|
private
|
11
11
|
|
12
12
|
def self.class_for(code_object)
|
13
|
-
class_name = code_object.class.to_s.split(
|
13
|
+
class_name = code_object.class.to_s.split("::").last
|
14
14
|
const_get(class_name)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
20
|
+
require "inch/evaluation/proxy/base"
|
21
|
+
require "inch/evaluation/proxy/namespace_object"
|
22
|
+
require "inch/evaluation/proxy/class_object"
|
23
|
+
require "inch/evaluation/proxy/class_variable_object"
|
24
|
+
require "inch/evaluation/proxy/constant_object"
|
25
|
+
require "inch/evaluation/proxy/method_object"
|
26
|
+
require "inch/evaluation/proxy/module_object"
|
@@ -95,13 +95,19 @@ module Inch
|
|
95
95
|
Role::Object::WithDoc => score_for(:docstring),
|
96
96
|
Role::Object::WithoutDoc => score_for(:docstring),
|
97
97
|
Role::Object::WithCodeExample => score_for(:code_example_single),
|
98
|
-
Role::Object::WithMultipleCodeExamples =>
|
98
|
+
Role::Object::WithMultipleCodeExamples =>
|
99
|
+
score_for(:code_example_multi),
|
99
100
|
Role::Object::WithoutCodeExample => score_for(:code_example_single),
|
100
101
|
Role::Object::Tagged => score_for_unconsidered_tags,
|
101
102
|
Role::Object::TaggedAsAPI => nil,
|
102
103
|
Role::Object::TaggedAsInternalAPI => nil,
|
103
104
|
Role::Object::TaggedAsPrivate => nil,
|
104
|
-
Role::Object::Alias =>
|
105
|
+
Role::Object::Alias =>
|
106
|
+
if object.alias?
|
107
|
+
object.aliased_object.score
|
108
|
+
else
|
109
|
+
nil
|
110
|
+
end
|
105
111
|
}
|
106
112
|
end
|
107
113
|
|
@@ -124,9 +130,8 @@ module Inch
|
|
124
130
|
|
125
131
|
def __evaluate(object, role_classes)
|
126
132
|
role_classes.each do |role_class, score|
|
127
|
-
|
128
|
-
|
129
|
-
end
|
133
|
+
next unless role_class.applicable?(object)
|
134
|
+
add_role role_class.new(object, score)
|
130
135
|
end
|
131
136
|
end
|
132
137
|
|
@@ -144,7 +149,7 @@ module Inch
|
|
144
149
|
|
145
150
|
# @return [Float]
|
146
151
|
def __score
|
147
|
-
value = @roles.
|
152
|
+
value = @roles.reduce(0) { |sum, r| sum + r.score.to_f }.to_i
|
148
153
|
if value < min_score
|
149
154
|
min_score
|
150
155
|
elsif value > max_score
|
@@ -156,7 +161,7 @@ module Inch
|
|
156
161
|
|
157
162
|
# @return [Fixnum]
|
158
163
|
def __priority
|
159
|
-
@roles.
|
164
|
+
@roles.reduce(0) { |sum, r| sum + r.priority.to_i }
|
160
165
|
end
|
161
166
|
end
|
162
167
|
end
|