inch 0.4.10 → 0.5.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -11
- data/Gemfile +2 -5
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/bin/inch +3 -3
- data/config/defaults.rb +0 -7
- data/inch.gemspec +7 -7
- data/lib/inch.rb +9 -9
- data/lib/inch/api.rb +10 -10
- data/lib/inch/api/compare.rb +2 -2
- data/lib/inch/api/compare/code_objects.rb +3 -2
- data/lib/inch/api/compare/codebases.rb +1 -1
- data/lib/inch/api/diff.rb +10 -7
- data/lib/inch/api/filter.rb +1 -1
- data/lib/inch/api/get.rb +1 -1
- data/lib/inch/api/options/base.rb +4 -4
- data/lib/inch/api/options/filter.rb +4 -0
- data/lib/inch/api/options/suggest.rb +5 -1
- data/lib/inch/api/stats.rb +1 -0
- data/lib/inch/api/suggest.rb +10 -9
- data/lib/inch/cli.rb +6 -6
- data/lib/inch/cli/arguments.rb +2 -2
- data/lib/inch/cli/command.rb +15 -15
- data/lib/inch/cli/command/base.rb +4 -4
- data/lib/inch/cli/command/console.rb +5 -5
- data/lib/inch/cli/command/diff.rb +8 -7
- data/lib/inch/cli/command/inspect.rb +4 -5
- 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 +5 -9
- data/lib/inch/cli/command/options/console.rb +3 -4
- data/lib/inch/cli/command/options/diff.rb +6 -8
- data/lib/inch/cli/command/options/inspect.rb +2 -2
- data/lib/inch/cli/command/options/list.rb +2 -3
- data/lib/inch/cli/command/options/show.rb +2 -2
- data/lib/inch/cli/command/options/stats.rb +1 -2
- data/lib/inch/cli/command/options/suggest.rb +3 -6
- data/lib/inch/cli/command/output/base.rb +6 -4
- data/lib/inch/cli/command/output/console.rb +5 -4
- data/lib/inch/cli/command/output/diff.rb +6 -6
- data/lib/inch/cli/command/output/inspect.rb +8 -6
- data/lib/inch/cli/command/output/list.rb +1 -0
- data/lib/inch/cli/command/output/show.rb +5 -4
- data/lib/inch/cli/command/output/stats.rb +21 -21
- data/lib/inch/cli/command/output/suggest.rb +27 -30
- 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 +5 -6
- data/lib/inch/cli/sparkline_helper.rb +6 -6
- data/lib/inch/cli/trace_helper.rb +1 -1
- data/lib/inch/cli/yardopts_helper.rb +3 -4
- data/lib/inch/code_object.rb +3 -3
- data/lib/inch/code_object/converter.rb +8 -6
- data/lib/inch/code_object/provider.rb +1 -1
- data/lib/inch/code_object/provider/yard.rb +12 -10
- data/lib/inch/code_object/provider/yard/docstring.rb +19 -51
- data/lib/inch/code_object/provider/yard/nodoc_helper.rb +4 -4
- data/lib/inch/code_object/provider/yard/object.rb +10 -12
- data/lib/inch/code_object/provider/yard/object/base.rb +27 -48
- data/lib/inch/code_object/provider/yard/object/method_object.rb +10 -47
- data/lib/inch/code_object/provider/yard/object/method_parameter_object.rb +6 -10
- data/lib/inch/code_object/provider/yard/object/method_signature.rb +8 -12
- data/lib/inch/code_object/provider/yard/object/namespace_object.rb +4 -1
- data/lib/inch/code_object/provider/yard/parser.rb +3 -3
- data/lib/inch/code_object/proxy.rb +9 -10
- data/lib/inch/code_object/proxy/base.rb +10 -12
- data/lib/inch/code_object/proxy/method_object.rb +2 -3
- data/lib/inch/code_object/proxy/method_parameter_object.rb +3 -5
- data/lib/inch/codebase.rb +5 -4
- data/lib/inch/codebase/objects_filter.rb +4 -2
- data/lib/inch/codebase/serializer.rb +3 -3
- data/lib/inch/config.rb +2 -2
- data/lib/inch/config/base.rb +1 -0
- data/lib/inch/config/codebase.rb +4 -4
- data/lib/inch/core_ext.rb +1 -1
- data/lib/inch/core_ext/string.rb +1 -1
- data/lib/inch/evaluation.rb +15 -16
- data/lib/inch/evaluation/file.rb +1 -1
- data/lib/inch/evaluation/grade_list.rb +2 -2
- data/lib/inch/evaluation/object_schema.rb +1 -1
- data/lib/inch/evaluation/proxy.rb +7 -8
- data/lib/inch/evaluation/proxy/base.rb +10 -13
- data/lib/inch/evaluation/proxy/constant_object.rb +1 -1
- data/lib/inch/evaluation/proxy/method_object.rb +5 -12
- 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/method.rb +2 -2
- data/lib/inch/evaluation/role/method_parameter.rb +1 -2
- data/lib/inch/evaluation/role/object.rb +2 -2
- data/lib/inch/rake.rb +2 -2
- data/lib/inch/rake/suggest.rb +2 -3
- data/lib/inch/utils/shell_helper.rb +1 -1
- data/lib/inch/utils/ui.rb +5 -5
- data/lib/inch/utils/weighted_list.rb +3 -2
- data/lib/inch/version.rb +1 -1
- data/test/fixtures/simple/lib/broken.rb +7 -35
- data/test/fixtures/simple/lib/foo.rb +1 -22
- 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 +5 -4
- data/test/integration/cli/command/list_test.rb +4 -3
- 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 +10 -10
- data/test/integration/stats_options_test.rb +3 -3
- data/test/integration/visibility_options_test.rb +13 -13
- data/test/shared/base_list.rb +3 -4
- data/test/test_helper.rb +6 -16
- 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 +3 -4
- data/test/unit/code_object/converter_test.rb +1 -1
- data/test/unit/code_object/provider/yard/docstring_test.rb +28 -106
- data/test/unit/code_object/provider/yard/nodoc_helper_test.rb +5 -6
- data/test/unit/code_object/provider/yard/object/method_object_test.rb +10 -20
- 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 +262 -382
- 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 +2 -2
- data/test/unit/utils/ui_test.rb +4 -4
- data/test/unit/utils/weighted_list_test.rb +4 -7
- metadata +4 -14
- data/.rubocop.yml +0 -15
- data/.rubocop_todo.yml +0 -94
- data/lib/inch/code_object/provider/yard/object/class_variable_object.rb +0 -12
- data/lib/inch/code_object/proxy/class_variable_object.rb +0 -8
- data/lib/inch/evaluation/proxy/class_variable_object.rb +0 -19
- data/lib/inch/evaluation/role/class_variable.rb +0 -55
- data/test/fixtures/simple/lib/broken_ruby_2_0_features.rb +0 -7
- data/test/fixtures/simple/lib/directives.rb +0 -8
@@ -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,11 +66,13 @@ 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
|
-
|
73
|
+
if role.priority == 0
|
74
|
+
priority = priority.dark
|
75
|
+
end
|
74
76
|
|
75
77
|
echo name.ljust(40) + score + priority
|
76
78
|
print_min_max_score(role)
|
@@ -131,7 +133,7 @@ module Inch
|
|
131
133
|
end
|
132
134
|
|
133
135
|
def to_s
|
134
|
-
comments.join(
|
136
|
+
comments.join('') + abbrev_source
|
135
137
|
end
|
136
138
|
|
137
139
|
private
|
@@ -139,12 +141,12 @@ module Inch
|
|
139
141
|
def abbrev_source
|
140
142
|
lines = code_object.source.to_s.lines.to_a
|
141
143
|
if lines.size >= 5
|
142
|
-
indent = lines[1].scan(/^(\s+)/).flatten.join(
|
144
|
+
indent = lines[1].scan(/^(\s+)/).flatten.join('')
|
143
145
|
lines = lines[0..1] +
|
144
146
|
["#{indent}# ... snip ...\n"] +
|
145
147
|
lines[-2..-1]
|
146
148
|
end
|
147
|
-
lines.join(
|
149
|
+
lines.join('')
|
148
150
|
end
|
149
151
|
|
150
152
|
def comments
|
@@ -42,9 +42,10 @@ module Inch
|
|
42
42
|
if o.roles.empty?
|
43
43
|
echo "No roles assigned.".dark
|
44
44
|
else
|
45
|
-
o.roles.
|
46
|
-
|
47
|
-
|
45
|
+
o.roles.each_with_index do |role, index|
|
46
|
+
if role.suggestion
|
47
|
+
echo "+".color(COLOR) + " #{role.suggestion}"
|
48
|
+
end
|
48
49
|
end
|
49
50
|
end
|
50
51
|
echo separator
|
@@ -60,7 +61,7 @@ module Inch
|
|
60
61
|
|
61
62
|
def grade(score)
|
62
63
|
grade_lists ||= Evaluation.new_grade_lists
|
63
|
-
r = grade_lists.
|
64
|
+
r = grade_lists.detect { |r| r.scores.include?(score) }
|
64
65
|
"#{r.grade} - #{r.label}".color(r.color)
|
65
66
|
end
|
66
67
|
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,26 +31,25 @@ 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)} "
|
43
|
-
"objects"
|
42
|
+
puts " Overall: #{sparkline} #{objects.size.to_s.rjust(5)} objects"
|
44
43
|
puts
|
45
44
|
end
|
46
45
|
|
47
46
|
def print_grades_by_priority
|
48
|
-
puts
|
47
|
+
puts 'Grade distribution by priority:'
|
49
48
|
puts
|
50
49
|
Evaluation::PriorityRange.all.each do |priority_range|
|
51
50
|
list = objects.select { |o| priority_range.include?(o.priority) }
|
52
|
-
sparkline = grades_sparkline(list).to_s(
|
53
|
-
puts " #{priority_range.arrow} #{sparkline} "
|
51
|
+
sparkline = grades_sparkline(list).to_s(' ')
|
52
|
+
puts " #{priority_range.arrow} #{sparkline} " +
|
54
53
|
"#{list.size.to_s.rjust(5)} objects"
|
55
54
|
puts
|
56
55
|
end
|
@@ -65,10 +64,10 @@ module Inch
|
|
65
64
|
end
|
66
65
|
|
67
66
|
sparkline = Sparkr::Sparkline.new(priorities.values)
|
68
|
-
sparkline.format do |tick,
|
69
|
-
tick.color(PRIORITY_COLORS[index])
|
67
|
+
sparkline.format do |tick, count, index|
|
68
|
+
tick.color( PRIORITY_COLORS[index] )
|
70
69
|
end
|
71
|
-
puts " #{grade_list.grade}: " + sparkline.to_s(
|
70
|
+
puts " #{grade_list.grade}: " + sparkline.to_s(' ') +
|
72
71
|
" #{grade_list.objects.size.to_s.rjust(5)} objects"
|
73
72
|
puts
|
74
73
|
end
|
@@ -77,7 +76,7 @@ module Inch
|
|
77
76
|
arrows = Evaluation::PriorityRange.all.map(&:arrow)
|
78
77
|
puts "Priority distribution in grades: (low to high)"
|
79
78
|
puts
|
80
|
-
puts " #{arrows.reverse.join(
|
79
|
+
puts " #{arrows.reverse.join(' ')}"
|
81
80
|
@grade_lists.reverse.each do |grade_list|
|
82
81
|
print_grade_list(grade_list)
|
83
82
|
end
|
@@ -93,9 +92,9 @@ module Inch
|
|
93
92
|
|
94
93
|
def stats_hash
|
95
94
|
{
|
96
|
-
|
97
|
-
|
98
|
-
|
95
|
+
'grade_lists' => __grade_lists,
|
96
|
+
'scores' => __scores,
|
97
|
+
'priorities' => __priorities
|
99
98
|
}
|
100
99
|
end
|
101
100
|
|
@@ -124,6 +123,7 @@ module Inch
|
|
124
123
|
end
|
125
124
|
hash
|
126
125
|
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,20 +11,18 @@ module Inch
|
|
11
11
|
|
12
12
|
FILE_COLOR = :dark # TODO: store all colors somewhere
|
13
13
|
RANGE_LABELS = {
|
14
|
-
A
|
15
|
-
B
|
16
|
-
C
|
17
|
-
U
|
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]
|
21
|
-
# @param relevant_objects [Array<CodeObject::Proxy::Base>] the objects
|
22
|
-
# meeting the criteria defined in +options+
|
21
|
+
# @param relevant_objects [Array<CodeObject::Proxy::Base>] the objects meeting the criteria defined in +options+
|
23
22
|
# @param objects_to_display [Array<CodeObject::Proxy::Base>]
|
24
23
|
# @param grade_lists [Array<Evaluation::GradeList>]
|
25
24
|
# @param files [Array<Evaluation::File>]
|
26
|
-
def initialize(options, relevant_objects, objects_to_display,
|
27
|
-
grade_lists, files)
|
25
|
+
def initialize(options, relevant_objects, objects_to_display, grade_lists, files)
|
28
26
|
@options = options
|
29
27
|
@objects = objects_to_display
|
30
28
|
@relevant_objects = relevant_objects
|
@@ -47,7 +45,7 @@ module Inch
|
|
47
45
|
end
|
48
46
|
|
49
47
|
def display_distribution
|
50
|
-
sparkline = grades_sparkline(@relevant_objects).to_s(
|
48
|
+
sparkline = grades_sparkline(@relevant_objects).to_s(' ')
|
51
49
|
puts "Grade distribution (undocumented, C, B, A): " + sparkline
|
52
50
|
puts
|
53
51
|
puts priority_filter_hint
|
@@ -56,10 +54,10 @@ module Inch
|
|
56
54
|
def priority_filter_hint
|
57
55
|
arrows = min_priority_arrows
|
58
56
|
pretext = if @options.pedantic
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
"Considering priority objects: #{arrows}"
|
58
|
+
else
|
59
|
+
"Only considering priority objects: #{arrows}"
|
60
|
+
end
|
63
61
|
"#{pretext} (use `--help` for options).".dark
|
64
62
|
end
|
65
63
|
|
@@ -69,7 +67,7 @@ module Inch
|
|
69
67
|
ui.trace
|
70
68
|
|
71
69
|
files.each do |file|
|
72
|
-
filename = file.fullname.gsub(base_dir,
|
70
|
+
filename = file.fullname.gsub(base_dir, '')
|
73
71
|
ui.edged(FILE_COLOR, filename.color(FILE_COLOR))
|
74
72
|
end
|
75
73
|
ui.trace
|
@@ -79,30 +77,29 @@ module Inch
|
|
79
77
|
@options.grades_to_display.map do |grade|
|
80
78
|
r = grade_list(grade)
|
81
79
|
grade_objects = objects.select { |o| o.grade == r.grade }
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
80
|
+
unless grade_objects.empty?
|
81
|
+
ui.trace
|
82
|
+
ui.header(RANGE_LABELS[r.grade.to_sym], r.color, r.bg_color)
|
83
|
+
grade_objects.each do |o|
|
84
|
+
grade = o.grade.to_s.ljust(2).color(r.color)
|
85
|
+
priority = o.priority
|
86
|
+
ui.sub(" #{grade} #{priority_arrow(priority, r.color)} #{o.fullname}")
|
87
|
+
end
|
90
88
|
end
|
91
89
|
end
|
92
90
|
end
|
93
91
|
|
94
92
|
def display_no_objects_hint
|
95
93
|
hint = if @options.pedantic
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
end
|
94
|
+
"Even by my standards."
|
95
|
+
else
|
96
|
+
"Try --pedantic to be excessively concerned with minor details and rules."
|
97
|
+
end
|
101
98
|
ui.trace "Nothing to suggest.".color(:green) + " #{hint}"
|
102
99
|
end
|
103
100
|
|
104
101
|
def min_priority_arrows
|
105
|
-
priority_arrows_gte(@options.object_min_priority).join(
|
102
|
+
priority_arrows_gte(@options.object_min_priority).join(' ')
|
106
103
|
end
|
107
104
|
|
108
105
|
def priority_arrows_gte(min_priority)
|
@@ -112,7 +109,7 @@ module Inch
|
|
112
109
|
end
|
113
110
|
|
114
111
|
def grade_list(grade_symbol)
|
115
|
-
@grade_lists.
|
112
|
+
@grade_lists.detect { |r| r.grade.to_sym == grade_symbol }
|
116
113
|
end
|
117
114
|
end
|
118
115
|
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,
|
27
|
+
context.objects, context.grade_lists, context.files)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Inch
|
2
2
|
module CLI
|
3
|
-
# CommandParser parses a command-line arguments to decide which Command to
|
4
|
-
# run.
|
3
|
+
# CommandParser parses a command-line arguments to decide which Command to run.
|
5
4
|
#
|
6
5
|
# The basic form translates this shell command
|
7
6
|
#
|
@@ -56,7 +55,7 @@ module Inch
|
|
56
55
|
# argument.
|
57
56
|
# @return [Command::Base]
|
58
57
|
def run(*args)
|
59
|
-
if [
|
58
|
+
if ['--help', '-h'].include?(args.join)
|
60
59
|
list_commands
|
61
60
|
else
|
62
61
|
run_command(*args)
|
@@ -73,9 +72,9 @@ module Inch
|
|
73
72
|
ui.trace "Usage: inch <command> [options]"
|
74
73
|
ui.trace
|
75
74
|
ui.trace "Commands:"
|
76
|
-
commands.keys.sort_by {
|
75
|
+
commands.keys.sort_by {|k| k.to_s }.each do |command_name|
|
77
76
|
command = commands[command_name].new
|
78
|
-
ui.trace
|
77
|
+
ui.trace " %-8s %s" % [command_name, command.description]
|
79
78
|
end
|
80
79
|
end
|
81
80
|
|
@@ -88,7 +87,7 @@ module Inch
|
|
88
87
|
else
|
89
88
|
possible_command_name = args.first.to_sym
|
90
89
|
|
91
|
-
if commands.
|
90
|
+
if commands.has_key?(possible_command_name)
|
92
91
|
command_name = possible_command_name
|
93
92
|
args.shift
|
94
93
|
else
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Inch
|
2
2
|
module CLI
|
3
3
|
module SparklineHelper
|
4
|
-
def grade_lists_sparkline(
|
5
|
-
|
6
|
-
list =
|
7
|
-
__sparkline(list,
|
4
|
+
def grade_lists_sparkline(_grade_lists)
|
5
|
+
grade_lists = _grade_lists.reverse
|
6
|
+
list = grade_lists.map { |r| r.objects.size }
|
7
|
+
__sparkline(list, grade_lists)
|
8
8
|
end
|
9
9
|
|
10
10
|
def grades_sparkline(objects)
|
@@ -21,9 +21,9 @@ module Inch
|
|
21
21
|
|
22
22
|
def __sparkline(list, grade_lists)
|
23
23
|
sparkline = Sparkr::Sparkline.new(list)
|
24
|
-
sparkline.format do |tick,
|
24
|
+
sparkline.format do |tick, count, index|
|
25
25
|
t = tick.color(grade_lists[index].color)
|
26
|
-
index == 0 ? t +
|
26
|
+
index == 0 ? t + ' ' : t
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -8,8 +8,7 @@ module Inch
|
|
8
8
|
attr_accessor :excluded
|
9
9
|
|
10
10
|
VALID_YARD_SWITCHES = %w(--private --no-private --protected --no-public
|
11
|
-
|
12
|
-
--document --no-document)
|
11
|
+
--plugin --load --safe --yardopts --no-yardopts --document --no-document)
|
13
12
|
|
14
13
|
# Parses the option and gracefully handles invalid switches
|
15
14
|
#
|
@@ -18,7 +17,7 @@ module Inch
|
|
18
17
|
# array will be modified.
|
19
18
|
# @return [void]
|
20
19
|
def parse_yardopts_options(opts, args)
|
21
|
-
wrapper = YardoptsWrapper.new
|
20
|
+
wrapper = YardoptsWrapper.new()
|
22
21
|
|
23
22
|
dupped_args = args.dup
|
24
23
|
dupped_args.delete("--help")
|
@@ -36,7 +35,7 @@ module Inch
|
|
36
35
|
end
|
37
36
|
|
38
37
|
def yardopts_options(opts)
|
39
|
-
wrapper = YardoptsWrapper.new
|
38
|
+
wrapper = YardoptsWrapper.new()
|
40
39
|
wrapper.add_yardoc_options(opts)
|
41
40
|
end
|
42
41
|
|