editserver 0.1.1 → 0.1.3
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/lib/editserver/command.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require 'optparse'
|
|
2
2
|
require 'yaml'
|
|
3
|
+
require 'webrick/log'
|
|
3
4
|
require 'rack'
|
|
4
5
|
require 'editserver'
|
|
5
6
|
|
|
@@ -17,12 +18,13 @@ class Editserver
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
@rackopts = {
|
|
20
|
-
:environment => 'development',
|
|
21
|
-
:pid => nil,
|
|
22
|
-
:Port => 9999,
|
|
23
21
|
:Host => '127.0.0.1',
|
|
24
|
-
:
|
|
25
|
-
:
|
|
22
|
+
:Port => 9999,
|
|
23
|
+
:Logger => WEBrick::Log.new(nil, WEBrick::BasicLog::WARN), # be less chatty
|
|
24
|
+
:AccessLog => [], # rack does its own access logging, so keep this blank
|
|
25
|
+
:pid => nil,
|
|
26
|
+
:config => '',
|
|
27
|
+
:environment => 'deployment'
|
|
26
28
|
}
|
|
27
29
|
end
|
|
28
30
|
|
|
@@ -64,7 +66,7 @@ class Editserver
|
|
|
64
66
|
if @opts[:norcfile]
|
|
65
67
|
empty
|
|
66
68
|
elsif File.exists? rcfile
|
|
67
|
-
opts = YAML.load_file File.expand_path
|
|
69
|
+
opts = YAML.load_file File.expand_path(rcfile)
|
|
68
70
|
opts ||= {}
|
|
69
71
|
opts['rack'] ||= {}
|
|
70
72
|
opts['editor'] ||= {}
|
|
@@ -101,8 +103,35 @@ class Editserver
|
|
|
101
103
|
|
|
102
104
|
def run
|
|
103
105
|
options.parse @args
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
|
|
107
|
+
begin
|
|
108
|
+
$0 = 'editserver'
|
|
109
|
+
puts banner
|
|
110
|
+
server.start
|
|
111
|
+
ensure
|
|
112
|
+
puts fx("\nGoodbye!", [32,1])
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
private
|
|
117
|
+
|
|
118
|
+
def banner
|
|
119
|
+
%Q(\
|
|
120
|
+
__ __
|
|
121
|
+
/\\ \\ __/\\ \\__
|
|
122
|
+
__ \\_\\ \\/\\_\\ \\ ,_\\ ____ __ _ __ __ __ __ _ __
|
|
123
|
+
/'__`\\ /'_` \\/\\ \\ \\ \\/ /',__\\ /'__`\\/\\`'__\\/\\ \\/\\ \\ /'__`\\/\\`'__\\
|
|
124
|
+
/\\ __//\\ \\L\\ \\ \\ \\ \\ \\_/\\__, `\\/\\ __/\\ \\ \\/ \\ \\ \\_/ |/\\ __/\\ \\ \\/
|
|
125
|
+
\\ \\____\\ \\___,_\\ \\_\\ \\__\\/\\____/\\ \\____\\\\ \\_\\ \\ \\___/ \\ \\____\\\\ \\_\\
|
|
126
|
+
\\/____/\\/__,_ /\\/_/\\/__/\\/___/ \\/____/ \\/_/ \\/__/ \\/____/ \\/_/
|
|
127
|
+
|
|
128
|
+
Listening on #{fx "#{rackopts[:Host]}:#{rackopts[:Port]}", [32,1]}\
|
|
129
|
+
).gsub(/^ {8}/, '')
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def fx str, effects = []
|
|
133
|
+
return str unless $stdout.tty?
|
|
134
|
+
str.gsub /^(.*)$/, "\e[#{[effects].flatten.join ';'}m\\1\e[0m"
|
|
106
135
|
end
|
|
107
136
|
end
|
|
108
137
|
end
|
data/lib/editserver/version.rb
CHANGED
|
@@ -16,7 +16,7 @@ describe Editserver::Command do
|
|
|
16
16
|
cmd.instance_variable_get(:@opts).must_equal(:rcfile => '~/.editserverrc')
|
|
17
17
|
cmd.instance_variable_get(:@editoropts).must_equal('default' => nil, 'terminal' => nil)
|
|
18
18
|
cmd.instance_variable_get(:@rackopts).keys.sort_by(&:to_s).must_equal [
|
|
19
|
-
:
|
|
19
|
+
:Host, :Port, :Logger, :AccessLog, :pid, :config, :environment
|
|
20
20
|
].sort_by &:to_s
|
|
21
21
|
end
|
|
22
22
|
end
|
|
@@ -24,6 +24,7 @@ describe Editserver::Editor do
|
|
|
24
24
|
|
|
25
25
|
describe :@@terminal do
|
|
26
26
|
it "should have a reader and writer for the metaclass's @@terminal" do
|
|
27
|
+
@klass.terminal = nil
|
|
27
28
|
@klass.terminal.must_equal nil
|
|
28
29
|
@klass.terminal = 'xterm -fg white -bg black'
|
|
29
30
|
@klass.terminal.must_equal %w[xterm -fg white -bg black]
|
data/test/editserver.test.rb
CHANGED