-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jugyo
committed
Feb 10, 2011
1 parent
2243386
commit 2810923
Showing
7 changed files
with
147 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
configuration (1.2.0) | ||
diff-lcs (1.1.2) | ||
git (1.2.5) | ||
ir_b (1.2.0) | ||
jeweler (1.5.2) | ||
bundler (~> 1.0.0) | ||
git (>= 1.2.5) | ||
rake | ||
launchy (0.3.7) | ||
configuration (>= 0.0.5) | ||
rake (>= 0.8.1) | ||
rake (0.8.7) | ||
rcov (0.9.9) | ||
rspec (2.3.0) | ||
rspec-core (~> 2.3.0) | ||
rspec-expectations (~> 2.3.0) | ||
rspec-mocks (~> 2.3.0) | ||
rspec-core (2.3.1) | ||
rspec-expectations (2.3.0) | ||
diff-lcs (~> 1.1.2) | ||
rspec-mocks (2.3.0) | ||
web-socket-ruby (0.1.0) | ||
ws-io (1.0.1) | ||
web-socket-ruby (~> 0.1.0) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
bundler (~> 1.0.0) | ||
ir_b (~> 1.2) | ||
jeweler (~> 1.5.2) | ||
launchy (~> 0.3) | ||
rcov | ||
rspec (~> 2.3.0) | ||
ws-io (~> 1.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
= wr_b | ||
wr_b | ||
==== | ||
|
||
Description goes here. | ||
wr\_b is the ir\_b over the WebSocket. | ||
|
||
== Contributing to wr_b | ||
|
||
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet | ||
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it | ||
* Fork the project | ||
* Start a feature/bugfix branch | ||
* Commit and push until you are happy with your contribution | ||
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally. | ||
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it. | ||
You can start an irb session on the browser that supports WebSocket. | ||
|
||
== Copyright | ||
Install | ||
---- | ||
|
||
Copyright (c) 2011 jugyo. See LICENSE.txt for | ||
further details. | ||
gem install wr_b | ||
|
||
Usage | ||
---- | ||
|
||
require 'wr_b' | ||
... | ||
wr b | ||
|
||
Copyright | ||
---- | ||
|
||
Copyright (c) 2011 jugyo. See LICENSE.txt for further details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
$:.unshift File.dirname(__FILE__) + "/../lib" | ||
require 'wr_b' | ||
|
||
def foo(arg) | ||
wr b | ||
puts arg | ||
end | ||
|
||
foo("bar") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js?v=1"></script> | ||
<script type="text/javascript" charset="utf-8"> | ||
$(function() { | ||
var ws = new WebSocket("ws://127.0.0.1:8083"); | ||
ws.onmessage = function(e) { | ||
$("#result").append($("<div>").html(e.data)); | ||
$("body").scrollTop(document.height); | ||
}; | ||
ws.onclose = function() { | ||
$("#result").append($("<div class='alert'>").text("closed")); | ||
}; | ||
ws.onerror = function() { | ||
$("#result").append($("<div class='alert'>").text("error!")); | ||
}; | ||
|
||
$.eval = function() { | ||
ws.send($("#input").val()); | ||
$("#input").val('').focus(); | ||
} | ||
|
||
$('#input').keyup(function(e) { | ||
if(e.keyCode == 13) { | ||
$.eval() | ||
} | ||
}); | ||
|
||
$("#input").focus(); | ||
}); | ||
</script> | ||
<style type="text/css" media="screen"> | ||
body { | ||
padding: 10px; | ||
margin: 0; | ||
} | ||
pre { | ||
font-size: 13px; | ||
font-family: monospace; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
#input { | ||
font-size: 13px; | ||
font-family: monospace; | ||
margin: 0; | ||
padding: 0; | ||
border: none; | ||
outline: none; | ||
} | ||
.alert { | ||
color: red; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<pre><span id="result"></span><span id="prompt">> </span><input type="text" id="input" style="width: 400px" /></pre> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'ws-io' | ||
require 'ir_b' | ||
require 'launchy' | ||
|
||
module Kernel | ||
def wr(_binding) | ||
Launchy::Browser.run(File.expand_path('../public/index.html', __FILE__)) | ||
WsIo.start(['*'], 8083) do | ||
ir _binding | ||
end | ||
end | ||
end |