tailor 1.2.1 → 1.3.0
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/Gemfile.lock +30 -28
- data/History.md +257 -0
- data/README.md +486 -0
- data/Rakefile +1 -9
- data/lib/ext/string_ext.rb +1 -1
- data/lib/tailor/cli.rb +3 -1
- data/lib/tailor/cli/options.rb +59 -39
- data/lib/tailor/configuration.rb +8 -5
- data/lib/tailor/configuration/file_set.rb +1 -3
- data/lib/tailor/configuration/style.rb +2 -0
- data/lib/tailor/critic.rb +2 -2
- data/lib/tailor/formatters/text.rb +17 -16
- data/lib/tailor/lexed_line.rb +2 -4
- data/lib/tailor/lexer.rb +9 -9
- data/lib/tailor/lexer/lexer_constants.rb +32 -32
- data/lib/tailor/lexer/token.rb +8 -10
- data/lib/tailor/logger.rb +1 -1
- data/lib/tailor/problem.rb +4 -1
- data/lib/tailor/rake_task.rb +4 -1
- data/lib/tailor/reporter.rb +3 -3
- data/lib/tailor/ruler.rb +2 -2
- data/lib/tailor/rulers/allow_camel_case_methods_ruler.rb +2 -2
- data/lib/tailor/rulers/allow_hard_tabs_ruler.rb +1 -1
- data/lib/tailor/rulers/allow_invalid_ruby_ruler.rb +1 -1
- data/lib/tailor/rulers/allow_screaming_snake_case_classes_ruler.rb +2 -2
- data/lib/tailor/rulers/indentation_spaces_ruler.rb +24 -22
- data/lib/tailor/rulers/indentation_spaces_ruler/indentation_manager.rb +13 -13
- data/lib/tailor/rulers/max_code_lines_in_class_ruler.rb +2 -2
- data/lib/tailor/rulers/max_code_lines_in_method_ruler.rb +2 -2
- data/lib/tailor/rulers/spaces_after_comma_ruler.rb +6 -6
- data/lib/tailor/rulers/spaces_after_conditional_ruler.rb +48 -0
- data/lib/tailor/rulers/spaces_after_lbrace_ruler.rb +8 -8
- data/lib/tailor/rulers/spaces_after_lbracket_ruler.rb +6 -6
- data/lib/tailor/rulers/spaces_after_lparen_ruler.rb +6 -6
- data/lib/tailor/rulers/spaces_before_comma_ruler.rb +2 -2
- data/lib/tailor/rulers/spaces_before_lbrace_ruler.rb +4 -4
- data/lib/tailor/rulers/spaces_before_rbrace_ruler.rb +9 -9
- data/lib/tailor/rulers/spaces_before_rbracket_ruler.rb +6 -6
- data/lib/tailor/rulers/spaces_before_rparen_ruler.rb +6 -6
- data/lib/tailor/rulers/spaces_in_empty_braces_ruler.rb +1 -1
- data/lib/tailor/rulers/trailing_newlines_ruler.rb +2 -2
- data/lib/tailor/tailorrc.erb +1 -1
- data/lib/tailor/version.rb +1 -1
- data/spec/functional/conditional_spacing_spec.rb +149 -0
- data/spec/functional/configuration_spec.rb +36 -26
- data/spec/functional/horizontal_spacing/braces_spec.rb +1 -1
- data/spec/functional/horizontal_spacing/brackets_spec.rb +14 -14
- data/spec/functional/horizontal_spacing/comma_spacing_spec.rb +8 -8
- data/spec/functional/horizontal_spacing/hard_tabs_spec.rb +13 -13
- data/spec/functional/horizontal_spacing/long_lines_spec.rb +6 -6
- data/spec/functional/horizontal_spacing/long_methods_spec.rb +55 -0
- data/spec/functional/horizontal_spacing/parens_spec.rb +17 -17
- data/spec/functional/horizontal_spacing/trailing_whitespace_spec.rb +8 -8
- data/spec/functional/horizontal_spacing_spec.rb +11 -11
- data/spec/functional/indentation_spacing/bad_indentation_spec.rb +83 -83
- data/spec/functional/indentation_spacing_spec.rb +10 -10
- data/spec/functional/naming/camel_case_methods_spec.rb +6 -6
- data/spec/functional/naming/screaming_snake_case_classes_spec.rb +10 -10
- data/spec/functional/naming_spec.rb +3 -3
- data/spec/functional/vertical_spacing/class_length_spec.rb +6 -6
- data/spec/functional/vertical_spacing/method_length_spec.rb +6 -6
- data/spec/functional/vertical_spacing_spec.rb +3 -3
- data/spec/support/conditional_spacing_cases.rb +37 -0
- data/spec/support/good_indentation_cases.rb +1 -1
- data/spec/unit/tailor/cli/options_spec.rb +50 -0
- data/spec/unit/tailor/cli_spec.rb +3 -3
- data/spec/unit/tailor/composite_observable_spec.rb +8 -8
- data/spec/unit/tailor/configuration/file_set_spec.rb +2 -2
- data/spec/unit/tailor/configuration/style_spec.rb +30 -29
- data/spec/unit/tailor/configuration_spec.rb +39 -24
- data/spec/unit/tailor/critic_spec.rb +18 -17
- data/spec/unit/tailor/formatter_spec.rb +15 -15
- data/spec/unit/tailor/formatters/yaml_spec.rb +1 -1
- data/spec/unit/tailor/lexed_line_spec.rb +258 -258
- data/spec/unit/tailor/lexer/token_spec.rb +11 -11
- data/spec/unit/tailor/lexer_spec.rb +35 -35
- data/spec/unit/tailor/problem_spec.rb +13 -13
- data/spec/unit/tailor/reporter_spec.rb +19 -18
- data/spec/unit/tailor/ruler_spec.rb +15 -15
- data/spec/unit/tailor/rulers/indentation_spaces_ruler/indentation_manager_spec.rb +72 -72
- data/spec/unit/tailor/rulers/indentation_spaces_ruler_spec.rb +32 -32
- data/spec/unit/tailor/rulers/spaces_after_comma_ruler_spec.rb +8 -8
- data/spec/unit/tailor/rulers/spaces_after_lbrace_ruler_spec.rb +36 -36
- data/spec/unit/tailor/rulers/spaces_before_lbrace_ruler_spec.rb +14 -14
- data/spec/unit/tailor/rulers/spaces_before_rbrace_ruler_spec.rb +14 -14
- data/spec/unit/tailor/rulers_spec.rb +2 -2
- data/spec/unit/tailor/version_spec.rb +1 -1
- data/spec/unit/tailor_spec.rb +4 -4
- data/tailor.gemspec +1 -1
- metadata +16 -9
- data/History.rdoc +0 -189
- data/README.rdoc +0 -422
- data/spec/unit/tailor/options_spec.rb +0 -6
data/Rakefile
CHANGED
@@ -45,18 +45,10 @@ end
|
|
45
45
|
# yard
|
46
46
|
#------------------------------------------------------------------------------
|
47
47
|
YARD::Rake::YardocTask.new do |t|
|
48
|
-
t.files = %w(lib/**/*.rb - History.
|
48
|
+
t.files = %w(lib/**/*.rb - History.md)
|
49
49
|
t.options = %w(--private --protected --verbose)
|
50
50
|
end
|
51
51
|
|
52
|
-
namespace :yard do
|
53
|
-
YARD::Rake::YardocTask.new(:with_features) do |t|
|
54
|
-
YARD::Config.load_plugin 'cucumber'
|
55
|
-
|
56
|
-
t.files = %w(lib/**/*.rb features/**/*.feature - History.rdoc)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
52
|
|
61
53
|
desc "Run RSpec examples and Cucumber features"
|
62
54
|
task test: [:spec, :features]
|
data/lib/ext/string_ext.rb
CHANGED
data/lib/tailor/cli.rb
CHANGED
@@ -47,7 +47,9 @@ class Tailor
|
|
47
47
|
@reporter.file_report(problems_for_file, label)
|
48
48
|
end
|
49
49
|
|
50
|
-
@reporter.summary_report(@critic.problems,
|
50
|
+
@reporter.summary_report(@critic.problems,
|
51
|
+
output_file: @configuration.output_file)
|
52
|
+
|
51
53
|
@critic.problem_count(:error) > 0
|
52
54
|
end
|
53
55
|
|
data/lib/tailor/cli/options.rb
CHANGED
@@ -9,9 +9,11 @@ require_relative '../configuration'
|
|
9
9
|
class Tailor
|
10
10
|
class CLI
|
11
11
|
class Options
|
12
|
+
INTEGER_OR_OFF = /^(\d+|false|off)$/
|
12
13
|
@output_color = true
|
13
14
|
|
14
15
|
def self.parse!(args)
|
16
|
+
register_custom_option_types
|
15
17
|
options = OpenStruct.new
|
16
18
|
options.config_file = ''
|
17
19
|
options.output_file = ''
|
@@ -21,32 +23,32 @@ class Tailor
|
|
21
23
|
|
22
24
|
opts = OptionParser.new do |opt|
|
23
25
|
opt.banner = self.banner
|
24
|
-
opt.separator
|
25
|
-
opt.separator
|
26
|
-
opt.separator
|
27
|
-
opt.separator
|
26
|
+
opt.separator ''
|
27
|
+
opt.separator ' ' + ('-' * 73)
|
28
|
+
opt.separator ''
|
29
|
+
opt.separator 'Config file options:'
|
28
30
|
opt.on('-s', '--show-config', 'Show your current config.') do
|
29
31
|
options.show_config = true
|
30
32
|
end
|
31
33
|
|
32
34
|
opt.on('-c', '--config-file FILE',
|
33
|
-
|
35
|
+
'Use a specific config file.') do |config|
|
34
36
|
options.config_file = config
|
35
37
|
end
|
36
38
|
|
37
39
|
opt.on('-o', '--output-file FILE',
|
38
|
-
|
40
|
+
'Print result in a output file if using the proper formatter.') do |output|
|
39
41
|
options.output_file = output
|
40
42
|
end
|
41
43
|
|
42
44
|
opt.on('--create-config', 'Create a new .tailor file') do
|
43
45
|
if create_config
|
44
|
-
msg =
|
46
|
+
msg = 'Your new tailor config file was created at '
|
45
47
|
msg << "#{Dir.pwd}/.tailor"
|
46
48
|
$stdout.puts msg
|
47
49
|
exit
|
48
50
|
else
|
49
|
-
$stderr.puts
|
51
|
+
$stderr.puts 'Creation of .tailor failed!'
|
50
52
|
exit 1
|
51
53
|
end
|
52
54
|
end
|
@@ -54,14 +56,14 @@ class Tailor
|
|
54
56
|
#---------------------------------------------------------------------
|
55
57
|
# Style options
|
56
58
|
#---------------------------------------------------------------------
|
57
|
-
opt.separator
|
58
|
-
opt.separator
|
59
|
+
opt.separator ''
|
60
|
+
opt.separator 'Style Options:'
|
59
61
|
opt.separator " (Any option that doesn't have an explicit way of"
|
60
|
-
opt.separator
|
62
|
+
opt.separator ' turning it off can be done so simply by passing'
|
61
63
|
opt.separator " passing it 'false'.)"
|
62
64
|
|
63
|
-
opt.separator
|
64
|
-
opt.separator
|
65
|
+
opt.separator ''
|
66
|
+
opt.separator ' * Horizontal Spacing:'
|
65
67
|
opt.on('--allow-hard-tabs BOOL',
|
66
68
|
'Check for hard tabs? (default: true)') do |c|
|
67
69
|
options.style[:allow_hard_tabs] = c
|
@@ -73,70 +75,75 @@ class Tailor
|
|
73
75
|
options.style[:allow_trailing_line_spaces] = c
|
74
76
|
end
|
75
77
|
|
76
|
-
opt.on('--indentation-spaces NUMBER',
|
78
|
+
opt.on('--indentation-spaces NUMBER', INTEGER_OR_OFF,
|
77
79
|
'Spaces to expect indentation. (default: 2)') do |c|
|
78
80
|
options.style[:indentation_spaces] = c
|
79
81
|
end
|
80
82
|
|
81
|
-
opt.on('--max-line-length NUMBER',
|
83
|
+
opt.on('--max-line-length NUMBER', INTEGER_OR_OFF,
|
82
84
|
'Max characters in a line. (default: 80)') do |c|
|
83
85
|
options.style[:max_line_length] = c
|
84
86
|
end
|
85
87
|
|
86
|
-
opt.on('--spaces-after-comma NUMBER',
|
88
|
+
opt.on('--spaces-after-comma NUMBER', INTEGER_OR_OFF,
|
87
89
|
'Spaces to expect after a comma. (default: 1)') do |c|
|
88
90
|
options.style[:spaces_after_comma] = c
|
89
91
|
end
|
90
92
|
|
91
|
-
opt.on('--spaces-before-comma NUMBER',
|
93
|
+
opt.on('--spaces-before-comma NUMBER', INTEGER_OR_OFF,
|
92
94
|
'Spaces to expect before a comma. (default: 0)') do |c|
|
93
95
|
options.style[:spaces_before_comma] = c
|
94
96
|
end
|
95
97
|
|
96
|
-
opt.on('--spaces-after-
|
98
|
+
opt.on('--spaces-after-conditional NUMBER', INTEGER_OR_OFF,
|
99
|
+
'Spaces to expect after a conditional. (default: 1)') do |c|
|
100
|
+
options.style[:spaces_after_conditional] = c
|
101
|
+
end
|
102
|
+
|
103
|
+
opt.on('--spaces-after-lbrace NUMBER', INTEGER_OR_OFF,
|
97
104
|
'Spaces to expect after a {. (default: 1)') do |c|
|
98
105
|
options.style[:spaces_after_lbrace] = c
|
99
106
|
end
|
100
107
|
|
101
|
-
opt.on('--spaces-before-lbrace NUMBER',
|
108
|
+
opt.on('--spaces-before-lbrace NUMBER', INTEGER_OR_OFF,
|
102
109
|
'Spaces to expect before a {. (default: 1)') do |c|
|
103
110
|
options.style[:spaces_before_lbrace] = c
|
104
111
|
end
|
105
112
|
|
106
|
-
opt.on('--spaces-before-rbrace NUMBER',
|
113
|
+
opt.on('--spaces-before-rbrace NUMBER', INTEGER_OR_OFF,
|
107
114
|
'Spaces to expect before a }. (default: 1)') do |c|
|
108
115
|
options.style[:spaces_before_rbrace] = c
|
109
116
|
end
|
110
117
|
|
111
|
-
opt.on('--spaces-in-empty-braces NUMBER',
|
118
|
+
opt.on('--spaces-in-empty-braces NUMBER', INTEGER_OR_OFF,
|
112
119
|
'Spaces to expect between a { and }. (default: 0)') do |c|
|
113
120
|
options.style[:spaces_in_empty_braces] = c
|
114
121
|
end
|
115
122
|
|
116
|
-
opt.on('--spaces-after-lbracket NUMBER',
|
123
|
+
opt.on('--spaces-after-lbracket NUMBER', INTEGER_OR_OFF,
|
117
124
|
'Spaces to expect after a [. (default: 0)') do |c|
|
118
125
|
options.style[:spaces_after_lbracket] = c
|
119
126
|
end
|
120
127
|
|
121
|
-
opt.on('--spaces-before-rbracket NUMBER',
|
128
|
+
opt.on('--spaces-before-rbracket NUMBER', INTEGER_OR_OFF,
|
122
129
|
'Spaces to expect before a ]. (default: 0)') do |c|
|
123
130
|
options.style[:spaces_before_rbracket] = c
|
124
131
|
end
|
125
132
|
|
126
|
-
opt.on('--spaces-after-lparen NUMBER',
|
133
|
+
opt.on('--spaces-after-lparen NUMBER', INTEGER_OR_OFF,
|
127
134
|
'Spaces to expect after a (. (default: 0)') do |c|
|
128
135
|
options.style[:spaces_after_lparen] = c
|
129
136
|
end
|
130
137
|
|
131
|
-
opt.on('--spaces-before-rparen NUMBER',
|
138
|
+
opt.on('--spaces-before-rparen NUMBER', INTEGER_OR_OFF,
|
132
139
|
'Spaces to expect before a ). (default: 0)') do |c|
|
133
140
|
options.style[:spaces_before_rparen] = c
|
134
141
|
end
|
135
142
|
|
136
|
-
opt.separator
|
137
|
-
opt.separator
|
143
|
+
opt.separator ''
|
144
|
+
opt.separator ''
|
138
145
|
|
139
|
-
opt.separator
|
146
|
+
opt.separator ' * Naming:'
|
140
147
|
|
141
148
|
opt.on('--allow-camel-case-methods BOOL',
|
142
149
|
'Check for camel-case method names?', '(default: true)') do |c|
|
@@ -149,21 +156,21 @@ class Tailor
|
|
149
156
|
instance_eval(c)
|
150
157
|
end
|
151
158
|
|
152
|
-
opt.separator
|
153
|
-
opt.separator
|
154
|
-
opt.separator
|
159
|
+
opt.separator ''
|
160
|
+
opt.separator ''
|
161
|
+
opt.separator ' * Vertical Spacing'
|
155
162
|
|
156
|
-
opt.on('--max-code-lines-in-class NUMBER',
|
163
|
+
opt.on('--max-code-lines-in-class NUMBER', INTEGER_OR_OFF,
|
157
164
|
'Max number lines of code in a class.', '(default: 300)') do |c|
|
158
165
|
options.style[:max_code_lines_in_class] = c
|
159
166
|
end
|
160
167
|
|
161
|
-
opt.on('--max-code-lines-in-method NUMBER',
|
168
|
+
opt.on('--max-code-lines-in-method NUMBER', INTEGER_OR_OFF,
|
162
169
|
'Max number lines of code in a method.', '(default: 30)') do |c|
|
163
170
|
options.style[:max_code_lines_in_method] = c
|
164
171
|
end
|
165
172
|
|
166
|
-
opt.on('--trailing-newlines NUMBER',
|
173
|
+
opt.on('--trailing-newlines NUMBER', INTEGER_OR_OFF,
|
167
174
|
'Newlines to expect at the end of the file.', '(default: 1)') do |c|
|
168
175
|
options.style[:trailing_newlines] = c
|
169
176
|
end
|
@@ -171,8 +178,8 @@ class Tailor
|
|
171
178
|
#---------------------------------------------------------------------
|
172
179
|
# Common options
|
173
180
|
#---------------------------------------------------------------------
|
174
|
-
opt.separator
|
175
|
-
opt.separator
|
181
|
+
opt.separator ''
|
182
|
+
opt.separator 'Common options:'
|
176
183
|
|
177
184
|
=begin
|
178
185
|
opt.on('-f', '--format FORMATTER') do |format|
|
@@ -180,16 +187,16 @@ class Tailor
|
|
180
187
|
end
|
181
188
|
=end
|
182
189
|
|
183
|
-
opt.on('--[no-]color',
|
190
|
+
opt.on('--[no-]color', 'Output in color') do |color|
|
184
191
|
@output_color = color
|
185
192
|
end
|
186
193
|
|
187
|
-
opt.on_tail('-v', '--version',
|
194
|
+
opt.on_tail('-v', '--version', 'Show the version') do
|
188
195
|
puts version
|
189
196
|
exit
|
190
197
|
end
|
191
198
|
|
192
|
-
opt.on_tail('-d', '--debug',
|
199
|
+
opt.on_tail('-d', '--debug', 'Turn on debug logging') do
|
193
200
|
Tailor::Logger.log = true
|
194
201
|
end
|
195
202
|
|
@@ -269,6 +276,19 @@ tailor --show-config
|
|
269
276
|
File.open('.tailor', 'w') { |f| f.write default_config_file }
|
270
277
|
end
|
271
278
|
end
|
279
|
+
|
280
|
+
def self.register_custom_option_types
|
281
|
+
# We need to be able to mark integer options as :off as zero may be a
|
282
|
+
# valid value.
|
283
|
+
OptionParser.accept(INTEGER_OR_OFF) do |s|
|
284
|
+
raise OptionParser::InvalidArgument unless s =~ INTEGER_OR_OFF
|
285
|
+
if s == false.to_s || s == 'off'
|
286
|
+
:off
|
287
|
+
else
|
288
|
+
s.to_i
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
272
292
|
end
|
273
293
|
end
|
274
294
|
end
|
data/lib/tailor/configuration.rb
CHANGED
@@ -68,7 +68,7 @@ class Tailor
|
|
68
68
|
get_file_sets_from_config_file
|
69
69
|
end
|
70
70
|
else
|
71
|
-
log
|
71
|
+
log 'Creating default file set...'
|
72
72
|
@file_sets = { default: FileSet.new(@runtime_file_list) }
|
73
73
|
end
|
74
74
|
|
@@ -89,7 +89,8 @@ class Tailor
|
|
89
89
|
log "Loading config from file: #{user_config_file}"
|
90
90
|
|
91
91
|
begin
|
92
|
-
@config_from_file =
|
92
|
+
@config_from_file =
|
93
|
+
instance_eval(File.read(user_config_file), user_config_file)
|
93
94
|
log "Got new config from file: #{user_config_file}"
|
94
95
|
rescue LoadError => ex
|
95
96
|
raise Tailor::RuntimeError,
|
@@ -122,7 +123,7 @@ class Tailor
|
|
122
123
|
log "file set style: #{file_set[:style]}"
|
123
124
|
|
124
125
|
if @file_sets[label]
|
125
|
-
log
|
126
|
+
log 'label already exists. Updating...'
|
126
127
|
@file_sets[label].update_file_list(file_set[:file_list])
|
127
128
|
@file_sets[label].update_style(file_set[:style])
|
128
129
|
else
|
@@ -145,7 +146,7 @@ class Tailor
|
|
145
146
|
|
146
147
|
@options.style.each do |property, value|
|
147
148
|
@file_sets.keys.each do |label|
|
148
|
-
if value == :off || value ==
|
149
|
+
if value == :off || value == 'off'
|
149
150
|
@file_sets[label].style[property][1] = { level: :off }
|
150
151
|
else
|
151
152
|
@file_sets[label].style[property][0] = value
|
@@ -213,7 +214,9 @@ class Tailor
|
|
213
214
|
# @param [String] file_expression The expression to match recursively.
|
214
215
|
# @param [Symbol] label The file set label to use.
|
215
216
|
def recursive_file_set(file_expression, label=:default)
|
216
|
-
file_set("*/**/#{file_expression}", label)
|
217
|
+
file_set("*/**/#{file_expression}", label) do |style|
|
218
|
+
yield style if block_given?
|
219
|
+
end
|
217
220
|
end
|
218
221
|
|
219
222
|
# Displays the current configuration as a text table.
|
@@ -99,11 +99,9 @@ class Tailor
|
|
99
99
|
# @param [String] base_dir The directory to get the file list for.
|
100
100
|
# @return [Array<String>] The List of files.
|
101
101
|
def all_files_in_dir(base_dir)
|
102
|
-
|
102
|
+
Dir.glob(File.join(base_dir, '**', '*')).find_all do |file|
|
103
103
|
file if File.file?(file)
|
104
104
|
end
|
105
|
-
|
106
|
-
files
|
107
105
|
end
|
108
106
|
end
|
109
107
|
end
|
@@ -35,6 +35,7 @@ class Tailor
|
|
35
35
|
define_property :max_code_lines_in_method
|
36
36
|
define_property :max_line_length
|
37
37
|
define_property :spaces_after_comma
|
38
|
+
define_property :spaces_after_conditional
|
38
39
|
define_property :spaces_after_lbrace
|
39
40
|
define_property :spaces_after_lbracket
|
40
41
|
define_property :spaces_after_lparen
|
@@ -58,6 +59,7 @@ class Tailor
|
|
58
59
|
max_code_lines_in_method(30, level: :error)
|
59
60
|
max_line_length(80, level: :error)
|
60
61
|
spaces_after_comma(1, level: :error)
|
62
|
+
spaces_after_conditional(1, level: :error)
|
61
63
|
spaces_after_lbrace(1, level: :error)
|
62
64
|
spaces_after_lbracket(0, level: :error)
|
63
65
|
spaces_after_lparen(0, level: :error)
|
data/lib/tailor/critic.rb
CHANGED
@@ -65,7 +65,7 @@ class Tailor
|
|
65
65
|
log "<#{self.class}> Checking style of file: #{file}."
|
66
66
|
lexer = Tailor::Lexer.new(file)
|
67
67
|
ruler = Ruler.new
|
68
|
-
log
|
68
|
+
log 'Style:'
|
69
69
|
style.each { |property, values| log "#{property}: #{values}" }
|
70
70
|
init_rulers(style, lexer, ruler)
|
71
71
|
|
@@ -89,7 +89,7 @@ class Tailor
|
|
89
89
|
style.each do |ruler_name, values|
|
90
90
|
ruler = "Tailor::Rulers::#{camelize(ruler_name.to_s)}Ruler"
|
91
91
|
|
92
|
-
if values.last[:level] == :off || values.last[:level] ==
|
92
|
+
if values.last[:level] == :off || values.last[:level] == 'off'
|
93
93
|
msg = "Style option set to '#{values.last[:level]}'; "
|
94
94
|
log msg << "skipping init of '#{ruler}'"
|
95
95
|
next
|
@@ -21,7 +21,7 @@ class Tailor
|
|
21
21
|
# @return [String] The portion of the header that displays the file info.
|
22
22
|
def file_header(file)
|
23
23
|
file = Pathname(file)
|
24
|
-
message =
|
24
|
+
message = '# '
|
25
25
|
message << underscore { "File:\n" }
|
26
26
|
message << "# #{file.relative_path_from(@pwd)}\n"
|
27
27
|
message << "#\n"
|
@@ -32,7 +32,7 @@ class Tailor
|
|
32
32
|
# @return [String] The portion of the header that displays the file_set
|
33
33
|
# label info.
|
34
34
|
def file_set_header(file_set)
|
35
|
-
message =
|
35
|
+
message = '# '
|
36
36
|
message << underscore { "File Set:\n" }
|
37
37
|
message << "# #{file_set}\n"
|
38
38
|
message << "#\n"
|
@@ -43,19 +43,19 @@ class Tailor
|
|
43
43
|
# @return [String] The portion of the report that displays all of the
|
44
44
|
# problems for the file.
|
45
45
|
def problems_header(problem_list)
|
46
|
-
message =
|
46
|
+
message = '# '
|
47
47
|
message << underscore { "Problems:\n" }
|
48
48
|
|
49
49
|
problem_list.each_with_index do |problem, i|
|
50
50
|
color = PROBLEM_LEVEL_COLORS[problem[:level]] || 'white'
|
51
51
|
|
52
52
|
position = position(problem[:line], problem[:column])
|
53
|
-
message <<
|
54
|
-
message <<
|
53
|
+
message << '# ' + bold { "#{(i + 1)}." } + "\n"
|
54
|
+
message << '# * position: '
|
55
55
|
message << bold { instance_eval("#{color} position") } + "\n"
|
56
|
-
message <<
|
56
|
+
message << '# * property: '
|
57
57
|
message << instance_eval("#{color} problem[:type].to_s") + "\n"
|
58
|
-
message <<
|
58
|
+
message << '# * message: '
|
59
59
|
message << instance_eval("#{color} problem[:message].to_s") + "\n"
|
60
60
|
end
|
61
61
|
|
@@ -108,14 +108,14 @@ class Tailor
|
|
108
108
|
bold { report_line }
|
109
109
|
end
|
110
110
|
|
111
|
-
summary_table <<
|
111
|
+
summary_table << '# ' << report_line << reset << "|\n"
|
112
112
|
i += 1
|
113
113
|
end
|
114
114
|
|
115
115
|
summary_table << line
|
116
116
|
summary_table << summary_level_totals(problems)
|
117
|
-
summary_table <<
|
118
|
-
summary_table <<
|
117
|
+
summary_table << '# ' << bold{ summary_first_col('TOTAL', 67) }
|
118
|
+
summary_table << '|'
|
119
119
|
summary_table << bold { total_problems(problems).to_s.rjust(6) }
|
120
120
|
summary_table << " |\n"
|
121
121
|
summary_table << line
|
@@ -125,7 +125,7 @@ class Tailor
|
|
125
125
|
|
126
126
|
def summary_header
|
127
127
|
summary_table = line
|
128
|
-
summary_table <<
|
128
|
+
summary_table << '# '
|
129
129
|
summary_table << bold { 'Tailor Summary'.rjust(40) }
|
130
130
|
summary_table << "|\n".rjust(39)
|
131
131
|
summary_table << line
|
@@ -142,7 +142,8 @@ class Tailor
|
|
142
142
|
relative_path = file.relative_path_from(@pwd)
|
143
143
|
problem_count = problem_list.size
|
144
144
|
|
145
|
-
"#{summary_first_col(relative_path)} | " +
|
145
|
+
"#{summary_first_col(relative_path)} | " +
|
146
|
+
problem_count.to_s.rjust(5) + ' '
|
146
147
|
end
|
147
148
|
|
148
149
|
def summary_first_col(path, string_size=MAX_STRING_SIZE)
|
@@ -155,14 +156,14 @@ class Tailor
|
|
155
156
|
end
|
156
157
|
|
157
158
|
def summary_level_totals(problems)
|
158
|
-
return
|
159
|
+
return '' if total_problems(problems).zero?
|
159
160
|
|
160
|
-
output = problem_levels(problems).inject(
|
161
|
+
output = problem_levels(problems).inject('') do |result, level|
|
161
162
|
color = PROBLEM_LEVEL_COLORS[level] || 'white'
|
162
163
|
|
163
|
-
result <<
|
164
|
+
result << '# '
|
164
165
|
result << instance_eval("#{color} { summary_first_col(level.capitalize, 67) }")
|
165
|
-
result <<
|
166
|
+
result << '|'
|
166
167
|
result << instance_eval("#{color} { problems_at_level(problems, level).size.to_s.rjust(6) }")
|
167
168
|
result << " |\n"
|
168
169
|
end
|