Skip to content

Commit

Permalink
rename to nirvana
Browse files Browse the repository at this point in the history
  • Loading branch information
cldwalker committed Nov 12, 2010
1 parent 6329157 commit 9a460c4
Show file tree
Hide file tree
Showing 21 changed files with 38 additions and 38 deletions.
4 changes: 0 additions & 4 deletions bin/bs

This file was deleted.

4 changes: 0 additions & 4 deletions bin/bs-websocket

This file was deleted.

4 changes: 4 additions & 0 deletions bin/nirvana
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby

require 'nirvana'
Nirvana.start
4 changes: 4 additions & 0 deletions bin/nirvana-websocket
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby

require 'nirvana/websocket'
Nirvana::Websocket.run
6 changes: 0 additions & 6 deletions lib/bs/public/css/bs.css

This file was deleted.

12 changes: 6 additions & 6 deletions lib/bs.rb → lib/nirvana.rb
@@ -1,20 +1,20 @@
require 'ripl' require 'ripl'
require 'ripl/web' require 'ripl/web'
require 'bs/shell' require 'nirvana/shell'
require 'bs/util' require 'nirvana/util'


module Bs module Nirvana
def self.start_shell def self.start_shell
stdout, stderr = Util.capture_all { stdout, stderr = Util.capture_all {
Ripl::Runner.load_rc(Ripl.config[:riplrc]) Ripl::Runner.load_rc(Ripl.config[:riplrc])
Ripl.shell(:name=>'bs', :readline=>false).before_loop Ripl.shell(:name=>'nirvana', :readline=>false).before_loop
} }
(result = stdout.to_s + stderr.to_s) ? Util.format_output(result) : result (result = stdout.to_s + stderr.to_s) ? Util.format_output(result) : result
end end


def self.start def self.start
system "bs-websocket &" system "nirvana-websocket &"
html_file = File.expand_path(File.dirname(__FILE__) + '/bs/public/index.html') html_file = File.expand_path(File.dirname(__FILE__) + '/nirvana/public/index.html')
RUBY_PLATFORM[/darwin/i] ? system('open', html_file) : puts(html_file) RUBY_PLATFORM[/darwin/i] ? system('open', html_file) : puts(html_file)
end end
end end
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions lib/nirvana/public/css/nirvana.css
@@ -0,0 +1,6 @@
body .nirvana_exception {
color: red;
}
body .nirvana_warning {
color: #ffcc00;
}
File renamed without changes
10 changes: 5 additions & 5 deletions lib/bs/public/index.html → lib/nirvana/public/index.html
@@ -1,10 +1,10 @@
<html> <html>
<head> <head>
<title>bs</title> <title>nirvana</title>
<link href='css/jquery.repl.css' rel='stylesheet' type='text/css'> <link href='css/jquery.repl.css' rel='stylesheet' type='text/css'>
<link href='css/bs.css' rel='stylesheet' type='text/css'> <link href='css/nirvana.css' rel='stylesheet' type='text/css'>
<script src='js/jquery.min.js' type='text/javascript'></script> <script src='js/jquery.min.js' type='text/javascript'></script>
<script src='js/bs.js' type='text/javascript'></script> <script src='js/nirvana.js' type='text/javascript'></script>
<script src='js/jquery.hotkeys.js' type='text/javascript'></script> <script src='js/jquery.hotkeys.js' type='text/javascript'></script>
<script src="js/jquery.ui.autocomplete.min.js"></script> <script src="js/jquery.ui.autocomplete.min.js"></script>
<script src='js/jquery.readline.js' type='text/javascript'></script> <script src='js/jquery.readline.js' type='text/javascript'></script>
Expand All @@ -14,10 +14,10 @@
$('#input').readline({ $('#input').readline({
autocompleteCss: 'css/jquery.ui.autocomplete.css', autocompleteCss: 'css/jquery.ui.autocomplete.css',
readlineCss: 'css/jquery.readline.css', readlineCss: 'css/jquery.readline.css',
startCompletion: $.ws.bsComplete startCompletion: $.ws.nirvanaComplete
}).repl({ }).repl({
resultPrompt: '', resultPrompt: '',
startMessage: function() { return '$ bs' }, startMessage: function() { return '$ nirvana' },
spinner: 'images/spinner.gif', spinner: 'images/spinner.gif',
loop: function(val) { loop: function(val) {
$.readline.addHistory(val); $.readline.addHistory(val);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions lib/bs/public/js/bs.js → lib/nirvana/public/js/nirvana.js
@@ -1,5 +1,5 @@
(function($) { (function($) {
if (!('WebSocket' in window)) { alert("This browser does NOT support websockets and thus no bs for you :("); } if (!('WebSocket' in window)) { alert("This browser does NOT support websockets and thus nirvana fail :("); }


var ws = new WebSocket("ws://127.0.0.1:8080"); var ws = new WebSocket("ws://127.0.0.1:8080");
ws.onmessage = function(e) { ws.onmessage = function(e) {
Expand All @@ -13,12 +13,12 @@
}; };
ws.onclose = function() { ws.onclose = function() {
$.repl.disable(); $.repl.disable();
return $.repl.log("<div class='bs_exception'>bs: websocket closed</div>"); return $.repl.log("<div class='nirvana_exception'>nirvana: websocket closed</div>");
}; };
ws.onerror = function() { ws.onerror = function() {
return $.repl.log("<div class='bs_exception'>bs: websocket error</div>"); return $.repl.log("<div class='nirvana_exception'>nirvana: websocket error</div>");
}; };


$.ws = function() { return ws }; $.ws = function() { return ws };
$.ws.bsComplete = function(val) { ws.send(':AUTOCOMPLETE: '+val); }; $.ws.nirvanaComplete = function(val) { ws.send(':AUTOCOMPLETE: '+val); };
})(jQuery); })(jQuery);
8 changes: 4 additions & 4 deletions lib/bs/shell.rb → lib/nirvana/shell.rb
@@ -1,7 +1,7 @@
require 'yajl' require 'yajl'
require 'ripl/completion' require 'ripl/completion'


module Bs module Nirvana
module Shell module Shell
def web_loop_once(input) def web_loop_once(input)
super super
Expand All @@ -27,13 +27,13 @@ def print_eval_error(error)


def format_result(result) def format_result(result)
output = Util.format_output @stdout + super output = Util.format_output @stdout + super
output = "<div class='bs_warning'>#{@stderr}</div>" + output unless @stderr.to_s.empty? output = "<div class='nirvana_warning'>#{@stderr}</div>" + output unless @stderr.to_s.empty?
output output
end end


protected protected
def html_error(error, message) def html_error(error, message)
"<span class='bs_exception'>#{Util.format_output(message + format_error(error))}</span>" "<span class='nirvana_exception'>#{Util.format_output(message + format_error(error))}</span>"
end end


def get_completions(input) def get_completions(input)
Expand All @@ -52,4 +52,4 @@ def completions(line_buffer)
end end
end end


Ripl::Shell.send :include, Bs::Shell Ripl::Shell.send :include, Nirvana::Shell
2 changes: 1 addition & 1 deletion lib/bs/util.rb → lib/nirvana/util.rb
@@ -1,7 +1,7 @@
require 'stringio' require 'stringio'
require 'escape_utils' require 'escape_utils'


module Bs module Nirvana
module Util module Util
extend self extend self


Expand Down
8 changes: 4 additions & 4 deletions lib/bs/websocket.rb → lib/nirvana/websocket.rb
@@ -1,13 +1,13 @@
require 'em-websocket' require 'em-websocket'
require 'bs' require 'nirvana'


module Bs module Nirvana
module Websocket module Websocket
def self.run def self.run
EventMachine.run do EventMachine.run do
EventMachine::WebSocket.start(:host => '127.0.0.1', :port => 8080) do |ws| EventMachine::WebSocket.start(:host => '127.0.0.1', :port => 8080) do |ws|
ws.onopen { ws.onopen {
result = Bs.start_shell result = Nirvana.start_shell
ws.send(result) unless result.to_s.empty? ws.send(result) unless result.to_s.empty?
} }
ws.onmessage {|msg| ws.send Ripl.shell.web_loop_once(msg) } ws.onmessage {|msg| ws.send Ripl.shell.web_loop_once(msg) }
Expand All @@ -17,7 +17,7 @@ def self.run
rescue rescue
message = "Unable to start websocket since port 8080 is occupied" message = "Unable to start websocket since port 8080 is occupied"
message = $!.message unless $!.message[/no acceptor/] message = $!.message unless $!.message[/no acceptor/]
abort "bs websocket error: #{message}" abort "nirvana websocket error: #{message}"
end end
end end
end end

0 comments on commit 9a460c4

Please sign in to comment.