web-repl 0.10.1 → 0.10.2
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.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +4 -5
- data/lib/web-repl.rb +7 -1
- data/lib/web-repl/repl.rb +17 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cda2df4294808cb8a8c8c14f488a8e1c7f76fc94
|
4
|
+
data.tar.gz: 695d28c5724f5c0cd4bf45cb3e7b06b5b7028c54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bf1279f86055a3186a8b3e2e600a3080a42a5d23af5082e692fd192eceff546fa648567a86bfaa19470100dd1d28a68c88701fae64be236f2be19d915d099b9
|
7
|
+
data.tar.gz: f97dd88419310ba661eeb96eeb93ed5c5d47e3c9b16c82c6ebccd41ef3f90bf058c15dcff1a9f6ef81f5d4c4408d59da58d357089de80422b442b48a8996b9ce
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# web-repl
|
2
|
-
|
2
|
+
|
3
3
|
A Javascript [REPL](http://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) that runs in Ruby. Evaluation is done by a web browser instance.
|
4
4
|
|
5
5
|
One use of this is to replace the Chrome Developer Console remotely as such:
|
@@ -51,11 +51,11 @@ You can see an explanation of [background usage here](https://github.com/ariruss
|
|
51
51
|
To use this as a script, run this from the command line. (The script should install with the gem)
|
52
52
|
|
53
53
|
web-repl localhost:9007
|
54
|
-
|
54
|
+
|
55
55
|
#### Installation
|
56
56
|
|
57
57
|
gem install web-repl
|
58
|
-
|
58
|
+
|
59
59
|
or with Bundler
|
60
60
|
|
61
61
|
gem "web-repl"
|
@@ -63,5 +63,4 @@ or with Bundler
|
|
63
63
|
#### License
|
64
64
|
|
65
65
|
Licensed under Apache 2.0, See the file LICENSE
|
66
|
-
Copyright (c) 2014 [Ari Russo](http://arirusso.com)
|
67
|
-
|
66
|
+
Copyright (c) 2014-2015 [Ari Russo](http://arirusso.com)
|
data/lib/web-repl.rb
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# Web-repl
|
2
|
+
# Javascript/Web REPL in Ruby
|
3
|
+
#
|
4
|
+
# (c)2014-2015 Ari Russo
|
5
|
+
# Apache 2.0 License
|
6
|
+
|
1
7
|
# libs
|
2
8
|
require "colorize"
|
3
9
|
require "em-websocket"
|
@@ -13,7 +19,7 @@ require "web-repl/repl"
|
|
13
19
|
# A Javascript REPL that runs in Ruby. Evaluation is done by a web browser instance.
|
14
20
|
module WebRepl
|
15
21
|
|
16
|
-
VERSION = "0.10.
|
22
|
+
VERSION = "0.10.2"
|
17
23
|
|
18
24
|
# Shortcut to REPL.start
|
19
25
|
def self.start(*a)
|
data/lib/web-repl/repl.rb
CHANGED
@@ -28,7 +28,7 @@ module WebRepl
|
|
28
28
|
|
29
29
|
# Send a statement to the browser for evaluation
|
30
30
|
# @param [Fixnum, String] statement A Javascript statement to be evaluated
|
31
|
-
# @return [String, nil] The data that was sent to the browser, or nil if sending could not be completed.
|
31
|
+
# @return [String, nil] The data that was sent to the browser, or nil if sending could not be completed.
|
32
32
|
def evaluate(statement)
|
33
33
|
@messenger.out({ :statement => statement }) unless @messenger.nil?
|
34
34
|
end
|
@@ -72,7 +72,7 @@ module WebRepl
|
|
72
72
|
def puts_message(message)
|
73
73
|
keys = { :error => :red, :value => :white }
|
74
74
|
text = nil
|
75
|
-
keys.each do |k,v|
|
75
|
+
keys.each do |k,v|
|
76
76
|
text ||= message[k].to_s.send(v) unless message[k].nil?
|
77
77
|
end
|
78
78
|
text ||= "(void)"
|
@@ -80,17 +80,27 @@ module WebRepl
|
|
80
80
|
text
|
81
81
|
end
|
82
82
|
|
83
|
+
# Is the socket ready?
|
84
|
+
# @return [Boolean]
|
85
|
+
def ready?
|
86
|
+
!@socket.nil? && !@messenger.nil? && !@handshake.nil?
|
87
|
+
end
|
88
|
+
|
83
89
|
# Start the Websocket connection (blocking)
|
84
90
|
# @param [Hash] options
|
85
91
|
# @option options [Boolean] :background Do not wait for input, just run in the bg
|
86
92
|
def start(options = {}, &block)
|
87
93
|
@thread = Thread.new do
|
88
|
-
|
89
|
-
|
90
|
-
@socket
|
91
|
-
|
92
|
-
|
94
|
+
begin
|
95
|
+
EM::WebSocket.run(@config) do |ws|
|
96
|
+
if @socket.nil?
|
97
|
+
@socket = ws
|
98
|
+
@messenger = Messenger.new(@socket)
|
99
|
+
configure_event_handling(:background => options[:background], &block)
|
100
|
+
end
|
93
101
|
end
|
102
|
+
rescue Exception => exception
|
103
|
+
Thread.main.raise(exception)
|
94
104
|
end
|
95
105
|
end
|
96
106
|
Thread.abort_on_exception = true
|