Skip to content

Commit

Permalink
Second commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jugyo committed Feb 10, 2011
1 parent 2243386 commit 2810923
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 16 deletions.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ source "http://rubygems.org"
# Example:
# gem "activesupport", ">= 2.3.5"

gem 'ws-io', '~> 1.0'
gem 'ir_b', '~> 1.2'
gem 'launchy', '~> 0.3'

# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
Expand Down
39 changes: 39 additions & 0 deletions Gemfile.lock
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)
32 changes: 18 additions & 14 deletions README.rdoc
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.
7 changes: 5 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ Jeweler::Tasks.new do |gem|
gem.name = "wr_b"
gem.homepage = "http://github.com/jugyo/wr_b"
gem.license = "MIT"
gem.summary = %Q{TODO: one-line summary of your gem}
gem.description = %Q{TODO: longer description of your gem}
gem.summary = %Q{ir_b over the WebSocket. Usage: 'wr b'}
gem.description = %Q{wr_b is the ir_b over the WebSocket. You can start an irb session on the browser that supports WebSocket.}
gem.email = "jugyo.org@gmail.com"
gem.authors = ["jugyo"]
# Include your dependencies below. Runtime dependencies are required when using your gem,
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
gem.add_runtime_dependency 'ws-io', '~> 1.0'
gem.add_runtime_dependency 'ir_b', '~> 1.2'
gem.add_runtime_dependency 'launchy', '~> 0.3'
# gem.add_development_dependency 'rspec', '> 1.2.3'
end
Jeweler::RubygemsDotOrgTasks.new
Expand Down
9 changes: 9 additions & 0 deletions examples/example.rb
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")
60 changes: 60 additions & 0 deletions lib/public/index.html
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">&gt; </span><input type="text" id="input" style="width: 400px" /></pre>
</body>
</html>
12 changes: 12 additions & 0 deletions lib/wr_b.rb
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

0 comments on commit 2810923

Please sign in to comment.