tailor 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -3
  3. data/Gemfile.lock +39 -31
  4. data/History.md +220 -207
  5. data/README.md +58 -45
  6. data/features/step_definitions/indentation_steps.rb +1 -1
  7. data/lib/tailor/reporter.rb +19 -7
  8. data/lib/tailor/rulers/spaces_before_lbrace_ruler.rb +0 -1
  9. data/lib/tailor/rulers/spaces_before_rbrace_ruler.rb +0 -1
  10. data/lib/tailor/rulers/spaces_in_empty_braces_ruler.rb +0 -1
  11. data/lib/tailor/version.rb +1 -1
  12. data/spec/functional/conditional_parentheses_spec.rb +1 -1
  13. data/spec/functional/conditional_spacing_spec.rb +1 -1
  14. data/spec/functional/configuration_spec.rb +61 -52
  15. data/spec/functional/horizontal_spacing/braces_spec.rb +134 -134
  16. data/spec/functional/horizontal_spacing/brackets_spec.rb +34 -36
  17. data/spec/functional/horizontal_spacing/comma_spacing_spec.rb +25 -27
  18. data/spec/functional/horizontal_spacing/hard_tabs_spec.rb +42 -42
  19. data/spec/functional/horizontal_spacing/long_lines_spec.rb +15 -17
  20. data/spec/functional/horizontal_spacing/long_methods_spec.rb +4 -4
  21. data/spec/functional/horizontal_spacing/parens_spec.rb +45 -45
  22. data/spec/functional/horizontal_spacing/trailing_whitespace_spec.rb +7 -8
  23. data/spec/functional/horizontal_spacing_spec.rb +10 -11
  24. data/spec/functional/indentation_spacing/argument_alignment_spec.rb +33 -62
  25. data/spec/functional/indentation_spacing/bad_indentation_spec.rb +176 -179
  26. data/spec/functional/indentation_spacing_spec.rb +13 -14
  27. data/spec/functional/naming/camel_case_methods_spec.rb +4 -6
  28. data/spec/functional/naming/screaming_snake_case_classes_spec.rb +28 -31
  29. data/spec/functional/naming_spec.rb +3 -3
  30. data/spec/functional/rake_task_spec.rb +9 -28
  31. data/spec/functional/string_interpolation_spec.rb +1 -1
  32. data/spec/functional/string_quoting_spec.rb +1 -1
  33. data/spec/functional/vertical_spacing/class_length_spec.rb +4 -6
  34. data/spec/functional/vertical_spacing/method_length_spec.rb +15 -17
  35. data/spec/functional/vertical_spacing_spec.rb +3 -3
  36. data/spec/spec_helper.rb +2 -0
  37. data/spec/support/argument_alignment_cases.rb +32 -32
  38. data/spec/support/conditional_parentheses_cases.rb +26 -26
  39. data/spec/support/good_indentation_cases.rb +205 -205
  40. data/spec/support/horizontal_spacing_cases.rb +53 -54
  41. data/spec/support/line_indentation_cases.rb +20 -20
  42. data/spec/support/naming_cases.rb +12 -12
  43. data/spec/support/string_interpolation_cases.rb +17 -17
  44. data/spec/support/string_quoting_cases.rb +12 -12
  45. data/spec/support/vertical_spacing_cases.rb +8 -8
  46. data/spec/unit/tailor/cli/options_spec.rb +20 -14
  47. data/spec/unit/tailor/cli_spec.rb +29 -43
  48. data/spec/unit/tailor/composite_observable_spec.rb +1 -1
  49. data/spec/unit/tailor/configuration/file_set_spec.rb +10 -11
  50. data/spec/unit/tailor/configuration/style_spec.rb +41 -42
  51. data/spec/unit/tailor/configuration_spec.rb +14 -12
  52. data/spec/unit/tailor/formatter_spec.rb +3 -3
  53. data/spec/unit/tailor/formatters/yaml_spec.rb +12 -13
  54. data/spec/unit/tailor/lexed_line_spec.rb +67 -69
  55. data/spec/unit/tailor/lexer/token_spec.rb +7 -7
  56. data/spec/unit/tailor/lexer_spec.rb +24 -24
  57. data/spec/unit/tailor/problem_spec.rb +12 -12
  58. data/spec/unit/tailor/reporter_spec.rb +8 -9
  59. data/spec/unit/tailor/ruler_spec.rb +10 -10
  60. data/spec/unit/tailor/rulers/indentation_spaces_ruler/indentation_manager_spec.rb +90 -86
  61. data/spec/unit/tailor/rulers/indentation_spaces_ruler_spec.rb +13 -13
  62. data/spec/unit/tailor/rulers/spaces_after_comma_ruler_spec.rb +4 -4
  63. data/spec/unit/tailor/rulers/spaces_after_lbrace_ruler_spec.rb +19 -19
  64. data/spec/unit/tailor/rulers/spaces_before_lbrace_ruler_spec.rb +6 -6
  65. data/spec/unit/tailor/rulers/spaces_before_rbrace_ruler_spec.rb +6 -6
  66. data/spec/unit/tailor/rulers_spec.rb +1 -1
  67. data/spec/unit/tailor/version_spec.rb +1 -2
  68. data/spec/unit/tailor_spec.rb +2 -2
  69. data/tailor.gemspec +3 -3
  70. metadata +20 -6
@@ -1,8 +1,10 @@
1
1
  require 'fakefs/spec_helpers'
2
+ require 'rspec/its'
2
3
  require 'simplecov'
3
4
 
4
5
  SimpleCov.start
5
6
 
7
+
6
8
  RSpec.configure do |config|
7
9
  config.include FakeFS::SpecHelpers
8
10
 
@@ -1,93 +1,93 @@
1
1
  ARG_INDENT = {}
2
2
 
3
3
  ARG_INDENT['def_no_arguments'] =
4
- %q{def foo
4
+ %(def foo
5
5
  true
6
- end}
6
+ end)
7
7
 
8
8
  ARG_INDENT['def_arguments_fit_on_one_line'] =
9
- %q{def foo(foo, bar, baz)
9
+ %(def foo(foo, bar, baz)
10
10
  true
11
- end}
11
+ end)
12
12
 
13
13
  ARG_INDENT['def_arguments_aligned'] =
14
- %q{def something(waka, baka, bing,
14
+ %(def something(waka, baka, bing,
15
15
  bla, goop, foop)
16
16
  stuff
17
17
  end
18
- }
18
+ )
19
19
 
20
20
  ARG_INDENT['def_arguments_indented'] =
21
- %q{def something(waka, baka, bing,
21
+ %(def something(waka, baka, bing,
22
22
  bla, goop, foop)
23
23
  stuff
24
24
  end
25
- }
25
+ )
26
26
 
27
27
  ARG_INDENT['call_no_arguments'] =
28
- %q{bla = method()}
28
+ %(bla = method())
29
29
 
30
30
  ARG_INDENT['call_arguments_fit_on_one_line'] =
31
- %q{bla = method(foo, bar, baz, bing, ding)}
31
+ %(bla = method(foo, bar, baz, bing, ding))
32
32
 
33
33
  ARG_INDENT['call_arguments_aligned'] =
34
- %q{bla = Something::SomethingElse::SomeClass.method(foo, bar, baz,
34
+ %(bla = Something::SomethingElse::SomeClass.method(foo, bar, baz,
35
35
  bing, ding)
36
- }
36
+ )
37
37
 
38
38
  ARG_INDENT['call_arguments_aligned_args_are_integer_literals'] =
39
- %q{bla = Something::SomethingElse::SomeClass.method(1, 2, 3,
39
+ %(bla = Something::SomethingElse::SomeClass.method(1, 2, 3,
40
40
  4, 5)
41
- }
41
+ )
42
42
 
43
43
  ARG_INDENT['call_arguments_aligned_args_are_string_literals'] =
44
- %q{bla = Something::SomethingElse::SomeClass.method('foo', 'bar', 'baz',
44
+ %(bla = Something::SomethingElse::SomeClass.method('foo', 'bar', 'baz',
45
45
  'bing', 'ding')
46
- }
46
+ )
47
47
 
48
48
  ARG_INDENT['call_arguments_aligned_args_have_parens'] =
49
- %q{bla = Something::SomethingElse::SomeClass.method(foo, bar(), baz,
49
+ %(bla = Something::SomethingElse::SomeClass.method(foo, bar(), baz,
50
50
  bing, ding)
51
- }
51
+ )
52
52
 
53
53
  ARG_INDENT['call_arguments_aligned_no_parens'] =
54
- %q{bla = Something::SomethingElse::SomeClass.method foo, bar, baz,
54
+ %(bla = Something::SomethingElse::SomeClass.method foo, bar, baz,
55
55
  bing, ding
56
- }
56
+ )
57
57
 
58
58
  ARG_INDENT['call_arguments_aligned_multiple_lines'] =
59
- %q{bla = Something::SomethingElse::SomeClass.method(foo, bar, baz,
59
+ %(bla = Something::SomethingElse::SomeClass.method(foo, bar, baz,
60
60
  bing, ding,
61
61
  ginb, gind)
62
- }
62
+ )
63
63
 
64
64
  ARG_INDENT['call_arguments_indented'] =
65
- %q{bla = Something::SomethingElse::SomeClass.method(foo, bar, baz,
65
+ %(bla = Something::SomethingElse::SomeClass.method(foo, bar, baz,
66
66
  bing, ding)
67
- }
67
+ )
68
68
 
69
69
  ARG_INDENT['call_arguments_indented_separate_line'] =
70
- %q{bla = Something::SomethingElse::SomeClass.method(
70
+ %(bla = Something::SomethingElse::SomeClass.method(
71
71
  foo, bar, baz,
72
72
  bing, ding
73
- )}
73
+ ))
74
74
 
75
75
  ARG_INDENT['call_arguments_on_next_line'] =
76
- %q{some_long_method_that_goes_out_to_the_end_of_the_line(
76
+ %(some_long_method_that_goes_out_to_the_end_of_the_line(
77
77
  foo, bar)
78
- }
78
+ )
79
79
 
80
80
  ARG_INDENT['call_arguments_on_next_line_nested'] =
81
- %q{if some_long_method_that_goes_out_to_the_end_of_the_line(
81
+ %(if some_long_method_that_goes_out_to_the_end_of_the_line(
82
82
  foo, bar)
83
83
  my_nested_expression
84
- end}
84
+ end)
85
85
 
86
86
  ARG_INDENT['call_arguments_on_next_line_multiple'] =
87
- %q{some_long_method_that_goes_out_to_the_end_of_the_line(
87
+ %(some_long_method_that_goes_out_to_the_end_of_the_line(
88
88
  foo, bar)
89
89
 
90
90
  if diff_long_method_that_goes_out_to_the_end_of_the_line(
91
91
  foo, bar)
92
92
  my_nested_expression
93
- end}
93
+ end)
@@ -1,60 +1,60 @@
1
1
  CONDITIONAL_PARENTHESES = {}
2
2
 
3
3
  CONDITIONAL_PARENTHESES['no_parentheses'] =
4
- %q{if foo
5
- end}
4
+ %(if foo
5
+ end)
6
6
 
7
7
  CONDITIONAL_PARENTHESES['with_parentheses'] =
8
- %q{if (foo)
9
- end}
8
+ %(if (foo)
9
+ end)
10
10
 
11
11
  CONDITIONAL_PARENTHESES['with_parentheses_no_space'] =
12
- %q{if(foo)
13
- end}
12
+ %(if(foo)
13
+ end)
14
14
 
15
15
  CONDITIONAL_PARENTHESES['method_call'] =
16
- %q{if foo(bar)
17
- end}
16
+ %(if foo(bar)
17
+ end)
18
18
 
19
19
  CONDITIONAL_PARENTHESES['indented_method_call'] =
20
- %q{foo do
20
+ %(foo do
21
21
  if foo(bar)
22
22
  end
23
- end}
23
+ end)
24
24
 
25
25
  CONDITIONAL_PARENTHESES['method_call_on_parens'] =
26
- %q{unless (foo & bar).sort
26
+ %(unless (foo & bar).sort
27
27
  end
28
- }
28
+ )
29
29
 
30
30
  CONDITIONAL_PARENTHESES['double_parens'] =
31
- %q{if ((bar))
32
- end}
31
+ %(if ((bar))
32
+ end)
33
33
 
34
34
  CONDITIONAL_PARENTHESES['unless_no_parentheses'] =
35
- %q{unless bar
36
- end}
35
+ %(unless bar
36
+ end)
37
37
 
38
38
  CONDITIONAL_PARENTHESES['unless_with_parentheses'] =
39
- %q{unless (bar)
40
- end}
39
+ %(unless (bar)
40
+ end)
41
41
 
42
42
  CONDITIONAL_PARENTHESES['case_no_parentheses'] =
43
- %q{case bar
43
+ %(case bar
44
44
  when 1 then 'a'
45
45
  when 2 then 'b'
46
- end}
46
+ end)
47
47
 
48
48
  CONDITIONAL_PARENTHESES['case_with_parentheses'] =
49
- %q{case (bar)
49
+ %(case (bar)
50
50
  when 1 then 'a'
51
51
  when 2 then 'b'
52
- end}
52
+ end)
53
53
 
54
54
  CONDITIONAL_PARENTHESES['while_no_parentheses'] =
55
- %q{while bar
56
- end}
55
+ %(while bar
56
+ end)
57
57
 
58
58
  CONDITIONAL_PARENTHESES['while_with_parentheses'] =
59
- %q{while (bar)
60
- end}
59
+ %(while (bar)
60
+ end)
@@ -1,84 +1,84 @@
1
1
  INDENT_OK = {}
2
2
 
3
3
  INDENT_OK['class'] =
4
- %Q{class MyClass
5
- end}
4
+ %(class MyClass
5
+ end)
6
6
 
7
7
  INDENT_OK['one_line_class'] =
8
- %Q{class MyClass; end}
8
+ %(class MyClass; end)
9
9
 
10
10
  INDENT_OK['one_line_subclass'] =
11
- %Q{class MyClass < RuntimeError; end}
11
+ %(class MyClass < RuntimeError; end)
12
12
 
13
13
  INDENT_OK['one_line_subclass_with_inheritance'] =
14
- %Q{class MyClass < Array
14
+ %(class MyClass < Array
15
15
  class MyError < RuntimeError; end
16
16
  include AnotherThing
17
- end}
17
+ end)
18
18
 
19
19
  INDENT_OK['class_empty'] =
20
- %Q{class MyClass
20
+ %(class MyClass
21
21
 
22
- end}
22
+ end)
23
23
 
24
24
  INDENT_OK['class_empty_trailing_comment'] =
25
- %Q{class MyClass # Comment!
25
+ %(class MyClass # Comment!
26
26
 
27
- end}
27
+ end)
28
28
 
29
29
  INDENT_OK['class_singlestatement'] =
30
- %Q{class MyClass
30
+ %(class MyClass
31
31
  include Stuff
32
- end}
32
+ end)
33
33
 
34
34
  INDENT_OK['assignment_addition_multistatement'] =
35
- %Q{thing = 1 +
35
+ %(thing = 1 +
36
36
  2 + 3 + 4 +
37
- 5}
37
+ 5)
38
38
 
39
39
  INDENT_OK['assignment_addition_multistatement_trailing_comment'] =
40
- %Q{thing = 1 + # Comment!
40
+ %(thing = 1 + # Comment!
41
41
  2 + 3 + 4 +
42
- 5}
42
+ 5)
43
43
 
44
44
  INDENT_OK['assignment_hash_multistatement'] =
45
- %Q{thing = {
45
+ %(thing = {
46
46
  :one => 'one',
47
47
  two: 'two'
48
- }}
48
+ })
49
49
 
50
50
  INDENT_OK['assignment_hash_multistatement_trailing_comment'] =
51
- %Q{thing = {
51
+ %(thing = {
52
52
  :one => 'one', # Comment
53
53
  two: 'two'
54
- }}
54
+ })
55
55
 
56
56
  INDENT_OK['assignment_array_multistatement'] =
57
- %Q{thing = [
57
+ %(thing = [
58
58
  :one,
59
59
  :two
60
- ]}
60
+ ])
61
61
 
62
62
  INDENT_OK['assignment_array_multistatement_trailing_comment'] =
63
- %Q{thing = [
63
+ %(thing = [
64
64
  :one, # comment
65
65
  :two
66
- ]}
66
+ ])
67
67
 
68
68
  INDENT_OK['assignment_paren_multistatement'] =
69
- %Q{eval('puts',
69
+ %(eval('puts',
70
70
  binding,
71
71
  'my_file.rb',
72
- 5)}
72
+ 5))
73
73
 
74
74
  INDENT_OK['assignment_paren_multistatement_trailing_comment'] =
75
- %Q{eval('puts',
75
+ %(eval('puts',
76
76
  binding,
77
77
  'my_file.rb', # comment
78
- 5)}
78
+ 5))
79
79
 
80
80
  INDENT_OK['assignment_twolevel_hash_multistatement'] =
81
- %Q{thing = {
81
+ %(thing = {
82
82
  :one => {
83
83
  :a => 'a',
84
84
  b: 'b'
@@ -87,56 +87,56 @@ INDENT_OK['assignment_twolevel_hash_multistatement'] =
87
87
  x: 'x',
88
88
  :y => 'y'
89
89
  }
90
- }}
90
+ })
91
91
 
92
92
  INDENT_OK['assignment_twolevel_array_multistatement'] =
93
- %Q{thing = [
93
+ %(thing = [
94
94
  [:one],
95
95
  [
96
96
  :two,
97
97
  :three
98
98
  ]
99
- ]}
99
+ ])
100
100
 
101
101
  INDENT_OK['assignment_twolevel_paren_multistatement'] =
102
- %Q{result = Integer(
102
+ %(result = Integer(
103
103
  String.new(
104
104
  '1'
105
105
  ).to_i,
106
106
  16
107
- )}
107
+ ))
108
108
 
109
109
  INDENT_OK['method_call_multistatement'] =
110
- %Q{my_method_with_many_params(one, two,
110
+ %(my_method_with_many_params(one, two,
111
111
  three,
112
112
  four,
113
- five)}
113
+ five))
114
114
 
115
115
  INDENT_OK['method_call_multistatement_trailing_comment'] =
116
- %Q{my_method_with_many_params(one, two,
116
+ %(my_method_with_many_params(one, two,
117
117
  three, # comment
118
118
  four,
119
- five)}
119
+ five))
120
120
 
121
121
  INDENT_OK['method_call_multistatement_lonely_paren'] =
122
- %Q{my_method_with_many_params(one, two,
122
+ %(my_method_with_many_params(one, two,
123
123
  three,
124
124
  four,
125
125
  five
126
- )}
126
+ ))
127
127
 
128
128
  INDENT_OK['method_call_multistatement_lonely_paren_trailing_comment'] =
129
- %Q{my_method_with_many_params(one, two, # comment
129
+ %(my_method_with_many_params(one, two, # comment
130
130
  three,
131
131
  four,
132
132
  five
133
- )}
133
+ ))
134
134
 
135
135
  #-------------------------------------------------------------------------------
136
136
  # Continuation keywords
137
137
  #-------------------------------------------------------------------------------
138
138
  INDENT_OK['rescue_ending_with_comma'] =
139
- %Q{begin
139
+ %(begin
140
140
  ssh.upload source, dest
141
141
  @logger.info "Successfully copied the file \#{source} to " +
142
142
  "\#{@config[:scp_hostname]}:\#{dest}."
@@ -144,10 +144,10 @@ rescue SocketError, ArgumentError, SystemCallError,
144
144
  Net::SCP::Exception, Timeout::Error => ex
145
145
  @logger.error "Failed to copy the file \#{source} to \#{dest} due to " +
146
146
  ex.message
147
- end}
147
+ end)
148
148
 
149
149
  INDENT_OK['rescue_ending_with_comma_trailing_comment'] =
150
- %Q{begin
150
+ %(begin
151
151
  ssh.upload source, dest
152
152
  @logger.info "Successfully copied the file \#{source} to " +
153
153
  "\#{@config[:scp_hostname]}:\#{dest}."
@@ -155,79 +155,79 @@ rescue SocketError, ArgumentError, SystemCallError, # comment
155
155
  Net::SCP::Exception, Timeout::Error => ex
156
156
  @logger.error "Failed to copy the file \#{source} to \#{dest} due to " +
157
157
  ex.message
158
- end}
158
+ end)
159
159
 
160
160
  INDENT_OK['def_rescue'] =
161
- %Q{def some_method
161
+ %(def some_method
162
162
  do_something(one, two)
163
163
  rescue => e
164
164
  log 'It didn't work.'
165
165
  raise e
166
- end}
166
+ end)
167
167
 
168
168
  INDENT_OK['keyword_ending_with_period'] =
169
- %Q{if [].
169
+ %(if [].
170
170
  empty?
171
171
  puts 'hi'
172
- end}
172
+ end)
173
173
 
174
174
  INDENT_OK['keyword_ending_with_period_trailing_comment'] =
175
- %Q{if []. # comment
175
+ %(if []. # comment
176
176
  empty?
177
177
  puts 'hi'
178
- end}
178
+ end)
179
179
 
180
180
  INDENT_OK['def'] =
181
- %Q{def a_method
182
- end}
181
+ %(def a_method
182
+ end)
183
183
 
184
184
  INDENT_OK['def_empty'] =
185
- %Q{def a_method
185
+ %(def a_method
186
186
 
187
- end}
187
+ end)
188
188
 
189
189
  INDENT_OK['nested_def'] =
190
- %Q{def first_method
190
+ %(def first_method
191
191
  def second_method
192
192
  puts 'hi'
193
193
  end
194
- end}
194
+ end)
195
195
 
196
196
  INDENT_OK['nested_class'] =
197
- %Q{class MyClass
197
+ %(class MyClass
198
198
  class AnotherClass
199
199
  end
200
- end}
200
+ end)
201
201
 
202
202
  INDENT_OK['require_class_singlestatement'] =
203
- %Q{require 'time'
203
+ %(require 'time'
204
204
 
205
205
  class MyClass
206
206
  include Stuff
207
- end}
207
+ end)
208
208
 
209
209
  INDENT_OK['class_as_symbol'] =
210
- %Q{INDENT_OK = {}
210
+ %(INDENT_OK = {}
211
211
 
212
212
  INDENT_OK[:class] =
213
213
  %Q{class MyClass
214
214
  end}
215
215
 
216
216
  INDENT_OK[:one_line_class] =
217
- %Q{class MyClass; end}}
217
+ %Q{class MyClass; end})
218
218
 
219
219
  INDENT_OK['require_class_singlestatement_def'] =
220
- %Q{require 'time'
220
+ %(require 'time'
221
221
 
222
222
  class MyClass
223
223
  include Stuff
224
224
 
225
225
  def a_method
226
226
  end
227
- end}
227
+ end)
228
228
 
229
229
  INDENT_OK['require_class_singlestatement_def_content'] =
230
- %Q{require 'time'
230
+ %(require 'time'
231
231
 
232
232
  class MyClass
233
233
  include Stuff
@@ -235,201 +235,201 @@ class MyClass
235
235
  def a_method
236
236
  puts 'hello'
237
237
  end
238
- end}
238
+ end)
239
239
 
240
240
  INDENT_OK['if_modifier'] =
241
- %Q{puts 'hi' if nil.nil?}
241
+ %(puts 'hi' if nil.nil?)
242
242
 
243
243
  INDENT_OK['if_modifier2'] =
244
- %Q{start_key_registration_server if @profiles.values.include? :SM5000}
244
+ %(start_key_registration_server if @profiles.values.include? :SM5000)
245
245
 
246
246
  INDENT_OK['def_return_if_modifier'] =
247
- %Q{def a_method
247
+ %(def a_method
248
248
  return @something if @something
249
- end}
249
+ end)
250
250
 
251
251
  INDENT_OK['unless_modifier'] =
252
- %Q{puts 'hi' unless nil.nil?}
252
+ %(puts 'hi' unless nil.nil?)
253
253
 
254
254
  INDENT_OK['def_return_unless_modifier'] =
255
- %Q{def a_method
255
+ %(def a_method
256
256
  return @something unless @something
257
- end}
257
+ end)
258
258
 
259
259
  INDENT_OK['multi_line_if_with_trailing_andop'] =
260
- %Q{unless Tim::Runner.configuration[:scp_hostname].nil?
260
+ %(unless Tim::Runner.configuration[:scp_hostname].nil?
261
261
  @reporter.secure_copy if Tim::Runner.configuration[:scp_username] &&
262
262
  Tim::Runner.configuration[:scp_password]
263
- end}
263
+ end)
264
264
 
265
265
  INDENT_OK['while_within_single_line_block'] =
266
- %Q{Timeout::timeout(DEVICE_TIMEOUT) { sleep(0.5) while @device_server.urls.nil? }}
266
+ %(Timeout::timeout(DEVICE_TIMEOUT) { sleep(0.5) while @device_server.urls.nil? })
267
267
 
268
268
  INDENT_OK['case_whens_level'] =
269
- %Q{def my_method
269
+ %(def my_method
270
270
  case true
271
271
  when true
272
272
  puts 'stuff'
273
273
  when false
274
274
  puts 'blah blah'
275
275
  end
276
- end}
276
+ end)
277
277
 
278
278
  INDENT_OK['case_strings_in_strings'] =
279
- %Q{case type
279
+ %(case type
280
280
  when :output
281
281
  "I like to \#{eval('puts')}, but should be \#{eval('print')}"
282
282
  when :input
283
283
  "Gimme \#{eval('gets')}!"
284
- end}
284
+ end)
285
285
 
286
286
  =begin
287
287
  INDENT_OK['case_whens_in'] =
288
- %Q{def my_method
288
+ %(def my_method
289
289
  case true
290
290
  when true
291
291
  puts "stuff"
292
292
  when false
293
293
  puts "blah blah"
294
294
  end
295
- end}
295
+ end)
296
296
  =end
297
297
 
298
298
  INDENT_OK['while_do_loop'] =
299
- %Q{while true do
299
+ %(while true do
300
300
  puts 'something'
301
- end}
301
+ end)
302
302
 
303
303
  INDENT_OK['while_do_loop2'] =
304
- %Q{i = 0;
304
+ %(i = 0;
305
305
  num = 5;
306
306
 
307
307
  while i < num do
308
308
  puts("Inside the loop i = \#{i}");
309
309
  i +=1;
310
- end}
310
+ end)
311
311
 
312
312
  INDENT_OK['until_do_loop'] =
313
- %Q{until true do
313
+ %(until true do
314
314
  puts 'something'
315
- end}
315
+ end)
316
316
 
317
317
  INDENT_OK['until_do_loop2'] =
318
- %Q{i = 0;
318
+ %(i = 0;
319
319
  num = 5;
320
320
 
321
321
  until i > num do
322
322
  puts("Inside the loop i = \#{i}");
323
323
  i +=1;
324
- end}
324
+ end)
325
325
 
326
326
  INDENT_OK['for_do_loop'] =
327
- %Q{for i in 1..100 do
327
+ %(for i in 1..100 do
328
328
  puts i
329
- end}
329
+ end)
330
330
 
331
331
  INDENT_OK['loop_do_loop'] =
332
- %Q{loop do
332
+ %(loop do
333
333
  puts 'looping'
334
- end}
334
+ end)
335
335
 
336
336
  INDENT_OK['while_as_modifier_loop'] =
337
- %Q{i = 0;
337
+ %(i = 0;
338
338
  num = 5;
339
339
  begin
340
340
  puts("Inside the loop i = \#{i}");
341
341
  i +=1;
342
- end while i < num}
342
+ end while i < num)
343
343
 
344
344
  INDENT_OK['until_as_modifier_loop'] =
345
- %Q{i = 0;
345
+ %(i = 0;
346
346
  num = 5;
347
347
  begin
348
348
  puts("Inside the loop i = \#{i}");
349
349
  i +=1;
350
- end until i > num}
350
+ end until i > num)
351
351
 
352
352
  INDENT_OK['for_with_break_loop'] =
353
- %Q{for i in 0..5
353
+ %(for i in 0..5
354
354
  if i > 2 then
355
355
  break
356
356
  end
357
357
  puts "Value of local variable is \#{i}"
358
- end}
358
+ end)
359
359
 
360
360
  INDENT_OK['for_with_next_loop'] =
361
- %Q{for i in 0..5
361
+ %(for i in 0..5
362
362
  if i < 2 then
363
363
  next
364
364
  end
365
365
  puts "Value of local variable is \#{i}"
366
- end}
366
+ end)
367
367
 
368
368
  INDENT_OK['for_with_redo_loop'] =
369
- %Q{for i in 0..5
369
+ %(for i in 0..5
370
370
  if i < 2 then
371
371
  puts "Value of local variable is \#{i}"
372
372
  redo
373
373
  end
374
- end}
374
+ end)
375
375
 
376
376
  INDENT_OK['for_with_retry_loop'] =
377
- %Q{for i in 1..5
377
+ %(for i in 1..5
378
378
  retry if i > 2
379
379
  puts "Value of local variable is \#{i}"
380
- end}
380
+ end)
381
381
 
382
382
  INDENT_OK['loop_with_braces'] =
383
- %Q<loop {
383
+ %(loop {
384
384
  puts 'stuff'
385
- }>
385
+ })
386
386
 
387
387
  #----------- Braces ----------#
388
388
  INDENT_OK['single_line_braces'] =
389
- %Q<{ one: 1, two: 2 }>
389
+ %({ one: 1, two: 2 })
390
390
 
391
391
  INDENT_OK['single_line_braces_as_t_string'] =
392
- %Q<%Q{this is a t string!}>
392
+ %(%Q{this is a t string!})
393
393
 
394
394
  INDENT_OK['multi_line_braces'] =
395
- %Q<{ one: 1,
396
- two: 2 }>
395
+ %({ one: 1,
396
+ two: 2 })
397
397
 
398
398
  INDENT_OK['multi_line_braces_as_t_string'] =
399
- %Q<%Q{this is a t string!
400
- suckaaaaaa!}>
399
+ %(%Q{this is a t string!
400
+ suckaaaaaa!})
401
401
 
402
- # For some reason, Ruby doesn't like '%Q<> here. Using [] instead.
402
+ # For some reason, Ruby doesn't like '%Q<> here.
403
403
  INDENT_OK['multi_line_lonely_braces'] =
404
- %Q[{
404
+ %({
405
405
  :one => 'one', :two => 'two',
406
406
  :three => 'three'
407
- }]
407
+ })
408
408
 
409
409
  INDENT_OK['multi_line_lonely_braces_as_t_string'] =
410
- %Q<%Q{
410
+ %(%Q{
411
411
  this is a t string!
412
412
  suckaaaaaa!
413
- }>
413
+ })
414
414
 
415
415
  INDENT_OK['multi_line_braces_embedded_arrays'] =
416
- %Q[{
416
+ %({
417
417
  :one => ['one', 17, {}], :two => ['two'],
418
418
  :three => 'three'
419
- }]
419
+ })
420
420
 
421
421
  INDENT_OK['braces_combo'] =
422
- %Q<{ three: 3 }
422
+ %({ three: 3 }
423
423
  {
424
424
  three: 3 }
425
425
  { three: 3
426
426
  }
427
427
  {
428
428
  three: 3
429
- }>
429
+ })
430
430
 
431
431
  INDENT_OK['deep_hash_with_rockets'] =
432
- %Q[im_deep =
432
+ %(im_deep =
433
433
  { 'one' =>
434
434
  { '1' =>
435
435
  { 'a' => 'A',
@@ -438,10 +438,10 @@ INDENT_OK['deep_hash_with_rockets'] =
438
438
  '2' =>
439
439
  { 'd' => 'D',
440
440
  'e' => 'E',
441
- 'f' => 'F' } } }]
441
+ 'f' => 'F' } } })
442
442
 
443
443
  INDENT_OK['embedded_strings_in_embedded_strings'] =
444
- %q[def friendly_time(time)
444
+ %q(def friendly_time(time)
445
445
  if hours < 24
446
446
  "#{(hours > 0) ? "#{hours} hour" : '' }#{(hours > 1) ? 's' : ''}" +
447
447
  " #{(mins > 0) ? "#{mins} minute" : '' }#{(mins > 1) ? 's' : ''}" +
@@ -449,116 +449,116 @@ INDENT_OK['embedded_strings_in_embedded_strings'] =
449
449
  else
450
450
  time.to_s
451
451
  end
452
- end]
452
+ end)
453
453
 
454
454
  #----------- Brackets ----------#
455
455
  INDENT_OK['single_line_brackets'] =
456
- %Q{['one', 'two', 'three']}
456
+ %(['one', 'two', 'three'])
457
457
 
458
458
  INDENT_OK['single_line_brackets_as_t_string'] =
459
- %Q{%Q[this is a t string!]}
459
+ %(%Q[this is a t string!])
460
460
 
461
461
  INDENT_OK['multi_line_brackets'] =
462
- %Q{['one',
462
+ %(['one',
463
463
  'two',
464
- 'three']}
464
+ 'three'])
465
465
 
466
466
  INDENT_OK['multi_line_brackets_as_t_string'] =
467
- %Q{%Q[this is a t string!
467
+ %(%Q[this is a t string!
468
468
  it doesn't matter that this is way over here.
469
- suckaaaaaa!]}
469
+ suckaaaaaa!])
470
470
 
471
471
  INDENT_OK['multi_line_lonely_brackets'] =
472
- %Q{[
472
+ %([
473
473
  'one',
474
474
  'two',
475
475
  'three'
476
- ]}
476
+ ])
477
477
 
478
478
  INDENT_OK['multi_line_lonely_brackets_as_t_string'] =
479
- %Q{%Q[
479
+ %(%Q[
480
480
  this is a t string!
481
481
  it doesn't matter that this is way over here.
482
482
  suckaaaaaa!
483
- ]}
483
+ ])
484
484
 
485
485
  INDENT_OK['multi_line_brackets_embedded_hashes'] =
486
- %Q{summary_table.rows << [{ value: 'File', align: :center },
487
- { value: 'Total Problems', align: :center }]}
486
+ %(summary_table.rows << [{ value: 'File', align: :center },
487
+ { value: 'Total Problems', align: :center }])
488
488
 
489
489
  INDENT_OK['brackets_combo'] =
490
- %Q{[2]
490
+ %([2]
491
491
  [
492
492
  2]
493
493
  [2
494
494
  ]
495
495
  [
496
496
  2
497
- ]}
497
+ ])
498
498
 
499
499
  #----------- Parens ----------#
500
500
 
501
501
  INDENT_OK['single_line_parens'] =
502
- %Q{(true || false)}
502
+ %((true || false))
503
503
 
504
504
  INDENT_OK['single_line_parens_as_t_string'] =
505
- %Q{%Q(this is a t string!)}
505
+ %(%Q(this is a t string!))
506
506
 
507
507
  INDENT_OK['multi_line_parens'] =
508
- %Q{my_method(first_argument, second_arg,
509
- third_arg)}
508
+ %(my_method(first_argument, second_arg,
509
+ third_arg))
510
510
 
511
511
  INDENT_OK['multi_line_parens_as_t_string'] =
512
- %Q{%Q(this is a t string!
512
+ %(%Q(this is a t string!
513
513
  and i'm not going
514
- anywhere!')}
514
+ anywhere!'))
515
515
 
516
516
  INDENT_OK['multi_line_lonely_parens'] =
517
- %Q{my_method(
517
+ %(my_method(
518
518
  first_argument
519
- )}
519
+ ))
520
520
 
521
521
  INDENT_OK['multi_line_lonely_parens_with_commas'] =
522
- %Q{my_method(
522
+ %(my_method(
523
523
  first_argument, second_arg,
524
524
  third_arg
525
- )}
525
+ ))
526
526
 
527
527
  INDENT_OK['multi_line_lonely_parens_as_t_string'] =
528
- %Q{%Q(
528
+ %(%Q(
529
529
  this is a t string!
530
530
  and i'm not going
531
531
  anywhere!'
532
- )}
532
+ ))
533
533
 
534
534
  INDENT_OK['parens_combo'] =
535
- %Q{(1)
535
+ %((1)
536
536
  (
537
537
  1)
538
538
  (1
539
539
  )
540
540
  (
541
541
  1
542
- )}
542
+ ))
543
543
 
544
544
 
545
545
  #-------------------------------------------------------------------------------
546
546
  # Operators
547
547
  #-------------------------------------------------------------------------------
548
548
  INDENT_OK['multi_line_ops'] =
549
- %Q{2 -
549
+ %(2 -
550
550
  1 -
551
551
  0 +
552
- 12}
552
+ 12)
553
553
 
554
554
  INDENT_OK['multi_line_andop_in_method'] =
555
- %Q{def end_of_multiline_string?(lexed_line_output)
555
+ %(def end_of_multiline_string?(lexed_line_output)
556
556
  lexed_line_output.any? { |e| e[1] == :on_tstring_end } &&
557
557
  lexed_line_output.none? { |e| e[1] == :on_tstring_beg }
558
- end}
558
+ end)
559
559
 
560
560
  INDENT_OK['multi_line_rshift_in_method'] =
561
- %Q{rule(:transport_specifier) do
561
+ %(rule(:transport_specifier) do
562
562
  match('[A-Za-z]').repeat(3).as(:streaming_protocol) >> forward_slash >>
563
563
  match('[A-Za-z]').repeat(3).as(:profile) >>
564
564
  (forward_slash >> match('[A-Za-z]').repeat(3).as(:transport_protocol)).maybe
@@ -571,18 +571,18 @@ end
571
571
 
572
572
  rule(:ttl) do
573
573
  str('ttl=') >> match('[\d]').repeat(1, 3).as(:ttl)
574
- end}
574
+ end)
575
575
 
576
576
  INDENT_OK['multi_line_string_concat_with_plus'] =
577
- %Q{DVR_SSDP_NOTIFICATION_TEMPLATE = File.dirname(__FILE__) +
578
- '/profiles/DVR5000/ssdp_notification.erb'}
577
+ %(DVR_SSDP_NOTIFICATION_TEMPLATE = File.dirname(__FILE__) +
578
+ '/profiles/DVR5000/ssdp_notification.erb')
579
579
 
580
580
  INDENT_OK['multi_line_string_concat_with_plus_in_parens'] =
581
- %Q{DVR_CONFIG_RENDERER = Erubis::Eruby.new(File.read File.dirname(__FILE__) +
582
- '/profiles/DVR5000/device_config.xml.erb')}
581
+ %(DVR_CONFIG_RENDERER = Erubis::Eruby.new(File.read File.dirname(__FILE__) +
582
+ '/profiles/DVR5000/device_config.xml.erb'))
583
583
 
584
584
  INDENT_OK['multi_line_string_concat_twice'] =
585
- %Q{unless Tim::Runner.configuration[:email].nil? ||
585
+ %(unless Tim::Runner.configuration[:email].nil? ||
586
586
  Tim::Runner.configuration[:email].empty?
587
587
  Tim::EmailReporter.subject_status ||= subject_status
588
588
  @email_reporter.send_email
@@ -592,13 +592,13 @@ def print_iteration_start iteration_number
592
592
  iteration_message = "Running Iteration \#{iteration_number} of " +
593
593
  @config[:suite_iterations].to_s
594
594
  @logger.info bar(iteration_message)
595
- end}
595
+ end)
596
596
 
597
597
  #-------------------------------------------------------------------------------
598
598
  # Method calls
599
599
  #-------------------------------------------------------------------------------
600
600
  INDENT_OK['multi_line_method_call'] =
601
- %Q{def initialize(raw_response)
601
+ %(def initialize(raw_response)
602
602
  if raw_response.nil? || raw_response.empty?
603
603
  raise RTSP::Error,
604
604
  "\#{self.class} received nil string--this shouldn't happen."
@@ -609,39 +609,39 @@ INDENT_OK['multi_line_method_call'] =
609
609
  head, body = split_head_and_body_from @raw_response
610
610
  parse_head(head)
611
611
  @body = parse_body(body)
612
- end}
612
+ end)
613
613
 
614
614
  INDENT_OK['multi_line_method_call_ends_with_period'] =
615
- %Q{unless streamer == MulticastStreamer.instance
615
+ %(unless streamer == MulticastStreamer.instance
616
616
  streamer.state = :DISCONNECTED
617
617
  UnicastStreamer.pool << streamer unless UnicastStreamer.pool.
618
618
  member? streamer
619
- end}
619
+ end)
620
620
 
621
621
  INDENT_OK['multi_line_method_call_ends_with_many_periods'] =
622
- %Q{my_hashie.first_level.
622
+ %(my_hashie.first_level.
623
623
  second_level.
624
- third_level}
624
+ third_level)
625
625
 
626
626
  =begin
627
627
  INDENT_OK['method_closing_lonely_paren'] =
628
- %Q{def your_thing(one
628
+ %(def your_thing(one
629
629
  )
630
- end}
630
+ end)
631
631
  =end
632
632
 
633
633
  INDENT_OK['method_lonely_args'] =
634
- %Q{def your_thing(
634
+ %(def your_thing(
635
635
  one
636
636
  )
637
637
  puts 'stuff'
638
- end}
638
+ end)
639
639
 
640
640
  #------------------------------------------------------------------------------
641
641
  # If + logical operators
642
642
  #------------------------------------------------------------------------------
643
643
  INDENT_OK['multi_line_if_logical_and'] =
644
- %Q{if @indentation_ruler.op_statement_nesting.empty? &&
644
+ %(if @indentation_ruler.op_statement_nesting.empty? &&
645
645
  @indentation_ruler.tstring_nesting.empty? &&
646
646
  @indentation_ruler.paren_nesting.empty? &&
647
647
  @indentation_ruler.brace_nesting.empty? &&
@@ -654,35 +654,35 @@ INDENT_OK['multi_line_if_logical_and'] =
654
654
  @indentation_ruler.last_comma_statement_line = lineno
655
655
  log "last: \#{@indentation_ruler.last_comma_statement_line}"
656
656
  end
657
- end}
657
+ end)
658
658
 
659
659
  INDENT_OK['multi_line_each_block'] =
660
- %Q{style.each do |ruler_name, value|
660
+ %(style.each do |ruler_name, value|
661
661
  instance_eval(
662
662
  "Tailor::Rulers::\#{camelize(ruler_name.to_s)}Ruler.new(\#{value})"
663
663
  )
664
664
  parent_ruler.add_child_ruler(ruler)
665
- end}
665
+ end)
666
666
 
667
667
  INDENT_OK['multi_line_each_block_with_op_and_parens'] =
668
- %Q{style.each do |ruler_name, value|
668
+ %(style.each do |ruler_name, value|
669
669
  ruler =
670
670
  instance_eval(
671
671
  "Tailor::Rulers::\#{camelize(ruler_name.to_s)}Ruler.new(\#{value})"
672
672
  )
673
673
  parent_ruler.add_child_ruler(ruler)
674
- end}
674
+ end)
675
675
 
676
676
  INDENT_OK['do_end_block_in_parens'] =
677
- %Q{begin
677
+ %(begin
678
678
  throw(:result, sexp_line.flatten.compact.any? do |s|
679
679
  s == MODIFIERS[self]
680
680
  end)
681
681
  rescue NoMethodError
682
- end}
682
+ end)
683
683
 
684
684
  INDENT_OK['block_in_block_ends_on_same_line'] =
685
- %Q{%w{
685
+ %(%w{
686
686
  foo
687
687
  bar
688
688
  baz
@@ -691,53 +691,53 @@ INDENT_OK['block_in_block_ends_on_same_line'] =
691
691
  puts 'stuff'
692
692
  end end
693
693
 
694
- puts 'post ends'}
694
+ puts 'post ends')
695
695
 
696
696
  =begin
697
697
  INDENT_OK['rparen_and_do_same_line'] =
698
- %Q{opt.on('-c', '--config-file FILE',
698
+ %(opt.on('-c', '--config-file FILE',
699
699
  "Use a specific config file.") do |config|
700
700
  options.config_file = config
701
- end}
701
+ end)
702
702
  =end
703
703
 
704
704
  #-------------------------------------------------------------------------------
705
705
  # Single-line keywords
706
706
  #-------------------------------------------------------------------------------
707
707
  INDENT_OK['single_line_begin_rescue_end'] =
708
- %Q{def log
708
+ %(def log
709
709
  l = begin; lineno; rescue; '<EOF>'; end
710
710
  c = begin; column; rescue; '<EOF>'; end
711
711
  subclass_name = self.class.to_s.sub(/^Tailor::/, '')
712
712
  args.first.insert(0, "<\#{subclass_name}> \#{l}[\#{c}]: ")
713
713
  Tailor::Logger.log(*args)
714
- end}
714
+ end)
715
715
 
716
716
  #-------------------------------------------------------------------------------
717
717
  # Combos
718
718
  #-------------------------------------------------------------------------------
719
719
  INDENT_OK['combo1'] =
720
- %Q{def set_default_smtp
720
+ %(def set_default_smtp
721
721
  Mail.defaults do
722
722
  @config = Tim::Runner.configuration
723
723
  delivery_method(:smtp,
724
724
  { :address => @config[:smtp_server],
725
725
  :port => @config[:smtp_server_port] })
726
726
  end
727
- end}
727
+ end)
728
728
 
729
729
  INDENT_OK['combo2'] =
730
- %Q{class C
730
+ %(class C
731
731
 
732
732
  send :each do
733
733
  def foo
734
734
  end
735
735
  end
736
736
 
737
- end}
737
+ end)
738
738
 
739
739
  INDENT_OK['combo3'] =
740
- %Q{def report_turducken(results, performance_results)
740
+ %(def report_turducken(results, performance_results)
741
741
  stuffing[:log_files] = { "\#{File.basename @logger.log_file_location}/path" =>
742
742
  File.read(@logger.log_file_location).gsub(/(?<f><)(?<q>\\/)?(?<w>\\w)/,
743
743
  '\\k<f>!\\k<q>\\k<w>') }.merge remote_logs
@@ -751,24 +751,24 @@ INDENT_OK['combo3'] =
751
751
  end
752
752
 
753
753
  suite_result_url
754
- end}
754
+ end)
755
755
 
756
756
  INDENT_OK['brace_bracket_paren_combo1'] =
757
- %Q{[{ :one => your_thing(
757
+ %([{ :one => your_thing(
758
758
  1)
759
759
  }
760
- ]}
760
+ ])
761
761
 
762
762
  INDENT_OK['paren_comma_combo1'] =
763
- %Q{def do_something
763
+ %(def do_something
764
764
  self[:log_file_location] = Time.now.strftime(File.join(Tim::LOG_DIR,
765
765
  "\#{self[:product]}_%Y-%m-%d_%H-%M-%S.log"))
766
766
 
767
767
  handle_arguments arg_list
768
- end}
768
+ end)
769
769
 
770
770
  INDENT_OK['line_ends_with_label'] =
771
- %Q{options = {
771
+ %(options = {
772
772
  actual_trailing_spaces:
773
773
  lexed_line.last_non_line_feed_event.last.size
774
- }}
774
+ })