redcar 0.3.9 → 0.3.10.0dev
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.
- data/CHANGES +18 -2
- data/Rakefile +9 -1
- data/bin/redcar +1 -1
- data/lib/redcar.rb +26 -21
- data/lib/redcar/runner.rb +8 -4
- data/plugins/document_search/features/replace.feature +9 -0
- data/plugins/document_search/lib/document_search/search.rb +7 -5
- data/plugins/project/lib/project.rb +1 -1
- data/plugins/project/lib/project/adapters/remote.rb +0 -2
- data/plugins/project/lib/project/adapters/remote_protocols/ftp.rb +2 -2
- data/plugins/project/lib/project/adapters/remote_protocols/protocol.rb +0 -2
- data/plugins/project/lib/project/adapters/remote_protocols/sftp.rb +2 -2
- data/plugins/redcar/redcar.rb +4 -1
- data/plugins/runnables/lib/runnables.rb +27 -12
- data/plugins/runnables/lib/runnables/command_output_controller.rb +20 -3
- data/plugins/runnables/lib/runnables/output_processor.rb +63 -0
- data/plugins/runnables/spec/runnables/output_processor_spec.rb +57 -0
- data/plugins/runnables/spec/spec_helper.rb +5 -0
- data/plugins/runnables/vendor/session/LICENSE +3 -0
- data/plugins/runnables/vendor/{session-2.4.0/HISTORY → session/README} +96 -1
- data/plugins/runnables/vendor/session/Rakefile +233 -0
- data/plugins/runnables/vendor/session/gemspec.rb +62 -0
- data/plugins/runnables/vendor/{session-2.4.0 → session}/lib/session.rb +6 -103
- data/plugins/runnables/vendor/{session-2.4.0 → session}/sample/bash.rb +0 -0
- data/plugins/runnables/vendor/{session-2.4.0 → session}/sample/driver.rb +0 -0
- data/plugins/runnables/vendor/{session-2.4.0 → session}/sample/session_idl.rb +0 -0
- data/plugins/runnables/vendor/{session-2.4.0 → session}/sample/session_sh.rb +0 -0
- data/plugins/runnables/vendor/{session-2.4.0 → session}/sample/sh0.rb +0 -0
- data/plugins/runnables/vendor/{session-2.4.0 → session}/sample/stdin.rb +0 -0
- data/plugins/runnables/vendor/{session-2.4.0 → session}/sample/threadtest.rb +0 -0
- data/plugins/runnables/vendor/session/session.gemspec +27 -0
- data/plugins/runnables/vendor/{session-2.4.0 → session}/test/session.rb +3 -0
- data/plugins/runnables/views/basic_ansi.css +34 -0
- data/plugins/runnables/views/color_tester.html +50 -0
- data/plugins/runnables/views/command_output.html.erb +7 -1
- data/plugins/strip_trailing_spaces/CHANGELOG +12 -0
- data/plugins/strip_trailing_spaces/README.md +32 -0
- data/plugins/strip_trailing_spaces/lib/strip_trailing_spaces.rb +53 -0
- data/plugins/strip_trailing_spaces/plugin.rb +8 -0
- metadata +4225 -4200
- data/plugins/runnables/vendor/session-2.4.0/README +0 -89
- data/plugins/runnables/vendor/session-2.4.0/TODO +0 -3
- data/plugins/runnables/vendor/session-2.4.0/VERSION +0 -1
- data/plugins/runnables/vendor/session-2.4.0/gemspec.rb +0 -22
- data/plugins/runnables/vendor/session-2.4.0/install.rb +0 -143
- data/plugins/runnables/vendor/session-2.4.0/session-2.4.0.gem +0 -0
@@ -5,8 +5,8 @@ require 'yaml'
|
|
5
5
|
require 'tempfile'
|
6
6
|
|
7
7
|
module Session
|
8
|
-
|
9
|
-
VERSION
|
8
|
+
VERSION = '3.1.0'
|
9
|
+
def self.version() VERSION end
|
10
10
|
|
11
11
|
@track_history = ENV['SESSION_HISTORY'] || ENV['SESSION_TRACK_HISTORY']
|
12
12
|
@use_spawn = ENV['SESSION_USE_SPAWN']
|
@@ -15,44 +15,34 @@ module Session
|
|
15
15
|
@debug = ENV['SESSION_DEBUG']
|
16
16
|
|
17
17
|
class << self
|
18
|
-
#--{{{
|
19
18
|
attr :track_history, true
|
20
19
|
attr :use_spawn, true
|
21
20
|
attr :use_open3, true
|
22
21
|
attr :use_open4, true
|
23
22
|
attr :debug, true
|
24
23
|
def new(*a, &b)
|
25
|
-
#--{{{
|
26
24
|
Sh::new(*a, &b)
|
27
|
-
#--}}}
|
28
25
|
end
|
29
26
|
alias [] new
|
30
|
-
#--}}}
|
31
27
|
end
|
32
28
|
|
33
29
|
class PipeError < StandardError; end
|
34
30
|
class ExecutionError < StandardError; end
|
35
31
|
|
36
32
|
class History
|
37
|
-
#--{{{
|
38
33
|
def initialize; @a = []; end
|
39
34
|
def method_missing(m,*a,&b); @a.send(m,*a,&b); end
|
40
35
|
def to_yaml(*a,&b); @a.to_yaml(*a,&b); end
|
41
36
|
alias to_s to_yaml
|
42
37
|
alias to_str to_yaml
|
43
|
-
#--}}}
|
44
38
|
end # class History
|
45
39
|
class Command
|
46
|
-
#--{{{
|
47
40
|
class << self
|
48
|
-
#--{{{
|
49
41
|
def cmdno; @cmdno ||= 0; end
|
50
42
|
def cmdno= n; @cmdno = n; end
|
51
|
-
#--}}}
|
52
43
|
end
|
53
44
|
|
54
45
|
# attributes
|
55
|
-
#--{{{
|
56
46
|
attr :cmd
|
57
47
|
attr :cmdno
|
58
48
|
attr :out,true
|
@@ -66,10 +56,8 @@ module Session
|
|
66
56
|
attr :end_err
|
67
57
|
attr :begin_err_pat
|
68
58
|
attr :end_err_pat
|
69
|
-
#--}}}
|
70
59
|
|
71
60
|
def initialize(command)
|
72
|
-
#--{{{
|
73
61
|
@cmd = command.to_s
|
74
62
|
@cmdno = self.class.cmdno
|
75
63
|
self.class.cmdno += 1
|
@@ -84,30 +72,21 @@ module Session
|
|
84
72
|
@end_err = "__CMD_ERR_%s_END__" % cid
|
85
73
|
@begin_err_pat = %r/#{ Regexp.escape(@begin_err) }/
|
86
74
|
@end_err_pat = %r/#{ Regexp.escape(@end_err) }/
|
87
|
-
#--}}}
|
88
75
|
end
|
89
76
|
def to_hash
|
90
|
-
#--{{{
|
91
77
|
%w(cmdno cmd out err cid).inject({}){|h,k| h.update k => send(k) }
|
92
|
-
#--}}}
|
93
78
|
end
|
94
79
|
def to_yaml(*a,&b)
|
95
|
-
#--{{{
|
96
80
|
to_hash.to_yaml(*a,&b)
|
97
|
-
#--}}}
|
98
81
|
end
|
99
82
|
alias to_s to_yaml
|
100
83
|
alias to_str to_yaml
|
101
|
-
#--}}}
|
102
84
|
end # class Command
|
103
85
|
class AbstractSession
|
104
|
-
#--{{{
|
105
86
|
|
106
87
|
# class methods
|
107
88
|
class << self
|
108
|
-
#--{{{
|
109
89
|
def default_prog
|
110
|
-
#--{{{
|
111
90
|
return @default_prog if defined? @default_prog and @default_prog
|
112
91
|
if defined? self::DEFAULT_PROG
|
113
92
|
return @default_prog = self::DEFAULT_PROG
|
@@ -115,12 +94,9 @@ module Session
|
|
115
94
|
@default_prog = ENV["SESSION_#{ self }_PROG"]
|
116
95
|
end
|
117
96
|
nil
|
118
|
-
#--}}}
|
119
97
|
end
|
120
98
|
def default_prog= prog
|
121
|
-
#--{{{
|
122
99
|
@default_prog = prog
|
123
|
-
#--}}}
|
124
100
|
end
|
125
101
|
attr :track_history, true
|
126
102
|
attr :use_spawn, true
|
@@ -128,23 +104,19 @@ module Session
|
|
128
104
|
attr :use_open4, true
|
129
105
|
attr :debug, true
|
130
106
|
def init
|
131
|
-
#--{{{
|
132
107
|
@track_history = nil
|
133
108
|
@use_spawn = nil
|
134
109
|
@use_open3 = nil
|
135
110
|
@use_open4 = nil
|
136
111
|
@debug = nil
|
137
|
-
#--}}}
|
138
112
|
end
|
139
113
|
alias [] new
|
140
|
-
#--}}}
|
141
114
|
end
|
142
115
|
|
143
116
|
# class init
|
144
117
|
init
|
145
118
|
|
146
119
|
# attributes
|
147
|
-
#--{{{
|
148
120
|
attr :opts
|
149
121
|
attr :prog
|
150
122
|
attr :stdin
|
@@ -164,11 +136,9 @@ module Session
|
|
164
136
|
alias debug? debug
|
165
137
|
attr :threads
|
166
138
|
attr :pid
|
167
|
-
|
168
|
-
|
139
|
+
|
169
140
|
# instance methods
|
170
141
|
def initialize(*args)
|
171
|
-
#--{{{
|
172
142
|
@opts = hashify(*args)
|
173
143
|
|
174
144
|
@prog = getopt('prog', opts, getopt('program', opts, self.class::default_prog))
|
@@ -189,8 +159,8 @@ module Session
|
|
189
159
|
@use_open3 = nil
|
190
160
|
@use_open3 = Session::use_open3 unless Session::use_open3.nil?
|
191
161
|
@use_open3 = self.class::use_open3 unless self.class::use_open3.nil?
|
192
|
-
@use_open3 = getopt('use_open3', opts) if hasopt('use_open3', opts)
|
193
|
-
|
162
|
+
@use_open3 = getopt('use_open3', opts) if hasopt('use_open3', opts)
|
163
|
+
|
194
164
|
@use_open4 = nil
|
195
165
|
@use_open4 = Session::use_open4 unless Session::use_open4.nil?
|
196
166
|
@use_open4 = self.class::use_open4 unless self.class::use_open4.nil?
|
@@ -233,10 +203,8 @@ module Session
|
|
233
203
|
end
|
234
204
|
|
235
205
|
return self
|
236
|
-
#--}}}
|
237
206
|
end
|
238
207
|
def getopt opt, hash, default = nil
|
239
|
-
#--{{{
|
240
208
|
key = opt
|
241
209
|
return hash[key] if hash.has_key? key
|
242
210
|
key = "#{ key }"
|
@@ -244,10 +212,8 @@ module Session
|
|
244
212
|
key = key.intern
|
245
213
|
return hash[key] if hash.has_key? key
|
246
214
|
return default
|
247
|
-
#--}}}
|
248
215
|
end
|
249
216
|
def hasopt opt, hash
|
250
|
-
#--{{{
|
251
217
|
key = opt
|
252
218
|
return key if hash.has_key? key
|
253
219
|
key = "#{ key }"
|
@@ -255,14 +221,12 @@ module Session
|
|
255
221
|
key = key.intern
|
256
222
|
return key if hash.has_key? key
|
257
223
|
return false
|
258
|
-
#--}}}
|
259
224
|
end
|
260
225
|
def __popen3(*cmd)
|
261
|
-
#--{{{
|
262
226
|
pw = IO::pipe # pipe[0] for read, pipe[1] for write
|
263
227
|
pr = IO::pipe
|
264
228
|
pe = IO::pipe
|
265
|
-
|
229
|
+
|
266
230
|
pid =
|
267
231
|
__fork{
|
268
232
|
# child
|
@@ -296,10 +260,8 @@ module Session
|
|
296
260
|
end
|
297
261
|
end
|
298
262
|
pi
|
299
|
-
#--}}}
|
300
263
|
end
|
301
264
|
def __fork(*a, &b)
|
302
|
-
#--{{{
|
303
265
|
verbose = $VERBOSE
|
304
266
|
begin
|
305
267
|
$VERBOSE = nil
|
@@ -307,62 +269,44 @@ module Session
|
|
307
269
|
ensure
|
308
270
|
$VERBOSE = verbose
|
309
271
|
end
|
310
|
-
#--}}}
|
311
272
|
end
|
312
273
|
|
313
274
|
# abstract methods
|
314
275
|
def clear
|
315
|
-
#--{{{
|
316
276
|
raise NotImplementedError
|
317
|
-
#--}}}
|
318
277
|
end
|
319
278
|
alias flush clear
|
320
279
|
def path
|
321
|
-
#--{{{
|
322
280
|
raise NotImplementedError
|
323
|
-
#--}}}
|
324
281
|
end
|
325
282
|
def path=
|
326
|
-
#--{{{
|
327
283
|
raise NotImplementedError
|
328
|
-
#--}}}
|
329
284
|
end
|
330
285
|
def send_command cmd
|
331
|
-
#--{{{
|
332
286
|
raise NotImplementedError
|
333
|
-
#--}}}
|
334
287
|
end
|
335
288
|
|
336
289
|
# concrete methods
|
337
290
|
def track_history= bool
|
338
|
-
#--{{{
|
339
291
|
@history ||= History::new
|
340
292
|
@track_history = bool
|
341
|
-
#--}}}
|
342
293
|
end
|
343
294
|
def ready?
|
344
|
-
#--{{{
|
345
295
|
(stdin and stdout and stderr) and
|
346
296
|
(IO === stdin and IO === stdout and IO === stderr) and
|
347
297
|
(not (stdin.closed? or stdout.closed? or stderr.closed?))
|
348
|
-
#--}}}
|
349
298
|
end
|
350
299
|
def close!
|
351
|
-
#--{{{
|
352
300
|
[stdin, stdout, stderr].each{|pipe| pipe.close}
|
353
301
|
stdin, stdout, stderr = nil, nil, nil
|
354
302
|
true
|
355
|
-
#--}}}
|
356
303
|
end
|
357
304
|
alias close close!
|
358
305
|
def hashify(*a)
|
359
|
-
#--{{{
|
360
306
|
a.inject({}){|o,h| o.update(h)}
|
361
|
-
#--}}}
|
362
307
|
end
|
363
308
|
private :hashify
|
364
309
|
def execute(command, redirects = {})
|
365
|
-
#--{{{
|
366
310
|
$session_command = command if @debug
|
367
311
|
|
368
312
|
raise(PipeError, command) unless ready?
|
@@ -498,12 +442,9 @@ module Session
|
|
498
442
|
out = err = iodat = nil
|
499
443
|
|
500
444
|
return [cmd.out, cmd.err]
|
501
|
-
#--}}}
|
502
445
|
end
|
503
|
-
#--}}}
|
504
446
|
end # class AbstractSession
|
505
447
|
class Sh < AbstractSession
|
506
|
-
#--{{{
|
507
448
|
DEFAULT_PROG = 'sh'
|
508
449
|
ECHO = 'echo'
|
509
450
|
|
@@ -512,17 +453,14 @@ module Session
|
|
512
453
|
alias exitstatus status
|
513
454
|
|
514
455
|
def clear
|
515
|
-
#--{{{
|
516
456
|
stdin.puts "#{ ECHO } __clear__ 1>&2"
|
517
457
|
stdin.puts "#{ ECHO } __clear__"
|
518
458
|
stdin.flush
|
519
459
|
while((line = stderr.gets) and line !~ %r/__clear__/o); end
|
520
460
|
while((line = stdout.gets) and line !~ %r/__clear__/o); end
|
521
461
|
self
|
522
|
-
#--}}}
|
523
462
|
end
|
524
463
|
def send_command cmd
|
525
|
-
#--{{{
|
526
464
|
stdin.printf "%s '%s' 1>&2\n", ECHO, cmd.begin_err
|
527
465
|
stdin.printf "%s '%s' \n", ECHO, cmd.begin_out
|
528
466
|
|
@@ -533,26 +471,20 @@ module Session
|
|
533
471
|
stdin.printf "%s '%s' \n", ECHO, cmd.end_out
|
534
472
|
|
535
473
|
stdin.flush
|
536
|
-
#--}}}
|
537
474
|
end
|
538
475
|
def get_status
|
539
|
-
#--{{{
|
540
476
|
@status = get_var '__exit_status__'
|
541
477
|
unless @status =~ /^\s*\d+\s*$/o
|
542
478
|
raise ExecutionError, "could not determine exit status from <#{ @status.inspect }>"
|
543
479
|
end
|
544
480
|
|
545
481
|
@status = Integer @status
|
546
|
-
#--}}}
|
547
482
|
end
|
548
483
|
def set_var name, value
|
549
|
-
#--{{{
|
550
484
|
stdin.puts "export #{ name }=#{ value }"
|
551
485
|
stdin.flush
|
552
|
-
#--}}}
|
553
486
|
end
|
554
487
|
def get_var name
|
555
|
-
#--{{{
|
556
488
|
stdin.puts "#{ ECHO } \"#{ name }=${#{ name }}\""
|
557
489
|
stdin.flush
|
558
490
|
|
@@ -567,16 +499,12 @@ module Session
|
|
567
499
|
end
|
568
500
|
|
569
501
|
var
|
570
|
-
#--}}}
|
571
502
|
end
|
572
503
|
def path
|
573
|
-
#--{{{
|
574
504
|
var = get_var 'PATH'
|
575
505
|
var.strip.split %r/:/o
|
576
|
-
#--}}}
|
577
506
|
end
|
578
507
|
def path= arg
|
579
|
-
#--{{{
|
580
508
|
case arg
|
581
509
|
when Array
|
582
510
|
arg = arg.join ':'
|
@@ -586,10 +514,8 @@ module Session
|
|
586
514
|
|
587
515
|
set_var 'PATH', "'#{ arg }'"
|
588
516
|
self.path
|
589
|
-
#--}}}
|
590
517
|
end
|
591
518
|
def execute(command, redirects = {}, &block)
|
592
|
-
#--{{{
|
593
519
|
# setup redirect on stdin
|
594
520
|
rin = redirects[:i] || redirects[:in] || redirects[:stdin] ||
|
595
521
|
redirects['stdin'] || redirects['i'] || redirects['in'] ||
|
@@ -624,27 +550,21 @@ module Session
|
|
624
550
|
else
|
625
551
|
super
|
626
552
|
end
|
627
|
-
#--}}}
|
628
553
|
end
|
629
|
-
#--}}}
|
630
554
|
end # class Sh
|
631
555
|
class Bash < Sh
|
632
|
-
#--{{{
|
633
556
|
DEFAULT_PROG = 'bash'
|
634
557
|
class Login < Bash
|
635
558
|
DEFAULT_PROG = 'bash --login'
|
636
559
|
end
|
637
|
-
#--}}}
|
638
560
|
end # class Bash
|
639
561
|
class Shell < Bash; end
|
640
562
|
# IDL => interactive data language - see http://www.rsinc.com/
|
641
563
|
class IDL < AbstractSession
|
642
|
-
#--{{{
|
643
564
|
class LicenseManagerError < StandardError; end
|
644
565
|
DEFAULT_PROG = 'idl'
|
645
566
|
MAX_TRIES = 32
|
646
567
|
def initialize(*args)
|
647
|
-
#--{{{
|
648
568
|
tries = 0
|
649
569
|
ret = nil
|
650
570
|
begin
|
@@ -659,10 +579,8 @@ module Session
|
|
659
579
|
end
|
660
580
|
end
|
661
581
|
ret
|
662
|
-
#--}}}
|
663
582
|
end
|
664
583
|
def clear
|
665
|
-
#--{{{
|
666
584
|
stdin.puts "retall"
|
667
585
|
stdin.puts "printf, -2, '__clear__'"
|
668
586
|
stdin.puts "printf, -1, '__clear__'"
|
@@ -674,10 +592,8 @@ module Session
|
|
674
592
|
raise LicenseManagerError, line if line =~ %r/license\s*manager/io
|
675
593
|
end
|
676
594
|
self
|
677
|
-
#--}}}
|
678
595
|
end
|
679
596
|
def send_command cmd
|
680
|
-
#--{{{
|
681
597
|
stdin.printf "printf, -2, '%s'\n", cmd.begin_err
|
682
598
|
stdin.printf "printf, -1, '%s'\n", cmd.begin_out
|
683
599
|
|
@@ -687,16 +603,12 @@ module Session
|
|
687
603
|
stdin.printf "printf, -2, '%s'\n", cmd.end_err
|
688
604
|
stdin.printf "printf, -1, '%s'\n", cmd.end_out
|
689
605
|
stdin.flush
|
690
|
-
#--}}}
|
691
606
|
end
|
692
607
|
def path
|
693
|
-
#--{{{
|
694
608
|
stdout, stderr = execute "print, !path"
|
695
609
|
stdout.strip.split %r/:/o
|
696
|
-
#--}}}
|
697
610
|
end
|
698
611
|
def path= arg
|
699
|
-
#--{{{
|
700
612
|
case arg
|
701
613
|
when Array
|
702
614
|
arg = arg.join ':'
|
@@ -706,15 +618,11 @@ module Session
|
|
706
618
|
stdout, stderr = execute "!path='#{ arg }'"
|
707
619
|
|
708
620
|
self.path
|
709
|
-
#--}}}
|
710
621
|
end
|
711
|
-
#--}}}
|
712
622
|
end # class IDL
|
713
623
|
module Spawn
|
714
|
-
#--{{{
|
715
624
|
class << self
|
716
625
|
def spawn command
|
717
|
-
#--{{{
|
718
626
|
ipath = tmpfifo
|
719
627
|
opath = tmpfifo
|
720
628
|
epath = tmpfifo
|
@@ -727,10 +635,8 @@ module Session
|
|
727
635
|
e = open epath, 'r'
|
728
636
|
|
729
637
|
[i,o,e]
|
730
|
-
#--}}}
|
731
638
|
end
|
732
639
|
def tmpfifo
|
733
|
-
#--{{{
|
734
640
|
path = nil
|
735
641
|
42.times do |i|
|
736
642
|
tpath = File::join(Dir::tmpdir, "#{ $$ }.#{ rand }.#{ i }")
|
@@ -748,10 +654,7 @@ module Session
|
|
748
654
|
end
|
749
655
|
raise "could not generate tmpfifo" unless path
|
750
656
|
path
|
751
|
-
#--}}}
|
752
657
|
end
|
753
658
|
end
|
754
|
-
#--}}}
|
755
659
|
end # module Spawn
|
756
|
-
#--}}}
|
757
660
|
end # module Session
|
File without changes
|