web-repl 0.10.1 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6a0ad277ec5784183b51b03e62b06cfb0e37dc2
4
- data.tar.gz: 627b30b062576ee663088ed9d4e63f27e8ccb620
3
+ metadata.gz: cda2df4294808cb8a8c8c14f488a8e1c7f76fc94
4
+ data.tar.gz: 695d28c5724f5c0cd4bf45cb3e7b06b5b7028c54
5
5
  SHA512:
6
- metadata.gz: 72f65b498afe760381f2c2d73610f8124b00b3867f9edda0f981701ee055006cad4befaa1798dc1c7a036d5c1025f6badc03fd45c3c1bf87464799222adb8b2b
7
- data.tar.gz: 8f0b40f894d64462abd7a5789a7a5e65ba19e615eba1bca1fa648574947da04004f75cfba8f331b2cd7a3df235afac0b977c6c31d176d3817e7e5f6b1b97606c
6
+ metadata.gz: 2bf1279f86055a3186a8b3e2e600a3080a42a5d23af5082e692fd192eceff546fa648567a86bfaa19470100dd1d28a68c88701fae64be236f2be19d915d099b9
7
+ data.tar.gz: f97dd88419310ba661eeb96eeb93ed5c5d47e3c9b16c82c6ebccd41ef3f90bf058c15dcff1a9f6ef81f5d4c4408d59da58d357089de80422b442b48a8996b9ce
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2014 Ari Russo
1
+ Copyright 2014-2015 Ari Russo
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
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)
@@ -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.1"
22
+ VERSION = "0.10.2"
17
23
 
18
24
  # Shortcut to REPL.start
19
25
  def self.start(*a)
@@ -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
- EM::WebSocket.run(@config) do |ws|
89
- if @socket.nil?
90
- @socket = ws
91
- @messenger = Messenger.new(@socket)
92
- configure_event_handling(:background => options[:background], &block)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web-repl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ari Russo