motion-redgreen 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +3 -0
- data/Rakefile +2 -0
- data/lib/motion-redgreen/ansiterm.rb +558 -0
- data/lib/motion-redgreen/config.rb +8 -0
- data/lib/motion-redgreen/spec_setup.rb +107 -0
- data/lib/motion-redgreen/string.rb +5 -0
- data/lib/motion-redgreen/version.rb +5 -0
- data/lib/motion-redgreen.rb +10 -0
- data/motion-redgreen.gemspec +17 -0
- metadata +58 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Vladimir Pouzanov
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,558 @@
|
|
1
|
+
#return unless App.development?
|
2
|
+
|
3
|
+
module Term
|
4
|
+
# The ANSIColor module can be used for namespacing and mixed into your own
|
5
|
+
# classes.
|
6
|
+
module ANSIColor
|
7
|
+
# :stopdoc:
|
8
|
+
ATTRIBUTES = [
|
9
|
+
[ :clear , 0 ],
|
10
|
+
[ :reset , 0 ], # synonym for :clear
|
11
|
+
[ :bold , 1 ],
|
12
|
+
[ :dark , 2 ],
|
13
|
+
[ :italic , 3 ], # not widely implemented
|
14
|
+
[ :underline , 4 ],
|
15
|
+
[ :underscore , 4 ], # synonym for :underline
|
16
|
+
[ :blink , 5 ],
|
17
|
+
[ :rapid_blink , 6 ], # not widely implemented
|
18
|
+
[ :negative , 7 ], # no reverse because of String#reverse
|
19
|
+
[ :concealed , 8 ],
|
20
|
+
[ :strikethrough, 9 ], # not widely implemented
|
21
|
+
[ :black , 30 ],
|
22
|
+
[ :red , 31 ],
|
23
|
+
[ :green , 32 ],
|
24
|
+
[ :yellow , 33 ],
|
25
|
+
[ :blue , 34 ],
|
26
|
+
[ :magenta , 35 ],
|
27
|
+
[ :cyan , 36 ],
|
28
|
+
[ :white , 37 ],
|
29
|
+
[ :on_black , 40 ],
|
30
|
+
[ :on_red , 41 ],
|
31
|
+
[ :on_green , 42 ],
|
32
|
+
[ :on_yellow , 43 ],
|
33
|
+
[ :on_blue , 44 ],
|
34
|
+
[ :on_magenta , 45 ],
|
35
|
+
[ :on_cyan , 46 ],
|
36
|
+
[ :on_white , 47 ],
|
37
|
+
]
|
38
|
+
|
39
|
+
ATTRIBUTE_NAMES = ATTRIBUTES.transpose.first
|
40
|
+
# :startdoc:
|
41
|
+
|
42
|
+
# Returns true, if the coloring function of this module
|
43
|
+
# is switched on, false otherwise.
|
44
|
+
def self.coloring?
|
45
|
+
@coloring
|
46
|
+
end
|
47
|
+
|
48
|
+
# Turns the coloring on or off globally, so you can easily do
|
49
|
+
# this for example:
|
50
|
+
# Term::ANSIColor::coloring = STDOUT.isatty
|
51
|
+
def self.coloring=(val)
|
52
|
+
@coloring = val
|
53
|
+
end
|
54
|
+
self.coloring = true
|
55
|
+
|
56
|
+
|
57
|
+
def clear(string = nil)
|
58
|
+
result = ''
|
59
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
60
|
+
if block_given?
|
61
|
+
result << yield
|
62
|
+
elsif string
|
63
|
+
result << string
|
64
|
+
elsif respond_to?(:to_str)
|
65
|
+
result << self
|
66
|
+
else
|
67
|
+
return result #only switch on
|
68
|
+
end
|
69
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
70
|
+
result
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
def reset(string = nil)
|
75
|
+
result = ''
|
76
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
77
|
+
if block_given?
|
78
|
+
result << yield
|
79
|
+
elsif string
|
80
|
+
result << string
|
81
|
+
elsif respond_to?(:to_str)
|
82
|
+
result << self
|
83
|
+
else
|
84
|
+
return result #only switch on
|
85
|
+
end
|
86
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
87
|
+
result
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
def bold(string = nil)
|
92
|
+
result = ''
|
93
|
+
result << "[1m" if Term::ANSIColor.coloring?
|
94
|
+
if block_given?
|
95
|
+
result << yield
|
96
|
+
elsif string
|
97
|
+
result << string
|
98
|
+
elsif respond_to?(:to_str)
|
99
|
+
result << self
|
100
|
+
else
|
101
|
+
return result #only switch on
|
102
|
+
end
|
103
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
104
|
+
result
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
def dark(string = nil)
|
109
|
+
result = ''
|
110
|
+
result << "[2m" if Term::ANSIColor.coloring?
|
111
|
+
if block_given?
|
112
|
+
result << yield
|
113
|
+
elsif string
|
114
|
+
result << string
|
115
|
+
elsif respond_to?(:to_str)
|
116
|
+
result << self
|
117
|
+
else
|
118
|
+
return result #only switch on
|
119
|
+
end
|
120
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
121
|
+
result
|
122
|
+
end
|
123
|
+
|
124
|
+
|
125
|
+
def italic(string = nil)
|
126
|
+
result = ''
|
127
|
+
result << "[3m" if Term::ANSIColor.coloring?
|
128
|
+
if block_given?
|
129
|
+
result << yield
|
130
|
+
elsif string
|
131
|
+
result << string
|
132
|
+
elsif respond_to?(:to_str)
|
133
|
+
result << self
|
134
|
+
else
|
135
|
+
return result #only switch on
|
136
|
+
end
|
137
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
138
|
+
result
|
139
|
+
end
|
140
|
+
|
141
|
+
|
142
|
+
def underline(string = nil)
|
143
|
+
result = ''
|
144
|
+
result << "[4m" if Term::ANSIColor.coloring?
|
145
|
+
if block_given?
|
146
|
+
result << yield
|
147
|
+
elsif string
|
148
|
+
result << string
|
149
|
+
elsif respond_to?(:to_str)
|
150
|
+
result << self
|
151
|
+
else
|
152
|
+
return result #only switch on
|
153
|
+
end
|
154
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
155
|
+
result
|
156
|
+
end
|
157
|
+
|
158
|
+
|
159
|
+
def underscore(string = nil)
|
160
|
+
result = ''
|
161
|
+
result << "[4m" if Term::ANSIColor.coloring?
|
162
|
+
if block_given?
|
163
|
+
result << yield
|
164
|
+
elsif string
|
165
|
+
result << string
|
166
|
+
elsif respond_to?(:to_str)
|
167
|
+
result << self
|
168
|
+
else
|
169
|
+
return result #only switch on
|
170
|
+
end
|
171
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
172
|
+
result
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
def blink(string = nil)
|
177
|
+
result = ''
|
178
|
+
result << "[5m" if Term::ANSIColor.coloring?
|
179
|
+
if block_given?
|
180
|
+
result << yield
|
181
|
+
elsif string
|
182
|
+
result << string
|
183
|
+
elsif respond_to?(:to_str)
|
184
|
+
result << self
|
185
|
+
else
|
186
|
+
return result #only switch on
|
187
|
+
end
|
188
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
189
|
+
result
|
190
|
+
end
|
191
|
+
|
192
|
+
|
193
|
+
def rapid_blink(string = nil)
|
194
|
+
result = ''
|
195
|
+
result << "[6m" if Term::ANSIColor.coloring?
|
196
|
+
if block_given?
|
197
|
+
result << yield
|
198
|
+
elsif string
|
199
|
+
result << string
|
200
|
+
elsif respond_to?(:to_str)
|
201
|
+
result << self
|
202
|
+
else
|
203
|
+
return result #only switch on
|
204
|
+
end
|
205
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
206
|
+
result
|
207
|
+
end
|
208
|
+
|
209
|
+
|
210
|
+
def negative(string = nil)
|
211
|
+
result = ''
|
212
|
+
result << "[7m" if Term::ANSIColor.coloring?
|
213
|
+
if block_given?
|
214
|
+
result << yield
|
215
|
+
elsif string
|
216
|
+
result << string
|
217
|
+
elsif respond_to?(:to_str)
|
218
|
+
result << self
|
219
|
+
else
|
220
|
+
return result #only switch on
|
221
|
+
end
|
222
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
223
|
+
result
|
224
|
+
end
|
225
|
+
|
226
|
+
|
227
|
+
def concealed(string = nil)
|
228
|
+
result = ''
|
229
|
+
result << "[8m" if Term::ANSIColor.coloring?
|
230
|
+
if block_given?
|
231
|
+
result << yield
|
232
|
+
elsif string
|
233
|
+
result << string
|
234
|
+
elsif respond_to?(:to_str)
|
235
|
+
result << self
|
236
|
+
else
|
237
|
+
return result #only switch on
|
238
|
+
end
|
239
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
240
|
+
result
|
241
|
+
end
|
242
|
+
|
243
|
+
|
244
|
+
def strikethrough(string = nil)
|
245
|
+
result = ''
|
246
|
+
result << "[9m" if Term::ANSIColor.coloring?
|
247
|
+
if block_given?
|
248
|
+
result << yield
|
249
|
+
elsif string
|
250
|
+
result << string
|
251
|
+
elsif respond_to?(:to_str)
|
252
|
+
result << self
|
253
|
+
else
|
254
|
+
return result #only switch on
|
255
|
+
end
|
256
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
257
|
+
result
|
258
|
+
end
|
259
|
+
|
260
|
+
|
261
|
+
def black(string = nil)
|
262
|
+
result = ''
|
263
|
+
result << "[30m" if Term::ANSIColor.coloring?
|
264
|
+
if block_given?
|
265
|
+
result << yield
|
266
|
+
elsif string
|
267
|
+
result << string
|
268
|
+
elsif respond_to?(:to_str)
|
269
|
+
result << self
|
270
|
+
else
|
271
|
+
return result #only switch on
|
272
|
+
end
|
273
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
274
|
+
result
|
275
|
+
end
|
276
|
+
|
277
|
+
|
278
|
+
def red(string = nil)
|
279
|
+
result = ''
|
280
|
+
result << "[31m" if Term::ANSIColor.coloring?
|
281
|
+
if block_given?
|
282
|
+
result << yield
|
283
|
+
elsif string
|
284
|
+
result << string
|
285
|
+
elsif respond_to?(:to_str)
|
286
|
+
result << self
|
287
|
+
else
|
288
|
+
return result #only switch on
|
289
|
+
end
|
290
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
291
|
+
result
|
292
|
+
end
|
293
|
+
|
294
|
+
|
295
|
+
def green(string = nil)
|
296
|
+
result = ''
|
297
|
+
result << "[32m" if Term::ANSIColor.coloring?
|
298
|
+
if block_given?
|
299
|
+
result << yield
|
300
|
+
elsif string
|
301
|
+
result << string
|
302
|
+
elsif respond_to?(:to_str)
|
303
|
+
result << self
|
304
|
+
else
|
305
|
+
return result #only switch on
|
306
|
+
end
|
307
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
308
|
+
result
|
309
|
+
end
|
310
|
+
|
311
|
+
|
312
|
+
def yellow(string = nil)
|
313
|
+
result = ''
|
314
|
+
result << "[33m" if Term::ANSIColor.coloring?
|
315
|
+
if block_given?
|
316
|
+
result << yield
|
317
|
+
elsif string
|
318
|
+
result << string
|
319
|
+
elsif respond_to?(:to_str)
|
320
|
+
result << self
|
321
|
+
else
|
322
|
+
return result #only switch on
|
323
|
+
end
|
324
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
325
|
+
result
|
326
|
+
end
|
327
|
+
|
328
|
+
|
329
|
+
def blue(string = nil)
|
330
|
+
result = ''
|
331
|
+
result << "[34m" if Term::ANSIColor.coloring?
|
332
|
+
if block_given?
|
333
|
+
result << yield
|
334
|
+
elsif string
|
335
|
+
result << string
|
336
|
+
elsif respond_to?(:to_str)
|
337
|
+
result << self
|
338
|
+
else
|
339
|
+
return result #only switch on
|
340
|
+
end
|
341
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
342
|
+
result
|
343
|
+
end
|
344
|
+
|
345
|
+
|
346
|
+
def magenta(string = nil)
|
347
|
+
result = ''
|
348
|
+
result << "[35m" if Term::ANSIColor.coloring?
|
349
|
+
if block_given?
|
350
|
+
result << yield
|
351
|
+
elsif string
|
352
|
+
result << string
|
353
|
+
elsif respond_to?(:to_str)
|
354
|
+
result << self
|
355
|
+
else
|
356
|
+
return result #only switch on
|
357
|
+
end
|
358
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
359
|
+
result
|
360
|
+
end
|
361
|
+
|
362
|
+
|
363
|
+
def cyan(string = nil)
|
364
|
+
result = ''
|
365
|
+
result << "[36m" if Term::ANSIColor.coloring?
|
366
|
+
if block_given?
|
367
|
+
result << yield
|
368
|
+
elsif string
|
369
|
+
result << string
|
370
|
+
elsif respond_to?(:to_str)
|
371
|
+
result << self
|
372
|
+
else
|
373
|
+
return result #only switch on
|
374
|
+
end
|
375
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
376
|
+
result
|
377
|
+
end
|
378
|
+
|
379
|
+
|
380
|
+
def white(string = nil)
|
381
|
+
result = ''
|
382
|
+
result << "[37m" if Term::ANSIColor.coloring?
|
383
|
+
if block_given?
|
384
|
+
result << yield
|
385
|
+
elsif string
|
386
|
+
result << string
|
387
|
+
elsif respond_to?(:to_str)
|
388
|
+
result << self
|
389
|
+
else
|
390
|
+
return result #only switch on
|
391
|
+
end
|
392
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
393
|
+
result
|
394
|
+
end
|
395
|
+
|
396
|
+
|
397
|
+
def on_black(string = nil)
|
398
|
+
result = ''
|
399
|
+
result << "[40m" if Term::ANSIColor.coloring?
|
400
|
+
if block_given?
|
401
|
+
result << yield
|
402
|
+
elsif string
|
403
|
+
result << string
|
404
|
+
elsif respond_to?(:to_str)
|
405
|
+
result << self
|
406
|
+
else
|
407
|
+
return result #only switch on
|
408
|
+
end
|
409
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
410
|
+
result
|
411
|
+
end
|
412
|
+
|
413
|
+
|
414
|
+
def on_red(string = nil)
|
415
|
+
result = ''
|
416
|
+
result << "[41m" if Term::ANSIColor.coloring?
|
417
|
+
if block_given?
|
418
|
+
result << yield
|
419
|
+
elsif string
|
420
|
+
result << string
|
421
|
+
elsif respond_to?(:to_str)
|
422
|
+
result << self
|
423
|
+
else
|
424
|
+
return result #only switch on
|
425
|
+
end
|
426
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
427
|
+
result
|
428
|
+
end
|
429
|
+
|
430
|
+
|
431
|
+
def on_green(string = nil)
|
432
|
+
result = ''
|
433
|
+
result << "[42m" if Term::ANSIColor.coloring?
|
434
|
+
if block_given?
|
435
|
+
result << yield
|
436
|
+
elsif string
|
437
|
+
result << string
|
438
|
+
elsif respond_to?(:to_str)
|
439
|
+
result << self
|
440
|
+
else
|
441
|
+
return result #only switch on
|
442
|
+
end
|
443
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
444
|
+
result
|
445
|
+
end
|
446
|
+
|
447
|
+
|
448
|
+
def on_yellow(string = nil)
|
449
|
+
result = ''
|
450
|
+
result << "[43m" if Term::ANSIColor.coloring?
|
451
|
+
if block_given?
|
452
|
+
result << yield
|
453
|
+
elsif string
|
454
|
+
result << string
|
455
|
+
elsif respond_to?(:to_str)
|
456
|
+
result << self
|
457
|
+
else
|
458
|
+
return result #only switch on
|
459
|
+
end
|
460
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
461
|
+
result
|
462
|
+
end
|
463
|
+
|
464
|
+
|
465
|
+
def on_blue(string = nil)
|
466
|
+
result = ''
|
467
|
+
result << "[44m" if Term::ANSIColor.coloring?
|
468
|
+
if block_given?
|
469
|
+
result << yield
|
470
|
+
elsif string
|
471
|
+
result << string
|
472
|
+
elsif respond_to?(:to_str)
|
473
|
+
result << self
|
474
|
+
else
|
475
|
+
return result #only switch on
|
476
|
+
end
|
477
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
478
|
+
result
|
479
|
+
end
|
480
|
+
|
481
|
+
|
482
|
+
def on_magenta(string = nil)
|
483
|
+
result = ''
|
484
|
+
result << "[45m" if Term::ANSIColor.coloring?
|
485
|
+
if block_given?
|
486
|
+
result << yield
|
487
|
+
elsif string
|
488
|
+
result << string
|
489
|
+
elsif respond_to?(:to_str)
|
490
|
+
result << self
|
491
|
+
else
|
492
|
+
return result #only switch on
|
493
|
+
end
|
494
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
495
|
+
result
|
496
|
+
end
|
497
|
+
|
498
|
+
|
499
|
+
def on_cyan(string = nil)
|
500
|
+
result = ''
|
501
|
+
result << "[46m" if Term::ANSIColor.coloring?
|
502
|
+
if block_given?
|
503
|
+
result << yield
|
504
|
+
elsif string
|
505
|
+
result << string
|
506
|
+
elsif respond_to?(:to_str)
|
507
|
+
result << self
|
508
|
+
else
|
509
|
+
return result #only switch on
|
510
|
+
end
|
511
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
512
|
+
result
|
513
|
+
end
|
514
|
+
|
515
|
+
|
516
|
+
def on_white(string = nil)
|
517
|
+
result = ''
|
518
|
+
result << "[47m" if Term::ANSIColor.coloring?
|
519
|
+
if block_given?
|
520
|
+
result << yield
|
521
|
+
elsif string
|
522
|
+
result << string
|
523
|
+
elsif respond_to?(:to_str)
|
524
|
+
result << self
|
525
|
+
else
|
526
|
+
return result #only switch on
|
527
|
+
end
|
528
|
+
result << "[0m" if Term::ANSIColor.coloring?
|
529
|
+
result
|
530
|
+
end
|
531
|
+
|
532
|
+
# Regular expression that is used to scan for ANSI-sequences while
|
533
|
+
# uncoloring strings.
|
534
|
+
COLORED_REGEXP = /\e\[([34][0-7]|[0-9])m/
|
535
|
+
|
536
|
+
# Returns an uncolored version of the string, that is all
|
537
|
+
# ANSI-sequences are stripped from the string.
|
538
|
+
def uncolored(string = nil) # :yields:
|
539
|
+
if block_given?
|
540
|
+
yield.gsub(COLORED_REGEXP, '')
|
541
|
+
elsif string
|
542
|
+
string.gsub(COLORED_REGEXP, '')
|
543
|
+
elsif respond_to?(:to_str)
|
544
|
+
gsub(COLORED_REGEXP, '')
|
545
|
+
else
|
546
|
+
''
|
547
|
+
end
|
548
|
+
end
|
549
|
+
|
550
|
+
module_function
|
551
|
+
|
552
|
+
# Returns an array of all Term::ANSIColor attributes as symbols.
|
553
|
+
def attributes
|
554
|
+
ATTRIBUTE_NAMES
|
555
|
+
end
|
556
|
+
extend self
|
557
|
+
end
|
558
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# Supported styles:
|
2
|
+
# :focused, :full, :original
|
3
|
+
# --------------
|
4
|
+
style = :focused
|
5
|
+
# --------------
|
6
|
+
if Term.nil? || (style == :original)
|
7
|
+
if Term.nil?
|
8
|
+
puts "You need to get the RubyMotion-compatible ansiterm lib."
|
9
|
+
puts "You can find it at https://github.com/mdks/rm-regreen"
|
10
|
+
end
|
11
|
+
else
|
12
|
+
puts "Bacon Output Style: :#{style}".cyan
|
13
|
+
def color_for(error)
|
14
|
+
if error =~ /ERROR/
|
15
|
+
:red
|
16
|
+
elsif error =~ /MISSING/
|
17
|
+
:yellow
|
18
|
+
else
|
19
|
+
:red
|
20
|
+
end
|
21
|
+
end
|
22
|
+
if style == :full
|
23
|
+
module Bacon
|
24
|
+
module SpecDoxOutput
|
25
|
+
def handle_specification_begin(name)
|
26
|
+
puts "#{spaces + name}".bold
|
27
|
+
end
|
28
|
+
|
29
|
+
def handle_specification_end
|
30
|
+
puts if Counter[:context_depth] == 1
|
31
|
+
end
|
32
|
+
|
33
|
+
def handle_requirement_begin(description)
|
34
|
+
puts "#{spaces} - #{description}".magenta
|
35
|
+
end
|
36
|
+
|
37
|
+
def handle_requirement_end(error)
|
38
|
+
color = color_for(error)
|
39
|
+
if error.empty?
|
40
|
+
mark = "✓".green
|
41
|
+
msg = "This test has passed! Good job!".green
|
42
|
+
else
|
43
|
+
mark = "✗".send(color)
|
44
|
+
msg = "This test has not passed: #{error}!".send(color)
|
45
|
+
error_output = "[#{error}] \n BACKTRACE: #{ErrorLog}".send(color)
|
46
|
+
end
|
47
|
+
puts " [#{mark}] #{msg} \n #{error_output ||= ""}"
|
48
|
+
ErrorLog.clear
|
49
|
+
end
|
50
|
+
|
51
|
+
def handle_summary
|
52
|
+
puts "%d specifications (%d requirements), %d failures, %d errors" %
|
53
|
+
# if Backtraces
|
54
|
+
# print ErrorLog
|
55
|
+
# end
|
56
|
+
Counter.values_at(:specifications, :requirements, :failed, :errors)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
elsif style == :focused
|
61
|
+
module Bacon
|
62
|
+
module SpecDoxOutput
|
63
|
+
@focus = nil
|
64
|
+
|
65
|
+
def handle_specification_begin(name)
|
66
|
+
puts "#{spaces + name}".bold
|
67
|
+
end
|
68
|
+
|
69
|
+
def handle_specification_end
|
70
|
+
puts if Counter[:context_depth] == 1
|
71
|
+
end
|
72
|
+
|
73
|
+
def handle_requirement_begin(description)
|
74
|
+
@spec_description_cache = description
|
75
|
+
end
|
76
|
+
|
77
|
+
def handle_requirement_end(error)
|
78
|
+
if error.empty?
|
79
|
+
print ".".green
|
80
|
+
else
|
81
|
+
if @focus.nil?
|
82
|
+
@focus = @spec_description_cache
|
83
|
+
color = color_for(error)
|
84
|
+
print "\n#{spaces}[#{error}]".send(color)
|
85
|
+
print " - #{@focus}".magenta
|
86
|
+
print "\nBACKTRACE: #{ErrorLog}".send(color)
|
87
|
+
else
|
88
|
+
if error =~ /MISSING/
|
89
|
+
print "?".yellow
|
90
|
+
else
|
91
|
+
print "F".red
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def handle_summary
|
98
|
+
puts "%d specifications (%d requirements), %d failures, %d errors" %
|
99
|
+
# if Backtraces
|
100
|
+
# print ErrorLog
|
101
|
+
# end
|
102
|
+
Counter.values_at(:specifications, :requirements, :failed, :errors)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require "motion-redgreen/version"
|
2
|
+
require "motion-redgreen/config"
|
3
|
+
|
4
|
+
Motion::Project::App.setup do |app|
|
5
|
+
app.development do
|
6
|
+
app.files << File.expand_path(File.dirname(__FILE__) + '/motion-redgreen/ansiterm.rb')
|
7
|
+
app.files << File.expand_path(File.dirname(__FILE__) + '/motion-redgreen/string.rb')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/motion-redgreen/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Vladimir Pouzanov"]
|
6
|
+
gem.email = ["farcaller@gmail.com"]
|
7
|
+
gem.description = "RedGreen support for RubyMotion"
|
8
|
+
gem.summary = "RedGreen support for RubyMotion"
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "motion-redgreen"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Motion::Redgreen::VERSION
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: motion-redgreen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Vladimir Pouzanov
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-21 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: RedGreen support for RubyMotion
|
15
|
+
email:
|
16
|
+
- farcaller@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- lib/motion-redgreen.rb
|
27
|
+
- lib/motion-redgreen/ansiterm.rb
|
28
|
+
- lib/motion-redgreen/config.rb
|
29
|
+
- lib/motion-redgreen/spec_setup.rb
|
30
|
+
- lib/motion-redgreen/string.rb
|
31
|
+
- lib/motion-redgreen/version.rb
|
32
|
+
- motion-redgreen.gemspec
|
33
|
+
homepage: ''
|
34
|
+
licenses: []
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
requirements: []
|
52
|
+
rubyforge_project:
|
53
|
+
rubygems_version: 1.8.21
|
54
|
+
signing_key:
|
55
|
+
specification_version: 3
|
56
|
+
summary: RedGreen support for RubyMotion
|
57
|
+
test_files: []
|
58
|
+
has_rdoc:
|