inch 0.3.0 → 0.3.1.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -11
- data/TODOS.md +1 -1
- data/lib/inch/api/suggest.rb +1 -1
- data/lib/inch/cli/command/options/base.rb +6 -6
- data/lib/inch/cli/command/output/list.rb +6 -6
- data/lib/inch/cli/command/output/show.rb +3 -3
- data/lib/inch/cli/command/output/suggest.rb +9 -9
- data/lib/inch/cli/command_parser.rb +5 -5
- data/lib/inch/cli/trace_helper.rb +5 -36
- data/lib/inch/cli/yardopts_helper.rb +1 -1
- data/lib/inch/code_object/provider/yard/object/base.rb +32 -11
- data/lib/inch/code_object/provider/yard/object/method_object.rb +10 -4
- data/lib/inch/code_object/provider/yard/object/method_parameter_object.rb +4 -4
- data/lib/inch/code_object/proxy/base.rb +0 -1
- data/lib/inch/code_object/proxy/method_parameter_object.rb +0 -1
- data/lib/inch/evaluation/proxy/base.rb +45 -25
- data/lib/inch/utils/ui.rb +70 -0
- data/lib/inch/version.rb +1 -1
- data/test/fixtures/parameters/lib/foo.rb +20 -0
- data/test/fixtures/simple/lib/broken.rb +13 -0
- data/test/inch/cli/trace_helper_test.rb +2 -37
- data/test/inch/code_object/proxy/method_object_test.rb +15 -0
- data/test/inch/utils/ui_test.rb +42 -0
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 865abcc4558e39bb63f029bd4244559dee50b179
|
4
|
+
data.tar.gz: 898d3f31226eb312704e1e2daf4af53236d59719
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ad4ada205e23045470dd5c6544a9a4fc6a8d5fbabc8feaa6d9ecdfc4c4cddec812048bfbaa73e7493444cf1c3238c82b3cb041109160d87b780c56f351e9833
|
7
|
+
data.tar.gz: 4d7a265a1ab81537a0351ebed51c3dea1e4b60efd9ca7bfb715c8e38216b2b1d2c0135d1b63586974c5188623814b2d2a334fcbb2d9260a306dbfc7075c37ff5
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Inch [![Build Status](https://travis-ci.org/rrrene/inch.png)](https://travis-ci.org/rrrene/inch)
|
1
|
+
# Inch [![Build Status](https://travis-ci.org/rrrene/inch.png)](https://travis-ci.org/rrrene/inch) [![Code Climate](https://codeclimate.com/github/rrrene/inch.png)](https://codeclimate.com/github/rrrene/inch) [![Inline docs](http://inch-pages.github.io/github/rrrene/inch.png)](http://inch-pages.github.io/github/rrrene/inch)
|
2
2
|
|
3
3
|
`inch` gives you hints where to improve your docs. One Inch at a time.
|
4
4
|
|
@@ -8,7 +8,7 @@ Take a look at the [project page with screenshots (live and in full color)](http
|
|
8
8
|
|
9
9
|
`inch` is a little bit like Code Climate, but for your inline code documentation (and not a webservice).
|
10
10
|
|
11
|
-
It is a command-line utility that suggests places in your codebase where documentation can be improved.
|
11
|
+
It is a command-line utility that suggests places in your codebase where documentation can be improved.
|
12
12
|
|
13
13
|
If there are no inline-docs yet, `inch` can tell you where to start.
|
14
14
|
|
@@ -61,20 +61,20 @@ end
|
|
61
61
|
Inch will suggest that the docs could be improved:
|
62
62
|
|
63
63
|
# Properly documented, could be improved:
|
64
|
-
|
64
|
+
|
65
65
|
┃ B ↑ Foo#complicated
|
66
|
-
|
66
|
+
|
67
67
|
# Undocumented:
|
68
|
-
|
68
|
+
|
69
69
|
┃ U ↑ Foo
|
70
70
|
┃ U ↗ Foo#filename
|
71
|
-
|
71
|
+
|
72
72
|
You might want to look at these files:
|
73
|
-
|
73
|
+
|
74
74
|
┃ lib/foo.rb
|
75
|
-
|
75
|
+
|
76
76
|
Grade distribution (undocumented, C, B, A): █ ▁ ▄ ▄
|
77
|
-
|
77
|
+
|
78
78
|
Only considering priority objects: ↑ ↗ → (use `--help` for options).
|
79
79
|
|
80
80
|
|
@@ -144,9 +144,9 @@ This tells you three things:
|
|
144
144
|
* There are still undocumented methods.
|
145
145
|
|
146
146
|
Inch does not really tell you what to do from here. It suggests objects and
|
147
|
-
files that could be improved to get a better rating, but that is all. This
|
147
|
+
files that could be improved to get a better rating, but that is all. This
|
148
148
|
way, it is perfectly reasonable to leave parts of your codebase
|
149
|
-
undocumented.
|
149
|
+
undocumented.
|
150
150
|
|
151
151
|
Instead of reporting
|
152
152
|
|
data/TODOS.md
CHANGED
data/lib/inch/api/suggest.rb
CHANGED
@@ -129,11 +129,11 @@ module Inch
|
|
129
129
|
Term::ANSIColor::coloring = v
|
130
130
|
end
|
131
131
|
opts.on_tail('-v', '--version', 'Show version.') do
|
132
|
-
trace "inch #{Inch::VERSION}"
|
132
|
+
ui.trace "inch #{Inch::VERSION}"
|
133
133
|
exit
|
134
134
|
end
|
135
135
|
opts.on_tail('-h', '--help', 'Show this help.') do
|
136
|
-
trace opts
|
136
|
+
ui.trace opts
|
137
137
|
exit
|
138
138
|
end
|
139
139
|
end
|
@@ -143,9 +143,9 @@ module Inch
|
|
143
143
|
# @param msg [String,nil] optional, message to be displayed
|
144
144
|
# @return [void]
|
145
145
|
def kill(msg = nil)
|
146
|
-
warn usage
|
147
|
-
warn msg.red unless msg.nil?
|
148
|
-
warn "Try `--help' for more information."
|
146
|
+
ui.warn usage
|
147
|
+
ui.warn msg.red unless msg.nil?
|
148
|
+
ui.warn "Try `--help' for more information."
|
149
149
|
exit 1
|
150
150
|
end
|
151
151
|
|
@@ -173,7 +173,7 @@ module Inch
|
|
173
173
|
# @param [OptionParser::ParseError] err the exception raised by the
|
174
174
|
# option parser
|
175
175
|
def unrecognized_option(err)
|
176
|
-
|
176
|
+
ui.warn "Unrecognized/#{err.message}".red
|
177
177
|
end
|
178
178
|
end
|
179
179
|
end
|
@@ -23,16 +23,16 @@ module Inch
|
|
23
23
|
if range.objects.empty?
|
24
24
|
# pass
|
25
25
|
else
|
26
|
-
trace
|
27
|
-
|
26
|
+
ui.trace
|
27
|
+
ui.header(range.label, range.color, range.bg_color)
|
28
28
|
display_grade_list(range)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
if @omitted > 0
|
33
|
-
trace
|
34
|
-
trace "This output omitted #{@omitted} objects. ".dark +
|
35
|
-
|
33
|
+
ui.trace
|
34
|
+
ui.trace "This output omitted #{@omitted} objects. ".dark +
|
35
|
+
"Use `--all` to display all objects.".dark
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -55,7 +55,7 @@ module Inch
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def echo(color, msg)
|
58
|
-
|
58
|
+
ui.edged(color, msg)
|
59
59
|
end
|
60
60
|
|
61
61
|
def result(object, color)
|
@@ -25,8 +25,8 @@ module Inch
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def print_object(o)
|
28
|
-
trace
|
29
|
-
|
28
|
+
ui.trace
|
29
|
+
ui.header(o.fullname, COLOR, BG_COLOR)
|
30
30
|
|
31
31
|
print_file_info(o, COLOR)
|
32
32
|
print_grade_info(o)
|
@@ -52,7 +52,7 @@ module Inch
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def echo(msg = "")
|
55
|
-
|
55
|
+
ui.edged(COLOR, msg)
|
56
56
|
end
|
57
57
|
|
58
58
|
def separator
|
@@ -62,15 +62,15 @@ module Inch
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def display_files
|
65
|
-
trace
|
66
|
-
trace "You might want to look at these files:"
|
67
|
-
trace
|
65
|
+
ui.trace
|
66
|
+
ui.trace "You might want to look at these files:"
|
67
|
+
ui.trace
|
68
68
|
|
69
69
|
files.each do |file|
|
70
70
|
filename = file.fullname.gsub(base_dir, '')
|
71
|
-
|
71
|
+
ui.edged(FILE_COLOR, filename.color(FILE_COLOR))
|
72
72
|
end
|
73
|
-
trace
|
73
|
+
ui.trace
|
74
74
|
end
|
75
75
|
|
76
76
|
def display_list
|
@@ -78,12 +78,12 @@ module Inch
|
|
78
78
|
r = grade_list(grade)
|
79
79
|
grade_objects = objects.select { |o| o.grade == r.grade }
|
80
80
|
unless grade_objects.empty?
|
81
|
-
trace
|
82
|
-
|
81
|
+
ui.trace
|
82
|
+
ui.header(RANGE_LABELS[r.grade.to_sym], r.color, r.bg_color)
|
83
83
|
grade_objects.each do |o|
|
84
84
|
grade = o.grade.to_s.ljust(2).color(r.color)
|
85
85
|
priority = o.priority
|
86
|
-
|
86
|
+
ui.sub(" #{grade} #{priority_arrow(priority, r.color)} #{o.fullname}")
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
@@ -95,7 +95,7 @@ module Inch
|
|
95
95
|
else
|
96
96
|
"Try --pedantic to be excessively concerned with minor details and rules."
|
97
97
|
end
|
98
|
-
trace "Nothing to suggest.".color(:green) + " #{hint}"
|
98
|
+
ui.trace "Nothing to suggest.".color(:green) + " #{hint}"
|
99
99
|
end
|
100
100
|
|
101
101
|
def min_priority_arrows
|
@@ -44,7 +44,7 @@ module Inch
|
|
44
44
|
end
|
45
45
|
|
46
46
|
self.commands = {}
|
47
|
-
|
47
|
+
|
48
48
|
# Convenience method to create a new CommandParser and call {#run}
|
49
49
|
# @return (see #run)
|
50
50
|
def self.run(*args)
|
@@ -69,12 +69,12 @@ module Inch
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def list_commands
|
72
|
-
trace "Usage: inch <command> [options]"
|
73
|
-
trace
|
74
|
-
trace "Commands:"
|
72
|
+
ui.trace "Usage: inch <command> [options]"
|
73
|
+
ui.trace
|
74
|
+
ui.trace "Commands:"
|
75
75
|
commands.keys.sort_by {|k| k.to_s }.each do |command_name|
|
76
76
|
command = commands[command_name].new
|
77
|
-
trace " %-8s %s" % [command_name, command.description]
|
77
|
+
ui.trace " %-8s %s" % [command_name, command.description]
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
@@ -1,44 +1,13 @@
|
|
1
|
-
|
1
|
+
require 'inch/utils/ui'
|
2
2
|
|
3
3
|
module Inch
|
4
4
|
module CLI
|
5
|
+
# Adds a method called +ui+, that can be used to output messages to the
|
6
|
+
# user.
|
5
7
|
module TraceHelper
|
6
|
-
def
|
7
|
-
|
8
|
-
msg.to_s.lines.each do |line|
|
9
|
-
trace edged :dark, line.gsub(/\n$/,'').dark
|
10
|
-
end
|
8
|
+
def ui
|
9
|
+
@ui ||= Inch::Utils::UI.new
|
11
10
|
end
|
12
|
-
|
13
|
-
# Writes the given +text+ to stdout
|
14
|
-
# @param text [String]
|
15
|
-
# @return [void]
|
16
|
-
def trace(text = "")
|
17
|
-
puts text
|
18
|
-
end
|
19
|
-
|
20
|
-
def trace_header(text, color, bg_color = nil)
|
21
|
-
trace header(text, color, bg_color)
|
22
|
-
trace if !use_color?
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def edged(color, msg, edge = "┃ ")
|
28
|
-
edge.color(color) + msg
|
29
|
-
end
|
30
|
-
|
31
|
-
def header(text, color, bg_color = nil)
|
32
|
-
bg_color ||= "intense_#{color}"
|
33
|
-
bar = " #{text}".ljust(CLI::COLUMNS-1)
|
34
|
-
.on_color(bg_color).color(:color16)
|
35
|
-
"#".color(color).on_color(color) + bar
|
36
|
-
end
|
37
|
-
|
38
|
-
def use_color?
|
39
|
-
Term::ANSIColor::coloring?
|
40
|
-
end
|
41
|
-
|
42
11
|
end
|
43
12
|
end
|
44
13
|
end
|
@@ -25,6 +25,9 @@ module Inch
|
|
25
25
|
# @param object [YARD::CodeObjects::Base] the actual (YARD) code object
|
26
26
|
def initialize(object)
|
27
27
|
@object = object
|
28
|
+
@__api_tag = __api_tag
|
29
|
+
@__parent = __parent
|
30
|
+
@__private_tag = __private_tag
|
28
31
|
end
|
29
32
|
|
30
33
|
def api_tag?
|
@@ -32,7 +35,7 @@ module Inch
|
|
32
35
|
end
|
33
36
|
|
34
37
|
def api_tag
|
35
|
-
|
38
|
+
@__api_tag
|
36
39
|
end
|
37
40
|
|
38
41
|
# To be overridden
|
@@ -100,11 +103,11 @@ module Inch
|
|
100
103
|
end
|
101
104
|
|
102
105
|
def fullname
|
103
|
-
object.path
|
106
|
+
@fullname ||= object.path
|
104
107
|
end
|
105
108
|
|
106
109
|
def name
|
107
|
-
object.name
|
110
|
+
@name ||= object.name
|
108
111
|
end
|
109
112
|
|
110
113
|
def has_alias?
|
@@ -157,14 +160,9 @@ module Inch
|
|
157
160
|
#
|
158
161
|
# @note top-level counts, that's why Foo has depth 1!
|
159
162
|
#
|
160
|
-
# @param i [Fixnum] a counter for recursive method calls
|
161
163
|
# @return [Fixnum] the depth of the object in terms of namespace
|
162
|
-
def depth
|
163
|
-
|
164
|
-
parent.depth(i+1)
|
165
|
-
else
|
166
|
-
i
|
167
|
-
end
|
164
|
+
def depth
|
165
|
+
@__depth ||= __depth
|
168
166
|
end
|
169
167
|
|
170
168
|
# @return [Boolean] +true+ if the object represents a method
|
@@ -183,6 +181,10 @@ module Inch
|
|
183
181
|
|
184
182
|
# @return [Array,nil] the parent of the current object or +nil+
|
185
183
|
def parent
|
184
|
+
@__parent
|
185
|
+
end
|
186
|
+
|
187
|
+
def __parent
|
186
188
|
YARD::Object.for(object.parent) if object.parent
|
187
189
|
end
|
188
190
|
|
@@ -197,7 +199,7 @@ module Inch
|
|
197
199
|
end
|
198
200
|
|
199
201
|
def private_tag
|
200
|
-
|
202
|
+
@__private_tag
|
201
203
|
end
|
202
204
|
|
203
205
|
def private_api_tag?
|
@@ -254,6 +256,25 @@ module Inch
|
|
254
256
|
CONSIDERED_YARD_TAGS.include?(tag.tag_name)
|
255
257
|
end
|
256
258
|
end
|
259
|
+
|
260
|
+
def __depth(i = 0)
|
261
|
+
if parent
|
262
|
+
parent.__depth(i+1)
|
263
|
+
else
|
264
|
+
i
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
private
|
269
|
+
|
270
|
+
def __api_tag
|
271
|
+
tag(:api) || (parent && parent.api_tag)
|
272
|
+
end
|
273
|
+
|
274
|
+
def __private_tag
|
275
|
+
tag(:private) || (parent && parent.private_tag)
|
276
|
+
end
|
277
|
+
|
257
278
|
end
|
258
279
|
end
|
259
280
|
end
|
@@ -38,9 +38,9 @@ module Inch
|
|
38
38
|
|
39
39
|
def parameters
|
40
40
|
@parameters ||= all_parameter_names.map do |name|
|
41
|
-
|
42
|
-
tag = parameter_tag(name)
|
43
|
-
MethodParameterObject.new(self, name,
|
41
|
+
signature_name = in_signature(name)
|
42
|
+
tag = parameter_tag(name) || parameter_tag(signature_name)
|
43
|
+
MethodParameterObject.new(self, name, signature_name, tag)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -87,7 +87,8 @@ module Inch
|
|
87
87
|
def all_parameter_names
|
88
88
|
names = signature_parameter_names
|
89
89
|
names.concat parameter_tags.map(&:name)
|
90
|
-
names.
|
90
|
+
names.map { |name| name.gsub(/[\*\&]/, '') }
|
91
|
+
.compact.uniq
|
91
92
|
end
|
92
93
|
|
93
94
|
def implicit_docstring?
|
@@ -101,6 +102,11 @@ module Inch
|
|
101
102
|
end
|
102
103
|
end
|
103
104
|
|
105
|
+
def in_signature(name)
|
106
|
+
possible_names = [name, "*#{name}", "&#{name}"]
|
107
|
+
(signature_parameter_names & possible_names).first
|
108
|
+
end
|
109
|
+
|
104
110
|
def signature_parameter_names
|
105
111
|
object.parameters.map(&:first)
|
106
112
|
end
|
@@ -9,9 +9,9 @@ module Inch
|
|
9
9
|
|
10
10
|
# @param method [YARD::Object::MethodObject] the method the parameter belongs to
|
11
11
|
# @param name [String] the name of the parameter
|
12
|
+
# @param in_signature [String] how the parameter is noted in the method's signature
|
12
13
|
# @param tag [YARD::Tags::Tag] the Tag object for the parameter
|
13
|
-
|
14
|
-
def initialize(method, name, tag, in_signature)
|
14
|
+
def initialize(method, name, in_signature, tag)
|
15
15
|
@method = method
|
16
16
|
@name = name
|
17
17
|
@tag = tag
|
@@ -29,7 +29,7 @@ module Inch
|
|
29
29
|
|
30
30
|
# @return [Boolean] +true+ if the parameter is a block
|
31
31
|
def block?
|
32
|
-
|
32
|
+
@in_signature.to_s =~ /^\&/
|
33
33
|
end
|
34
34
|
|
35
35
|
# @return [Boolean] +true+ if an additional description given?
|
@@ -44,7 +44,7 @@ module Inch
|
|
44
44
|
|
45
45
|
# @return [Boolean] +true+ if the parameter is a splat argument
|
46
46
|
def splat?
|
47
|
-
|
47
|
+
@in_signature.to_s =~ /^\*/
|
48
48
|
end
|
49
49
|
|
50
50
|
# @return [Boolean] +true+ if the type of the parameter is defined
|
@@ -50,41 +50,24 @@ module Inch
|
|
50
50
|
__evaluate(object, relevant_roles)
|
51
51
|
end
|
52
52
|
|
53
|
-
|
54
|
-
role_classes.each do |role_class, score|
|
55
|
-
if role_class.applicable?(object)
|
56
|
-
add_role role_class.new(object, score)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# @return [Float]
|
53
|
+
# @return [Float] the max score that is assignable to +object+
|
62
54
|
def max_score
|
63
|
-
|
64
|
-
[MAX_SCORE].concat(arr).min
|
55
|
+
@__max_score = __max_score
|
65
56
|
end
|
66
57
|
|
67
|
-
# @return [Float]
|
58
|
+
# @return [Float] the min score that is assignable to +object+
|
68
59
|
def min_score
|
69
|
-
|
70
|
-
[MIN_SCORE].concat(arr).max
|
60
|
+
@__min_score = __min_score
|
71
61
|
end
|
72
62
|
|
73
|
-
# @return [Float]
|
63
|
+
# @return [Float] the final score for +object+
|
74
64
|
def score
|
75
|
-
|
76
|
-
if value < min_score
|
77
|
-
min_score
|
78
|
-
elsif value > max_score
|
79
|
-
max_score
|
80
|
-
else
|
81
|
-
value
|
82
|
-
end
|
65
|
+
@__score ||= __score
|
83
66
|
end
|
84
67
|
|
85
|
-
# @return [Fixnum]
|
68
|
+
# @return [Fixnum] the priority for +object+
|
86
69
|
def priority
|
87
|
-
@
|
70
|
+
@__priority ||= __priority
|
88
71
|
end
|
89
72
|
|
90
73
|
# @return [Array<Evaluation::Role::Base>]
|
@@ -140,6 +123,43 @@ module Inch
|
|
140
123
|
def score_for(criteria_name)
|
141
124
|
criteria.send(criteria_name) * MAX_SCORE
|
142
125
|
end
|
126
|
+
|
127
|
+
def __evaluate(object, role_classes)
|
128
|
+
role_classes.each do |role_class, score|
|
129
|
+
if role_class.applicable?(object)
|
130
|
+
add_role role_class.new(object, score)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
# @return [Float] the max score that is assignable to +object+
|
136
|
+
def __max_score
|
137
|
+
arr = @roles.map(&:max_score).compact
|
138
|
+
[MAX_SCORE].concat(arr).min
|
139
|
+
end
|
140
|
+
|
141
|
+
# @return [Float] the max score that is assignable to +object+
|
142
|
+
def __min_score
|
143
|
+
arr = @roles.map(&:min_score).compact
|
144
|
+
[MIN_SCORE].concat(arr).max
|
145
|
+
end
|
146
|
+
|
147
|
+
# @return [Float]
|
148
|
+
def __score
|
149
|
+
value = @roles.inject(0) { |sum,r| sum + r.score.to_f }
|
150
|
+
if value < min_score
|
151
|
+
min_score
|
152
|
+
elsif value > max_score
|
153
|
+
max_score
|
154
|
+
else
|
155
|
+
value
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
# @return [Fixnum]
|
160
|
+
def __priority
|
161
|
+
@roles.inject(0) { |sum,r| sum + r.priority.to_i }
|
162
|
+
end
|
143
163
|
end
|
144
164
|
end
|
145
165
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Inch
|
4
|
+
module Utils
|
5
|
+
class UI
|
6
|
+
attr_reader :out, :err
|
7
|
+
|
8
|
+
def initialize(stdout = $stdout, stderr = $stderr)
|
9
|
+
@out, @err = stdout, stderr
|
10
|
+
end
|
11
|
+
|
12
|
+
def debug(msg)
|
13
|
+
return unless ENV['DEBUG']
|
14
|
+
msg.to_s.lines.each do |line|
|
15
|
+
trace edged :dark, line.gsub(/\n$/,'').dark
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def sub(msg = "")
|
20
|
+
color = @current_header_color || :white
|
21
|
+
trace __edged(color, msg)
|
22
|
+
end
|
23
|
+
|
24
|
+
def edged(color, msg, edge = "┃ ")
|
25
|
+
trace __edged(color, msg, edge)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Writes the given +text+ to out
|
29
|
+
#
|
30
|
+
# @param text [String]
|
31
|
+
# @return [void]
|
32
|
+
def trace(text = "")
|
33
|
+
@current_header_color = nil if text.to_s.empty?
|
34
|
+
out.puts text
|
35
|
+
end
|
36
|
+
|
37
|
+
# Writes the given +text+ to err
|
38
|
+
#
|
39
|
+
# @param text [String]
|
40
|
+
# @return [void]
|
41
|
+
def warn(text = "")
|
42
|
+
err.puts text
|
43
|
+
end
|
44
|
+
|
45
|
+
def header(text, color, bg_color = nil)
|
46
|
+
@current_header_color = color
|
47
|
+
trace __header(text, color, bg_color)
|
48
|
+
trace if !use_color?
|
49
|
+
end
|
50
|
+
|
51
|
+
# @return [Boolean] true if the UI uses coloring
|
52
|
+
def use_color?
|
53
|
+
Term::ANSIColor::coloring?
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def __edged(color, msg, edge = "┃ ")
|
59
|
+
edge.color(color) + msg
|
60
|
+
end
|
61
|
+
|
62
|
+
def __header(text, color, bg_color = nil)
|
63
|
+
bg_color ||= "intense_#{color}"
|
64
|
+
bar = " #{text}".ljust(CLI::COLUMNS-1)
|
65
|
+
.on_color(bg_color).color(:color16)
|
66
|
+
"#".color(color).on_color(color) + bar
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/inch/version.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
class Foo
|
2
|
+
# A complicated method
|
3
|
+
def complicated(o, i, *args, &block)
|
4
|
+
# ... snip ...
|
5
|
+
end
|
6
|
+
|
7
|
+
# The problem here is that ...
|
8
|
+
#
|
9
|
+
# @param *names [Array]
|
10
|
+
# @return [String]
|
11
|
+
def method_with_splat_parameter(*names)
|
12
|
+
end
|
13
|
+
|
14
|
+
# The problem here is that ...
|
15
|
+
#
|
16
|
+
# @param names [Array]
|
17
|
+
# @return [String]
|
18
|
+
def method_with_splat_parameter2(*names)
|
19
|
+
end
|
20
|
+
end
|
@@ -13,7 +13,20 @@ module Foo
|
|
13
13
|
# @param [Encoding] e
|
14
14
|
# @return [String]
|
15
15
|
def method_with_empty_param_tag_text(e)
|
16
|
+
end
|
16
17
|
|
18
|
+
# The problem here is that ...
|
19
|
+
#
|
20
|
+
# @param *names [Array]
|
21
|
+
# @return [String]
|
22
|
+
def method_with_splat_parameter(*names)
|
23
|
+
end
|
24
|
+
|
25
|
+
# The problem here is that ...
|
26
|
+
#
|
27
|
+
# @param names [Array]
|
28
|
+
# @return [String]
|
29
|
+
def method_with_splat_parameter2(*names)
|
17
30
|
end
|
18
31
|
end
|
19
32
|
|
@@ -5,43 +5,8 @@ class Tracer
|
|
5
5
|
end
|
6
6
|
|
7
7
|
describe ::Inch::CLI::TraceHelper do
|
8
|
-
|
8
|
+
it "should be a UI instance" do
|
9
9
|
@instance = Tracer.new
|
10
|
+
assert @instance.ui.is_a?(Inch::Utils::UI)
|
10
11
|
end
|
11
|
-
|
12
|
-
it "should trace" do
|
13
|
-
out, err = capture_io do
|
14
|
-
@instance.trace("Test")
|
15
|
-
end
|
16
|
-
refute out.empty?, "there should be no output"
|
17
|
-
assert err.empty?, "there should be no errors"
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should trace header" do
|
21
|
-
out, err = capture_io do
|
22
|
-
@instance.trace_header("Test", :red)
|
23
|
-
end
|
24
|
-
refute out.empty?, "there should be no output"
|
25
|
-
assert err.empty?, "there should be no errors"
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should trace debug if ENV variable is set" do
|
29
|
-
ENV['DEBUG'] = "1"
|
30
|
-
out, err = capture_io do
|
31
|
-
@instance.debug("Test")
|
32
|
-
end
|
33
|
-
ENV['DEBUG'] = nil
|
34
|
-
refute out.empty?, "there should be no output"
|
35
|
-
assert err.empty?, "there should be no errors"
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should not trace debug if ENV variable is set" do
|
39
|
-
refute ENV['DEBUG']
|
40
|
-
out, err = capture_io do
|
41
|
-
@instance.debug("Test")
|
42
|
-
end
|
43
|
-
assert out.empty?, "there should be no output"
|
44
|
-
assert err.empty?, "there should be no errors"
|
45
|
-
end
|
46
|
-
|
47
12
|
end
|
@@ -173,6 +173,15 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
173
173
|
assert m.score > 0
|
174
174
|
end
|
175
175
|
|
176
|
+
def test_depth
|
177
|
+
m = @codebase.objects.find("#root_method")
|
178
|
+
assert_equal 1, m.depth
|
179
|
+
m = @codebase.objects.find("InchTest#getter")
|
180
|
+
assert_equal 2, m.depth
|
181
|
+
m = @codebase.objects.find("Foo::Bar#method_without_doc")
|
182
|
+
assert_equal 3, m.depth
|
183
|
+
end
|
184
|
+
|
176
185
|
def test_getter
|
177
186
|
m = @codebase.objects.find("InchTest#getter")
|
178
187
|
assert m.getter?, "should be a getter"
|
@@ -214,4 +223,10 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
|
|
214
223
|
refute m.getter?
|
215
224
|
assert m.setter?, "should be a setter"
|
216
225
|
end
|
226
|
+
|
227
|
+
def test_splat_parameter_notation
|
228
|
+
m1 = @codebase.objects.find("Foo#method_with_splat_parameter")
|
229
|
+
m2 = @codebase.objects.find("Foo#method_with_splat_parameter2")
|
230
|
+
assert_equal m1.score, m2.score
|
231
|
+
end
|
217
232
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
|
3
|
+
describe ::Inch::Utils::UI do
|
4
|
+
it "should trace" do
|
5
|
+
out, err = capture_io do
|
6
|
+
@instance = ::Inch::Utils::UI.new
|
7
|
+
@instance.trace("Test")
|
8
|
+
end
|
9
|
+
refute out.empty?, "there should be no output"
|
10
|
+
assert err.empty?, "there should be no errors"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should trace header" do
|
14
|
+
out, err = capture_io do
|
15
|
+
@instance = ::Inch::Utils::UI.new
|
16
|
+
@instance.header("Test", :red)
|
17
|
+
end
|
18
|
+
refute out.empty?, "there should be no output"
|
19
|
+
assert err.empty?, "there should be no errors"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should trace debug if ENV variable is set" do
|
23
|
+
ENV['DEBUG'] = "1"
|
24
|
+
out, err = capture_io do
|
25
|
+
@instance = ::Inch::Utils::UI.new
|
26
|
+
@instance.debug("Test")
|
27
|
+
end
|
28
|
+
ENV['DEBUG'] = nil
|
29
|
+
refute out.empty?, "there should be no output"
|
30
|
+
assert err.empty?, "there should be no errors"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should not trace debug if ENV variable is set" do
|
34
|
+
refute ENV['DEBUG']
|
35
|
+
out, err = capture_io do
|
36
|
+
@instance = ::Inch::Utils::UI.new
|
37
|
+
@instance.debug("Test")
|
38
|
+
end
|
39
|
+
assert out.empty?, "there should be no output"
|
40
|
+
assert err.empty?, "there should be no errors"
|
41
|
+
end
|
42
|
+
end
|
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.
|
4
|
+
version: 0.3.1.rc1
|
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-
|
11
|
+
date: 2014-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -219,9 +219,11 @@ files:
|
|
219
219
|
- lib/inch/rake.rb
|
220
220
|
- lib/inch/rake/suggest.rb
|
221
221
|
- lib/inch/utils/read_write_methods.rb
|
222
|
+
- lib/inch/utils/ui.rb
|
222
223
|
- lib/inch/utils/weighted_list.rb
|
223
224
|
- lib/inch/version.rb
|
224
225
|
- test/fixtures/code_examples/lib/foo.rb
|
226
|
+
- test/fixtures/parameters/lib/foo.rb
|
225
227
|
- test/fixtures/readme/lib/foo.rb
|
226
228
|
- test/fixtures/really_good/lib/foo.rb
|
227
229
|
- test/fixtures/really_good_pedantic/lib/foo.rb
|
@@ -262,6 +264,7 @@ files:
|
|
262
264
|
- test/inch/codebase/objects_test.rb
|
263
265
|
- test/inch/codebase/proxy_test.rb
|
264
266
|
- test/inch/evaluation/role/base_test.rb
|
267
|
+
- test/inch/utils/ui_test.rb
|
265
268
|
- test/inch/utils/weighted_list_test.rb
|
266
269
|
- test/integration/stats_options_test.rb
|
267
270
|
- test/integration/visibility_options_test.rb
|
@@ -282,9 +285,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
282
285
|
version: '0'
|
283
286
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
284
287
|
requirements:
|
285
|
-
- - "
|
288
|
+
- - ">"
|
286
289
|
- !ruby/object:Gem::Version
|
287
|
-
version:
|
290
|
+
version: 1.3.1
|
288
291
|
requirements: []
|
289
292
|
rubyforge_project:
|
290
293
|
rubygems_version: 2.2.2
|
@@ -293,6 +296,7 @@ specification_version: 4
|
|
293
296
|
summary: Documentation measurement tool for Ruby
|
294
297
|
test_files:
|
295
298
|
- test/fixtures/code_examples/lib/foo.rb
|
299
|
+
- test/fixtures/parameters/lib/foo.rb
|
296
300
|
- test/fixtures/readme/lib/foo.rb
|
297
301
|
- test/fixtures/really_good/lib/foo.rb
|
298
302
|
- test/fixtures/really_good_pedantic/lib/foo.rb
|
@@ -333,6 +337,7 @@ test_files:
|
|
333
337
|
- test/inch/codebase/objects_test.rb
|
334
338
|
- test/inch/codebase/proxy_test.rb
|
335
339
|
- test/inch/evaluation/role/base_test.rb
|
340
|
+
- test/inch/utils/ui_test.rb
|
336
341
|
- test/inch/utils/weighted_list_test.rb
|
337
342
|
- test/integration/stats_options_test.rb
|
338
343
|
- test/integration/visibility_options_test.rb
|