torquebox-console 0.2.1 → 0.2.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.
- data/bin/tbconsole +3 -1
- data/lib/torquebox/console/client.rb +17 -8
- data/lib/torquebox/console/version.rb +1 -1
- metadata +2 -2
data/bin/tbconsole
CHANGED
@@ -54,8 +54,10 @@ EOT
|
|
54
54
|
end
|
55
55
|
|
56
56
|
desc "connect", "Runs the CLI console"
|
57
|
+
method_option :hostname, :type => :string, :default => "localhost"
|
58
|
+
method_option :port, :type => :numeric, :default => 8675
|
57
59
|
def connect
|
58
|
-
TorqueBox::Console::Client.connect
|
60
|
+
TorqueBox::Console::Client.connect({ :host => options[:hostname], :port => options[:port] })
|
59
61
|
end
|
60
62
|
|
61
63
|
protected
|
@@ -18,21 +18,22 @@ require 'readline'
|
|
18
18
|
module TorqueBox
|
19
19
|
module Console
|
20
20
|
class Client
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
DEFAULT_HEADERS = { "accept-version" => "1.1" }
|
22
|
+
DEFAULT_HOST = { :host => "localhost", :port => 8675 }
|
23
|
+
DEFAULT_PARAMS = { :max_reconnect_attempts => -1 }
|
24
24
|
|
25
25
|
attr_accessor :client, :closed
|
26
26
|
|
27
|
-
def initialize
|
27
|
+
def initialize (host = DEFAULT_HOST)
|
28
|
+
build_globals(host)
|
28
29
|
@closed = false
|
29
|
-
@client = Stomp::Client.new(
|
30
|
+
@client = Stomp::Client.new(@params)
|
30
31
|
rescue Stomp::Error::MaxReconnectAttempts
|
31
32
|
puts "Cannot connect to TorqueBox. Are you sure the server is running?"
|
32
33
|
end
|
33
34
|
|
34
|
-
def self.connect
|
35
|
-
Client.new.run
|
35
|
+
def self.connect (host = DEFAULT_HOST)
|
36
|
+
Client.new(host).run
|
36
37
|
end
|
37
38
|
|
38
39
|
def run
|
@@ -57,7 +58,7 @@ module TorqueBox
|
|
57
58
|
while !received_prompt && !closed
|
58
59
|
sleep 0.05
|
59
60
|
end
|
60
|
-
while !closed && (input = Readline.readline(
|
61
|
+
while !closed && (input = Readline.readline(prompt, true))
|
61
62
|
received_prompt = false
|
62
63
|
client.publish("/stomplet/console", input) unless closed
|
63
64
|
while !received_prompt && !closed
|
@@ -69,6 +70,14 @@ module TorqueBox
|
|
69
70
|
$stderr.close
|
70
71
|
end
|
71
72
|
end
|
73
|
+
|
74
|
+
protected
|
75
|
+
|
76
|
+
def build_globals (host)
|
77
|
+
@hosts = [host]
|
78
|
+
@headers = DEFAULT_HEADERS.merge({ :host => host[:host] })
|
79
|
+
@params = DEFAULT_PARAMS.merge({ :hosts => @hosts, :connect_headers => @headers })
|
80
|
+
end
|
72
81
|
end
|
73
82
|
end
|
74
83
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: torquebox-console
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Lance Ball
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date:
|
13
|
+
date: 2013-01-02 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: pry
|