mojodna-switchboard 0.0.5 → 0.0.6

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/README.markdown CHANGED
@@ -22,3 +22,21 @@ Run it:
22
22
  $ switchboard roster list
23
23
  $ switchboard roster add fireeagle.com
24
24
  $ ...
25
+
26
+ Subscribe to a node using OAuth, overriding default settings:
27
+
28
+ $ switchboard --jid subscriber@example.com --password pa55word \
29
+ pubsub --oauth \
30
+ --oauth-consumer-key <consumer key> \
31
+ --oauth-consumer-secret <consumer secret> \
32
+ --oauth-token <token> \
33
+ --oauth-token-secret <token secret> \
34
+ --server fireeagle.com \
35
+ --node "/api/0.1/user/<token>" \
36
+ subscribe
37
+
38
+ Publish iTunes' current track using UserTune (XEP-0118):
39
+
40
+ $ switchboard --resource switchtunes pep tune
41
+
42
+ _You can do this using a JID that is already online._
@@ -0,0 +1,112 @@
1
+ module Switchboard
2
+ class Client < Core
3
+ attr_reader :client, :roster
4
+
5
+ def initialize(settings = Switchboard::Settings.new, spin = true)
6
+ super(settings, spin)
7
+
8
+ # TODO jid may already have a resource, so account for that
9
+ @client = Jabber::Client.new([settings["jid"], settings["resource"]] * "/")
10
+
11
+ on_stream_connected do
12
+ register_roster_callbacks
13
+
14
+ # tell others that we're online
15
+ presence
16
+
17
+ defer :roster_loaded do
18
+ # wait for the roster to load
19
+ roster.wait_for_roster
20
+
21
+ # roster has now been loaded
22
+ on(:roster_loaded)
23
+ end
24
+ end
25
+ end
26
+
27
+ def on_roster_presence(&block)
28
+ register_hook(:roster_presence, &block)
29
+ end
30
+
31
+ def on_roster_query(&block)
32
+ register_hook(:roster_query, &block)
33
+ end
34
+
35
+ def on_roster_subscription(&block)
36
+ register_hook(:roster_subscription, &block)
37
+ end
38
+
39
+ def on_roster_subscription_request(&block)
40
+ register_hook(:roster_subscription_request, &block)
41
+ end
42
+
43
+ def on_roster_loaded(&block)
44
+ register_hook(:roster_loaded, &block)
45
+ end
46
+
47
+ def on_roster_update(&block)
48
+ register_hook(:roster_update, &block)
49
+ end
50
+
51
+ protected
52
+
53
+ def auth!
54
+ client.auth(settings["password"])
55
+ @roster = Jabber::Roster::Helper.new(client)
56
+ rescue Jabber::ClientAuthenticationFailure => e
57
+ puts "Could not authenticate as #{settings["jid"]}"
58
+ shutdown(false)
59
+ exit 1
60
+ end
61
+
62
+ def connect!
63
+ client.connect
64
+ auth!
65
+ end
66
+
67
+ def disconnect!
68
+ presence(:unavailable)
69
+ client.close
70
+ end
71
+
72
+ def presence(status = nil, to = nil)
73
+ presence = Jabber::Presence.new(nil, status)
74
+ presence.to = to
75
+ client.send(presence)
76
+ end
77
+
78
+ def register_roster_callbacks
79
+ # presence from someone on my roster
80
+ roster.add_presence_callback do |item, old_presence, new_presence|
81
+ on(:roster_presence, item, old_presence, new_presence)
82
+ end
83
+
84
+ # roster query completed (rarely used)
85
+ roster.add_query_callback do |query|
86
+ on(:roster_query, query)
87
+ end
88
+
89
+ # roster subscription
90
+ roster.add_subscription_callback do |item, presence|
91
+ # confirmation that we were able to subscribe to someone else
92
+ on(:roster_subscription, item, presence)
93
+ end
94
+
95
+ roster.add_subscription_request_callback do |item, presence|
96
+ # someone wants to subscribe to me!
97
+ on(:roster_subscription_request, item, presence)
98
+ end
99
+
100
+ # roster was updated (rarely used)
101
+ roster.add_update_callback do |old_item, new_item|
102
+ # roster has been updated; don't care
103
+ # puts "update: #{old_item.inspect}, #{new_item.inspect}"
104
+ on(:roster_update, old_item, new_item)
105
+ end
106
+ end
107
+
108
+ def stream
109
+ client
110
+ end
111
+ end
112
+ end
@@ -14,7 +14,7 @@ module Switchboard
14
14
  description "Broadcasting UserTune (XEP-0118)"
15
15
 
16
16
  def self.run!
17
- switchboard = Switchboard::Core.new do
17
+ switchboard = Switchboard::Client.new do
18
18
  @tune_helper = Jabber::UserTune::Helper.new(client, nil)
19
19
 
20
20
  itunes = Appscript.app('iTunes')
@@ -5,13 +5,9 @@ module Switchboard
5
5
  description "Lists pubsub affiliations"
6
6
 
7
7
  def self.run!
8
- switchboard = Switchboard::Core.new do
8
+ switchboard = Switchboard::Client.new do
9
9
  defer :affiliations_received do
10
- begin
11
- pubsub.get_affiliations(OPTIONS["pubsub.node"])
12
- rescue Jabber::ServerError => e
13
- puts e
14
- end
10
+ pubsub.get_affiliations(OPTIONS["pubsub.node"])
15
11
  end
16
12
 
17
13
  def affiliations_received(affiliations)
@@ -5,20 +5,16 @@ module Switchboard
5
5
  description "Gets the configuration for a pubsub node"
6
6
 
7
7
  def self.run!
8
- switchboard = Switchboard::Core.new do
8
+ switchboard = Switchboard::Client.new do
9
9
  defer :configuration_retrieved do
10
- begin
11
- if ARGV.length == 2
12
- key, value = ARGV
13
- puts "Setting '#{key}' to '#{value}'"
14
- config = Jabber::PubSub::NodeConfig.new(OPTIONS["pubsub.node"], key => value)
15
- set_config_for(OPTIONS["pubsub.node"], config)
16
- end
17
-
18
- get_config_from(OPTIONS["pubsub.node"])
19
- rescue Jabber::ServerError => e
20
- puts e
10
+ if ARGV.length == 2
11
+ key, value = ARGV
12
+ puts "Setting '#{key}' to '#{value}'"
13
+ config = Jabber::PubSub::NodeConfig.new(OPTIONS["pubsub.node"], key => value)
14
+ set_config_for(OPTIONS["pubsub.node"], config)
21
15
  end
16
+
17
+ get_config_from(OPTIONS["pubsub.node"])
22
18
  end
23
19
 
24
20
  def configuration_retrieved(config)
@@ -10,16 +10,12 @@ module Switchboard
10
10
  end
11
11
 
12
12
  def self.run!
13
- switchboard = Switchboard::Core.new do
13
+ switchboard = Switchboard::Client.new do
14
14
  defer :node_created do
15
- begin
16
- if OPTIONS["pubsub.create.node_type"] == "collection"
17
- create_collection_node(OPTIONS["pubsub.node"])
18
- else
19
- create_node(OPTIONS["pubsub.node"])
20
- end
21
- rescue Jabber::ServerError => e
22
- puts e
15
+ if OPTIONS["pubsub.create.node_type"] == "collection"
16
+ create_collection_node(OPTIONS["pubsub.node"], nil)
17
+ else
18
+ create_node(OPTIONS["pubsub.node"], nil)
23
19
  end
24
20
  end
25
21
 
@@ -5,13 +5,9 @@ module Switchboard
5
5
  description "Deletes a pubsub node"
6
6
 
7
7
  def self.run!
8
- switchboard = Switchboard::Core.new do
8
+ switchboard = Switchboard::Client.new do
9
9
  defer :node_deleted do
10
- begin
11
- delete_node(OPTIONS["pubsub.node"])
12
- rescue Jabber::ServerError => e
13
- puts e
14
- end
10
+ delete_node(OPTIONS["pubsub.node"])
15
11
  end
16
12
 
17
13
  def node_deleted(success)
@@ -6,14 +6,10 @@ module Switchboard
6
6
  description "Gets information about a pubsub resource"
7
7
 
8
8
  def self.run!
9
- switchboard = Switchboard::Core.new do
9
+ switchboard = Switchboard::Client.new do
10
10
  defer :info_retrieved do
11
- begin
12
- browser = Jabber::PubSub::NodeBrowser.new(client)
13
- browser.get_info(OPTIONS["pubsub.server"], OPTIONS["pubsub.node"])
14
- rescue Jabber::ServerError => e
15
- puts e
16
- end
11
+ browser = Jabber::PubSub::NodeBrowser.new(client)
12
+ browser.get_info(OPTIONS["pubsub.server"], OPTIONS["pubsub.node"])
17
13
  end
18
14
 
19
15
  def info_retrieved(info)
@@ -10,13 +10,9 @@ module Switchboard
10
10
  end
11
11
 
12
12
  def self.run!
13
- switchboard = Switchboard::Core.new do
13
+ switchboard = Switchboard::Client.new do
14
14
  defer :items_retrieved do
15
- begin
16
- get_items_from(OPTIONS["pubsub.node"], OPTIONS["pubsub.items.count"])
17
- rescue Jabber::ServerError => e
18
- puts e
19
- end
15
+ get_items_from(OPTIONS["pubsub.node"], OPTIONS["pubsub.items.count"])
20
16
  end
21
17
 
22
18
  def items_retrieved(items)
@@ -5,7 +5,7 @@ module Switchboard
5
5
  description "Listens for pubsub events"
6
6
 
7
7
  def self.run!
8
- switchboard = Switchboard::Core.new
8
+ switchboard = Switchboard::Client.new
9
9
  switchboard.plug!(PubSubJack)
10
10
 
11
11
  switchboard.on_pubsub_event do |event|
@@ -6,14 +6,10 @@ module Switchboard
6
6
  description "Lists available pubsub nodes (maybe use pubsub.<server>)"
7
7
 
8
8
  def self.run!
9
- switchboard = Switchboard::Core.new do
9
+ switchboard = Switchboard::Client.new do
10
10
  defer :nodes_retrieved do
11
- begin
12
- browser = Jabber::PubSub::NodeBrowser.new(client)
13
- browser.nodes(OPTIONS["pubsub.server"])
14
- rescue Jabber::ServerError => e
15
- puts e
16
- end
11
+ browser = Jabber::PubSub::NodeBrowser.new(client)
12
+ browser.nodes(OPTIONS["pubsub.server"])
17
13
  end
18
14
 
19
15
  def nodes_retrieved(nodes)
@@ -10,13 +10,9 @@ module Switchboard
10
10
  end
11
11
 
12
12
  def self.run!
13
- switchboard = Switchboard::Core.new do
13
+ switchboard = Switchboard::Client.new do
14
14
  defer :options_retrieved do
15
- begin
16
- get_options_from(OPTIONS["pubsub.node"], OPTIONS["pubsub.subscriber"] || OPTIONS["jid"])
17
- rescue Jabber::ServerError => e
18
- puts e
19
- end
15
+ get_options_from(OPTIONS["pubsub.node"], OPTIONS["pubsub.subscriber"] || OPTIONS["jid"])
20
16
  end
21
17
 
22
18
  def options_retrieved(options)
@@ -10,18 +10,14 @@ module Switchboard
10
10
  end
11
11
 
12
12
  def self.run!
13
- switchboard = Switchboard::Core.new do
13
+ switchboard = Switchboard::Client.new do
14
14
  defer :item_published do
15
- begin
16
- item = Jabber::PubSub::Item.new
17
- item.text = STDIN.read
18
- if OPTIONS["pubsub.publish.id"]
19
- publish_item_with_id_to(OPTIONS["pubsub.node"], item, OPTIONS["pubsub.publish.id"])
20
- else
21
- publish_item_to(OPTIONS["pubsub.node"], item)
22
- end
23
- rescue Jabber::ServerError => e
24
- puts e
15
+ item = Jabber::PubSub::Item.new
16
+ item.text = STDIN.read
17
+ if OPTIONS["pubsub.publish.id"]
18
+ publish_item_with_id_to(OPTIONS["pubsub.node"], item, OPTIONS["pubsub.publish.id"])
19
+ else
20
+ publish_item_to(OPTIONS["pubsub.node"], item)
25
21
  end
26
22
  end
27
23
 
@@ -5,13 +5,9 @@ module Switchboard
5
5
  description "Purges a pubsub node"
6
6
 
7
7
  def self.run!
8
- switchboard = Switchboard::Core.new do
8
+ switchboard = Switchboard::Client.new do
9
9
  defer :node_purged do
10
- begin
11
- purge_items_from(OPTIONS["pubsub.node"])
12
- rescue Jabber::ServerError => e
13
- puts e
14
- end
10
+ purge_items_from(OPTIONS["pubsub.node"])
15
11
  end
16
12
 
17
13
  def node_purged(success)
@@ -5,14 +5,10 @@ module Switchboard
5
5
  description "Subscribe to a pubsub node"
6
6
 
7
7
  def self.run!
8
- switchboard = Switchboard::Core.new do
8
+ switchboard = Switchboard::Client.new do
9
9
  # this executes in the main loop, so it doesn't really matter that this runs in a different thread
10
10
  defer :subscribed do
11
- begin
12
- subscribe_to(settings["pubsub.node"])
13
- rescue Jabber::ServerError => e
14
- puts e
15
- end
11
+ subscribe_to(settings["pubsub.node"])
16
12
  end
17
13
 
18
14
  # define here or as hydrant.subscriptions_received
@@ -5,14 +5,10 @@ module Switchboard
5
5
  description "List pubsub subscriptions"
6
6
 
7
7
  def self.run!
8
- switchboard = Switchboard::Core.new do
8
+ switchboard = Switchboard::Client.new do
9
9
  # this executes in the main loop, so it doesn't really matter that this runs in a different thread
10
10
  defer :subscriptions_received do
11
- begin
12
- subscriptions(settings["pubsub.node"])
13
- rescue Jabber::ServerError => e
14
- puts e
15
- end
11
+ subscriptions(settings["pubsub.node"])
16
12
  end
17
13
 
18
14
  # define here or as hydrant.subscriptions_received
@@ -5,14 +5,10 @@ module Switchboard
5
5
  description "Unsubscribe from a pubsub node"
6
6
 
7
7
  def self.run!
8
- switchboard = Switchboard::Core.new do
8
+ switchboard = Switchboard::Client.new do
9
9
  # this executes in the main loop, so it doesn't really matter that this runs in a different thread
10
10
  defer :unsubscribed do
11
- begin
12
- unsubscribe_from(settings["pubsub.node"])
13
- rescue Jabber::ServerError => e
14
- puts e
15
- end
11
+ unsubscribe_from(settings["pubsub.node"])
16
12
  end
17
13
 
18
14
  # define here or as hydrant.subscriptions_received
@@ -3,7 +3,7 @@ module Switchboard
3
3
  class Register < Switchboard::Command
4
4
  description "Register a JID"
5
5
 
6
- class Registration < Switchboard::Core
6
+ class Registration < Switchboard::Client
7
7
  def initialize(settings = Switchboard::Settings.new, spin = false)
8
8
  super(settings, false)
9
9
  end
@@ -5,8 +5,9 @@ module Switchboard
5
5
  description "Add a JID to your roster"
6
6
 
7
7
  def self.run!
8
- # TODO override settings with values from the command line
9
- switchboard = Switchboard::Core.new do
8
+ switchboard = Switchboard::Client.new(Switchboard::Settings.new, false)
9
+
10
+ switchboard.on_roster_loaded do
10
11
  # add the server as a contact if it wasn't already added
11
12
  ARGV.each do |jid|
12
13
  if roster.find(jid).empty?
@@ -6,7 +6,9 @@ module Switchboard
6
6
 
7
7
  def self.run!
8
8
  # TODO override settings with values from the command line
9
- switchboard = Switchboard::Core.new do
9
+ switchboard = Switchboard::Client.new(Switchboard::Settings.new, false)
10
+
11
+ switchboard.on_roster_loaded do
10
12
  if roster.items.any?
11
13
  puts "#{settings["jid"]}'s roster:"
12
14
  puts roster.items.keys.map { |jid| jid.to_s } * "\n"
@@ -4,14 +4,10 @@ module Switchboard
4
4
  class Remove < Switchboard::Command
5
5
  description "Remove a JID from your roster"
6
6
 
7
- def self.options(opts)
8
- super(opts)
9
- # opts.on("-l", "--log=path", String, "Specifies a path to log script output.") { |v| OPTIONS[:log] = v }
10
- end
11
-
12
7
  def self.run!
13
- # TODO override settings with values from the command line
14
- switchboard = Switchboard::Core.new do
8
+ switchboard = Switchboard::Client.new(Switchboard::Settings.new, false)
9
+
10
+ switchboard.on_roster_loaded do
15
11
  ARGV.each do |jid|
16
12
  if (items = roster.find(jid)).any?
17
13
  item = items.values.first
@@ -4,7 +4,7 @@ module Switchboard
4
4
  description "Unregister a JID"
5
5
 
6
6
  def self.run!
7
- switchboard = Switchboard::Core.new do
7
+ switchboard = Switchboard::Client.new do
8
8
  begin
9
9
  client.remove_registration
10
10
  rescue Jabber::ServerError => e
@@ -14,12 +14,11 @@ require 'switchboard/ext/delegate'
14
14
  require 'switchboard/ext/instance_exec'
15
15
  require 'xmpp4r/roster'
16
16
 
17
-
18
17
  module Switchboard
19
18
  class Core
20
19
  include Timeout
21
20
 
22
- attr_reader :client, :jacks, :roster, :settings
21
+ attr_reader :jacks, :settings
23
22
 
24
23
  def initialize(settings = Switchboard::Settings.new, spin = true, &block)
25
24
  # register a handler for SIGINTs
@@ -42,12 +41,9 @@ module Switchboard
42
41
  @shutdown = false
43
42
  @deferreds = {}
44
43
  @main = block if block_given?
45
-
46
- # TODO jid may already have a resource, so account for that
47
- @client = Jabber::Client.new([settings["jid"], settings["resource"]] * "/")
48
44
  end
49
45
 
50
- # Turn the hydrant on.
46
+ # Start running.
51
47
  def run!
52
48
  startup
53
49
 
@@ -63,18 +59,22 @@ module Switchboard
63
59
  # TODO don't start threads yet; wait until all startup hooks have been run
64
60
  def defer(callback_name, timeout = 30, &block)
65
61
  puts "Deferring to #{callback_name}..." if debug?
66
- @deferreds[callback_name.to_sym] = Thread.new do
62
+ @deferreds[callback_name.to_sym] = Thread.new(callback_name.to_sym) do |callback|
67
63
 
68
64
  begin
69
65
 
70
66
  timeout(timeout) do
71
- results = instance_eval(&block)
72
- send(callback_name.to_sym, results)
67
+ begin
68
+ results = instance_eval(&block)
69
+ send(callback, results) if respond_to?(callback)
70
+ rescue Jabber::ServerError => e
71
+ puts "Server error: #{e}"
72
+ end
73
73
  end
74
74
 
75
- puts "Done with #{callback_name}." if debug?
75
+ puts "Done with #{callback}." if debug?
76
76
  # TODO make this thread-safe
77
- @deferreds.delete(callback_name.to_sym)
77
+ @deferreds.delete(callback)
78
78
 
79
79
  rescue Timeout::Error
80
80
  puts "Deferred method timed out."
@@ -101,7 +101,7 @@ module Switchboard
101
101
  end
102
102
  end
103
103
 
104
- # Register a hook to run when the Jabber::Client encounters an exception.
104
+ # Register a hook to run when the Jabber::Stream encounters an exception.
105
105
  def on_exception(&block)
106
106
  register_hook(:exception, &block)
107
107
  end
@@ -121,56 +121,24 @@ module Switchboard
121
121
  register_hook(:presence, &block)
122
122
  end
123
123
 
124
- def on_roster_presence(&block)
125
- register_hook(:roster_presence, &block)
126
- end
127
-
128
- def on_roster_query(&block)
129
- register_hook(:roster_query, &block)
130
- end
131
-
132
- def on_roster_subscription(&block)
133
- register_hook(:roster_subscription, &block)
134
- end
135
-
136
- def on_roster_subscription_request(&block)
137
- register_hook(:roster_subscription_request, &block)
138
- end
139
-
140
- def on_roster_loaded(&block)
141
- register_hook(:roster_loaded, &block)
142
- end
143
-
144
- def on_roster_update(&block)
145
- register_hook(:roster_update, &block)
146
- end
147
-
148
124
  # Register a startup hook.
149
- # Hooks will be given 5 seconds to complete before moving on.
150
125
  def on_startup(&block)
151
126
  register_hook(:startup, &block)
152
127
  end
153
128
 
129
+ def on_stream_connected(&block)
130
+ register_hook(:stream_connected, &block)
131
+ end
132
+
154
133
  # Register a shutdown hook.
155
- # Hooks will be given 5 seconds to complete before moving on.
156
134
  def on_shutdown(&block)
157
135
  register_hook(:shutdown, &block)
158
136
  end
159
137
 
160
138
  protected
161
139
 
162
- def auth!
163
- client.auth(settings["password"])
164
- @roster = Jabber::Roster::Helper.new(client)
165
- rescue Jabber::ClientAuthenticationFailure => e
166
- puts "Could not authenticate as #{settings["jid"]}"
167
- shutdown(false)
168
- exit 1
169
- end
170
-
171
140
  def connect!
172
- client.connect
173
- auth!
141
+ raise NotImplementedError, "subclasses of Switchboard::Core must implement connect!"
174
142
  end
175
143
 
176
144
  def connected?
@@ -181,9 +149,8 @@ module Switchboard
181
149
  settings["debug"]
182
150
  end
183
151
 
184
- def disconnect
185
- presence(:unavailable)
186
- client.close
152
+ def disconnect!
153
+ raise NotImplementedError, "subclasses of Switchboard::Core must implement disconnect!"
187
154
  end
188
155
 
189
156
  def register_hook(name, &block)
@@ -220,14 +187,8 @@ module Switchboard
220
187
  @loop
221
188
  end
222
189
 
223
- def presence(status = nil, to = nil)
224
- presence = Jabber::Presence.new(nil, status)
225
- presence.to = to
226
- client.send(presence)
227
- end
228
-
229
190
  def register_default_callbacks
230
- client.on_exception do |e, stream, where|
191
+ stream.on_exception do |e, stream, where|
231
192
  on(:exception, e, stream, where)
232
193
 
233
194
  case where
@@ -238,49 +199,19 @@ module Switchboard
238
199
  end
239
200
  end
240
201
 
241
- client.add_presence_callback do |presence|
202
+ stream.add_presence_callback do |presence|
242
203
  on(:presence, presence)
243
204
  end
244
205
 
245
- client.add_message_callback do |message|
206
+ stream.add_message_callback do |message|
246
207
  on(:message, message)
247
208
  end
248
209
 
249
- client.add_iq_callback do |iq|
210
+ stream.add_iq_callback do |iq|
250
211
  on(:iq, iq)
251
212
  end
252
213
  end
253
214
 
254
- def register_roster_callbacks
255
- # presence from someone on my roster
256
- roster.add_presence_callback do |item, old_presence, new_presence|
257
- on(:roster_presence, item, old_presence, new_presence)
258
- end
259
-
260
- # roster query completed (rarely used)
261
- roster.add_query_callback do |query|
262
- on(:roster_query, query)
263
- end
264
-
265
- # roster subscription
266
- roster.add_subscription_callback do |item, presence|
267
- # confirmation that we were able to subscribe to someone else
268
- on(:roster_subscription, item, presence)
269
- end
270
-
271
- roster.add_subscription_request_callback do |item, presence|
272
- # someone wants to subscribe to me!
273
- on(:roster_subscription_request, item, presence)
274
- end
275
-
276
- # roster was updated (rarely used)
277
- roster.add_update_callback do |old_item, new_item|
278
- # roster has been updated; don't care
279
- # puts "update: #{old_item.inspect}, #{new_item.inspect}"
280
- on(:roster_update, old_item, new_item)
281
- end
282
- end
283
-
284
215
  def startup
285
216
  begin
286
217
  timeout(30) do
@@ -288,13 +219,7 @@ module Switchboard
288
219
  @connected = true
289
220
 
290
221
  register_default_callbacks
291
- register_roster_callbacks
292
-
293
- # tell others that we're online
294
- presence
295
-
296
- # wait for the roster to load
297
- roster.wait_for_roster
222
+ on(:stream_connected)
298
223
  end
299
224
  rescue Timeout::Error
300
225
  puts "Startup took too long. Shutting down."
@@ -302,9 +227,6 @@ module Switchboard
302
227
  exit 1
303
228
  end
304
229
 
305
- # roster has now been loaded
306
- on(:roster_loaded)
307
-
308
230
  puts "Core startup completed." if debug?
309
231
 
310
232
  # run startup hooks
@@ -313,6 +235,10 @@ module Switchboard
313
235
  puts "=> Switchboard started."
314
236
  end
315
237
 
238
+ def stream
239
+ raise NotImplementedError, "subclasses of Switchboard::Core must implement stream"
240
+ end
241
+
316
242
  def shutdown!
317
243
  puts "Shutdown initiated."
318
244
  @shutdown = true
@@ -328,7 +254,7 @@ module Switchboard
328
254
  on(:shutdown) if run_hooks
329
255
 
330
256
  puts "Shutting down..." if debug?
331
- disconnect if connected?
257
+ disconnect! if connected?
332
258
  end
333
259
 
334
260
  def shutdown?
@@ -1,4 +1,5 @@
1
1
  require 'switchboard/core'
2
+ require 'switchboard/client'
2
3
  require 'switchboard/commands'
3
4
  require 'switchboard/jacks'
4
5
  require 'switchboard/settings'
@@ -1,3 +1,3 @@
1
1
  module Switchboard
2
- VERSION = [0, 0, 5]
2
+ VERSION = [0, 0, 6]
3
3
  end
data/switchboard.gemspec CHANGED
@@ -1,12 +1,12 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "switchboard"
3
- s.version = "0.0.5"
3
+ s.version = "0.0.6"
4
4
  s.summary = "XMPP toolkit."
5
5
  s.description = "A toolkit for assembling XMPP clients and interacting with XMPP servers."
6
6
  s.authors = ["Seth Fitzsimmons"]
7
7
  s.email = ["seth@mojodna.net"]
8
8
 
9
- s.files = ["bin/switchboard", "examples/election_results.rb", "lib/switchboard/colors.rb", "lib/switchboard/commands/command.rb", "lib/switchboard/commands/config/config.rb", "lib/switchboard/commands/config.rb", "lib/switchboard/commands/default.rb", "lib/switchboard/commands/help/help.rb", "lib/switchboard/commands/help.rb", "lib/switchboard/commands/pep/pep.rb", "lib/switchboard/commands/pep/tune.rb", "lib/switchboard/commands/pep.rb", "lib/switchboard/commands/pubsub/affiliations.rb", "lib/switchboard/commands/pubsub/config.rb", "lib/switchboard/commands/pubsub/create.rb", "lib/switchboard/commands/pubsub/delete.rb", "lib/switchboard/commands/pubsub/info.rb", "lib/switchboard/commands/pubsub/items.rb", "lib/switchboard/commands/pubsub/listen.rb", "lib/switchboard/commands/pubsub/nodes.rb", "lib/switchboard/commands/pubsub/options.rb", "lib/switchboard/commands/pubsub/publish.rb", "lib/switchboard/commands/pubsub/pubsub.rb", "lib/switchboard/commands/pubsub/purge.rb", "lib/switchboard/commands/pubsub/subscribe.rb", "lib/switchboard/commands/pubsub/subscriptions.rb", "lib/switchboard/commands/pubsub/unsubscribe.rb", "lib/switchboard/commands/pubsub.rb", "lib/switchboard/commands/register.rb", "lib/switchboard/commands/roster/add.rb", "lib/switchboard/commands/roster/list.rb", "lib/switchboard/commands/roster/remove.rb", "lib/switchboard/commands/roster/roster.rb", "lib/switchboard/commands/roster.rb", "lib/switchboard/commands/unregister.rb", "lib/switchboard/commands.rb", "lib/switchboard/core.rb", "lib/switchboard/ext/delegate.rb", "lib/switchboard/ext/instance_exec.rb", "lib/switchboard/helpers/oauth_pubsub.rb", "lib/switchboard/helpers/pubsub.rb", "lib/switchboard/jacks/auto_accept.rb", "lib/switchboard/jacks/debug.rb", "lib/switchboard/jacks/notify.rb", "lib/switchboard/jacks/oauth_pubsub.rb", "lib/switchboard/jacks/pubsub.rb", "lib/switchboard/jacks/roster_debug.rb", "lib/switchboard/jacks.rb", "lib/switchboard/oauth/request_proxy/mock_request.rb", "lib/switchboard/settings.rb", "lib/switchboard/switchboard.rb", "lib/switchboard/version.rb", "lib/switchboard/xmpp4r/pubsub/helper/oauth_service_helper.rb", "lib/switchboard.rb", "Rakefile", "README.markdown", "switchboard.gemspec"]
9
+ s.files = ["bin/switchboard", "examples/election_results.rb", "lib/switchboard/client.rb", "lib/switchboard/colors.rb", "lib/switchboard/commands/command.rb", "lib/switchboard/commands/config/config.rb", "lib/switchboard/commands/config.rb", "lib/switchboard/commands/default.rb", "lib/switchboard/commands/help/help.rb", "lib/switchboard/commands/help.rb", "lib/switchboard/commands/pep/pep.rb", "lib/switchboard/commands/pep/tune.rb", "lib/switchboard/commands/pep.rb", "lib/switchboard/commands/pubsub/affiliations.rb", "lib/switchboard/commands/pubsub/config.rb", "lib/switchboard/commands/pubsub/create.rb", "lib/switchboard/commands/pubsub/delete.rb", "lib/switchboard/commands/pubsub/info.rb", "lib/switchboard/commands/pubsub/items.rb", "lib/switchboard/commands/pubsub/listen.rb", "lib/switchboard/commands/pubsub/nodes.rb", "lib/switchboard/commands/pubsub/options.rb", "lib/switchboard/commands/pubsub/publish.rb", "lib/switchboard/commands/pubsub/pubsub.rb", "lib/switchboard/commands/pubsub/purge.rb", "lib/switchboard/commands/pubsub/subscribe.rb", "lib/switchboard/commands/pubsub/subscriptions.rb", "lib/switchboard/commands/pubsub/unsubscribe.rb", "lib/switchboard/commands/pubsub.rb", "lib/switchboard/commands/register.rb", "lib/switchboard/commands/roster/add.rb", "lib/switchboard/commands/roster/list.rb", "lib/switchboard/commands/roster/remove.rb", "lib/switchboard/commands/roster/roster.rb", "lib/switchboard/commands/roster.rb", "lib/switchboard/commands/unregister.rb", "lib/switchboard/commands.rb", "lib/switchboard/core.rb", "lib/switchboard/ext/delegate.rb", "lib/switchboard/ext/instance_exec.rb", "lib/switchboard/helpers/oauth_pubsub.rb", "lib/switchboard/helpers/pubsub.rb", "lib/switchboard/jacks/auto_accept.rb", "lib/switchboard/jacks/debug.rb", "lib/switchboard/jacks/notify.rb", "lib/switchboard/jacks/oauth_pubsub.rb", "lib/switchboard/jacks/pubsub.rb", "lib/switchboard/jacks/roster_debug.rb", "lib/switchboard/jacks.rb", "lib/switchboard/oauth/request_proxy/mock_request.rb", "lib/switchboard/settings.rb", "lib/switchboard/switchboard.rb", "lib/switchboard/version.rb", "lib/switchboard/xmpp4r/pubsub/helper/oauth_service_helper.rb", "lib/switchboard.rb", "Rakefile", "README.markdown", "switchboard.gemspec"]
10
10
  s.executables = ["switchboard"]
11
11
  s.require_paths = ["lib"]
12
12
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mojodna-switchboard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Fitzsimmons
@@ -51,6 +51,7 @@ extra_rdoc_files: []
51
51
  files:
52
52
  - bin/switchboard
53
53
  - examples/election_results.rb
54
+ - lib/switchboard/client.rb
54
55
  - lib/switchboard/colors.rb
55
56
  - lib/switchboard/commands/command.rb
56
57
  - lib/switchboard/commands/config/config.rb