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
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe Redcar::Runnables::OutputProcessor do
|
4
|
+
before do
|
5
|
+
@processor = Redcar::Runnables::OutputProcessor.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def processed
|
9
|
+
@processor.process(@input)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should htmlize output" do
|
13
|
+
@input = "Some text with & and <tags/>"
|
14
|
+
processed.should == "Some text with & and <tags/>"
|
15
|
+
|
16
|
+
@input = " Some indenting"
|
17
|
+
processed.should == " Some indenting"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should convert ANSI colors to span classes" do
|
21
|
+
@input = "Some \e[31mred\e[0m text."
|
22
|
+
processed.should == 'Some <span class="ansi-red">red</span> text.'
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should convert ANSI bold to span class" do
|
26
|
+
@input = "Some \e[1;31mbold red\e[0m text."
|
27
|
+
processed.should == 'Some <span class="ansi-bold ansi-red">bold red</span> text.'
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should include ANSI light variants" do
|
31
|
+
@input = "Some \e[93mlight yellow\e[0m text."
|
32
|
+
processed.should == 'Some <span class="ansi-light ansi-yellow">light yellow</span> text.'
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should close out all spans on ANSI 0m" do
|
36
|
+
@input = "Some \e[1;32mbold green\e[0;32mregular green\e[0m"
|
37
|
+
processed.should == 'Some <span class="ansi-bold ansi-green">bold green<span class="ansi-regular ansi-green">regular green</span></span>'
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should close out all spans at then end of the line" do
|
41
|
+
@input = "Some \e[34mblue text"
|
42
|
+
processed.should == 'Some <span class="ansi-blue">blue text</span>'
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should continue color in next line" do
|
46
|
+
@input = "Some \e[34mblue text"
|
47
|
+
processed
|
48
|
+
@input = "that spans lines\e[0m"
|
49
|
+
processed.should == '<span class="ansi-blue">that spans lines</span>'
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should separate HTML output's head and body" do
|
53
|
+
# This is a planned feature but will get implemented in another branch.
|
54
|
+
# The intention is to somehow handle cucumbers --format html for interactive
|
55
|
+
# runnable output.
|
56
|
+
end
|
57
|
+
end
|
@@ -1,4 +1,94 @@
|
|
1
|
-
|
1
|
+
URLS: |
|
2
|
+
|
3
|
+
http://raa.ruby-lang.org/project/session/
|
4
|
+
http://www.codeforpeople.com/lib/ruby/session/
|
5
|
+
|
6
|
+
|
7
|
+
NAME: |
|
8
|
+
|
9
|
+
Session
|
10
|
+
::Sh
|
11
|
+
::Bash
|
12
|
+
::Shell
|
13
|
+
::IDL
|
14
|
+
|
15
|
+
SYNOPSIS: |
|
16
|
+
|
17
|
+
Session::* offers a set of classes built upon Open3::popen3 for driving
|
18
|
+
external progams via pipes. It offers a significant abstraction over
|
19
|
+
Open3::popen in that the stdout/stderr of each command sent can be deliniated:
|
20
|
+
|
21
|
+
open3:
|
22
|
+
|
23
|
+
i,o,e = Open3::popen3 '/bin/sh'
|
24
|
+
|
25
|
+
i.puts 'ls'
|
26
|
+
i.puts 'echo 42'
|
27
|
+
|
28
|
+
now, how to determine the boundry between the output from 'ls' and 'echo'?
|
29
|
+
the only (simple) way is start a process for each command
|
30
|
+
|
31
|
+
i,o,e = Open3::popen3 '/bin/sh'
|
32
|
+
i.puts 'ls'
|
33
|
+
i.close
|
34
|
+
stdout, stderr = o.read, e.read
|
35
|
+
|
36
|
+
i,o,e = Open3::popen3 '/bin/sh'
|
37
|
+
i.puts 'echo 42'
|
38
|
+
i.close
|
39
|
+
stdout, stderr = o.read, e.read
|
40
|
+
|
41
|
+
session:
|
42
|
+
|
43
|
+
sh = Session::new
|
44
|
+
|
45
|
+
stdout, stderr = sh.execute 'ls'
|
46
|
+
stdout, stderr = sh.execute 'echo 42'
|
47
|
+
|
48
|
+
Both stderr and stdout can be redirected, and the exit_status of each command
|
49
|
+
is made available:
|
50
|
+
|
51
|
+
bash = Session::Bash.new
|
52
|
+
stdout, stderr = StringIO::new, StringIO::new
|
53
|
+
|
54
|
+
bash.execute 'ls', :stdout => stdout, :stderr => stderr
|
55
|
+
# bash.execute 'ls', 1 => stdout, 2 => stderr # same thing
|
56
|
+
# bash.execute 'ls', :o => stdout, :e => stderr # same thing
|
57
|
+
|
58
|
+
exit_status = bash.exit_status
|
59
|
+
|
60
|
+
A block form can be used to specify a callback to be invoked whenever output
|
61
|
+
has become availible:
|
62
|
+
|
63
|
+
bash = Session::Bash.new
|
64
|
+
|
65
|
+
bash.execute( 'long_running_command.exe' ) do |out, err|
|
66
|
+
logger << out if out
|
67
|
+
elogger << err if err
|
68
|
+
end
|
69
|
+
|
70
|
+
Sessions are Thread safe (in the sense that they do not block on io
|
71
|
+
operations) allowing commands spawned from guis to update widgets with output
|
72
|
+
while running in the background.
|
73
|
+
|
74
|
+
button.configure 'action' => lambda do
|
75
|
+
sh = Session::new
|
76
|
+
sh.execute(cmd) do |o,e|
|
77
|
+
out_widget.update o if o
|
78
|
+
err_widget.update e if e
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
SAMPLES: |
|
83
|
+
|
84
|
+
see samples/*
|
85
|
+
|
86
|
+
HISTORY: |
|
87
|
+
3.1.0:
|
88
|
+
- patches from @headius
|
89
|
+
|
90
|
+
3.0.0
|
91
|
+
- move to github
|
2
92
|
|
3
93
|
2.4.0:
|
4
94
|
- added ability to specify stdin for Session::Bash and Session::Sh
|
@@ -71,3 +161,8 @@ HISTORY:
|
|
71
161
|
2.1.4:
|
72
162
|
- added Thread.exclusive{} wrapper when io is read to works in multi
|
73
163
|
threaded apps
|
164
|
+
|
165
|
+
|
166
|
+
AUTHOR: |
|
167
|
+
|
168
|
+
ara.t.howard@noaa.gov
|
@@ -0,0 +1,233 @@
|
|
1
|
+
|
2
|
+
This.rubyforge_project = 'codeforpeople'
|
3
|
+
This.author = "Ara T. Howard"
|
4
|
+
This.email = "ara.t.howard@gmail.com"
|
5
|
+
This.homepage = "http://github.com/ahoward/#{ This.lib }/tree/master"
|
6
|
+
|
7
|
+
|
8
|
+
task :default do
|
9
|
+
puts(Rake::Task.tasks.map{|task| task.name} - ['default'])
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
task :gemspec do
|
14
|
+
ignore_extensions = 'git', 'svn', 'tmp', /sw./, 'bak', 'gem'
|
15
|
+
ignore_directories = 'pkg'
|
16
|
+
ignore_files = 'test/log'
|
17
|
+
|
18
|
+
shiteless =
|
19
|
+
lambda do |list|
|
20
|
+
list.delete_if do |entry|
|
21
|
+
next unless test(?e, entry)
|
22
|
+
extension = File.basename(entry).split(%r/[.]/).last
|
23
|
+
ignore_extensions.any?{|ext| ext === extension}
|
24
|
+
end
|
25
|
+
list.delete_if do |entry|
|
26
|
+
next unless test(?d, entry)
|
27
|
+
dirname = File.expand_path(entry)
|
28
|
+
ignore_directories.any?{|dir| File.expand_path(dir) == dirname}
|
29
|
+
end
|
30
|
+
list.delete_if do |entry|
|
31
|
+
next unless test(?f, entry)
|
32
|
+
filename = File.expand_path(entry)
|
33
|
+
ignore_files.any?{|file| File.expand_path(file) == filename}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
lib = This.lib
|
38
|
+
object = This.object
|
39
|
+
version = This.version
|
40
|
+
files = shiteless[Dir::glob("**/**")]
|
41
|
+
executables = shiteless[Dir::glob("bin/*")].map{|exe| File.basename(exe)}
|
42
|
+
has_rdoc = true #File.exist?('doc')
|
43
|
+
test_files = "test/#{ lib }.rb" if File.file?("test/#{ lib }.rb")
|
44
|
+
summary = object.respond_to?(:summary) ? object.summary : "summary: #{ lib } kicks the ass"
|
45
|
+
description = object.respond_to?(:description) ? object.description : "description: #{ lib } kicks the ass"
|
46
|
+
|
47
|
+
extensions = This.extensions
|
48
|
+
if extensions.nil?
|
49
|
+
%w( Makefile configure extconf.rb ).each do |ext|
|
50
|
+
extensions << ext if File.exists?(ext)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
extensions = [extensions].flatten.compact
|
54
|
+
|
55
|
+
template =
|
56
|
+
if test(?e, 'gemspec.erb')
|
57
|
+
Template{ IO.read('gemspec.erb') }
|
58
|
+
else
|
59
|
+
Template {
|
60
|
+
<<-__
|
61
|
+
## #{ lib }.gemspec
|
62
|
+
#
|
63
|
+
|
64
|
+
Gem::Specification::new do |spec|
|
65
|
+
spec.name = #{ lib.inspect }
|
66
|
+
spec.version = #{ version.inspect }
|
67
|
+
spec.platform = Gem::Platform::RUBY
|
68
|
+
spec.summary = #{ lib.inspect }
|
69
|
+
spec.description = #{ description.inspect }
|
70
|
+
|
71
|
+
spec.files = #{ files.inspect }
|
72
|
+
spec.executables = #{ executables.inspect }
|
73
|
+
|
74
|
+
spec.require_path = "lib"
|
75
|
+
|
76
|
+
spec.has_rdoc = #{ has_rdoc.inspect }
|
77
|
+
spec.test_files = #{ test_files.inspect }
|
78
|
+
#spec.add_dependency 'lib', '>= version'
|
79
|
+
spec.add_dependency 'fattr'
|
80
|
+
|
81
|
+
spec.extensions.push(*#{ extensions.inspect })
|
82
|
+
|
83
|
+
spec.rubyforge_project = #{ This.rubyforge_project.inspect }
|
84
|
+
spec.author = #{ This.author.inspect }
|
85
|
+
spec.email = #{ This.email.inspect }
|
86
|
+
spec.homepage = #{ This.homepage.inspect }
|
87
|
+
end
|
88
|
+
__
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
92
|
+
open("#{ lib }.gemspec", "w"){|fd| fd.puts template}
|
93
|
+
This.gemspec = "#{ lib }.gemspec"
|
94
|
+
end
|
95
|
+
|
96
|
+
task :gem => [:clean, :gemspec] do
|
97
|
+
Fu.mkdir_p This.pkgdir
|
98
|
+
before = Dir['*.gem']
|
99
|
+
cmd = "gem build #{ This.gemspec }"
|
100
|
+
`#{ cmd }`
|
101
|
+
after = Dir['*.gem']
|
102
|
+
gem = ((after - before).first || after.first) or abort('no gem!')
|
103
|
+
Fu.mv gem, This.pkgdir
|
104
|
+
This.gem = File.basename(gem)
|
105
|
+
end
|
106
|
+
|
107
|
+
task :readme do
|
108
|
+
samples = ''
|
109
|
+
prompt = '~ > '
|
110
|
+
lib = This.lib
|
111
|
+
version = This.version
|
112
|
+
|
113
|
+
Dir['sample*/*'].sort.each do |sample|
|
114
|
+
samples << "\n" << " <========< #{ sample } >========>" << "\n\n"
|
115
|
+
|
116
|
+
cmd = "cat #{ sample }"
|
117
|
+
samples << Util.indent(prompt + cmd, 2) << "\n\n"
|
118
|
+
samples << Util.indent(`#{ cmd }`, 4) << "\n"
|
119
|
+
|
120
|
+
cmd = "ruby #{ sample }"
|
121
|
+
samples << Util.indent(prompt + cmd, 2) << "\n\n"
|
122
|
+
|
123
|
+
cmd = "ruby -e'STDOUT.sync=true; exec %(ruby -I ./lib #{ sample })'"
|
124
|
+
samples << Util.indent(`#{ cmd } 2>&1`, 4) << "\n"
|
125
|
+
end
|
126
|
+
|
127
|
+
template =
|
128
|
+
if test(?e, 'readme.erb')
|
129
|
+
Template{ IO.read('readme.erb') }
|
130
|
+
else
|
131
|
+
Template {
|
132
|
+
<<-__
|
133
|
+
NAME
|
134
|
+
#{ lib }
|
135
|
+
|
136
|
+
DESCRIPTION
|
137
|
+
|
138
|
+
INSTALL
|
139
|
+
gem install #{ lib }
|
140
|
+
|
141
|
+
SAMPLES
|
142
|
+
#{ samples }
|
143
|
+
__
|
144
|
+
}
|
145
|
+
end
|
146
|
+
|
147
|
+
open("README", "w"){|fd| fd.puts template}
|
148
|
+
end
|
149
|
+
|
150
|
+
|
151
|
+
task :clean do
|
152
|
+
Dir[File.join(This.pkgdir, '**/**')].each{|entry| Fu.rm_rf(entry)}
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
task :release => [:clean, :gemspec, :gem] do
|
157
|
+
gems = Dir[File.join(This.pkgdir, '*.gem')].flatten
|
158
|
+
raise "which one? : #{ gems.inspect }" if gems.size > 1
|
159
|
+
raise "no gems?" if gems.size < 1
|
160
|
+
cmd = "rubyforge login && rubyforge add_release #{ This.rubyforge_project } #{ This.lib } #{ This.version } #{ This.pkgdir }/#{ This.gem }"
|
161
|
+
puts cmd
|
162
|
+
system cmd
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
BEGIN {
|
170
|
+
$VERBOSE = nil
|
171
|
+
|
172
|
+
require 'ostruct'
|
173
|
+
require 'erb'
|
174
|
+
require 'fileutils'
|
175
|
+
|
176
|
+
Fu = FileUtils
|
177
|
+
|
178
|
+
This = OpenStruct.new
|
179
|
+
|
180
|
+
This.file = File.expand_path(__FILE__)
|
181
|
+
This.dir = File.dirname(This.file)
|
182
|
+
This.pkgdir = File.join(This.dir, 'pkg')
|
183
|
+
|
184
|
+
lib = ENV['LIB']
|
185
|
+
unless lib
|
186
|
+
lib = File.basename(Dir.pwd)
|
187
|
+
end
|
188
|
+
This.lib = lib
|
189
|
+
|
190
|
+
version = ENV['VERSION']
|
191
|
+
unless version
|
192
|
+
require "./lib/#{ This.lib }"
|
193
|
+
This.name = lib.capitalize
|
194
|
+
This.object = eval(This.name)
|
195
|
+
version = This.object.send(:version)
|
196
|
+
end
|
197
|
+
This.version = version
|
198
|
+
|
199
|
+
abort('no lib') unless This.lib
|
200
|
+
abort('no version') unless This.version
|
201
|
+
|
202
|
+
module Util
|
203
|
+
def indent(s, n = 2)
|
204
|
+
s = unindent(s)
|
205
|
+
ws = ' ' * n
|
206
|
+
s.gsub(%r/^/, ws)
|
207
|
+
end
|
208
|
+
|
209
|
+
def unindent(s)
|
210
|
+
indent = nil
|
211
|
+
s.each do |line|
|
212
|
+
next if line =~ %r/^\s*$/
|
213
|
+
indent = line[%r/^\s*/] and break
|
214
|
+
end
|
215
|
+
indent ? s.gsub(%r/^#{ indent }/, "") : s
|
216
|
+
end
|
217
|
+
extend self
|
218
|
+
end
|
219
|
+
|
220
|
+
class Template
|
221
|
+
def initialize(&block)
|
222
|
+
@block = block
|
223
|
+
@template = block.call.to_s
|
224
|
+
end
|
225
|
+
def expand(b=nil)
|
226
|
+
ERB.new(Util.unindent(@template)).result(b||@block)
|
227
|
+
end
|
228
|
+
alias_method 'to_s', 'expand'
|
229
|
+
end
|
230
|
+
def Template(*args, &block) Template.new(*args, &block) end
|
231
|
+
|
232
|
+
Dir.chdir(This.dir)
|
233
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
lib, version, *ignored = ARGV
|
4
|
+
|
5
|
+
unless lib
|
6
|
+
lib = File.basename(Dir.pwd)
|
7
|
+
end
|
8
|
+
|
9
|
+
unless version
|
10
|
+
mod = lib.capitalize
|
11
|
+
require "./lib/#{ lib }"
|
12
|
+
version = eval(mod).send(:version)
|
13
|
+
end
|
14
|
+
|
15
|
+
abort('no lib') unless lib
|
16
|
+
abort('no version') unless version
|
17
|
+
|
18
|
+
puts "### gemspec: #{ lib }-#{ version }"
|
19
|
+
|
20
|
+
$VERBOSE = nil
|
21
|
+
|
22
|
+
shiteless = lambda{|list| list.delete_if{|file| file =~ %r/\.(git|svn|tmp|sw.|bak)$/}}
|
23
|
+
|
24
|
+
files = shiteless[Dir::glob("**/**")]
|
25
|
+
executables = shiteless[Dir::glob("bin/*")].map{|exe| File.basename(exe)}
|
26
|
+
has_rdoc = true #File.exist?('doc')
|
27
|
+
test_files = "test/#{ lib }.rb" if File.file?("test/#{ lib }.rb")
|
28
|
+
|
29
|
+
extensions = []
|
30
|
+
%w( Makefile configure extconf.rb rakefile Rakefile mkrf_conf ).each do |ext|
|
31
|
+
extensions << ext if File.exists?(ext)
|
32
|
+
end
|
33
|
+
|
34
|
+
template = <<-__
|
35
|
+
|
36
|
+
Gem::Specification::new do |spec|
|
37
|
+
spec.name = #{ lib.inspect }
|
38
|
+
spec.version = #{ version.inspect }
|
39
|
+
spec.platform = Gem::Platform::RUBY
|
40
|
+
spec.summary = #{ lib.inspect }
|
41
|
+
|
42
|
+
spec.files = #{ files.inspect }
|
43
|
+
spec.executables = #{ executables.inspect }
|
44
|
+
|
45
|
+
spec.require_path = "lib"
|
46
|
+
|
47
|
+
spec.has_rdoc = #{ has_rdoc.inspect }
|
48
|
+
spec.test_files = #{ test_files.inspect }
|
49
|
+
#spec.add_dependency 'lib', '>= version'
|
50
|
+
#spec.add_dependency 'fattr'
|
51
|
+
|
52
|
+
spec.extensions.push(*#{ extensions.inspect })
|
53
|
+
|
54
|
+
spec.rubyforge_project = 'codeforpeople'
|
55
|
+
spec.author = "Ara T. Howard"
|
56
|
+
spec.email = "ara.t.howard@gmail.com"
|
57
|
+
spec.homepage = "http://github.com/ahoward/#{ lib }/tree/master"
|
58
|
+
end
|
59
|
+
|
60
|
+
__
|
61
|
+
|
62
|
+
puts template
|