inch 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -27,7 +27,7 @@ module Inch
|
|
27
27
|
private
|
28
28
|
|
29
29
|
def show(added, improved, degraded)
|
30
|
-
|
30
|
+
unless added.empty? && improved.empty?
|
31
31
|
ui.trace
|
32
32
|
ui.header("Added or improved:", :green)
|
33
33
|
added.each do |compare|
|
@@ -38,7 +38,7 @@ module Inch
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
|
41
|
+
unless degraded.empty?
|
42
42
|
ui.trace
|
43
43
|
ui.header("Degraded:", :red)
|
44
44
|
degraded.each do |compare|
|
@@ -54,7 +54,6 @@ module Inch
|
|
54
54
|
|
55
55
|
def puts_added(o)
|
56
56
|
grade = colored_grade(o)
|
57
|
-
priority = o.priority
|
58
57
|
change = " + ".dark + grade + " " + priority_arrow(o.priority)
|
59
58
|
ui.sub(" #{change} #{o.fullname}")
|
60
59
|
end
|
@@ -62,10 +61,11 @@ module Inch
|
|
62
61
|
def puts_improved(before, o)
|
63
62
|
before_grade = colored_grade(before)
|
64
63
|
grade = colored_grade(o)
|
65
|
-
change = before_grade + " -> ".dark + grade + " " +
|
64
|
+
change = before_grade + " -> ".dark + grade + " " +
|
65
|
+
priority_arrow(o.priority)
|
66
66
|
ui.sub(" #{change} #{o.fullname}")
|
67
67
|
end
|
68
|
-
|
68
|
+
alias_method :puts_degraded, :puts_improved
|
69
69
|
|
70
70
|
def colored_grade(o)
|
71
71
|
r = grade_list(o.grade.to_sym)
|
@@ -74,7 +74,7 @@ module Inch
|
|
74
74
|
|
75
75
|
def grade_list(grade_symbol)
|
76
76
|
@grade_lists ||= Evaluation.new_grade_lists
|
77
|
-
@grade_lists.
|
77
|
+
@grade_lists.find { |r| r.grade.to_sym == grade_symbol }
|
78
78
|
end
|
79
79
|
|
80
80
|
def rev_hint
|
@@ -48,7 +48,7 @@ module Inch
|
|
48
48
|
def print_code_info(o)
|
49
49
|
if o.method?
|
50
50
|
CommentAndAbbrevSource.new(o).lines.each do |line|
|
51
|
-
echo line.gsub(/\n$/m,
|
51
|
+
echo line.gsub(/\n$/m, "").color(COMMENT_COLOR)
|
52
52
|
end
|
53
53
|
echo separator
|
54
54
|
end
|
@@ -66,13 +66,11 @@ module Inch
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def print_role_info(role)
|
69
|
-
name = role.class.to_s.split(
|
69
|
+
name = role.class.to_s.split("::Role::").last
|
70
70
|
score = colored_role_score(role)
|
71
71
|
|
72
72
|
priority = role.priority.to_s.rjust(4)
|
73
|
-
if role.priority == 0
|
74
|
-
priority = priority.dark
|
75
|
-
end
|
73
|
+
priority = priority.dark if role.priority == 0
|
76
74
|
|
77
75
|
echo name.ljust(40) + score + priority
|
78
76
|
print_min_max_score(role)
|
@@ -133,7 +131,7 @@ module Inch
|
|
133
131
|
end
|
134
132
|
|
135
133
|
def to_s
|
136
|
-
comments.join(
|
134
|
+
comments.join("") + abbrev_source
|
137
135
|
end
|
138
136
|
|
139
137
|
private
|
@@ -141,12 +139,12 @@ module Inch
|
|
141
139
|
def abbrev_source
|
142
140
|
lines = code_object.source.to_s.lines.to_a
|
143
141
|
if lines.size >= 5
|
144
|
-
indent = lines[1].scan(/^(\s+)/).flatten.join(
|
142
|
+
indent = lines[1].scan(/^(\s+)/).flatten.join("")
|
145
143
|
lines = lines[0..1] +
|
146
144
|
["#{indent}# ... snip ...\n"] +
|
147
145
|
lines[-2..-1]
|
148
146
|
end
|
149
|
-
lines.join(
|
147
|
+
lines.join("")
|
150
148
|
end
|
151
149
|
|
152
150
|
def comments
|
@@ -42,10 +42,9 @@ module Inch
|
|
42
42
|
if o.roles.empty?
|
43
43
|
echo "No roles assigned.".dark
|
44
44
|
else
|
45
|
-
o.roles.
|
46
|
-
|
47
|
-
|
48
|
-
end
|
45
|
+
o.roles.each do |role|
|
46
|
+
next unless role.suggestion
|
47
|
+
echo "+".color(COLOR) + " #{role.suggestion}"
|
49
48
|
end
|
50
49
|
end
|
51
50
|
echo separator
|
@@ -61,7 +60,7 @@ module Inch
|
|
61
60
|
|
62
61
|
def grade(score)
|
63
62
|
grade_lists ||= Evaluation.new_grade_lists
|
64
|
-
r = grade_lists.
|
63
|
+
r = grade_lists.find { |v| v.scores.include?(score) }
|
65
64
|
"#{r.grade} - #{r.label}".color(r.color)
|
66
65
|
end
|
67
66
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "json"
|
2
|
+
require "yaml"
|
3
3
|
|
4
4
|
module Inch
|
5
5
|
module CLI
|
@@ -11,10 +11,10 @@ module Inch
|
|
11
11
|
attr_reader :objects
|
12
12
|
|
13
13
|
PRIORITY_COLORS = [
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
[213, 212, 211, 210, 210, 209, 209],
|
15
|
+
[177],
|
16
|
+
[203, 203, 204, 204, 205, 206, 207]
|
17
|
+
].flatten.map { |s| :"color#{s}" }
|
18
18
|
|
19
19
|
def initialize(options, objects, grade_lists)
|
20
20
|
@options = options
|
@@ -31,25 +31,26 @@ module Inch
|
|
31
31
|
print_grades_by_priority
|
32
32
|
print_priorities
|
33
33
|
puts
|
34
|
-
puts
|
34
|
+
puts "Try `--format json|yaml` for raw numbers.".dark
|
35
35
|
end
|
36
36
|
|
37
37
|
def print_grades
|
38
|
-
sparkline = grade_lists_sparkline(@grade_lists).to_s(
|
38
|
+
sparkline = grade_lists_sparkline(@grade_lists).to_s(" ")
|
39
39
|
puts
|
40
|
-
puts
|
40
|
+
puts "Grade distribution: (undocumented, C, B, A)"
|
41
41
|
puts
|
42
|
-
puts " Overall: #{sparkline} #{objects.size.to_s.rjust(5)}
|
42
|
+
puts " Overall: #{sparkline} #{objects.size.to_s.rjust(5)} " \
|
43
|
+
"objects"
|
43
44
|
puts
|
44
45
|
end
|
45
46
|
|
46
47
|
def print_grades_by_priority
|
47
|
-
puts
|
48
|
+
puts "Grade distribution by priority:"
|
48
49
|
puts
|
49
50
|
Evaluation::PriorityRange.all.each do |priority_range|
|
50
51
|
list = objects.select { |o| priority_range.include?(o.priority) }
|
51
|
-
sparkline = grades_sparkline(list).to_s(
|
52
|
-
puts " #{priority_range.arrow} #{sparkline} "
|
52
|
+
sparkline = grades_sparkline(list).to_s(" ")
|
53
|
+
puts " #{priority_range.arrow} #{sparkline} " \
|
53
54
|
"#{list.size.to_s.rjust(5)} objects"
|
54
55
|
puts
|
55
56
|
end
|
@@ -64,10 +65,10 @@ module Inch
|
|
64
65
|
end
|
65
66
|
|
66
67
|
sparkline = Sparkr::Sparkline.new(priorities.values)
|
67
|
-
sparkline.format do |tick,
|
68
|
-
tick.color(
|
68
|
+
sparkline.format do |tick, _count, index|
|
69
|
+
tick.color(PRIORITY_COLORS[index])
|
69
70
|
end
|
70
|
-
puts " #{grade_list.grade}: " + sparkline.to_s(
|
71
|
+
puts " #{grade_list.grade}: " + sparkline.to_s(" ") +
|
71
72
|
" #{grade_list.objects.size.to_s.rjust(5)} objects"
|
72
73
|
puts
|
73
74
|
end
|
@@ -76,7 +77,7 @@ module Inch
|
|
76
77
|
arrows = Evaluation::PriorityRange.all.map(&:arrow)
|
77
78
|
puts "Priority distribution in grades: (low to high)"
|
78
79
|
puts
|
79
|
-
puts " #{arrows.reverse.join(
|
80
|
+
puts " #{arrows.reverse.join(" ")}"
|
80
81
|
@grade_lists.reverse.each do |grade_list|
|
81
82
|
print_grade_list(grade_list)
|
82
83
|
end
|
@@ -92,9 +93,9 @@ module Inch
|
|
92
93
|
|
93
94
|
def stats_hash
|
94
95
|
{
|
95
|
-
|
96
|
-
|
97
|
-
|
96
|
+
"grade_lists" => __grade_lists,
|
97
|
+
"scores" => __scores,
|
98
|
+
"priorities" => __priorities
|
98
99
|
}
|
99
100
|
end
|
100
101
|
|
@@ -123,7 +124,6 @@ module Inch
|
|
123
124
|
end
|
124
125
|
hash
|
125
126
|
end
|
126
|
-
|
127
127
|
end
|
128
128
|
end
|
129
129
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "sparkr"
|
2
2
|
|
3
3
|
module Inch
|
4
4
|
module CLI
|
@@ -11,10 +11,10 @@ module Inch
|
|
11
11
|
|
12
12
|
FILE_COLOR = :dark # TODO: store all colors somewhere
|
13
13
|
RANGE_LABELS = {
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
14
|
+
A: "Nearly perfect:",
|
15
|
+
B: "Properly documented, could be improved:",
|
16
|
+
C: "Not properly documented:",
|
17
|
+
U: "Undocumented:"
|
18
18
|
}
|
19
19
|
|
20
20
|
# @param options [Command::Options::Suggest]
|
@@ -22,7 +22,8 @@ module Inch
|
|
22
22
|
# @param objects_to_display [Array<CodeObject::Proxy::Base>]
|
23
23
|
# @param grade_lists [Array<Evaluation::GradeList>]
|
24
24
|
# @param files [Array<Evaluation::File>]
|
25
|
-
def initialize(options, relevant_objects, objects_to_display,
|
25
|
+
def initialize(options, relevant_objects, objects_to_display,
|
26
|
+
grade_lists, files)
|
26
27
|
@options = options
|
27
28
|
@objects = objects_to_display
|
28
29
|
@relevant_objects = relevant_objects
|
@@ -45,7 +46,7 @@ module Inch
|
|
45
46
|
end
|
46
47
|
|
47
48
|
def display_distribution
|
48
|
-
sparkline = grades_sparkline(@relevant_objects).to_s(
|
49
|
+
sparkline = grades_sparkline(@relevant_objects).to_s(" ")
|
49
50
|
puts "Grade distribution (undocumented, C, B, A): " + sparkline
|
50
51
|
puts
|
51
52
|
puts priority_filter_hint
|
@@ -54,10 +55,10 @@ module Inch
|
|
54
55
|
def priority_filter_hint
|
55
56
|
arrows = min_priority_arrows
|
56
57
|
pretext = if @options.pedantic
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
"Considering priority objects: #{arrows}"
|
59
|
+
else
|
60
|
+
"Only considering priority objects: #{arrows}"
|
61
|
+
end
|
61
62
|
"#{pretext} (use `--help` for options).".dark
|
62
63
|
end
|
63
64
|
|
@@ -67,7 +68,7 @@ module Inch
|
|
67
68
|
ui.trace
|
68
69
|
|
69
70
|
files.each do |file|
|
70
|
-
filename = file.fullname.gsub(base_dir,
|
71
|
+
filename = file.fullname.gsub(base_dir, "")
|
71
72
|
ui.edged(FILE_COLOR, filename.color(FILE_COLOR))
|
72
73
|
end
|
73
74
|
ui.trace
|
@@ -77,29 +78,30 @@ module Inch
|
|
77
78
|
@options.grades_to_display.map do |grade|
|
78
79
|
r = grade_list(grade)
|
79
80
|
grade_objects = objects.select { |o| o.grade == r.grade }
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
81
|
+
next if grade_objects.empty?
|
82
|
+
ui.trace
|
83
|
+
ui.header(RANGE_LABELS[r.grade.to_sym], r.color, r.bg_color)
|
84
|
+
grade_objects.each do |o|
|
85
|
+
grade = o.grade.to_s.ljust(2).color(r.color)
|
86
|
+
priority = o.priority
|
87
|
+
ui.sub(" #{grade} #{priority_arrow(priority, r.color)} " \
|
88
|
+
"#{o.fullname}")
|
88
89
|
end
|
89
90
|
end
|
90
91
|
end
|
91
92
|
|
92
93
|
def display_no_objects_hint
|
93
94
|
hint = if @options.pedantic
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
95
|
+
"Even by my standards."
|
96
|
+
else
|
97
|
+
"Try --pedantic to be excessively concerned with minor " \
|
98
|
+
"details and rules."
|
99
|
+
end
|
98
100
|
ui.trace "Nothing to suggest.".color(:green) + " #{hint}"
|
99
101
|
end
|
100
102
|
|
101
103
|
def min_priority_arrows
|
102
|
-
priority_arrows_gte(@options.object_min_priority).join(
|
104
|
+
priority_arrows_gte(@options.object_min_priority).join(" ")
|
103
105
|
end
|
104
106
|
|
105
107
|
def priority_arrows_gte(min_priority)
|
@@ -109,7 +111,7 @@ module Inch
|
|
109
111
|
end
|
110
112
|
|
111
113
|
def grade_list(grade_symbol)
|
112
|
-
@grade_lists.
|
114
|
+
@grade_lists.find { |r| r.grade.to_sym == grade_symbol }
|
113
115
|
end
|
114
116
|
end
|
115
117
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "inch/cli/command/options/show"
|
2
|
+
require "inch/cli/command/output/show"
|
3
3
|
|
4
4
|
module Inch
|
5
5
|
module CLI
|
@@ -8,11 +8,11 @@ module Inch
|
|
8
8
|
register_command_as :show
|
9
9
|
|
10
10
|
def description
|
11
|
-
|
11
|
+
"Shows an object with its results"
|
12
12
|
end
|
13
13
|
|
14
14
|
def usage
|
15
|
-
|
15
|
+
"Usage: inch show [paths] OBJECT_NAME [[OBJECT_NAME2] ...] [options]"
|
16
16
|
end
|
17
17
|
|
18
18
|
def run(*args)
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "inch/cli/command/options/stats"
|
2
|
+
require "inch/cli/command/output/stats"
|
3
3
|
|
4
4
|
module Inch
|
5
5
|
module CLI
|
@@ -8,11 +8,11 @@ module Inch
|
|
8
8
|
register_command_as :stats
|
9
9
|
|
10
10
|
def description
|
11
|
-
|
11
|
+
"Show statistics"
|
12
12
|
end
|
13
13
|
|
14
14
|
def usage
|
15
|
-
|
15
|
+
"Usage: inch stats [paths] [options]"
|
16
16
|
end
|
17
17
|
|
18
18
|
def run(*args)
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "inch/cli/command/options/suggest"
|
2
|
+
require "inch/cli/command/output/suggest"
|
3
3
|
|
4
4
|
module Inch
|
5
5
|
module CLI
|
@@ -8,11 +8,11 @@ module Inch
|
|
8
8
|
register_command_as :suggest, true
|
9
9
|
|
10
10
|
def description
|
11
|
-
|
11
|
+
"Suggests some objects to be documented (better)"
|
12
12
|
end
|
13
13
|
|
14
14
|
def usage
|
15
|
-
|
15
|
+
"Usage: inch suggest [paths] [options]"
|
16
16
|
end
|
17
17
|
|
18
18
|
# Runs the commandline utility, parsing arguments and displaying a
|
@@ -23,8 +23,8 @@ module Inch
|
|
23
23
|
def run(*args)
|
24
24
|
prepare_codebase(*args)
|
25
25
|
context = API::Suggest.new(codebase, @options)
|
26
|
-
Output::Suggest.new(@options, context.all_objects,
|
27
|
-
|
26
|
+
Output::Suggest.new(@options, context.all_objects, context.objects,
|
27
|
+
context.grade_lists, context.files)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Inch
|
2
2
|
module CLI
|
3
|
-
# CommandParser parses a command-line arguments to decide which Command to
|
3
|
+
# CommandParser parses a command-line arguments to decide which Command to
|
4
|
+
# run.
|
4
5
|
#
|
5
6
|
# The basic form translates this shell command
|
6
7
|
#
|
@@ -55,7 +56,7 @@ module Inch
|
|
55
56
|
# argument.
|
56
57
|
# @return [Command::Base]
|
57
58
|
def run(*args)
|
58
|
-
if [
|
59
|
+
if ["--help", "-h"].include?(args.join)
|
59
60
|
list_commands
|
60
61
|
else
|
61
62
|
run_command(*args)
|
@@ -72,9 +73,9 @@ module Inch
|
|
72
73
|
ui.trace "Usage: inch <command> [options]"
|
73
74
|
ui.trace
|
74
75
|
ui.trace "Commands:"
|
75
|
-
commands.keys.sort_by {|k| k.to_s }.each do |command_name|
|
76
|
+
commands.keys.sort_by { |k| k.to_s }.each do |command_name|
|
76
77
|
command = commands[command_name].new
|
77
|
-
ui.trace " %-8s %s"
|
78
|
+
ui.trace format(" %-8s %s", command_name, command.description)
|
78
79
|
end
|
79
80
|
end
|
80
81
|
|
@@ -87,7 +88,7 @@ module Inch
|
|
87
88
|
else
|
88
89
|
possible_command_name = args.first.to_sym
|
89
90
|
|
90
|
-
if commands.
|
91
|
+
if commands.key?(possible_command_name)
|
91
92
|
command_name = possible_command_name
|
92
93
|
args.shift
|
93
94
|
else
|